mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-06-12 17:16:43 +00:00
[DEV-66] Make only transaction version 1 a standard transaction (#40)
* [DEV-66] Make only transaction version 1 a standard transaction * [DEV-66] change checkTransactionStandard to get policy as argument
This commit is contained in:
parent
904f2cf2e3
commit
ed5df3bf7d
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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.
|
||||
|
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user