From 3f5c1a017120f1e7a0cde83bb737779a5bb9f418 Mon Sep 17 00:00:00 2001 From: brianddk Date: Wed, 5 Aug 2020 01:47:35 -0500 Subject: [PATCH] Correct errors in command 'serialize(deserialize(pbst))' The fields for 'locktime' and 'value_sats' were not parsing properly. Fixed 'locktime' typo and made 'value' and 'value_sats' synonyms --- electrum/commands.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/electrum/commands.py b/electrum/commands.py index 59a07506b..ab20d6ba8 100644 --- a/electrum/commands.py +++ b/electrum/commands.py @@ -362,7 +362,7 @@ class Commands: """ keypairs = {} inputs = [] # type: List[PartialTxInput] - locktime = jsontx.get('lockTime', 0) + locktime = jsontx.get('locktime', 0) for txin_dict in jsontx.get('inputs'): if txin_dict.get('prevout_hash') is not None and txin_dict.get('prevout_n') is not None: prevout = TxOutpoint(txid=bfh(txin_dict['prevout_hash']), out_idx=int(txin_dict['prevout_n'])) @@ -371,7 +371,7 @@ class Commands: else: raise Exception("missing prevout for txin") txin = PartialTxInput(prevout=prevout) - txin._trusted_value_sats = int(txin_dict['value']) + txin._trusted_value_sats = int(txin_dict.get('value', txin_dict['value_sats'])) nsequence = txin_dict.get('nsequence', None) if nsequence is not None: txin.nsequence = nsequence @@ -385,7 +385,7 @@ class Commands: txin.num_sig = 1 inputs.append(txin) - outputs = [PartialTxOutput.from_address_and_value(txout['address'], int(txout['value'])) + outputs = [PartialTxOutput.from_address_and_value(txout['address'], int(txout.get('value', txout['value_sats']))) for txout in jsontx.get('outputs')] tx = PartialTransaction.from_io(inputs, outputs, locktime=locktime) tx.sign(keypairs)