Skip to content

Commit

Permalink
Merge pull request #216 from bitcoin-sv/fix/tx-size-bytes
Browse files Browse the repository at this point in the history
Change min tx size in bytes
  • Loading branch information
boecklim authored Dec 15, 2023
2 parents 9c5b22e + 7369932 commit 9ac2406
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
4 changes: 2 additions & 2 deletions doc/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
ErrStatusFrozenConsensus: Input Frozen (blacklist manager consensus blacklisted) The transaction is attempting to spend frozen digital assets.
15 changes: 9 additions & 6 deletions validator/default/default_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9ac2406

Please sign in to comment.