Generates splice related examples
(node_factory, bitcoind)
| 1312 | |
| 1313 | |
| 1314 | def generate_splice_examples(node_factory, bitcoind): |
| 1315 | """Generates splice related examples""" |
| 1316 | try: |
| 1317 | logger.info('Splice Start...') |
| 1318 | # Basic setup for l7->l8 |
| 1319 | options = [ |
| 1320 | { |
| 1321 | 'allow-deprecated-apis': True, |
| 1322 | 'allow_bad_gossip': True, |
| 1323 | 'broken_log': '.*', |
| 1324 | 'dev-bitcoind-poll': 3, |
| 1325 | }.copy() |
| 1326 | for i in range(2) |
| 1327 | ] |
| 1328 | l7, l8 = node_factory.get_nodes(2, opts=options) |
| 1329 | l7.fundwallet(FUND_WALLET_AMOUNT_SAT) |
| 1330 | l7.rpc.connect(l8.info['id'], 'localhost', l8.port) |
| 1331 | c78, c78res = l7.fundchannel(l8, FUND_CHANNEL_AMOUNT_SAT) |
| 1332 | mine_funding_to_announce(bitcoind, [l7, l8]) |
| 1333 | l7.wait_channel_active(c78) |
| 1334 | chan_id_78 = l7.get_channel_id(l8) |
| 1335 | # Splice |
| 1336 | funds_result_1 = l7.rpc.fundpsbt('109000sat', 'slow', 166, excess_as_change=True) |
| 1337 | spinit_res1 = update_example(node=l7, method='splice_init', params={'channel_id': chan_id_78, 'relative_amount': 100000, 'initialpsbt': funds_result_1['psbt']}) |
| 1338 | spupdate1_res1 = l7.rpc.splice_update(chan_id_78, spinit_res1['psbt']) |
| 1339 | assert(spupdate1_res1['commitments_secured'] is False) |
| 1340 | spupdate2_res1 = update_example(node=l7, method='splice_update', params={'channel_id': chan_id_78, 'psbt': spupdate1_res1['psbt']}) |
| 1341 | assert(spupdate2_res1['commitments_secured'] is True) |
| 1342 | signpsbt_res1 = l7.rpc.signpsbt(spupdate2_res1['psbt']) |
| 1343 | spsigned_res1 = update_example(node=l7, method='splice_signed', params={'channel_id': chan_id_78, 'psbt': signpsbt_res1['signed_psbt']}) |
| 1344 | |
| 1345 | bitcoind.generate_block(1) |
| 1346 | sync_blockheight(bitcoind, [l7]) |
| 1347 | l7.daemon.wait_for_log(' to CHANNELD_NORMAL') |
| 1348 | time.sleep(1) |
| 1349 | |
| 1350 | # Splice out |
| 1351 | funds_result_2 = l7.rpc.addpsbtoutput(100000) |
| 1352 | |
| 1353 | # Pay with fee by subtracting 5000 from channel balance |
| 1354 | spinit_res2 = update_example(node=l7, method='splice_init', params=[chan_id_78, -105000, funds_result_2['psbt']]) |
| 1355 | spupdate1_res2 = l7.rpc.splice_update(chan_id_78, spinit_res2['psbt']) |
| 1356 | assert(spupdate1_res2['commitments_secured'] is False) |
| 1357 | spupdate2_res2 = update_example(node=l7, method='splice_update', params=[chan_id_78, spupdate1_res2['psbt']]) |
| 1358 | assert(spupdate2_res2['commitments_secured'] is True) |
| 1359 | spsigned_res2 = update_example(node=l7, method='splice_signed', params={'channel_id': chan_id_78, 'psbt': spupdate2_res2['psbt']}) |
| 1360 | update_example(node=l7, method='stop', params={}) |
| 1361 | |
| 1362 | REPLACE_RESPONSE_VALUES.extend([ |
| 1363 | {'data_keys': ['any', 'channel_id', 'account'], 'original_value': chan_id_78, 'new_value': NEW_VALUES_LIST['c78_channel_id']}, |
| 1364 | {'data_keys': ['any', 'psbt'], 'original_value': spinit_res1['psbt'], 'new_value': NEW_VALUES_LIST['psbt_1']}, |
| 1365 | {'data_keys': ['any', 'psbt'], 'original_value': spinit_res2['psbt'], 'new_value': NEW_VALUES_LIST['psbt_2']}, |
| 1366 | {'data_keys': ['any', 'initialpsbt', 'psbt'], 'original_value': funds_result_1['psbt'], 'new_value': NEW_VALUES_LIST['psbt_3']}, |
| 1367 | {'data_keys': ['any', 'initialpsbt', 'psbt'], 'original_value': funds_result_2['psbt'], 'new_value': NEW_VALUES_LIST['psbt_4']}, |
| 1368 | {'data_keys': ['psbt'], 'original_value': spupdate2_res1['psbt'], 'new_value': NEW_VALUES_LIST['psbt_5_2']}, |
| 1369 | {'data_keys': ['tx'], 'original_value': spsigned_res1['tx'], 'new_value': NEW_VALUES_LIST['send_tx_1']}, |
| 1370 | {'data_keys': ['txid'], 'original_value': spsigned_res1['txid'], 'new_value': NEW_VALUES_LIST['send_txid_1']}, |
| 1371 | {'data_keys': ['psbt'], 'original_value': spsigned_res1['psbt'], 'new_value': NEW_VALUES_LIST['psbt_1']}, |