diff --git a/doc/errors.md b/doc/errors.md index 1fb0f0f59..a7aa9cacc 100644 --- a/doc/errors.md +++ b/doc/errors.md @@ -20,7 +20,7 @@ ErrStatusInputs: Either the input satoshis sum is too high, or there are no inpu ErrStatusOutputs: Transaction is invalid because the outputs are non-existent or attempting to create a non-zero false return output, or satoshi values greater than max value. # 464 -ErrStatusMalformed: Either the transaction is too small (100 bytes min), there are too many sig ops, or there is a non-data push in the unlocking script. +ErrStatusMalformed: Either the transaction is too small (61 bytes min), there are too many sig ops, or there is a non-data push in the unlocking script. # 465 ErrStatusFees: The fees are too low, sum satoshis out is not less than sum satoshis in. @@ -32,4 +32,4 @@ Conflict: Transaction is invalid because the network has already seen a tx which ErrStatusFrozenPolicy: Input Frozen (blacklist manager policy blacklisted). The transaction is attempting to spend frozen digital assets. # 482 -ErrStatusFrozenConsensus: Input Frozen (blacklist manager consensus blacklisted) The transaction is attempting to spend frozen digital assets. \ No newline at end of file +ErrStatusFrozenConsensus: Input Frozen (blacklist manager consensus blacklisted) The transaction is attempting to spend frozen digital assets. diff --git a/validator/default/default_validator.go b/validator/default/default_validator.go index 11524c519..fff3c6c9a 100644 --- a/validator/default/default_validator.go +++ b/validator/default/default_validator.go @@ -14,10 +14,13 @@ import ( ) // MaxBlockSize is set dynamically in a node, and should be gotten from the policy -const MaxBlockSize = 4 * 1024 * 1024 * 1024 -const MaxSatoshis = 21_000_000_00_000_000 -const coinbaseTxID = "0000000000000000000000000000000000000000000000000000000000000000" -const MaxTxSigopsCountPolicyAfterGenesis = ^uint32(0) // UINT32_MAX +const ( + MaxBlockSize = 4 * 1024 * 1024 * 1024 + MaxSatoshis = 21_000_000_00_000_000 + coinbaseTxID = "0000000000000000000000000000000000000000000000000000000000000000" + MaxTxSigopsCountPolicyAfterGenesis = ^uint32(0) // UINT32_MAX + minTxSizeBytes = 61 +) type DefaultValidator struct { policy *bitcoin.Settings @@ -69,8 +72,8 @@ func (v *DefaultValidator) ValidateTransaction(tx *bt.Tx, skipFeeValidation bool // => checked by the node, we do not want to have to know the current block height // 7) The transaction size in bytes is greater than or equal to 100 - if txSize < 100 { - return validator.NewError(fmt.Errorf("transaction size in bytes is less than 100 bytes"), api.ErrStatusMalformed) + if txSize < minTxSizeBytes { + return validator.NewError(fmt.Errorf("transaction size in bytes is less than %d bytes", minTxSizeBytes), api.ErrStatusMalformed) } // 8) The number of signature operations (SIGOPS) contained in the transaction is less than the signature operation limit