@@ -53,8 +53,12 @@ const (
5353 // after the UAHF hard fork
5454 MaxTransactionSize = oneMegabyte
5555
56- // MinTransactionSize is the minimum transaction size allowed on the
56+ // MagneticAnomalyMinTransactionSize is the minimum transaction size allowed on the
5757 // network after the magneticanomaly hardfork
58+ MagneticAnomalyMinTransactionSize = 100
59+
60+ // MinTransactionSize is the minimum transaction size allowed on the
61+ // network after the upgrade9 hardfork
5862 MinTransactionSize = 65
5963
6064 // BlockMaxBytesMaxSigChecksRatio is the ratio between the maximum allowable
@@ -235,7 +239,7 @@ func CalcBlockSubsidy(height int32, chainParams *chaincfg.Params) int64 {
235239
236240// CheckTransactionSanity performs some preliminary checks on a transaction to
237241// ensure it is sane. These checks are context free.
238- func CheckTransactionSanity (tx * bchutil.Tx , magneticAnomalyActive bool , scriptFlags txscript.ScriptFlags ) error {
242+ func CheckTransactionSanity (tx * bchutil.Tx , magneticAnomalyActive bool , upgrade9Active bool , scriptFlags txscript.ScriptFlags ) error {
239243 // A transaction must have at least one input.
240244 msgTx := tx .MsgTx ()
241245 if len (msgTx .TxIn ) == 0 {
@@ -255,9 +259,14 @@ func CheckTransactionSanity(tx *bchutil.Tx, magneticAnomalyActive bool, scriptFl
255259 "%d, max %d" , serializedTxSize , MaxTransactionSize )
256260 return ruleError (ErrTxTooBig , str )
257261 }
258- if magneticAnomalyActive && serializedTxSize < MinTransactionSize {
262+
263+ if magneticAnomalyActive && serializedTxSize < MagneticAnomalyMinTransactionSize {
264+ minTxSize := MagneticAnomalyMinTransactionSize
265+ if upgrade9Active {
266+ minTxSize = MinTransactionSize
267+ }
259268 str := fmt .Sprintf ("serialized transaction is too small - got " +
260- "%d, min %d" , serializedTxSize , MinTransactionSize )
269+ "%d, min %d" , serializedTxSize , minTxSize )
261270 return ruleError (ErrTxTooSmall , str )
262271 }
263272
@@ -457,6 +466,8 @@ func checkBlockSanity(block *bchutil.Block, powLimit *big.Int, timeSource Median
457466
458467 magneticAnomaly := flags .HasFlag (BFMagneticAnomaly )
459468
469+ upgrade9 := flags .HasFlag (BFUpgrade9 )
470+
460471 // TODO: This is not a full set of ScriptFlags and only
461472 // covers the Nov 2018 fork.
462473 var scriptFlags txscript.ScriptFlags
@@ -476,7 +487,7 @@ func checkBlockSanity(block *bchutil.Block, powLimit *big.Int, timeSource Median
476487 return ruleError (ErrInvalidTxOrder , "transactions are not in lexicographical order" )
477488 }
478489 lastTxid = tx .Hash ()
479- err := CheckTransactionSanity (tx , magneticAnomaly , scriptFlags )
490+ err := CheckTransactionSanity (tx , magneticAnomaly , upgrade9 , scriptFlags )
480491 if err != nil {
481492 return err
482493 }
@@ -516,12 +527,15 @@ func checkBlockSanity(block *bchutil.Block, powLimit *big.Int, timeSource Median
516527
517528// CheckBlockSanity performs some preliminary checks on a block to ensure it is
518529// sane before continuing with block processing. These checks are context free.
519- func CheckBlockSanity (block * bchutil.Block , powLimit * big.Int , timeSource MedianTimeSource , magneticAnomalyActive bool ) error {
530+ func CheckBlockSanity (block * bchutil.Block , powLimit * big.Int , timeSource MedianTimeSource , magneticAnomalyActive bool , upgrade9Active bool ) error {
520531 behaviorFlags := BFNone
521532
522533 if magneticAnomalyActive {
523534 behaviorFlags |= BFMagneticAnomaly
524535 }
536+ if upgrade9Active {
537+ behaviorFlags |= BFUpgrade9
538+ }
525539
526540 return checkBlockSanity (block , powLimit , timeSource , behaviorFlags )
527541}
0 commit comments