From 4dd38df3114e6afbcddbe3a109e0c7b1df662a2e Mon Sep 17 00:00:00 2001 From: Jochen Hoenicke Date: Sun, 17 Sep 2017 12:46:10 +0200 Subject: [PATCH] Fix parsing of witnesses The lengths in the witness structure are `var_int` not pushes. From BIP-141: The `witness` is a serialization of all witness data of the transaction. Each txin is associated with a witness field. A witness field starts with a `var_int` to indicate the number of stack items for the txin. It is followed by stack items, with each item starts with a `var_int` to indicate the length. Witness data is NOT script. This bug was triggered by tx d379210d85c1346dafbfd60e3cbc5c5573e50b1f9576d39f177afb2b378f1b98 --- lib/transaction.py | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/lib/transaction.py b/lib/transaction.py index 48fe0243..ecd38a16 100644 --- a/lib/transaction.py +++ b/lib/transaction.py @@ -116,19 +116,6 @@ class BCDataStream(object): def write_int64(self, val): return self._write_num(' 2: txin['num_sig'] = n - 2 txin['signatures'] = parse_sig(w[1:-1])