mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
elements: Parametrize the sample addresses we test against
Since elements addresses look quite different from the bitcoin mainnet addresses I just added a sample to the chainparams fixture. In addition I extracted some of the fixed strings to reference chainparams instead. Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
committed by
Rusty Russell
parent
9e333f2416
commit
8a69ea7bf5
@@ -317,6 +317,8 @@ def chainparams():
|
|||||||
"name": "regtest",
|
"name": "regtest",
|
||||||
"p2sh_prefix": '2',
|
"p2sh_prefix": '2',
|
||||||
"elements": False,
|
"elements": False,
|
||||||
|
"example_addr": "bcrt1qeyyk6sl5pr49ycpqyckvmttus5ttj25pd0zpvg",
|
||||||
|
"feeoutput": False,
|
||||||
},
|
},
|
||||||
'liquid-regtest': {
|
'liquid-regtest': {
|
||||||
"bip173_prefix": "ert",
|
"bip173_prefix": "ert",
|
||||||
@@ -324,6 +326,8 @@ def chainparams():
|
|||||||
"name": "liquid-regtest",
|
"name": "liquid-regtest",
|
||||||
"p2sh_prefix": 'X',
|
"p2sh_prefix": 'X',
|
||||||
"elements": True,
|
"elements": True,
|
||||||
|
"example_addr": "ert1qq8adjz4u6enf0cjey9j8yt0y490tact9fahkwf",
|
||||||
|
"feeoutput": True,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
from fixtures import * # noqa: F401,F403
|
from fixtures import * # noqa: F401,F403
|
||||||
|
from fixtures import TEST_NETWORK
|
||||||
from flaky import flaky # noqa: F401
|
from flaky import flaky # noqa: F401
|
||||||
from lightning import RpcError
|
from lightning import RpcError
|
||||||
from utils import DEVELOPER, only_one, wait_for, sync_blockheight, VALGRIND, TIMEOUT, SLOW_MACHINE
|
from utils import DEVELOPER, only_one, wait_for, sync_blockheight, VALGRIND, TIMEOUT, SLOW_MACHINE
|
||||||
@@ -979,6 +980,7 @@ def test_funding_cancel_race(node_factory, bitcoind, executor):
|
|||||||
assert num_complete > 0
|
assert num_complete > 0
|
||||||
|
|
||||||
|
|
||||||
|
@unittest.skipIf(TEST_NETWORK != 'regtest', "External wallet support doesn't work with elements yet.")
|
||||||
def test_funding_external_wallet(node_factory, bitcoind):
|
def test_funding_external_wallet(node_factory, bitcoind):
|
||||||
l1 = node_factory.get_node()
|
l1 = node_factory.get_node()
|
||||||
l2 = node_factory.get_node()
|
l2 = node_factory.get_node()
|
||||||
|
|||||||
@@ -1512,12 +1512,12 @@ def test_newaddr(node_factory, chainparams):
|
|||||||
assert both['bech32'].startswith(chainparams['bip173_prefix'])
|
assert both['bech32'].startswith(chainparams['bip173_prefix'])
|
||||||
|
|
||||||
|
|
||||||
def test_newaddr_deprecated(node_factory):
|
def test_newaddr_deprecated(node_factory, chainparams):
|
||||||
l1 = node_factory.get_node(options={'allow-deprecated-apis': True})
|
l1 = node_factory.get_node(options={'allow-deprecated-apis': True})
|
||||||
p2sh = l1.rpc.newaddr('p2sh-segwit')
|
p2sh = l1.rpc.newaddr('p2sh-segwit')
|
||||||
assert p2sh['address'].startswith('2')
|
assert p2sh['address'].startswith(chainparams['p2sh_prefix'])
|
||||||
bech32 = l1.rpc.newaddr('bech32')
|
bech32 = l1.rpc.newaddr('bech32')
|
||||||
assert bech32['address'].startswith('bcrt1')
|
assert bech32['address'].startswith(chainparams['bip173_prefix'])
|
||||||
|
|
||||||
|
|
||||||
def test_bitcoind_fail_first(node_factory, bitcoind, executor):
|
def test_bitcoind_fail_first(node_factory, bitcoind, executor):
|
||||||
|
|||||||
@@ -1,13 +1,16 @@
|
|||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
from fixtures import * # noqa: F401,F403
|
from fixtures import * # noqa: F401,F403
|
||||||
|
from fixtures import TEST_NETWORK
|
||||||
from flaky import flaky # noqa: F401
|
from flaky import flaky # noqa: F401
|
||||||
from lightning import RpcError, Millisatoshi
|
from lightning import RpcError, Millisatoshi
|
||||||
from utils import only_one, wait_for, sync_blockheight
|
from utils import only_one, wait_for, sync_blockheight
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
import time
|
import time
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
|
||||||
|
@unittest.skipIf(TEST_NETWORK != 'regtest', "Test relies on a number of example addresses valid only in regtest")
|
||||||
def test_withdraw(node_factory, bitcoind):
|
def test_withdraw(node_factory, bitcoind):
|
||||||
amount = 1000000
|
amount = 1000000
|
||||||
# Don't get any funds from previous runs.
|
# Don't get any funds from previous runs.
|
||||||
@@ -213,9 +216,10 @@ def test_addfunds_from_block(node_factory, bitcoind):
|
|||||||
assert output['address'] == addr
|
assert output['address'] == addr
|
||||||
|
|
||||||
|
|
||||||
def test_txprepare(node_factory, bitcoind):
|
def test_txprepare(node_factory, bitcoind, chainparams):
|
||||||
amount = 1000000
|
amount = 1000000
|
||||||
l1 = node_factory.get_node(random_hsm=True)
|
l1 = node_factory.get_node(random_hsm=True)
|
||||||
|
addr = chainparams['example_addr']
|
||||||
|
|
||||||
# Add some funds to withdraw later: both bech32 and p2sh
|
# Add some funds to withdraw later: both bech32 and p2sh
|
||||||
for i in range(5):
|
for i in range(5):
|
||||||
@@ -227,59 +231,54 @@ def test_txprepare(node_factory, bitcoind):
|
|||||||
bitcoind.generate_block(1)
|
bitcoind.generate_block(1)
|
||||||
wait_for(lambda: len(l1.rpc.listfunds()['outputs']) == 10)
|
wait_for(lambda: len(l1.rpc.listfunds()['outputs']) == 10)
|
||||||
|
|
||||||
prep = l1.rpc.txprepare([{'bcrt1qeyyk6sl5pr49ycpqyckvmttus5ttj25pd0zpvg': Millisatoshi(amount * 3 * 1000)}])
|
prep = l1.rpc.txprepare([{addr: Millisatoshi(amount * 3 * 1000)}])
|
||||||
decode = bitcoind.rpc.decoderawtransaction(prep['unsigned_tx'])
|
decode = bitcoind.rpc.decoderawtransaction(prep['unsigned_tx'])
|
||||||
assert decode['txid'] == prep['txid']
|
assert decode['txid'] == prep['txid']
|
||||||
# 4 inputs, 2 outputs.
|
# 4 inputs, 2 outputs (3 if we have a fee output).
|
||||||
assert len(decode['vin']) == 4
|
assert len(decode['vin']) == 4
|
||||||
assert len(decode['vout']) == 2
|
assert len(decode['vout']) == 2 if not chainparams['feeoutput'] else 3
|
||||||
|
|
||||||
# One output will be correct.
|
# One output will be correct.
|
||||||
if decode['vout'][0]['value'] == Decimal(amount * 3) / 10**8:
|
outnum = [i for i, o in enumerate(decode['vout']) if o['value'] == Decimal(amount * 3) / 10**8][0]
|
||||||
outnum = 0
|
|
||||||
changenum = 1
|
|
||||||
elif decode['vout'][1]['value'] == Decimal(amount * 3) / 10**8:
|
|
||||||
outnum = 1
|
|
||||||
changenum = 0
|
|
||||||
else:
|
|
||||||
assert False
|
|
||||||
|
|
||||||
assert decode['vout'][outnum]['scriptPubKey']['type'] == 'witness_v0_keyhash'
|
for i, o in enumerate(decode['vout']):
|
||||||
assert decode['vout'][outnum]['scriptPubKey']['addresses'] == ['bcrt1qeyyk6sl5pr49ycpqyckvmttus5ttj25pd0zpvg']
|
if i == outnum:
|
||||||
|
assert o['scriptPubKey']['type'] == 'witness_v0_keyhash'
|
||||||
assert decode['vout'][changenum]['scriptPubKey']['type'] == 'witness_v0_keyhash'
|
assert o['scriptPubKey']['addresses'] == [addr]
|
||||||
|
else:
|
||||||
|
assert o['scriptPubKey']['type'] in ['witness_v0_keyhash', 'fee']
|
||||||
|
|
||||||
# Now prepare one with no change.
|
# Now prepare one with no change.
|
||||||
prep2 = l1.rpc.txprepare([{'bcrt1qeyyk6sl5pr49ycpqyckvmttus5ttj25pd0zpvg': 'all'}])
|
prep2 = l1.rpc.txprepare([{addr: 'all'}])
|
||||||
decode = bitcoind.rpc.decoderawtransaction(prep2['unsigned_tx'])
|
decode = bitcoind.rpc.decoderawtransaction(prep2['unsigned_tx'])
|
||||||
assert decode['txid'] == prep2['txid']
|
assert decode['txid'] == prep2['txid']
|
||||||
# 6 inputs, 1 outputs.
|
# 6 inputs, 1 outputs.
|
||||||
assert len(decode['vin']) == 6
|
assert len(decode['vin']) == 6
|
||||||
assert len(decode['vout']) == 1
|
assert len(decode['vout']) == 1 if not chainparams['feeoutput'] else 2
|
||||||
|
|
||||||
# Some fees will be paid.
|
# Some fees will be paid.
|
||||||
assert decode['vout'][0]['value'] < Decimal(amount * 6) / 10**8
|
assert decode['vout'][0]['value'] < Decimal(amount * 6) / 10**8
|
||||||
assert decode['vout'][0]['value'] > Decimal(amount * 6) / 10**8 - Decimal(0.0002)
|
assert decode['vout'][0]['value'] > Decimal(amount * 6) / 10**8 - Decimal(0.0002)
|
||||||
assert decode['vout'][0]['scriptPubKey']['type'] == 'witness_v0_keyhash'
|
assert decode['vout'][0]['scriptPubKey']['type'] == 'witness_v0_keyhash'
|
||||||
assert decode['vout'][0]['scriptPubKey']['addresses'] == ['bcrt1qeyyk6sl5pr49ycpqyckvmttus5ttj25pd0zpvg']
|
assert decode['vout'][0]['scriptPubKey']['addresses'] == [addr]
|
||||||
|
|
||||||
# If I cancel the first one, I can get those first 4 outputs.
|
# If I cancel the first one, I can get those first 4 outputs.
|
||||||
discard = l1.rpc.txdiscard(prep['txid'])
|
discard = l1.rpc.txdiscard(prep['txid'])
|
||||||
assert discard['txid'] == prep['txid']
|
assert discard['txid'] == prep['txid']
|
||||||
assert discard['unsigned_tx'] == prep['unsigned_tx']
|
assert discard['unsigned_tx'] == prep['unsigned_tx']
|
||||||
|
|
||||||
prep3 = l1.rpc.txprepare([{'bcrt1qeyyk6sl5pr49ycpqyckvmttus5ttj25pd0zpvg': 'all'}])
|
prep3 = l1.rpc.txprepare([{addr: 'all'}])
|
||||||
decode = bitcoind.rpc.decoderawtransaction(prep3['unsigned_tx'])
|
decode = bitcoind.rpc.decoderawtransaction(prep3['unsigned_tx'])
|
||||||
assert decode['txid'] == prep3['txid']
|
assert decode['txid'] == prep3['txid']
|
||||||
# 4 inputs, 1 outputs.
|
# 4 inputs, 1 outputs.
|
||||||
assert len(decode['vin']) == 4
|
assert len(decode['vin']) == 4
|
||||||
assert len(decode['vout']) == 1
|
assert len(decode['vout']) == 1 if not chainparams['feeoutput'] else 2
|
||||||
|
|
||||||
# Some fees will be taken
|
# Some fees will be taken
|
||||||
assert decode['vout'][0]['value'] < Decimal(amount * 4) / 10**8
|
assert decode['vout'][0]['value'] < Decimal(amount * 4) / 10**8
|
||||||
assert decode['vout'][0]['value'] > Decimal(amount * 4) / 10**8 - Decimal(0.0002)
|
assert decode['vout'][0]['value'] > Decimal(amount * 4) / 10**8 - Decimal(0.0002)
|
||||||
assert decode['vout'][0]['scriptPubKey']['type'] == 'witness_v0_keyhash'
|
assert decode['vout'][0]['scriptPubKey']['type'] == 'witness_v0_keyhash'
|
||||||
assert decode['vout'][0]['scriptPubKey']['addresses'] == ['bcrt1qeyyk6sl5pr49ycpqyckvmttus5ttj25pd0zpvg']
|
assert decode['vout'][0]['scriptPubKey']['addresses'] == [addr]
|
||||||
|
|
||||||
# Cannot discard twice.
|
# Cannot discard twice.
|
||||||
with pytest.raises(RpcError, match=r'not an unreleased txid'):
|
with pytest.raises(RpcError, match=r'not an unreleased txid'):
|
||||||
@@ -288,24 +287,24 @@ def test_txprepare(node_factory, bitcoind):
|
|||||||
# Discard everything, we should now spend all inputs.
|
# Discard everything, we should now spend all inputs.
|
||||||
l1.rpc.txdiscard(prep2['txid'])
|
l1.rpc.txdiscard(prep2['txid'])
|
||||||
l1.rpc.txdiscard(prep3['txid'])
|
l1.rpc.txdiscard(prep3['txid'])
|
||||||
prep4 = l1.rpc.txprepare([{'bcrt1qeyyk6sl5pr49ycpqyckvmttus5ttj25pd0zpvg': 'all'}])
|
prep4 = l1.rpc.txprepare([{addr: 'all'}])
|
||||||
decode = bitcoind.rpc.decoderawtransaction(prep4['unsigned_tx'])
|
decode = bitcoind.rpc.decoderawtransaction(prep4['unsigned_tx'])
|
||||||
assert decode['txid'] == prep4['txid']
|
assert decode['txid'] == prep4['txid']
|
||||||
# 10 inputs, 1 outputs.
|
# 10 inputs, 1 outputs.
|
||||||
assert len(decode['vin']) == 10
|
assert len(decode['vin']) == 10
|
||||||
assert len(decode['vout']) == 1
|
assert len(decode['vout']) == 1 if not chainparams['feeoutput'] else 2
|
||||||
|
|
||||||
# Some fees will be taken
|
# Some fees will be taken
|
||||||
assert decode['vout'][0]['value'] < Decimal(amount * 10) / 10**8
|
assert decode['vout'][0]['value'] < Decimal(amount * 10) / 10**8
|
||||||
assert decode['vout'][0]['value'] > Decimal(amount * 10) / 10**8 - Decimal(0.0003)
|
assert decode['vout'][0]['value'] > Decimal(amount * 10) / 10**8 - Decimal(0.0003)
|
||||||
assert decode['vout'][0]['scriptPubKey']['type'] == 'witness_v0_keyhash'
|
assert decode['vout'][0]['scriptPubKey']['type'] == 'witness_v0_keyhash'
|
||||||
assert decode['vout'][0]['scriptPubKey']['addresses'] == ['bcrt1qeyyk6sl5pr49ycpqyckvmttus5ttj25pd0zpvg']
|
assert decode['vout'][0]['scriptPubKey']['addresses'] == [addr]
|
||||||
l1.rpc.txdiscard(prep4['txid'])
|
l1.rpc.txdiscard(prep4['txid'])
|
||||||
|
|
||||||
# Try passing in a utxo set
|
# Try passing in a utxo set
|
||||||
utxos = [utxo["txid"] + ":" + str(utxo["output"]) for utxo in l1.rpc.listfunds()["outputs"]][:4]
|
utxos = [utxo["txid"] + ":" + str(utxo["output"]) for utxo in l1.rpc.listfunds()["outputs"]][:4]
|
||||||
|
|
||||||
prep5 = l1.rpc.txprepare([{'bcrt1qeyyk6sl5pr49ycpqyckvmttus5ttj25pd0zpvg':
|
prep5 = l1.rpc.txprepare([{addr:
|
||||||
Millisatoshi(amount * 3.5 * 1000)}], utxos=utxos)
|
Millisatoshi(amount * 3.5 * 1000)}], utxos=utxos)
|
||||||
|
|
||||||
decode = bitcoind.rpc.decoderawtransaction(prep5['unsigned_tx'])
|
decode = bitcoind.rpc.decoderawtransaction(prep5['unsigned_tx'])
|
||||||
@@ -318,26 +317,26 @@ def test_txprepare(node_factory, bitcoind):
|
|||||||
assert utxo in vins
|
assert utxo in vins
|
||||||
|
|
||||||
# We should have a change output, so this is exact
|
# We should have a change output, so this is exact
|
||||||
assert len(decode['vout']) == 2
|
assert len(decode['vout']) == 3 if chainparams['feeoutput'] else 2
|
||||||
assert decode['vout'][1]['value'] == Decimal(amount * 3.5) / 10**8
|
assert decode['vout'][1]['value'] == Decimal(amount * 3.5) / 10**8
|
||||||
assert decode['vout'][1]['scriptPubKey']['type'] == 'witness_v0_keyhash'
|
assert decode['vout'][1]['scriptPubKey']['type'] == 'witness_v0_keyhash'
|
||||||
assert decode['vout'][1]['scriptPubKey']['addresses'] == ['bcrt1qeyyk6sl5pr49ycpqyckvmttus5ttj25pd0zpvg']
|
assert decode['vout'][1]['scriptPubKey']['addresses'] == [addr]
|
||||||
|
|
||||||
# Discard prep4 and get all funds again
|
# Discard prep4 and get all funds again
|
||||||
l1.rpc.txdiscard(prep5['txid'])
|
l1.rpc.txdiscard(prep5['txid'])
|
||||||
with pytest.raises(RpcError, match=r'this destination wants all satoshi. The count of outputs can\'t be more than 1'):
|
with pytest.raises(RpcError, match=r'this destination wants all satoshi. The count of outputs can\'t be more than 1'):
|
||||||
prep5 = l1.rpc.txprepare([{'bcrt1qeyyk6sl5pr49ycpqyckvmttus5ttj25pd0zpvg': Millisatoshi(amount * 3 * 1000)},
|
prep5 = l1.rpc.txprepare([{addr: Millisatoshi(amount * 3 * 1000)},
|
||||||
{'bcrt1qw508d6qejxtdg4y5r3zarvary0c5xw7kygt080': 'all'}])
|
{addr: 'all'}])
|
||||||
prep5 = l1.rpc.txprepare([{'bcrt1qeyyk6sl5pr49ycpqyckvmttus5ttj25pd0zpvg': Millisatoshi(amount * 3 * 500 + 100000)},
|
prep5 = l1.rpc.txprepare([{addr: Millisatoshi(amount * 3 * 500 + 100000)},
|
||||||
{'bcrt1qw508d6qejxtdg4y5r3zarvary0c5xw7kygt080': Millisatoshi(amount * 3 * 500 - 100000)}])
|
{addr: Millisatoshi(amount * 3 * 500 - 100000)}])
|
||||||
decode = bitcoind.rpc.decoderawtransaction(prep5['unsigned_tx'])
|
decode = bitcoind.rpc.decoderawtransaction(prep5['unsigned_tx'])
|
||||||
assert decode['txid'] == prep5['txid']
|
assert decode['txid'] == prep5['txid']
|
||||||
# 4 inputs, 3 outputs(include change).
|
# 4 inputs, 3 outputs(include change).
|
||||||
assert len(decode['vin']) == 4
|
assert len(decode['vin']) == 4
|
||||||
assert len(decode['vout']) == 3
|
assert len(decode['vout']) == 4 if chainparams['feeoutput'] else 3
|
||||||
|
|
||||||
# One output will be correct.
|
# One output will be correct.
|
||||||
for i in range(3):
|
for i in range(3 + chainparams['feeoutput']):
|
||||||
if decode['vout'][i - 1]['value'] == Decimal('0.01500100'):
|
if decode['vout'][i - 1]['value'] == Decimal('0.01500100'):
|
||||||
outnum1 = i - 1
|
outnum1 = i - 1
|
||||||
elif decode['vout'][i - 1]['value'] == Decimal('0.01499900'):
|
elif decode['vout'][i - 1]['value'] == Decimal('0.01499900'):
|
||||||
@@ -346,17 +345,18 @@ def test_txprepare(node_factory, bitcoind):
|
|||||||
changenum = i - 1
|
changenum = i - 1
|
||||||
|
|
||||||
assert decode['vout'][outnum1]['scriptPubKey']['type'] == 'witness_v0_keyhash'
|
assert decode['vout'][outnum1]['scriptPubKey']['type'] == 'witness_v0_keyhash'
|
||||||
assert decode['vout'][outnum1]['scriptPubKey']['addresses'] == ['bcrt1qeyyk6sl5pr49ycpqyckvmttus5ttj25pd0zpvg']
|
assert decode['vout'][outnum1]['scriptPubKey']['addresses'] == [addr]
|
||||||
|
|
||||||
assert decode['vout'][outnum2]['scriptPubKey']['type'] == 'witness_v0_keyhash'
|
assert decode['vout'][outnum2]['scriptPubKey']['type'] == 'witness_v0_keyhash'
|
||||||
assert decode['vout'][outnum2]['scriptPubKey']['addresses'] == ['bcrt1qw508d6qejxtdg4y5r3zarvary0c5xw7kygt080']
|
assert decode['vout'][outnum2]['scriptPubKey']['addresses'] == [addr]
|
||||||
|
|
||||||
assert decode['vout'][changenum]['scriptPubKey']['type'] == 'witness_v0_keyhash'
|
assert decode['vout'][changenum]['scriptPubKey']['type'] == 'witness_v0_keyhash'
|
||||||
|
|
||||||
|
|
||||||
def test_txsend(node_factory, bitcoind):
|
def test_txsend(node_factory, bitcoind, chainparams):
|
||||||
amount = 1000000
|
amount = 1000000
|
||||||
l1 = node_factory.get_node(random_hsm=True)
|
l1 = node_factory.get_node(random_hsm=True)
|
||||||
|
addr = chainparams['example_addr']
|
||||||
|
|
||||||
# Add some funds to withdraw later: both bech32 and p2sh
|
# Add some funds to withdraw later: both bech32 and p2sh
|
||||||
for i in range(5):
|
for i in range(5):
|
||||||
@@ -367,7 +367,7 @@ def test_txsend(node_factory, bitcoind):
|
|||||||
bitcoind.generate_block(1)
|
bitcoind.generate_block(1)
|
||||||
wait_for(lambda: len(l1.rpc.listfunds()['outputs']) == 10)
|
wait_for(lambda: len(l1.rpc.listfunds()['outputs']) == 10)
|
||||||
|
|
||||||
prep = l1.rpc.txprepare([{'bcrt1qeyyk6sl5pr49ycpqyckvmttus5ttj25pd0zpvg': Millisatoshi(amount * 3 * 1000)}])
|
prep = l1.rpc.txprepare([{addr: Millisatoshi(amount * 3 * 1000)}])
|
||||||
out = l1.rpc.txsend(prep['txid'])
|
out = l1.rpc.txsend(prep['txid'])
|
||||||
|
|
||||||
# Cannot discard after send!
|
# Cannot discard after send!
|
||||||
@@ -397,9 +397,10 @@ def test_txsend(node_factory, bitcoind):
|
|||||||
assert decode['vout'][changenum]['scriptPubKey']['addresses'][0] in [f['address'] for f in l1.rpc.listfunds()['outputs']]
|
assert decode['vout'][changenum]['scriptPubKey']['addresses'][0] in [f['address'] for f in l1.rpc.listfunds()['outputs']]
|
||||||
|
|
||||||
|
|
||||||
def test_txprepare_restart(node_factory, bitcoind):
|
def test_txprepare_restart(node_factory, bitcoind, chainparams):
|
||||||
amount = 1000000
|
amount = 1000000
|
||||||
l1 = node_factory.get_node(may_fail=True)
|
l1 = node_factory.get_node(may_fail=True)
|
||||||
|
addr = chainparams['example_addr']
|
||||||
|
|
||||||
# Add some funds to withdraw later: both bech32 and p2sh
|
# Add some funds to withdraw later: both bech32 and p2sh
|
||||||
for i in range(5):
|
for i in range(5):
|
||||||
@@ -410,7 +411,7 @@ def test_txprepare_restart(node_factory, bitcoind):
|
|||||||
bitcoind.generate_block(1)
|
bitcoind.generate_block(1)
|
||||||
wait_for(lambda: [o['status'] for o in l1.rpc.listfunds()['outputs']] == ['confirmed'] * 10)
|
wait_for(lambda: [o['status'] for o in l1.rpc.listfunds()['outputs']] == ['confirmed'] * 10)
|
||||||
|
|
||||||
prep = l1.rpc.txprepare([{'bcrt1qeyyk6sl5pr49ycpqyckvmttus5ttj25pd0zpvg': 'all'}])
|
prep = l1.rpc.txprepare([{addr: 'all'}])
|
||||||
decode = bitcoind.rpc.decoderawtransaction(prep['unsigned_tx'])
|
decode = bitcoind.rpc.decoderawtransaction(prep['unsigned_tx'])
|
||||||
assert decode['txid'] == prep['txid']
|
assert decode['txid'] == prep['txid']
|
||||||
# All 10 inputs
|
# All 10 inputs
|
||||||
@@ -425,7 +426,7 @@ def test_txprepare_restart(node_factory, bitcoind):
|
|||||||
with pytest.raises(RpcError, match=r'not an unreleased txid'):
|
with pytest.raises(RpcError, match=r'not an unreleased txid'):
|
||||||
l1.rpc.txdiscard(prep['txid'])
|
l1.rpc.txdiscard(prep['txid'])
|
||||||
|
|
||||||
prep = l1.rpc.txprepare([{'bcrt1qeyyk6sl5pr49ycpqyckvmttus5ttj25pd0zpvg': 'all'}])
|
prep = l1.rpc.txprepare([{addr: 'all'}])
|
||||||
|
|
||||||
decode = bitcoind.rpc.decoderawtransaction(prep['unsigned_tx'])
|
decode = bitcoind.rpc.decoderawtransaction(prep['unsigned_tx'])
|
||||||
assert decode['txid'] == prep['txid']
|
assert decode['txid'] == prep['txid']
|
||||||
@@ -442,7 +443,7 @@ def test_txprepare_restart(node_factory, bitcoind):
|
|||||||
for i in decode['vin']:
|
for i in decode['vin']:
|
||||||
assert l1.daemon.is_in_log('wallet: reserved output {}/{} reset to available'.format(i['txid'], i['vout']))
|
assert l1.daemon.is_in_log('wallet: reserved output {}/{} reset to available'.format(i['txid'], i['vout']))
|
||||||
|
|
||||||
prep = l1.rpc.txprepare([{'bcrt1qeyyk6sl5pr49ycpqyckvmttus5ttj25pd0zpvg': 'all'}])
|
prep = l1.rpc.txprepare([{addr: 'all'}])
|
||||||
decode = bitcoind.rpc.decoderawtransaction(prep['unsigned_tx'])
|
decode = bitcoind.rpc.decoderawtransaction(prep['unsigned_tx'])
|
||||||
assert decode['txid'] == prep['txid']
|
assert decode['txid'] == prep['txid']
|
||||||
# All 10 inputs
|
# All 10 inputs
|
||||||
|
|||||||
Reference in New Issue
Block a user