electrum

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

commit 5a5502303fc5e48cf0dc05e0f5c513dc0fddf4d3
parent 43c808291fcfc34582df8a2bf60f9c67401e923b
Author: ThomasV <thomasv@electrum.org>
Date:   Tue, 26 Jun 2018 13:09:02 +0200

make add_signature_to_txin an instance method

Diffstat:
Mlib/transaction.py | 15++++++---------
Mplugins/digitalbitbox/digitalbitbox.py | 3+--
Mplugins/ledger/ledger.py | 2+-
3 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/lib/transaction.py b/lib/transaction.py @@ -700,17 +700,18 @@ class Transaction: continue j = pubkeys.index(pubkey_hex) print_error("adding sig", i, j, pubkey_hex, sig) - self.add_signature_to_txin(self._inputs[i], j, sig) + self.add_signature_to_txin(i, j, sig) #self._inputs[i]['x_pubkeys'][j] = pubkey break # redo raw self.raw = self.serialize() - @classmethod - def add_signature_to_txin(cls, txin, signingPos, sig): + def add_signature_to_txin(self, i, signingPos, sig): + txin = self._inputs[i] txin['signatures'][signingPos] = sig txin['scriptSig'] = None # force re-serialization txin['witness'] = None # force re-serialization + self.raw = None def deserialize(self, force_full_parse=False): if self.raw is None: @@ -1164,13 +1165,9 @@ class Transaction: continue print_error("adding signature for", _pubkey) sec, compressed = keypairs.get(_pubkey) - # pubkey might not actually be a 02-04 pubkey for fd keys; so: - pubkey = ecc.ECPrivkey(sec).get_public_key_hex(compressed=compressed) - # add signature sig = self.sign_txin(i, sec) - self.add_signature_to_txin(txin, j, sig) - txin['pubkeys'][j] = pubkey # needed for fd keys - self._inputs[i] = txin + self.add_signature_to_txin(i, j, sig) + print_error("is_complete", self.is_complete()) self.raw = self.serialize() diff --git a/plugins/digitalbitbox/digitalbitbox.py b/plugins/digitalbitbox/digitalbitbox.py @@ -647,8 +647,7 @@ class DigitalBitbox_KeyStore(Hardware_KeyStore): sig_s = int(signed['sig'][64:], 16) sig = ecc.der_sig_from_r_and_s(sig_r, sig_s) sig = to_hexstr(sig) + '01' - Transaction.add_signature_to_txin(txin, ii, sig) - tx._inputs[i] = txin + tx.add_signature_to_txin(i, ii, sig) except UserCancelled: raise except BaseException as e: diff --git a/plugins/ledger/ledger.py b/plugins/ledger/ledger.py @@ -514,7 +514,7 @@ class Ledger_KeyStore(Hardware_KeyStore): for i, txin in enumerate(tx.inputs()): signingPos = inputs[i][4] - Transaction.add_signature_to_txin(txin, signingPos, bh2u(signatures[i])) + tx.add_signature_to_txin(i, signingPos, bh2u(signatures[i])) tx.raw = tx.serialize() @test_pin_unlocked