|
@ -13,7 +13,8 @@ from electrum.address_synchronizer import TX_HEIGHT_UNCONFIRMED, TX_HEIGHT_UNCON |
|
|
from electrum.wallet import (sweep, Multisig_Wallet, Standard_Wallet, Imported_Wallet, |
|
|
from electrum.wallet import (sweep, Multisig_Wallet, Standard_Wallet, Imported_Wallet, |
|
|
restore_wallet_from_text, Abstract_Wallet, BumpFeeStrategy) |
|
|
restore_wallet_from_text, Abstract_Wallet, BumpFeeStrategy) |
|
|
from electrum.util import bfh, bh2u, create_and_start_event_loop |
|
|
from electrum.util import bfh, bh2u, create_and_start_event_loop |
|
|
from electrum.transaction import TxOutput, Transaction, PartialTransaction, PartialTxOutput, PartialTxInput, tx_from_any |
|
|
from electrum.transaction import (TxOutput, Transaction, PartialTransaction, PartialTxOutput, |
|
|
|
|
|
PartialTxInput, tx_from_any, TxOutpoint) |
|
|
from electrum.mnemonic import seed_type |
|
|
from electrum.mnemonic import seed_type |
|
|
|
|
|
|
|
|
from electrum.plugins.trustedcoin import trustedcoin |
|
|
from electrum.plugins.trustedcoin import trustedcoin |
|
@ -2124,6 +2125,48 @@ class TestWalletSending(TestCaseForTestnet): |
|
|
str(tx_copy)) |
|
|
str(tx_copy)) |
|
|
self.assertEqual('3021a4fe24e33af9d0ccdf25c478387c97df671fe1fd8b4db0de4255b3a348c5', tx_copy.txid()) |
|
|
self.assertEqual('3021a4fe24e33af9d0ccdf25c478387c97df671fe1fd8b4db0de4255b3a348c5', tx_copy.txid()) |
|
|
|
|
|
|
|
|
|
|
|
@mock.patch.object(wallet.Abstract_Wallet, 'save_db') |
|
|
|
|
|
def test_wallet_history_chain_of_unsigned_transactions(self, mock_save_db): |
|
|
|
|
|
wallet = self.create_standard_wallet_from_seed('cross end slow expose giraffe fuel track awake turtle capital ranch pulp', |
|
|
|
|
|
config=self.config, gap_limit=3) |
|
|
|
|
|
|
|
|
|
|
|
# bootstrap wallet |
|
|
|
|
|
funding_tx = Transaction('0200000000010132515e6aade1b79ec7dd3bac0896d8b32c56195d23d07d48e21659cef24301560100000000fdffffff0112841e000000000016001477fe6d2a27e8860c278d4d2cd90bad716bb9521a02473044022041ed68ef7ef122813ac6a5e996b8284f645c53fbe6823b8e430604a8915a867802203233f5f4d347a687eb19b2aa570829ab12aeeb29a24cc6d6d20b8b3d79e971ae012102bee0ee043817e50ac1bb31132770f7c41e35946ccdcb771750fb9696bdd1b307ad951d00') |
|
|
|
|
|
funding_txid = funding_tx.txid() |
|
|
|
|
|
self.assertEqual('db949963c3787c90a40fb689ffdc3146c27a9874a970d1fd20921afbe79a7aa9', funding_txid) |
|
|
|
|
|
wallet.receive_tx_callback(funding_txid, funding_tx, TX_HEIGHT_UNCONFIRMED) |
|
|
|
|
|
|
|
|
|
|
|
# create tx1 |
|
|
|
|
|
outputs = [PartialTxOutput.from_address_and_value('tb1qsfcddwf7yytl62e3catwv8hpl2hs9e36g2cqxl', 100000)] |
|
|
|
|
|
coins = wallet.get_spendable_coins(domain=None) |
|
|
|
|
|
tx = wallet.make_unsigned_transaction(coins=coins, outputs=outputs, fee=190) |
|
|
|
|
|
tx.set_rbf(True) |
|
|
|
|
|
tx.locktime = 1938861 |
|
|
|
|
|
tx.version = 2 |
|
|
|
|
|
self.assertEqual("70736274ff0100710200000001a97a9ae7fb1a9220fdd170a974987ac24631dcff89b60fa4907c78c3639994db0000000000fdffffff02a0860100000000001600148270d6b93e2117fd2b31c756e61ee1faaf02e63ab4fc1c0000000000160014b8e4fdc91593b67de2bf214694ef47e38dc2ee8ead951d00000100bf0200000000010132515e6aade1b79ec7dd3bac0896d8b32c56195d23d07d48e21659cef24301560100000000fdffffff0112841e000000000016001477fe6d2a27e8860c278d4d2cd90bad716bb9521a02473044022041ed68ef7ef122813ac6a5e996b8284f645c53fbe6823b8e430604a8915a867802203233f5f4d347a687eb19b2aa570829ab12aeeb29a24cc6d6d20b8b3d79e971ae012102bee0ee043817e50ac1bb31132770f7c41e35946ccdcb771750fb9696bdd1b307ad951d002206026cc6a74c2b0e38661d341ffae48fe7dde5196ca4afe95d28b496673fa4cf6467105f83afb40000008000000000000000000022020312ea49b9b1eea28e3330316a5b7e6673b43e01da38f802c99a777d30b903fa5e105f83afb40000008000000000010000000022020349321bee98c012887997f26c6400018b0711dd254b702c038b96a30ebe2af1d2105f83afb400000080010000000000000000", |
|
|
|
|
|
tx.serialize_as_bytes().hex()) |
|
|
|
|
|
self.assertFalse(tx.is_complete()) |
|
|
|
|
|
self.assertTrue(tx.is_segwit()) |
|
|
|
|
|
wallet.add_transaction(tx) |
|
|
|
|
|
|
|
|
|
|
|
# create tx2, which spends from unsigned tx1 |
|
|
|
|
|
outputs = [PartialTxOutput.from_address_and_value('tb1qq0lm9esmq6pfjc3jls7v6twy93lnqcs85wlth3', '!')] |
|
|
|
|
|
coins = wallet.get_spendable_coins(domain=None) |
|
|
|
|
|
tx = wallet.make_unsigned_transaction(coins=coins, outputs=outputs, fee=5000) |
|
|
|
|
|
tx.set_rbf(True) |
|
|
|
|
|
tx.locktime = 1938863 |
|
|
|
|
|
tx.version = 2 |
|
|
|
|
|
self.assertEqual("70736274ff01007b020000000288234495e0ff1d8ac06038f6cc5d5a92738d719f4c15afd581366da94754478f0000000000fdffffff88234495e0ff1d8ac06038f6cc5d5a92738d719f4c15afd581366da94754478f0100000000fdffffff01cc6f1e000000000016001403ffb2e61b0682996232fc3ccd2dc42c7f306207af951d000001011fa0860100000000001600148270d6b93e2117fd2b31c756e61ee1faaf02e63a22060312ea49b9b1eea28e3330316a5b7e6673b43e01da38f802c99a777d30b903fa5e105f83afb40000008000000000010000000001011fb4fc1c0000000000160014b8e4fdc91593b67de2bf214694ef47e38dc2ee8e22060349321bee98c012887997f26c6400018b0711dd254b702c038b96a30ebe2af1d2105f83afb4000000800100000000000000002202036f9a5913f1c22742dbc9e7f3ac3064be8b125a23563fcc8a519f387e16c7244c105f83afb400000080000000000200000000", |
|
|
|
|
|
tx.serialize_as_bytes().hex()) |
|
|
|
|
|
self.assertFalse(tx.is_complete()) |
|
|
|
|
|
self.assertTrue(tx.is_segwit()) |
|
|
|
|
|
wallet.add_transaction(tx) |
|
|
|
|
|
|
|
|
|
|
|
coins = wallet.get_spendable_coins(domain=None) |
|
|
|
|
|
self.assertEqual(1, len(coins)) |
|
|
|
|
|
self.assertEqual("bf08206effded4126a95fbed375cedc0452b5e16a5d2025ac645dfae81addbe4:0", |
|
|
|
|
|
coins[0].prevout.to_str()) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestWalletOfflineSigning(TestCaseForTestnet): |
|
|
class TestWalletOfflineSigning(TestCaseForTestnet): |
|
|
|
|
|
|
|
|