diff --git a/mempool/mempool.go b/mempool/mempool.go index 492136fec..88f770fc4 100644 --- a/mempool/mempool.go +++ b/mempool/mempool.go @@ -677,8 +677,7 @@ func (mp *TxPool) maybeAcceptTransaction(tx *btcutil.Tx, isNew, rateLimit, rejec // forbid their acceptance. if !mp.cfg.Policy.AcceptNonStd { err = checkTransactionStandard(tx, nextBlockHeight, - medianTimePast, mp.cfg.Policy.MinRelayTxFee, - mp.cfg.Policy.MaxTxVersion) + medianTimePast, &mp.cfg.Policy) if err != nil { // Attempt to extract a reject code from the error so // it can be retained. When not possible, fall back to diff --git a/mempool/policy.go b/mempool/policy.go index 1f6c45f7f..aa23b3a1c 100644 --- a/mempool/policy.go +++ b/mempool/policy.go @@ -251,15 +251,14 @@ func isDust(txOut *wire.TxOut, minRelayTxFee btcutil.Amount) bool { // of recognized forms, and not containing "dust" outputs (those that are // so small it costs more to process them than they are worth). func checkTransactionStandard(tx *btcutil.Tx, height int32, - medianTimePast time.Time, minRelayTxFee btcutil.Amount, - maxTxVersion int32) error { + medianTimePast time.Time, policy *Policy) error { // The transaction must be a currently supported version. msgTx := tx.MsgTx() - if msgTx.Version > maxTxVersion || msgTx.Version < 1 { + if msgTx.Version > policy.MaxTxVersion || msgTx.Version < 1 { str := fmt.Sprintf("transaction version %d is not in the "+ "valid range of %d-%d", msgTx.Version, 1, - maxTxVersion) + policy.MaxTxVersion) return txRuleError(wire.RejectNonstandard, str) } @@ -326,7 +325,7 @@ func checkTransactionStandard(tx *btcutil.Tx, height int32, // "dust". if scriptClass == txscript.NullDataTy { numNullDataOutputs++ - } else if isDust(txOut, minRelayTxFee) { + } else if isDust(txOut, policy.MinRelayTxFee) { str := fmt.Sprintf("transaction output %d: payment "+ "of %d is dust", i, txOut.Value) return txRuleError(wire.RejectDust, str) diff --git a/mempool/policy_test.go b/mempool/policy_test.go index 505b95dc6..75df49964 100644 --- a/mempool/policy_test.go +++ b/mempool/policy_test.go @@ -470,7 +470,7 @@ func TestCheckTransactionStandard(t *testing.T) { for _, test := range tests { // Ensure standardness is as expected. err := checkTransactionStandard(btcutil.NewTx(&test.tx), - test.height, pastMedianTime, DefaultMinRelayTxFee, 1) + test.height, pastMedianTime, &Policy{MinRelayTxFee: DefaultMinRelayTxFee, MaxTxVersion: 1}) if err == nil && test.isStandard { // Test passes since function returned standard for a // transaction which is intended to be standard. diff --git a/server.go b/server.go index 281562870..f02aac0c3 100644 --- a/server.go +++ b/server.go @@ -25,9 +25,9 @@ import ( "github.com/daglabs/btcd/addrmgr" "github.com/daglabs/btcd/blockdag" "github.com/daglabs/btcd/blockdag/indexers" + "github.com/daglabs/btcd/connmgr" "github.com/daglabs/btcd/dagconfig" "github.com/daglabs/btcd/dagconfig/daghash" - "github.com/daglabs/btcd/connmgr" "github.com/daglabs/btcd/database" "github.com/daglabs/btcd/mempool" "github.com/daglabs/btcd/mining" @@ -2535,7 +2535,7 @@ func newServer(listenAddrs []string, db database.DB, chainParams *dagconfig.Para MaxOrphanTxSize: defaultMaxOrphanTxSize, MaxSigOpsPerTx: blockdag.MaxSigOpsPerBlock / 5, MinRelayTxFee: cfg.minRelayTxFee, - MaxTxVersion: 2, + MaxTxVersion: 1, }, ChainParams: chainParams, FetchUtxoView: s.dag.FetchUtxoView,