mirror of
https://github.com/aljazceru/lightning.git
synced 2026-02-23 06:54:30 +01:00
txprepare: remove old code, switch to plugin.
Some minor phrasing differences cause test changes. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Changelog-Changed: txprepare reservations stay across restarts: use fundpsbt/reservepsbt/unreservepsbt Changelog-Removed: txprepare `destination` `satoshi` argument form removed (deprecated v0.7.3)
This commit is contained in:
@@ -771,7 +771,7 @@ def test_funding_fail(node_factory, bitcoind):
|
||||
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
|
||||
|
||||
# We don't have enough left to cover fees if we try to spend it all.
|
||||
with pytest.raises(RpcError, match=r'Cannot afford transaction'):
|
||||
with pytest.raises(RpcError, match=r'Could not afford'):
|
||||
l1.rpc.fundchannel(l2.info['id'], funds)
|
||||
|
||||
# Should still be connected.
|
||||
@@ -863,7 +863,7 @@ def test_funding_by_utxos(node_factory, bitcoind):
|
||||
utxos = [utxo["txid"] + ":" + str(utxo["output"]) for utxo in l1.rpc.listfunds()["outputs"]]
|
||||
|
||||
# Fund with utxos we don't own
|
||||
with pytest.raises(RpcError, match=r"No matching utxo was found from the wallet"):
|
||||
with pytest.raises(RpcError, match=r"Unknown UTXO "):
|
||||
l3.rpc.fundchannel(l2.info["id"], int(0.01 * 10**8), utxos=utxos)
|
||||
|
||||
# Fund with an empty array
|
||||
@@ -878,7 +878,7 @@ def test_funding_by_utxos(node_factory, bitcoind):
|
||||
l1.rpc.fundchannel(l3.info["id"], int(0.007 * 10**8), utxos=[utxos[2]])
|
||||
|
||||
# Fund another channel with already spent utxos
|
||||
with pytest.raises(RpcError, match=r"No matching utxo was found from the wallet"):
|
||||
with pytest.raises(RpcError, match=r"Already spent UTXO "):
|
||||
l1.rpc.fundchannel(l3.info["id"], int(0.01 * 10**8), utxos=utxos)
|
||||
|
||||
|
||||
|
||||
@@ -341,8 +341,7 @@ def test_txprepare(node_factory, bitcoind, chainparams):
|
||||
# Try passing unconfirmed utxos
|
||||
unconfirmed_utxo = l1.rpc.withdraw(l1.rpc.newaddr()["bech32"], 10**5)
|
||||
uutxos = [unconfirmed_utxo["txid"] + ":0"]
|
||||
with pytest.raises(RpcError, match=r"Cannot afford transaction .* use "
|
||||
"confirmed utxos."):
|
||||
with pytest.raises(RpcError, match=r"Could not afford"):
|
||||
l1.rpc.txprepare([{addr: Millisatoshi(amount * 3.5 * 1000)}],
|
||||
utxos=uutxos)
|
||||
|
||||
@@ -357,15 +356,24 @@ def test_txprepare(node_factory, bitcoind, chainparams):
|
||||
|
||||
# We should have a change output, so this is exact
|
||||
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]['scriptPubKey']['type'] == 'witness_v0_keyhash'
|
||||
assert decode['vout'][1]['scriptPubKey']['addresses'] == [addr]
|
||||
# Change output pos is random.
|
||||
for vout in decode['vout']:
|
||||
if vout['scriptPubKey']['addresses'] == [addr]:
|
||||
changeout = vout
|
||||
|
||||
assert changeout['value'] == Decimal(amount * 3.5) / 10**8
|
||||
assert changeout['scriptPubKey']['type'] == 'witness_v0_keyhash'
|
||||
assert changeout['scriptPubKey']['addresses'] == [addr]
|
||||
|
||||
# Discard prep4 and get all funds again
|
||||
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'):
|
||||
prep5 = l1.rpc.txprepare([{addr: Millisatoshi(amount * 3 * 1000)},
|
||||
{addr: 'all'}])
|
||||
# You can have one which is all, but not two.
|
||||
prep5 = l1.rpc.txprepare([{addr: Millisatoshi(amount * 3 * 1000)},
|
||||
{addr: 'all'}])
|
||||
l1.rpc.txdiscard(prep5['txid'])
|
||||
with pytest.raises(RpcError, match=r"'all'"):
|
||||
prep5 = l1.rpc.txprepare([{addr: 'all'}, {addr: 'all'}])
|
||||
|
||||
prep5 = l1.rpc.txprepare([{addr: Millisatoshi(amount * 3 * 500 + 100000)},
|
||||
{addr: Millisatoshi(amount * 3 * 500 - 100000)}])
|
||||
decode = bitcoind.rpc.decoderawtransaction(prep5['unsigned_tx'])
|
||||
|
||||
Reference in New Issue
Block a user