(node_factory, bitcoind)
| 232 | @pytest.mark.openchannel('v2') |
| 233 | @unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need') |
| 234 | def test_splice_rbf(node_factory, bitcoind): |
| 235 | l1, l2 = node_factory.line_graph(2, fundamount=1000000, wait_for_announce=True) |
| 236 | |
| 237 | chan_id = l1.get_channel_id(l2) |
| 238 | |
| 239 | funds_result = l1.rpc.addpsbtoutput(100000) |
| 240 | |
| 241 | # Pay with fee by subtracting 5801 from channel balance |
| 242 | result = l1.rpc.splice_init(chan_id, -105801, funds_result['psbt']) |
| 243 | result = l1.rpc.splice_update(chan_id, result['psbt']) |
| 244 | assert(result['commitments_secured'] is False) |
| 245 | result = l1.rpc.splice_update(chan_id, result['psbt']) |
| 246 | assert(result['commitments_secured'] is True) |
| 247 | result = l1.rpc.splice_signed(chan_id, result['psbt']) |
| 248 | |
| 249 | l2.daemon.wait_for_log(r'CHANNELD_NORMAL to CHANNELD_AWAITING_SPLICE') |
| 250 | l1.daemon.wait_for_log(r'CHANNELD_NORMAL to CHANNELD_AWAITING_SPLICE') |
| 251 | |
| 252 | wait_for(lambda: len(list(bitcoind.rpc.getrawmempool(True).keys())) == 1) |
| 253 | mempool = bitcoind.rpc.getrawmempool(True) |
| 254 | assert result['txid'] in list(mempool.keys()) |
| 255 | |
| 256 | inv = l2.rpc.invoice(10**2, '1', 'no_1') |
| 257 | l1.rpc.xpay(inv['bolt11']) |
| 258 | |
| 259 | funds_result = l1.rpc.addpsbtoutput(100000) |
| 260 | |
| 261 | # Pay with fee by subtracting 5790 from channel balance |
| 262 | result = l1.rpc.splice_init(chan_id, -111722, funds_result['psbt']) |
| 263 | result = l1.rpc.splice_update(chan_id, result['psbt']) |
| 264 | assert(result['commitments_secured'] is False) |
| 265 | result = l1.rpc.splice_update(chan_id, result['psbt']) |
| 266 | assert(result['commitments_secured'] is True) |
| 267 | result = l1.rpc.splice_signed(chan_id, result['psbt']) |
| 268 | |
| 269 | l2.daemon.wait_for_log(r'CHANNELD_AWAITING_SPLICE to CHANNELD_AWAITING_SPLICE') |
| 270 | l1.daemon.wait_for_log(r'CHANNELD_AWAITING_SPLICE to CHANNELD_AWAITING_SPLICE') |
| 271 | |
| 272 | inv = l2.rpc.invoice(10**2, '2', 'no_2') |
| 273 | l1.rpc.xpay(inv['bolt11']) |
| 274 | |
| 275 | # Make sure l1 doesn't unilateral close if HTLC hasn't completely settled before deadline. |
| 276 | wait_for(lambda: only_one(l1.rpc.listpeerchannels()['channels'])['htlcs'] == []) |
| 277 | |
| 278 | bitcoind.generate_block(6, wait_for_mempool=1) |
| 279 | |
| 280 | l2.daemon.wait_for_log(r'CHANNELD_AWAITING_SPLICE to CHANNELD_NORMAL') |
| 281 | l1.daemon.wait_for_log(r'CHANNELD_AWAITING_SPLICE to CHANNELD_NORMAL') |
| 282 | |
| 283 | inv = l2.rpc.invoice(10**2, '3', 'no_3') |
| 284 | l1.rpc.xpay(inv['bolt11']) |
| 285 | |
| 286 | # Check that the splice doesn't generate a unilateral close transaction |
| 287 | time.sleep(5) |
| 288 | assert l1.db_query("SELECT count(*) as c FROM channeltxs;")[0]['c'] == 0 |
| 289 | |
| 290 | |
| 291 | @unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need') |
nothing calls this directly
no test coverage detected