MCPcopy Create free account
hub / github.com/ElementsProject/lightning / generate_list_examples

Function generate_list_examples

tests/autogenerate-rpc-examples.py:1850–2039  ·  view source on GitHub ↗

Generates lists rpc examples

(l1, l2, l3, c12, c23_2, inv_l31, inv_l32, offer_l23, inv_req_l1_l22, address_l22)

Source from the content-addressed store, hash-verified

1848
1849
1850def generate_list_examples(l1, l2, l3, c12, c23_2, inv_l31, inv_l32, offer_l23, inv_req_l1_l22, address_l22):
1851 """Generates lists rpc examples"""
1852 try:
1853 logger.info('Lists Start...')
1854 # Transactions Lists
1855 FUNDS_LEN = 3
1856 listfunds_res1 = l1.rpc.listfunds()
1857 listfunds_res1 = update_list_responses(listfunds_res1, list_key='outputs', slice_upto=FUNDS_LEN)
1858 listfunds_res1['channels'] = [channel for channel in listfunds_res1['channels'] if channel['peer_id'] != '0382ce59ebf18be7d84677c2e35f23294b9992ceca95491fcf8a56c6cb2d9de199']
1859 listfunds_res1['channels'] = sorted(listfunds_res1['channels'], key=lambda x: x['peer_id'])
1860 for i in range(1, FUNDS_LEN + 1):
1861 lfoutput = listfunds_res1['outputs'][i - 1]
1862 lfchannel = listfunds_res1['channels'][i - 1]
1863 lfoutput['output'] = i + 1
1864 lfoutput['txid'] = 'txid' + (('0000' + str(i)) * 12)
1865 lfoutput['scriptpubkey'] = 'scriptpubkey' + (f"{i:02}" * 28)
1866 lfoutput['address'] = 'bcrt1p00' + ('04' * 28)
1867 lfoutput['blockheight'] = NEW_VALUES_LIST['blockheight_160']
1868 lfoutput['amount_msat'] = 25000000 + (i * 1000000)
1869 lfchannel['funding_output'] = i
1870 lfchannel['funding_txid'] = 'txid' + (('0100' + str(i)) * 12)
1871 lfchannel['amount_msat'] = 10000000 + (i * 1000000)
1872 lfchannel['our_amount_msat'] = 35000000 + (i * 1000000)
1873 update_example(node=l1, method='listfunds', params={}, response=listfunds_res1)
1874
1875 listforwards_res1 = l2.rpc.listforwards(in_channel=c12, out_channel=c23_2, status='settled')
1876 listforwards_res1 = update_list_responses(listforwards_res1, list_key='forwards', slice_upto=5, update_func=lambda x, i: x.update({'received_time': NEW_VALUES_LIST['time_at_800'] + (i * 10000), 'resolved_time': NEW_VALUES_LIST['time_at_850'] + (i * 10000)}))
1877 update_example(node=l2, method='listforwards', params={'in_channel': c12, 'out_channel': c23_2, 'status': 'settled'}, response=listforwards_res1)
1878 listforwards_res2 = l2.rpc.listforwards()
1879 listforwards_res2 = update_list_responses(listforwards_res2, list_key='forwards', slice_upto=5, update_func=lambda x, i: x.update({'received_time': NEW_VALUES_LIST['time_at_800'] + (i * 10000), 'resolved_time': NEW_VALUES_LIST['time_at_850'] + (i * 10000)}))
1880 update_example(node=l2, method='listforwards', params={}, response=listforwards_res2)
1881
1882 listinvoices_res1 = l2.rpc.listinvoices(label='lbl_l21')
1883 listinvoices_res1 = update_list_responses(listinvoices_res1, list_key='invoices', slice_upto=5, update_func=lambda x, i: x.update({'paid_at': NEW_VALUES_LIST['time_at_850'] + (i * 10000), 'expires_at': NEW_VALUES_LIST['time_at_900'] + (i * 10000)}))
1884 update_example(node=l2, method='listinvoices', params={'label': 'lbl_l21'}, response=listinvoices_res1)
1885 listinvoices_res2 = l2.rpc.listinvoices()
1886 listinvoices_res2 = update_list_responses(listinvoices_res2, list_key='invoices', slice_upto=5, update_func=lambda x, i: x.update({'paid_at': NEW_VALUES_LIST['time_at_850'] + (i * 10000), 'expires_at': NEW_VALUES_LIST['time_at_900'] + (i * 10000)}))
1887 update_example(node=l2, method='listinvoices', params={}, response=listinvoices_res2)
1888
1889 listhtlcs_res1 = l1.rpc.listhtlcs(c12)
1890 listhtlcs_res1 = update_list_responses(listhtlcs_res1, list_key='htlcs')
1891 update_example(node=l1, method='listhtlcs', params=[c12], response=listhtlcs_res1)
1892 listhtlcs_res2 = l1.rpc.listhtlcs(index='created', start=4, limit=1)
1893 listhtlcs_res2 = update_list_responses(listhtlcs_res2, list_key='htlcs')
1894 update_example(node=l1, method='listhtlcs', params={'index': 'created', 'start': 4, 'limit': 1}, response=listhtlcs_res2)
1895
1896 listsendpays_res1 = l1.rpc.listsendpays(bolt11=inv_l31['bolt11'])
1897 listsendpays_res1 = update_list_responses(listsendpays_res1, list_key='payments', slice_upto=5, update_func=lambda x, i: x.update({'created_at': NEW_VALUES_LIST['time_at_800'] + (i * 10000), 'completed_at': NEW_VALUES_LIST['time_at_900'] + (i * 10000)}))
1898 update_example(node=l1, method='listsendpays', params={'bolt11': inv_l31['bolt11']}, response=listsendpays_res1)
1899 listsendpays_res2 = l1.rpc.listsendpays()
1900 listsendpays_res2 = update_list_responses(listsendpays_res2, list_key='payments', slice_upto=5, update_func=lambda x, i: x.update({'created_at': NEW_VALUES_LIST['time_at_800'] + (i * 10000), 'completed_at': NEW_VALUES_LIST['time_at_900'] + (i * 10000)}))
1901 update_example(node=l1, method='listsendpays', params={}, response=listsendpays_res2)
1902
1903 listpays_res1 = l2.rpc.listpays(bolt11=inv_l32['bolt11'])
1904 listpays_res1 = update_list_responses(listpays_res1, list_key='pays')
1905 update_example(node=l2, method='listpays', params={'bolt11': inv_l32['bolt11']}, response=listpays_res1)
1906 listpays_res2 = l2.rpc.listpays()
1907 listpays_res2 = update_list_responses(listpays_res2, list_key='pays')

Callers 1

test_generate_examplesFunction · 0.85

Calls 15

update_list_responsesFunction · 0.85
update_exampleFunction · 0.85
listforwardsMethod · 0.80
updateMethod · 0.80
listsendpaysMethod · 0.80
listpaysMethod · 0.80
listtransactionsMethod · 0.80
listconfigsMethod · 0.80
listpeerchannelsMethod · 0.80
subMethod · 0.80
listoffersMethod · 0.80
errorMethod · 0.80

Tested by 1

test_generate_examplesFunction · 0.68