multi: Remove treasury flag from IsSSGen.
This removes the treasury agenda flag from the stake.IsSSGen function since it is now unused due to it being removed from the stake.CheckSSGen function.
This commit is contained in:
parent
df64b960e8
commit
5b8b1f7b3d
@ -1001,7 +1001,7 @@ func countSpentStakeOutputs(block *dcrutil.Block, isTreasuryEnabled bool) int {
|
||||
var numSpent int
|
||||
for _, stx := range block.MsgBlock().STransactions {
|
||||
// Exclude the vote stakebase since it has no input.
|
||||
if stake.IsSSGen(stx, isTreasuryEnabled) {
|
||||
if stake.IsSSGen(stx) {
|
||||
numSpent++
|
||||
continue
|
||||
}
|
||||
@ -2096,7 +2096,7 @@ func stxosToScriptSource(block *dcrutil.Block, stxos []spentTxOut, isTreasuryEna
|
||||
continue
|
||||
}
|
||||
|
||||
isVote := stake.IsSSGen(tx, isTreasuryEnabled)
|
||||
isVote := stake.IsSSGen(tx)
|
||||
for txInIdx, txIn := range tx.TxIn {
|
||||
// Ignore stakebase since it has no input.
|
||||
if isVote && txInIdx == 0 {
|
||||
|
||||
@ -650,7 +650,7 @@ func deserializeSpendJournalEntry(serialized []byte, txns []*wire.MsgTx, isTreas
|
||||
// Calculate the total number of stxos.
|
||||
var numStxos int
|
||||
for _, tx := range txns {
|
||||
if stake.IsSSGen(tx, isTreasuryEnabled) {
|
||||
if stake.IsSSGen(tx) {
|
||||
numStxos++
|
||||
continue
|
||||
}
|
||||
@ -678,7 +678,7 @@ func deserializeSpendJournalEntry(serialized []byte, txns []*wire.MsgTx, isTreas
|
||||
stxos := make([]spentTxOut, numStxos)
|
||||
for txIdx := len(txns) - 1; txIdx > -1; txIdx-- {
|
||||
tx := txns[txIdx]
|
||||
isVote := stake.IsSSGen(tx, isTreasuryEnabled)
|
||||
isVote := stake.IsSSGen(tx)
|
||||
|
||||
// Loop backwards through all of the transaction inputs and read
|
||||
// the associated stxo.
|
||||
|
||||
@ -829,7 +829,7 @@ func (idx *AddrIndex) indexBlock(data writeIndexData, block *dcrutil.Block, prev
|
||||
msgTx := tx.MsgTx()
|
||||
thisTxOffset := txIdx + len(regularTxns)
|
||||
|
||||
isSSGen := stake.IsSSGen(msgTx, isTreasuryEnabled)
|
||||
isSSGen := stake.IsSSGen(msgTx)
|
||||
var (
|
||||
isTSpend, isTreasuryBase bool
|
||||
)
|
||||
@ -1050,7 +1050,7 @@ func (idx *AddrIndex) AddUnconfirmedTx(tx *dcrutil.Tx, prevScripts PrevScripter,
|
||||
// transaction has already been validated and thus all inputs are
|
||||
// already known to exist.
|
||||
msgTx := tx.MsgTx()
|
||||
isSSGen := stake.IsSSGen(msgTx, isTreasuryEnabled)
|
||||
isSSGen := stake.IsSSGen(msgTx)
|
||||
for i, txIn := range msgTx.TxIn {
|
||||
// Skip stakebase.
|
||||
if i == 0 && isSSGen {
|
||||
|
||||
@ -33,7 +33,7 @@ type SequenceLock struct {
|
||||
// that does not care about the specific reason the transaction is not a
|
||||
// stakebase, rather only if it is one or not.
|
||||
func isStakeBaseTx(tx *wire.MsgTx, isTreasuryEnabled bool) bool {
|
||||
return stake.IsSSGen(tx, isTreasuryEnabled)
|
||||
return stake.IsSSGen(tx)
|
||||
}
|
||||
|
||||
// calcSequenceLock computes the relative lock times for the passed transaction
|
||||
|
||||
@ -1155,7 +1155,7 @@ func CheckSSGen(tx *wire.MsgTx) error {
|
||||
|
||||
// IsSSGen returns whether or not a transaction is a stake submission generation
|
||||
// transaction. These are also known as votes.
|
||||
func IsSSGen(tx *wire.MsgTx, isTreasuryEnabled bool) bool {
|
||||
func IsSSGen(tx *wire.MsgTx) bool {
|
||||
return CheckSSGen(tx) == nil
|
||||
}
|
||||
|
||||
@ -1263,7 +1263,7 @@ func DetermineTxType(tx *wire.MsgTx, isTreasuryEnabled,
|
||||
if IsSStx(tx) {
|
||||
return TxTypeSStx
|
||||
}
|
||||
if IsSSGen(tx, isTreasuryEnabled) {
|
||||
if IsSSGen(tx) {
|
||||
return TxTypeSSGen
|
||||
}
|
||||
if IsSSRtx(tx) {
|
||||
@ -1312,19 +1312,7 @@ func FindSpentTicketsInBlock(block *wire.MsgBlock) *SpentTicketsInBlock {
|
||||
revocations := make([]chainhash.Hash, 0, block.Header.Revocations)
|
||||
|
||||
for _, stx := range block.STransactions {
|
||||
// It is safe to use the version as a proxy for treasury activation here
|
||||
// since the format of version 3 votes was invalid prior to its
|
||||
// activation and so even if there were votes with version >= 3 prior to
|
||||
// that point, those votes still would've had to conform to the rules
|
||||
// that existed at that time and therefore could not have simultaneously
|
||||
// had the new format and made it into a block. Further, the old format
|
||||
// is still treated as a valid vote when the flag is set, so the
|
||||
// historical consensus rules would not be violated by incorrectly
|
||||
// setting this flag even if there were votes with version >= 3 prior to
|
||||
// treasury activation. Finally, there were no votes with versions >= 3
|
||||
// prior to the treasury activation point on mainnet anyway.
|
||||
isTreasuryEnabled := stx.Version >= 3
|
||||
if IsSSGen(stx, isTreasuryEnabled) {
|
||||
if IsSSGen(stx) {
|
||||
voters = append(voters, stx.TxIn[1].PreviousOutPoint.Hash)
|
||||
votes = append(votes, VoteVersionTuple{
|
||||
Version: SSGenVersion(stx),
|
||||
|
||||
@ -20,18 +20,6 @@ import (
|
||||
"github.com/decred/dcrd/wire"
|
||||
)
|
||||
|
||||
const (
|
||||
// noTreasury signifies the treasury agenda should be treated as though
|
||||
// it is inactive. It is used to increase the readability of the
|
||||
// tests.
|
||||
noTreasury = false
|
||||
|
||||
// withTreasury signifies the treasury agenda should be treated as
|
||||
// though it is active. It is used to increase the readability of
|
||||
// the tests.
|
||||
withTreasury = true
|
||||
)
|
||||
|
||||
// hexToBytes converts the passed hex string into bytes and will panic if there
|
||||
// is an error. This is only provided for the hard-coded constants so errors in
|
||||
// the source code can be detected. It will only (and must only) be called with
|
||||
@ -329,7 +317,7 @@ func TestSSGen(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Errorf("IsSSGen: unexpected err: %v", err)
|
||||
}
|
||||
if !IsSSGen(ssgen.MsgTx(), noTreasury) {
|
||||
if !IsSSGen(ssgen.MsgTx()) {
|
||||
t.Errorf("IsSSGen claimed a valid ssgen is invalid")
|
||||
}
|
||||
|
||||
@ -357,7 +345,7 @@ func TestSSGen(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Errorf("IsSSGen: unexpected err: %v", err)
|
||||
}
|
||||
if !IsSSGen(ssgen.MsgTx(), noTreasury) {
|
||||
if !IsSSGen(ssgen.MsgTx()) {
|
||||
t.Errorf("IsSSGen claimed a valid ssgen is invalid")
|
||||
}
|
||||
}
|
||||
@ -387,7 +375,7 @@ func TestSSGenErrors(t *testing.T) {
|
||||
t.Errorf("CheckSSGen should have returned %v but instead returned %v",
|
||||
ErrSSGenWrongNumInputs, err)
|
||||
}
|
||||
if IsSSGen(ssgenExtraInputs.MsgTx(), noTreasury) {
|
||||
if IsSSGen(ssgenExtraInputs.MsgTx()) {
|
||||
t.Errorf("IsSSGen claimed an invalid ssgen is valid")
|
||||
}
|
||||
|
||||
@ -403,7 +391,7 @@ func TestSSGenErrors(t *testing.T) {
|
||||
t.Errorf("CheckSSGen should have returned %v but instead returned %v",
|
||||
ErrSSGenTooManyOutputs, err)
|
||||
}
|
||||
if IsSSGen(ssgenExtraOutputs.MsgTx(), noTreasury) {
|
||||
if IsSSGen(ssgenExtraOutputs.MsgTx()) {
|
||||
t.Errorf("IsSSGen claimed an invalid ssgen is valid")
|
||||
}
|
||||
|
||||
@ -419,7 +407,7 @@ func TestSSGenErrors(t *testing.T) {
|
||||
t.Errorf("CheckSSGen should have returned %v but instead returned %v",
|
||||
ErrSSGenNoStakebase, err)
|
||||
}
|
||||
if IsSSGen(ssgenStakeBaseWrong.MsgTx(), noTreasury) {
|
||||
if IsSSGen(ssgenStakeBaseWrong.MsgTx()) {
|
||||
t.Errorf("IsSSGen claimed an invalid ssgen is valid")
|
||||
}
|
||||
|
||||
@ -451,7 +439,7 @@ func TestSSGenErrors(t *testing.T) {
|
||||
t.Errorf("CheckSSGen should have returned %v but instead returned %v",
|
||||
ErrSSGenWrongTxTree, err)
|
||||
}
|
||||
if IsSSGen(ssgenWrongTreeIns.MsgTx(), noTreasury) {
|
||||
if IsSSGen(ssgenWrongTreeIns.MsgTx()) {
|
||||
t.Errorf("IsSSGen claimed an invalid ssgen is valid")
|
||||
}
|
||||
|
||||
@ -466,7 +454,7 @@ func TestSSGenErrors(t *testing.T) {
|
||||
t.Errorf("CheckSSGen should have returned %v but instead returned %v",
|
||||
ErrSSGenBadGenOuts, err)
|
||||
}
|
||||
if IsSSGen(ssgenTxBadVerOut.MsgTx(), noTreasury) {
|
||||
if IsSSGen(ssgenTxBadVerOut.MsgTx()) {
|
||||
t.Errorf("IsSSGen claimed an invalid ssgen is valid")
|
||||
}
|
||||
|
||||
@ -482,7 +470,7 @@ func TestSSGenErrors(t *testing.T) {
|
||||
t.Errorf("CheckSSGen should have returned %v but instead returned %v",
|
||||
ErrSSGenNoReference, err)
|
||||
}
|
||||
if IsSSGen(ssgenWrongZeroethOut.MsgTx(), noTreasury) {
|
||||
if IsSSGen(ssgenWrongZeroethOut.MsgTx()) {
|
||||
t.Errorf("IsSSGen claimed an invalid ssgen is valid")
|
||||
}
|
||||
|
||||
@ -524,7 +512,7 @@ func TestSSGenErrors(t *testing.T) {
|
||||
t.Errorf("CheckSSGen should have returned %v but instead returned %v",
|
||||
ErrSSGenBadReference, err)
|
||||
}
|
||||
if IsSSGen(ssgenWrongDataPush0Length.MsgTx(), noTreasury) {
|
||||
if IsSSGen(ssgenWrongDataPush0Length.MsgTx()) {
|
||||
t.Errorf("IsSSGen claimed an invalid ssgen is valid")
|
||||
}
|
||||
|
||||
@ -566,7 +554,7 @@ func TestSSGenErrors(t *testing.T) {
|
||||
t.Errorf("CheckSSGen should have returned %v but instead returned %v",
|
||||
ErrSSGenBadReference, err)
|
||||
}
|
||||
if IsSSGen(ssgenWrongNullData0Prefix.MsgTx(), noTreasury) {
|
||||
if IsSSGen(ssgenWrongNullData0Prefix.MsgTx()) {
|
||||
t.Errorf("IsSSGen claimed an invalid ssgen is valid")
|
||||
}
|
||||
|
||||
@ -582,7 +570,7 @@ func TestSSGenErrors(t *testing.T) {
|
||||
t.Errorf("CheckSSGen should have returned %v but instead returned %v",
|
||||
ErrSSGenNoVotePush, err)
|
||||
}
|
||||
if IsSSGen(ssgenWrongFirstOut.MsgTx(), noTreasury) {
|
||||
if IsSSGen(ssgenWrongFirstOut.MsgTx()) {
|
||||
t.Errorf("IsSSGen claimed an invalid ssgen is valid")
|
||||
}
|
||||
|
||||
@ -613,7 +601,7 @@ func TestSSGenErrors(t *testing.T) {
|
||||
t.Errorf("CheckSSGen should have returned %v but instead returned %v",
|
||||
ErrSSGenBadVotePush, err)
|
||||
}
|
||||
if IsSSGen(ssgenWrongDataPush1Length.MsgTx(), noTreasury) {
|
||||
if IsSSGen(ssgenWrongDataPush1Length.MsgTx()) {
|
||||
t.Errorf("IsSSGen claimed an invalid ssgen is valid")
|
||||
}
|
||||
|
||||
@ -645,7 +633,7 @@ func TestSSGenErrors(t *testing.T) {
|
||||
t.Errorf("CheckSSGen should have returned %v but instead returned %v",
|
||||
ErrSSGenBadVotePush, err)
|
||||
}
|
||||
if IsSSGen(ssgenWrongNullData1Prefix.MsgTx(), noTreasury) {
|
||||
if IsSSGen(ssgenWrongNullData1Prefix.MsgTx()) {
|
||||
t.Errorf("IsSSGen claimed an invalid ssgen is valid")
|
||||
}
|
||||
|
||||
@ -677,7 +665,7 @@ func TestSSGenErrors(t *testing.T) {
|
||||
t.Errorf("CheckSSGen should have returned %v but instead returned %v",
|
||||
ErrSSGenBadGenOuts, err)
|
||||
}
|
||||
if IsSSGen(ssgentestGenOutputUntagged.MsgTx(), noTreasury) {
|
||||
if IsSSGen(ssgentestGenOutputUntagged.MsgTx()) {
|
||||
t.Errorf("IsSSGen claimed an invalid ssgen is valid")
|
||||
}
|
||||
|
||||
@ -695,7 +683,7 @@ func TestSSGenErrors(t *testing.T) {
|
||||
t.Errorf("CheckSSGen should have returned %v but instead returned %v",
|
||||
ErrSSGenInvalidDiscriminatorLength, err)
|
||||
}
|
||||
if IsSSGen(ssgenNoDiscriminator.MsgTx(), withTreasury) {
|
||||
if IsSSGen(ssgenNoDiscriminator.MsgTx()) {
|
||||
t.Errorf("IsSSGen claimed an invalid ssgen is valid")
|
||||
}
|
||||
|
||||
@ -710,7 +698,7 @@ func TestSSGenErrors(t *testing.T) {
|
||||
t.Errorf("CheckSSGen should have returned %v but instead returned %v",
|
||||
ErrSSGenInvalidDiscriminatorLength, err)
|
||||
}
|
||||
if IsSSGen(ssgenInvalidDiscriminator.MsgTx(), withTreasury) {
|
||||
if IsSSGen(ssgenInvalidDiscriminator.MsgTx()) {
|
||||
t.Errorf("IsSSGen claimed an invalid ssgen is valid")
|
||||
}
|
||||
|
||||
@ -725,7 +713,7 @@ func TestSSGenErrors(t *testing.T) {
|
||||
t.Errorf("CheckSSGen should have returned %v but instead returned %v",
|
||||
ErrSSGenUnknownDiscriminator, err)
|
||||
}
|
||||
if IsSSGen(ssgenInvalidDiscriminator2.MsgTx(), withTreasury) {
|
||||
if IsSSGen(ssgenInvalidDiscriminator2.MsgTx()) {
|
||||
t.Errorf("IsSSGen claimed an invalid ssgen is valid")
|
||||
}
|
||||
|
||||
@ -739,7 +727,7 @@ func TestSSGenErrors(t *testing.T) {
|
||||
t.Errorf("CheckSSGen should have returned %v but instead returned %v",
|
||||
ErrSSGenBadGenOuts, err)
|
||||
}
|
||||
if IsSSGen(ssgenInvalidDiscriminator3.MsgTx(), withTreasury) {
|
||||
if IsSSGen(ssgenInvalidDiscriminator3.MsgTx()) {
|
||||
t.Errorf("IsSSGen claimed an invalid ssgen is valid")
|
||||
}
|
||||
// Verify we don't crash in this case as well.
|
||||
@ -759,7 +747,7 @@ func TestSSGenErrors(t *testing.T) {
|
||||
t.Errorf("CheckSSGen should have returned %v but instead returned %v",
|
||||
ErrSSGenInvalidTVLength, err)
|
||||
}
|
||||
if IsSSGen(ssgenInvalidTVNoVote.MsgTx(), withTreasury) {
|
||||
if IsSSGen(ssgenInvalidTVNoVote.MsgTx()) {
|
||||
t.Errorf("IsSSGen claimed an invalid ssgen is valid")
|
||||
}
|
||||
|
||||
@ -774,7 +762,7 @@ func TestSSGenErrors(t *testing.T) {
|
||||
t.Errorf("CheckSSGen should have returned %v but instead returned %v",
|
||||
ErrSSGenInvalidTVLength, err)
|
||||
}
|
||||
if IsSSGen(ssgenInvalidTVNoVote2.MsgTx(), withTreasury) {
|
||||
if IsSSGen(ssgenInvalidTVNoVote2.MsgTx()) {
|
||||
t.Errorf("IsSSGen claimed an invalid ssgen is valid")
|
||||
}
|
||||
|
||||
@ -790,7 +778,7 @@ func TestSSGenErrors(t *testing.T) {
|
||||
t.Errorf("CheckSSGen should have returned %v but instead returned %v",
|
||||
ErrSSGenInvalidTVLength, err)
|
||||
}
|
||||
if IsSSGen(ssgenInvalidTVNoVote3.MsgTx(), withTreasury) {
|
||||
if IsSSGen(ssgenInvalidTVNoVote3.MsgTx()) {
|
||||
t.Errorf("IsSSGen claimed an invalid ssgen is valid")
|
||||
}
|
||||
|
||||
@ -806,7 +794,7 @@ func TestSSGenErrors(t *testing.T) {
|
||||
t.Errorf("CheckSSGen should have returned %v but instead returned %v",
|
||||
ErrSSGenInvalidTVLength, err)
|
||||
}
|
||||
if IsSSGen(ssgenInvalidTVNoVote4.MsgTx(), withTreasury) {
|
||||
if IsSSGen(ssgenInvalidTVNoVote4.MsgTx()) {
|
||||
t.Errorf("IsSSGen claimed an invalid ssgen is valid")
|
||||
}
|
||||
|
||||
@ -822,7 +810,7 @@ func TestSSGenErrors(t *testing.T) {
|
||||
t.Errorf("CheckSSGen should have returned %v but instead returned %v",
|
||||
ErrSSGenInvalidDiscriminatorLength, err)
|
||||
}
|
||||
if IsSSGen(ssgenInvalidTVNoVote5.MsgTx(), withTreasury) {
|
||||
if IsSSGen(ssgenInvalidTVNoVote5.MsgTx()) {
|
||||
t.Errorf("IsSSGen claimed an invalid ssgen is valid")
|
||||
}
|
||||
|
||||
@ -837,7 +825,7 @@ func TestSSGenErrors(t *testing.T) {
|
||||
t.Errorf("CheckSSGen should have returned %v but instead returned %v",
|
||||
ErrSSGenInvalidTreasuryVote, err)
|
||||
}
|
||||
if IsSSGen(ssgenInvalidTVote.MsgTx(), withTreasury) {
|
||||
if IsSSGen(ssgenInvalidTVote.MsgTx()) {
|
||||
t.Errorf("IsSSGen claimed an invalid ssgen is valid")
|
||||
}
|
||||
|
||||
@ -852,7 +840,7 @@ func TestSSGenErrors(t *testing.T) {
|
||||
t.Errorf("CheckSSGen should have returned %v but instead returned %v",
|
||||
ErrSSGenInvalidTreasuryVote, err)
|
||||
}
|
||||
if IsSSGen(ssgenInvalidTVote2.MsgTx(), withTreasury) {
|
||||
if IsSSGen(ssgenInvalidTVote2.MsgTx()) {
|
||||
t.Errorf("IsSSGen claimed an invalid ssgen is valid")
|
||||
}
|
||||
|
||||
@ -867,7 +855,7 @@ func TestSSGenErrors(t *testing.T) {
|
||||
t.Errorf("CheckSSGen should have returned %v but instead returned %v",
|
||||
ErrSSGenDuplicateTreasuryVote, err)
|
||||
}
|
||||
if IsSSGen(ssgenInvalidTVote3.MsgTx(), withTreasury) {
|
||||
if IsSSGen(ssgenInvalidTVote3.MsgTx()) {
|
||||
t.Errorf("IsSSGen claimed an invalid ssgen is valid")
|
||||
}
|
||||
|
||||
@ -887,7 +875,7 @@ func TestSSGenTreasuryVotes(t *testing.T) {
|
||||
}
|
||||
|
||||
// Make sure ssgen is valid.
|
||||
if !IsSSGen(ssgenValidVote.MsgTx(), withTreasury) {
|
||||
if !IsSSGen(ssgenValidVote.MsgTx()) {
|
||||
t.Error("IsSSGen claimed a valid ssgen is invalid")
|
||||
}
|
||||
err := CheckSSGen(ssgenValidVote.MsgTx())
|
||||
|
||||
@ -139,7 +139,7 @@ func ticketsInBlock(bl *dcrutil.Block) []chainhash.Hash {
|
||||
func ticketsSpentInBlock(bl *dcrutil.Block) []chainhash.Hash {
|
||||
tickets := make([]chainhash.Hash, 0, bl.MsgBlock().Header.Voters)
|
||||
for _, stx := range bl.STransactions() {
|
||||
if IsSSGen(stx.MsgTx(), noTreasury) {
|
||||
if IsSSGen(stx.MsgTx()) {
|
||||
tickets = append(tickets, stx.MsgTx().TxIn[1].PreviousOutPoint.Hash)
|
||||
}
|
||||
}
|
||||
|
||||
@ -184,7 +184,7 @@ func calculateAddedSubsidy(block, parent *dcrutil.Block, isTreasuryEnabled bool)
|
||||
}
|
||||
|
||||
for _, stx := range block.MsgBlock().STransactions {
|
||||
if stake.IsSSGen(stx, isTreasuryEnabled) {
|
||||
if stake.IsSSGen(stx) {
|
||||
subsidy += stx.TxIn[0].ValueIn
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,13 +20,6 @@ import (
|
||||
"github.com/decred/dcrd/wire"
|
||||
)
|
||||
|
||||
const (
|
||||
// yesTreasury signifies the treasury agenda should be treated as
|
||||
// though it is active. It is used to increase the readability of the
|
||||
// code.
|
||||
yesTreasury = true
|
||||
)
|
||||
|
||||
// errDbTreasury signifies that a problem was encountered when fetching or
|
||||
// writing the treasury balance for a given block.
|
||||
type errDbTreasury string
|
||||
|
||||
@ -367,7 +367,7 @@ func addTSpendVotes(t *testing.T, tspendHashes []*chainhash.Hash, votes []stake.
|
||||
return func(b *wire.MsgBlock) {
|
||||
// Find SSGEN and append votes.
|
||||
for k, v := range b.STransactions {
|
||||
if !stake.IsSSGen(v, yesTreasury) {
|
||||
if !stake.IsSSGen(v) {
|
||||
continue
|
||||
}
|
||||
if len(v.TxOut) != 3 {
|
||||
@ -2727,7 +2727,7 @@ func TestTreasuryBalance(t *testing.T) {
|
||||
addTSpendVotes := func(b *wire.MsgBlock) {
|
||||
// Find SSGEN and append Yes vote.
|
||||
for k, v := range b.STransactions {
|
||||
if !stake.IsSSGen(v, yesTreasury) {
|
||||
if !stake.IsSSGen(v) {
|
||||
continue
|
||||
}
|
||||
if len(v.TxOut) != 3 {
|
||||
|
||||
@ -836,7 +836,7 @@ func scriptSourceFromSpendJournalV1(dbTx database.Tx, block *wire.MsgBlock) (scr
|
||||
var offset int
|
||||
for txIdx := len(txns) - 1; txIdx > -1; txIdx-- {
|
||||
tx := txns[txIdx]
|
||||
isVote := stake.IsSSGen(tx, false)
|
||||
isVote := stake.IsSSGen(tx)
|
||||
|
||||
// Loop backwards through all of the transaction inputs and read the
|
||||
// associated stxo.
|
||||
@ -2709,7 +2709,7 @@ func migrateSpendJournalVersion2To3(ctx context.Context, b *BlockChain) error {
|
||||
// Calculate the total number of stxos.
|
||||
var numStxos int
|
||||
for _, tx := range blockTxns {
|
||||
if stake.IsSSGen(tx, isTreasuryEnabled) {
|
||||
if stake.IsSSGen(tx) {
|
||||
numStxos++
|
||||
continue
|
||||
}
|
||||
@ -2752,7 +2752,7 @@ func migrateSpendJournalVersion2To3(ctx context.Context, b *BlockChain) error {
|
||||
offset := 0
|
||||
for txIdx := len(blockTxns) - 1; txIdx > -1; txIdx-- {
|
||||
tx := blockTxns[txIdx]
|
||||
isVote := stake.IsSSGen(tx, isTreasuryEnabled)
|
||||
isVote := stake.IsSSGen(tx)
|
||||
|
||||
// Loop backwards through all of the transaction inputs and read
|
||||
// the associated stxo.
|
||||
@ -4242,20 +4242,7 @@ func correctTreasurySpendVoteData(ctx context.Context, db database.DB, params *c
|
||||
revocations := make([]chainhash.Hash, 0, block.Header.Revocations)
|
||||
|
||||
for _, stx := range block.STransactions {
|
||||
// It is safe to use the version as a proxy for treasury activation
|
||||
// here since the format of version 3 votes was invalid prior to its
|
||||
// activation and so even if there were votes with version >= 3
|
||||
// prior to that point, those votes still would've had to conform to
|
||||
// the rules that existed at that time and therefore could not have
|
||||
// simultaneously had the new format and made it into a block.
|
||||
// Further, the old format is still treated as a valid vote when the
|
||||
// flag is set, so the historical consensus rules would not be
|
||||
// violated by incorrectly setting this flag even if there were
|
||||
// votes with version >= 3 prior to treasury activation. Finally,
|
||||
// there were no votes with versions >= 3 prior to the treasury
|
||||
// activation point on mainnet anyway.
|
||||
isTreasuryEnabled := stx.Version >= 3
|
||||
if stake.IsSSGen(stx, isTreasuryEnabled) {
|
||||
if stake.IsSSGen(stx) {
|
||||
voters = append(voters, stx.TxIn[1].PreviousOutPoint.Hash)
|
||||
votes = append(votes, blockIndexVoteVersionTuple{
|
||||
version: stake.SSGenVersion(stx),
|
||||
@ -4263,7 +4250,6 @@ func correctTreasurySpendVoteData(ctx context.Context, db database.DB, params *c
|
||||
})
|
||||
continue
|
||||
}
|
||||
|
||||
if stake.IsSSRtx(stx) {
|
||||
spentTicketHash := stx.TxIn[0].PreviousOutPoint.Hash
|
||||
revocations = append(revocations, spentTicketHash)
|
||||
|
||||
@ -234,7 +234,7 @@ func (view *UtxoViewpoint) connectTransaction(tx *dcrutil.Tx, blockHeight int64,
|
||||
|
||||
// Spend the referenced utxos by marking them spent in the view and, if a
|
||||
// slice was provided for the spent txout details, append an entry to it.
|
||||
isVote := stake.IsSSGen(msgTx, isTreasuryEnabled)
|
||||
isVote := stake.IsSSGen(msgTx)
|
||||
var isTSpend bool
|
||||
if isTreasuryEnabled {
|
||||
isTSpend = stake.IsTSpend(msgTx)
|
||||
@ -766,7 +766,7 @@ func (view *UtxoViewpoint) fetchInputUtxos(block *dcrutil.Block,
|
||||
// the block. This applies to both transactions earlier in the stake tree
|
||||
// as well as those in the regular tree.
|
||||
for _, stx := range block.STransactions() {
|
||||
isVote := stake.IsSSGen(stx.MsgTx(), isTreasuryEnabled)
|
||||
isVote := stake.IsSSGen(stx.MsgTx())
|
||||
for txInIdx, txIn := range stx.MsgTx().TxIn {
|
||||
// Ignore stakebase since it has no input.
|
||||
if isVote && txInIdx == 0 {
|
||||
@ -891,7 +891,7 @@ func (b *BlockChain) FetchUtxoView(tx *dcrutil.Tx, includeRegularTxns bool) (*Ut
|
||||
filteredSet.add(view, &outpoint)
|
||||
}
|
||||
if !standalone.IsCoinBaseTx(msgTx, isTreasuryEnabled) {
|
||||
isVote := stake.IsSSGen(msgTx, isTreasuryEnabled)
|
||||
isVote := stake.IsSSGen(msgTx)
|
||||
for txInIdx, txIn := range msgTx.TxIn {
|
||||
// Ignore stakebase since it has no input.
|
||||
if isVote && txInIdx == 0 {
|
||||
|
||||
@ -1933,7 +1933,7 @@ func (b *BlockChain) checkBlockContext(block *dcrutil.Block, prevNode *blockNode
|
||||
// We could potentially overflow the accumulator so check for overflow.
|
||||
lastSigOps := totalSigOps
|
||||
isCoinBase := standalone.IsCoinBaseTx(msgTx, isTreasuryEnabled)
|
||||
isSSGen := stake.IsSSGen(msgTx, isTreasuryEnabled)
|
||||
isSSGen := stake.IsSSGen(msgTx)
|
||||
totalSigOps += CountSigOps(tx, isCoinBase, isSSGen, isTreasuryEnabled)
|
||||
if totalSigOps < lastSigOps || totalSigOps > MaxSigOpsPerBlock {
|
||||
str := fmt.Sprintf("block contains too many signature operations "+
|
||||
@ -2010,7 +2010,7 @@ func (b *BlockChain) checkBlockContext(block *dcrutil.Block, prevNode *blockNode
|
||||
revocationTicketHashes := make([]chainhash.Hash, 0, ticketsPerBlock)
|
||||
for _, stx := range block.MsgBlock().STransactions {
|
||||
// Append vote ticket hashes.
|
||||
if stake.IsSSGen(stx, isTreasuryEnabled) {
|
||||
if stake.IsSSGen(stx) {
|
||||
ticketHash := stx.TxIn[1].PreviousOutPoint.Hash
|
||||
voteTicketHashes = append(voteTicketHashes, ticketHash)
|
||||
|
||||
@ -2889,7 +2889,7 @@ func CheckTransactionInputs(subsidyCache *standalone.SubsidyCache,
|
||||
//
|
||||
// Also keep track of whether or not it is a vote since some inputs need
|
||||
// to be skipped later.
|
||||
isVote := stake.IsSSGen(msgTx, isTreasuryEnabled)
|
||||
isVote := stake.IsSSGen(msgTx)
|
||||
if isVote {
|
||||
err := checkVoteInputs(subsidyCache, tx, txHeight, view,
|
||||
chainParams, prevHeader, isTreasuryEnabled,
|
||||
@ -3290,7 +3290,7 @@ func CountP2SHSigOps(tx *dcrutil.Tx, isCoinBaseTx bool, isStakeBaseTx bool, view
|
||||
// TxTree true == Regular, false == Stake
|
||||
func checkNumSigOps(tx *dcrutil.Tx, view *UtxoViewpoint, index int, txTree bool, cumulativeSigOps int, isTreasuryEnabled bool) (int, error) {
|
||||
msgTx := tx.MsgTx()
|
||||
isSSGen := stake.IsSSGen(msgTx, isTreasuryEnabled)
|
||||
isSSGen := stake.IsSSGen(msgTx)
|
||||
numsigOps := CountSigOps(tx, (index == 0) && txTree, isSSGen,
|
||||
isTreasuryEnabled)
|
||||
|
||||
@ -3332,7 +3332,7 @@ func checkStakeBaseAmounts(subsidyCache *standalone.SubsidyCache, height int64,
|
||||
|
||||
for _, tx := range txs {
|
||||
msgTx := tx.MsgTx()
|
||||
if stake.IsSSGen(msgTx, isTreasuryEnabled) {
|
||||
if stake.IsSSGen(msgTx) {
|
||||
// Ensure the input is available.
|
||||
txInOutpoint := msgTx.TxIn[1].PreviousOutPoint
|
||||
txInHash := &txInOutpoint.Hash
|
||||
@ -3378,7 +3378,7 @@ func getStakeBaseAmounts(txs []*dcrutil.Tx, view *UtxoViewpoint, isTreasuryEnabl
|
||||
totalOutputs := int64(0)
|
||||
for _, tx := range txs {
|
||||
msgTx := tx.MsgTx()
|
||||
if stake.IsSSGen(msgTx, isTreasuryEnabled) {
|
||||
if stake.IsSSGen(msgTx) {
|
||||
// Ensure the input is available.
|
||||
txInOutpoint := msgTx.TxIn[1].PreviousOutPoint
|
||||
txInHash := &txInOutpoint.Hash
|
||||
@ -3413,7 +3413,7 @@ func getStakeTreeFees(subsidyCache *standalone.SubsidyCache, height int64,
|
||||
totalOutputs := int64(0)
|
||||
for _, tx := range txs {
|
||||
msgTx := tx.MsgTx()
|
||||
isSSGen := stake.IsSSGen(msgTx, isTreasuryEnabled)
|
||||
isSSGen := stake.IsSSGen(msgTx)
|
||||
var isTSpend, isTreasuryBase bool
|
||||
if isTreasuryEnabled {
|
||||
isTSpend = stake.IsTSpend(msgTx)
|
||||
|
||||
@ -201,7 +201,7 @@ func (s *fakeChain) CalcSequenceLock(tx *dcrutil.Tx, view *blockchain.UtxoViewpo
|
||||
msgTx := tx.MsgTx()
|
||||
enforce := msgTx.Version >= 2
|
||||
if !enforce || standalone.IsCoinBaseTx(msgTx, noTreasury) ||
|
||||
stake.IsSSGen(msgTx, noTreasury) {
|
||||
stake.IsSSGen(msgTx) {
|
||||
return sequenceLock, nil
|
||||
}
|
||||
|
||||
|
||||
@ -776,7 +776,7 @@ func (g *BlkTmplGenerator) maybeInsertStakeTx(stx *dcrutil.Tx, treeValid bool, i
|
||||
return false
|
||||
}
|
||||
mstx := stx.MsgTx()
|
||||
isSSGen := stake.IsSSGen(mstx, isTreasuryEnabled)
|
||||
isSSGen := stake.IsSSGen(mstx)
|
||||
var isTSpend, isTreasuryBase bool
|
||||
if isTreasuryEnabled {
|
||||
isTSpend = stake.IsTSpend(mstx)
|
||||
@ -1954,7 +1954,7 @@ nextPriorityQueueItem:
|
||||
for _, tx := range blockTxns {
|
||||
msgTx := tx.MsgTx()
|
||||
|
||||
if stake.IsSSGen(msgTx, isTreasuryEnabled) {
|
||||
if stake.IsSSGen(msgTx) {
|
||||
txCopy := dcrutil.NewTxDeepTxIns(tx)
|
||||
if g.maybeInsertStakeTx(txCopy, !knownDisapproved,
|
||||
isTreasuryEnabled) {
|
||||
|
||||
@ -1121,7 +1121,7 @@ func createVinList(mtx *wire.MsgTx, isTreasuryEnabled bool) []types.Vin {
|
||||
|
||||
// Stakebase transactions (votes) have two inputs: a null stake base
|
||||
// followed by an input consuming a ticket's stakesubmission.
|
||||
isSSGen := stake.IsSSGen(mtx, isTreasuryEnabled)
|
||||
isSSGen := stake.IsSSGen(mtx)
|
||||
|
||||
for i, txIn := range mtx.TxIn {
|
||||
// Handle only the null input of a stakebase differently.
|
||||
@ -4088,7 +4088,7 @@ type retrievedTx struct {
|
||||
// then the transaction index for those already mined into blocks.
|
||||
func fetchInputTxos(s *Server, tx *wire.MsgTx, isTreasuryEnabled bool) (map[wire.OutPoint]wire.TxOut, error) {
|
||||
originOutputs := make(map[wire.OutPoint]wire.TxOut)
|
||||
voteTx := stake.IsSSGen(tx, isTreasuryEnabled)
|
||||
voteTx := stake.IsSSGen(tx)
|
||||
for txInIndex, txIn := range tx.TxIn {
|
||||
// vote tx have null input for vin[0],
|
||||
// skip since it resolves to an invalid transaction
|
||||
@ -4262,7 +4262,7 @@ func createVinListPrevOut(s *Server, mtx *wire.MsgTx,
|
||||
|
||||
// Stakebase transactions (votes) have two inputs: a null stake base
|
||||
// followed by an input consuming a ticket's stakesubmission.
|
||||
isSSGen := stake.IsSSGen(mtx, isTreasuryEnabled)
|
||||
isSSGen := stake.IsSSGen(mtx)
|
||||
|
||||
for i, txIn := range mtx.TxIn {
|
||||
// Handle only the null input of a stakebase differently.
|
||||
|
||||
@ -2197,7 +2197,7 @@ func rescanBlock(filter *wsClientFilter, block *dcrutil.Block, params *chaincfg.
|
||||
goto LoopOutputs
|
||||
}
|
||||
} else {
|
||||
if stake.IsSSGen(tx, isTreasuryEnabled) {
|
||||
if stake.IsSSGen(tx) {
|
||||
// Skip the first stakebase input. These do not
|
||||
// reference a previous output.
|
||||
inputs = inputs[1:]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user