electrum

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

commit 29534dcf3d23a620dced3b81793401dd143a03c8
parent 0d7bcde2db0fe72c29d61e6261adb963bab375c2
Author: SomberNight <somber.night@protonmail.com>
Date:   Sun, 28 Jun 2020 17:26:52 +0200

commands: allow setting custom 'nsequence' in 'serialize' cmd

closes #6297

Diffstat:
Melectrum/commands.py | 3+++
Melectrum/tests/test_commands.py | 22++++++++++++++++++++++
2 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/electrum/commands.py b/electrum/commands.py @@ -372,6 +372,9 @@ class Commands: raise Exception("missing prevout for txin") txin = PartialTxInput(prevout=prevout) txin._trusted_value_sats = int(txin_dict['value']) + nsequence = txin_dict.get('nsequence', None) + if nsequence is not None: + txin.nsequence = nsequence sec = txin_dict.get('privkey') if sec: txin_type, privkey, compressed = bitcoin.deserialize_privkey(sec) diff --git a/electrum/tests/test_commands.py b/electrum/tests/test_commands.py @@ -181,6 +181,28 @@ class TestCommandsTestnet(TestCaseForTestnet): self.assertEqual("0200000000010139c5375fe9da7bd377c1783002b129f8c57d3e724d62f5eacb9739ca691a229d0100000000feffffff01301b0f0000000000160014ac0e2d229200bffb2167ed6fd196aef9d687d8bb0247304402206367fb2ddd723985f5f51e0f2435084c0a66f5c26f4403a75d3dd417b71a20450220545dc3637bcb49beedbbdf5063e05cad63be91af4f839886451c30ecd6edf1d20121021f110909ded653828a254515b58498a6bafc96799fb0851554463ed44ca7d9da00000000", cmds._run('serialize', (jsontx,))) + def test_serialize_custom_nsequence(self): + cmds = Commands(config=self.config) + jsontx = { + "inputs": [ + { + "prevout_hash": "9d221a69ca3997cbeaf5624d723e7dc5f829b1023078c177d37bdae95f37c539", + "prevout_n": 1, + "value": 1000000, + "privkey": "p2wpkh:cVDXzzQg6RoCTfiKpe8MBvmm5d5cJc6JLuFApsFDKwWa6F5TVHpD", + "nsequence": 0xfffffffd + } + ], + "outputs": [ + { + "address": "tb1q4s8z6g5jqzllkgt8a4har94wl8tg0k9m8kv5zd", + "value": 990000 + } + ] + } + self.assertEqual("0200000000010139c5375fe9da7bd377c1783002b129f8c57d3e724d62f5eacb9739ca691a229d0100000000feffffff01301b0f0000000000160014ac0e2d229200bffb2167ed6fd196aef9d687d8bb0247304402206367fb2ddd723985f5f51e0f2435084c0a66f5c26f4403a75d3dd417b71a20450220545dc3637bcb49beedbbdf5063e05cad63be91af4f839886451c30ecd6edf1d20121021f110909ded653828a254515b58498a6bafc96799fb0851554463ed44ca7d9da00000000", + cmds._run('serialize', (jsontx,))) + @mock.patch.object(wallet.Abstract_Wallet, 'save_db') def test_getprivatekeyforpath(self, mock_save_db): wallet = restore_wallet_from_text('north rent dawn bunker hamster invest wagon market romance pig either squeeze',