Browse Source
stricter tx deserialization: forbid output amount values over 21 million btc
3.2.x
SomberNight
7 years ago
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9
2 changed files with
3 additions and
0 deletions
-
lib/bitcoin.py
-
lib/transaction.py
|
|
@ -38,6 +38,7 @@ from .crypto import Hash, sha256, hash_160 |
|
|
|
|
|
|
|
COINBASE_MATURITY = 100 |
|
|
|
COIN = 100000000 |
|
|
|
TOTAL_COIN_SUPPLY_LIMIT_IN_BTC = 21000000 |
|
|
|
|
|
|
|
# supported types of transaction outputs |
|
|
|
TYPE_ADDRESS = 0 |
|
|
|
|
|
@ -534,6 +534,8 @@ def parse_witness(vds, txin, full_parse: bool): |
|
|
|
def parse_output(vds, i): |
|
|
|
d = {} |
|
|
|
d['value'] = vds.read_int64() |
|
|
|
if d['value'] > TOTAL_COIN_SUPPLY_LIMIT_IN_BTC * COIN: |
|
|
|
raise SerializationError('invalid output amount (too large)') |
|
|
|
scriptPubKey = vds.read_bytes(vds.read_compact_size()) |
|
|
|
d['type'], d['address'] = get_address_from_output_script(scriptPubKey) |
|
|
|
d['scriptPubKey'] = bh2u(scriptPubKey) |
|
|
|