mirror of
https://github.com/FlipsideCrypto/dcrd.git
synced 2026-02-06 10:56:47 +00:00
stake: Remove unused TxSSGenStakeOutputInfo.
This removes the TxSSGenStakeOutputInfo since it is no longer used.
This commit is contained in:
parent
19139cc92c
commit
8fa43f71cc
@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2015-2016 The Decred developers
|
||||
// Copyright (c) 2015-2019 The Decred developers
|
||||
// Use of this source code is governed by an ISC
|
||||
// license that can be found in the LICENSE file.
|
||||
//
|
||||
@ -395,56 +395,6 @@ func AmountFromSStxPkScrCommitment(pkScript []byte) (dcrutil.Amount, error) {
|
||||
return dcrutil.Amount(binary.LittleEndian.Uint64(amtEncoded)), nil
|
||||
}
|
||||
|
||||
// TxSSGenStakeOutputInfo takes an SSGen tx as input and scans through its
|
||||
// outputs, returning the amount of the output and the PKH or SH that it was
|
||||
// sent to.
|
||||
func TxSSGenStakeOutputInfo(tx *wire.MsgTx, params *chaincfg.Params) ([]bool,
|
||||
[][]byte, []int64, error) {
|
||||
numOutputsInSSGen := len(tx.TxOut)
|
||||
|
||||
isP2SH := make([]bool, numOutputsInSSGen-2)
|
||||
addresses := make([][]byte, numOutputsInSSGen-2)
|
||||
amounts := make([]int64, numOutputsInSSGen-2)
|
||||
|
||||
// Cycle through the inputs and generate
|
||||
for idx, out := range tx.TxOut {
|
||||
// We only care about the outputs where we get proportional
|
||||
// amounts and the PKHs they were sent to.
|
||||
if (idx > 1) && (idx < numOutputsInSSGen) {
|
||||
// Get the PKH or SH it's going to, and what type of
|
||||
// script it is.
|
||||
class, addr, _, err :=
|
||||
txscript.ExtractPkScriptAddrs(out.Version, out.PkScript, params)
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
if class != txscript.StakeGenTy {
|
||||
return nil, nil, nil, fmt.Errorf("ssgen output included non "+
|
||||
"ssgen tagged output in idx %v", idx)
|
||||
}
|
||||
subClass, err := txscript.GetStakeOutSubclass(out.PkScript)
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
if !(subClass == txscript.PubKeyHashTy ||
|
||||
subClass == txscript.ScriptHashTy) {
|
||||
return nil, nil, nil, fmt.Errorf("bad script type")
|
||||
}
|
||||
isP2SH[idx-2] = false
|
||||
if subClass == txscript.ScriptHashTy {
|
||||
isP2SH[idx-2] = true
|
||||
}
|
||||
|
||||
// Get the amount that was sent.
|
||||
amt := out.Value
|
||||
addresses[idx-2] = addr[0].ScriptAddress()
|
||||
amounts[idx-2] = amt
|
||||
}
|
||||
}
|
||||
|
||||
return isP2SH, addresses, amounts, nil
|
||||
}
|
||||
|
||||
// SSGenBlockVotedOn takes an SSGen tx and returns the block voted on in the
|
||||
// first OP_RETURN by hash and height.
|
||||
//
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2015-2018 The Decred developers
|
||||
// Copyright (c) 2015-2019 The Decred developers
|
||||
// Use of this source code is governed by an ISC
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
@ -875,44 +875,6 @@ func TestGetSStxStakeOutputInfo(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetSSGenStakeOutputInfo(t *testing.T) {
|
||||
var ssgen = dcrutil.NewTx(ssgenMsgTx)
|
||||
ssgen.SetTree(wire.TxTreeStake)
|
||||
ssgen.SetIndex(0)
|
||||
|
||||
correctTyp := false
|
||||
|
||||
correctpkh := []byte{0xc3, 0x98, 0xef, 0xa9,
|
||||
0xc3, 0x92, 0xba, 0x60,
|
||||
0x13, 0xc5, 0xe0, 0x4e,
|
||||
0xe7, 0x29, 0x75, 0x5e,
|
||||
0xf7, 0xf5, 0x8b, 0x32,
|
||||
}
|
||||
|
||||
correctamt := int64(0x2123e300)
|
||||
|
||||
typs, pkhs, amts, err := stake.TxSSGenStakeOutputInfo(ssgen.MsgTx(),
|
||||
&chaincfg.RegNetParams)
|
||||
if err != nil {
|
||||
t.Errorf("Got unexpected error: %v", err.Error())
|
||||
}
|
||||
|
||||
if typs[0] != correctTyp {
|
||||
t.Errorf("Error thrown on TestGetSSGenStakeOutputInfo: Looking for "+
|
||||
"type %v, got type %v", correctamt, amts[0])
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(pkhs[0], correctpkh) {
|
||||
t.Errorf("Error thrown on TestGetSSGenStakeOutputInfo: Looking for "+
|
||||
"pkh %v, got pkh %v", correctpkh, pkhs[0])
|
||||
}
|
||||
|
||||
if amts[0] != correctamt {
|
||||
t.Errorf("Error thrown on TestGetSSGenStakeOutputInfo: Looking for "+
|
||||
"amount %v, got amount %v", correctamt, amts[0])
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetSSGenVoteBits(t *testing.T) {
|
||||
var ssgen = dcrutil.NewTx(ssgenMsgTx)
|
||||
ssgen.SetTree(wire.TxTreeStake)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user