(node_factory, bitcoind, chainparams)
| 275 | |
| 276 | @pytest.mark.developer("needs DEVELOPER=1") |
| 277 | def test_closing_specified_destination(node_factory, bitcoind, chainparams): |
| 278 | l1, l2, l3, l4 = node_factory.get_nodes(4) |
| 279 | |
| 280 | l1.rpc.connect(l2.info['id'], 'localhost', l2.port) |
| 281 | l1.rpc.connect(l3.info['id'], 'localhost', l3.port) |
| 282 | l1.rpc.connect(l4.info['id'], 'localhost', l4.port) |
| 283 | |
| 284 | chan12, _ = l1.fundchannel(l2, 10**6) |
| 285 | chan13, _ = l1.fundchannel(l3, 10**6) |
| 286 | chan14, _ = l1.fundchannel(l4, 10**6) |
| 287 | |
| 288 | l1.pay(l2, 100000000) |
| 289 | l1.pay(l3, 100000000) |
| 290 | l1.pay(l4, 100000000) |
| 291 | |
| 292 | mine_funding_to_announce(bitcoind, [l1, l2, l3, l4]) |
| 293 | |
| 294 | addr = chainparams['example_addr'] |
| 295 | l1.rpc.close(chan12, None, addr) |
| 296 | l1.rpc.call('close', {'id': chan13, 'destination': addr}) |
| 297 | l1.rpc.call('close', [chan14, None, addr]) |
| 298 | |
| 299 | l1.daemon.wait_for_logs([' to CLOSINGD_SIGEXCHANGE'] * 3) |
| 300 | |
| 301 | # Both nodes should have disabled the channel in their view |
| 302 | wait_for(lambda: len(l1.getactivechannels()) == 0) |
| 303 | |
| 304 | wait_for(lambda: bitcoind.rpc.getmempoolinfo()['size'] == 3) |
| 305 | |
| 306 | # Now grab the close transaction |
| 307 | closetxs = {} |
| 308 | for i, n in enumerate([l2, l3, l4]): |
| 309 | billboard = only_one(l1.rpc.listpeers(n.info['id'])['peers'][0]['channels'])['status'][0] |
| 310 | m = re.search(r'CLOSINGD_SIGEXCHANGE.* tx:([a-f0-9]{64})', billboard) |
| 311 | closetxs[n] = m.group(1) |
| 312 | |
| 313 | bitcoind.generate_block(1) |
| 314 | sync_blockheight(bitcoind, [l1, l2, l3, l4]) |
| 315 | |
| 316 | # l1 can't spent the output to addr. |
| 317 | for txid in closetxs.values(): |
| 318 | assert not l1.daemon.is_in_log(r'Owning output.* \(SEGWIT\).* txid {}.* CONFIRMED'.format(txid)) |
| 319 | |
| 320 | # Check the txid has at least 1 confirmation |
| 321 | for n, txid in closetxs.items(): |
| 322 | n.daemon.wait_for_log(r'Owning output.* \(SEGWIT\).* txid {}.* CONFIRMED'.format(txid)) |
| 323 | |
| 324 | for n in [l2, l3, l4]: |
| 325 | # Make sure both nodes have grabbed their close tx funds |
| 326 | closetx = closetxs[n] |
| 327 | outputs = n.rpc.listfunds()['outputs'] |
| 328 | assert closetx in set([o['txid'] for o in outputs]) |
| 329 | output_num2 = [o for o in outputs if o['txid'] == closetx][0]['output'] |
| 330 | output_num1 = 0 if output_num2 == 1 else 1 |
| 331 | # Check the another address is addr |
| 332 | assert addr == scriptpubkey_addr(bitcoind.rpc.gettxout(closetx, output_num1)['scriptPubKey']) |
| 333 | assert 1 == bitcoind.rpc.gettxout(closetx, output_num1)['confirmations'] |
| 334 |
nothing calls this directly
no test coverage detected