Fund a channel with specific utxos
(node_factory, bitcoind)
| 1190 | @pytest.mark.openchannel('v2') |
| 1191 | @pytest.mark.developer |
| 1192 | def test_funding_by_utxos(node_factory, bitcoind): |
| 1193 | """Fund a channel with specific utxos""" |
| 1194 | l1, l2, l3 = node_factory.line_graph(3, fundchannel=False) |
| 1195 | |
| 1196 | # Get 3 differents utxo |
| 1197 | l1.fundwallet(0.01 * 10**8) |
| 1198 | l1.fundwallet(0.01 * 10**8) |
| 1199 | l1.fundwallet(0.01 * 10**8) |
| 1200 | wait_for(lambda: len(l1.rpc.listfunds()["outputs"]) == 3) |
| 1201 | |
| 1202 | utxos = [utxo["txid"] + ":" + str(utxo["output"]) for utxo in l1.rpc.listfunds()["outputs"]] |
| 1203 | |
| 1204 | # Fund with utxos we don't own |
| 1205 | with pytest.raises(RpcError, match=r"Unknown UTXO "): |
| 1206 | l3.rpc.fundchannel(l2.info["id"], int(0.01 * 10**8), utxos=utxos) |
| 1207 | |
| 1208 | # Fund with an empty array |
| 1209 | with pytest.raises(RpcError, match=r"Please specify an array of \\'txid:output_index\\', not \"*\""): |
| 1210 | l1.rpc.fundchannel(l2.info["id"], int(0.01 * 10**8), utxos=[]) |
| 1211 | |
| 1212 | # Fund a channel from some of the utxos, without change |
| 1213 | l1.rpc.fundchannel(l2.info["id"], "all", utxos=utxos[0:2]) |
| 1214 | |
| 1215 | # Fund a channel from the rest of utxos, with change |
| 1216 | l1.rpc.connect(l3.info["id"], "localhost", l3.port) |
| 1217 | l1.rpc.fundchannel(l3.info["id"], int(0.007 * 10**8), utxos=[utxos[2]]) |
| 1218 | |
| 1219 | # Fund another channel with already reserved utxos |
| 1220 | with pytest.raises(RpcError, match=r"UTXO.*already reserved"): |
| 1221 | l1.rpc.fundchannel(l3.info["id"], int(0.01 * 10**8), utxos=utxos) |
| 1222 | |
| 1223 | bitcoind.generate_block(1, wait_for_mempool=1) |
| 1224 | sync_blockheight(bitcoind, [l1]) |
| 1225 | |
| 1226 | # Fund another channel with already spent utxos |
| 1227 | with pytest.raises(RpcError, match=r"Already spent UTXO "): |
| 1228 | l1.rpc.fundchannel(l3.info["id"], int(0.01 * 10**8), utxos=utxos) |
| 1229 | |
| 1230 | |
| 1231 | @pytest.mark.developer("needs dev_forget_channel") |
nothing calls this directly
no test coverage detected