electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 9ab18ea6c915102129368a8bf7a7cbde6ed7104a
parent 28572197fbdbc39d35f2e520b7deac670430845a
Author: SomberNight <somber.night@protonmail.com>
Date:   Tue, 25 Feb 2020 21:14:41 +0100

transaction.deserialize: more sanity checks

this is mandated by consensus
https://github.com/bitcoin/bitcoin/blob/99813a9745fe10a58bedd7a4cb721faf14f907a4/src/consensus/tx_check.cpp#L13

Diffstat:
Melectrum/transaction.py | 4++++
1 file changed, 4 insertions(+), 0 deletions(-)

diff --git a/electrum/transaction.py b/electrum/transaction.py @@ -564,8 +564,12 @@ class Transaction: if marker != b'\x01': raise ValueError('invalid txn marker byte: {}'.format(marker)) n_vin = vds.read_compact_size() + if n_vin < 1: + raise SerializationError('tx needs to have at least 1 input') self._inputs = [parse_input(vds) for i in range(n_vin)] n_vout = vds.read_compact_size() + if n_vout < 1: + raise SerializationError('tx needs to have at least 1 output') self._outputs = [parse_output(vds) for i in range(n_vout)] if is_segwit: for txin in self._inputs: