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

Function generate_utils_examples

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

Generates other utilities examples

(l1, l2, l3, l4, l5, l6, c23_2, c34_2, inv_l11, inv_l22, rune_l21, bitcoind)

Source from the content-addressed store, hash-verified

1168
1169
1170def generate_utils_examples(l1, l2, l3, l4, l5, l6, c23_2, c34_2, inv_l11, inv_l22, rune_l21, bitcoind):
1171 """Generates other utilities examples"""
1172 try:
1173 logger.info('General Utils Start...')
1174 update_example(node=l2, method='batching', params={'enable': True})
1175 update_example(node=l2, method='ping', params={'id': l1.info['id'], 'len': 128, 'pongbytes': 128})
1176 update_example(node=l2, method='ping', params={'id': l3.info['id'], 'len': 1000, 'pongbytes': 65535})
1177 update_example(node=l2, method='help', params={'command': 'pay'})
1178 update_example(node=l2, method='help', params={'command': 'dev'})
1179 update_example(node=l2, method='setconfig', params=['autoclean-expiredinvoices-age', 300])
1180 update_example(node=l2, method='setconfig', params={'config': 'min-capacity-sat', 'val': 500000})
1181 update_example(node=l2, method='addgossip', params={'message': '010078c3314666731e339c0b8434f7824797a084ed7ca3655991a672da068e2c44cb53b57b53a296c133bc879109a8931dc31e6913a4bda3d58559b99b95663e6d52775579447ef5526300e1bb89bc6af8557aa1c3810a91814eafad6d103f43182e17b16644cb38c1d58a8edd094303959a9f1f9d42ff6c32a21f9c118531f512c8679cabaccc6e39dbd95a4dac90e75a258893c3aa3f733d1b8890174d5ddea8003cadffe557773c54d2c07ca1d535c4bf85885f879ae466c16a516e8ffcfec1740e3f5c98ca9ce13f452e867befef5517f306ed6aa5119b79059bcc6f68f329986b665d16de7bc7df64e3537504c91eeabe0e59d3a2b68e4216ead2b0f6e3ef7c000006226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f0000670000010000022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d590266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c0351802e3bd38009866c9da8ec4aa99cc4ea9c6c0dd46df15c61ef0ce1f271291714e5702324266de8403b3ab157a09f1f784d587af61831c998c151bcc21bb74c2b2314b'})
1182 update_example(node=l2, method='addgossip', params={'message': '0102420526c8eb62ec6999bbee5f1de4841cab734374ec642b7deeb0259e76220bf82e97a241c907d5ff52019655f7f9a614c285bb35690f3a1a2b928d7b2349a79e06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f000067000001000065b32a0e010100060000000000000000000000010000000a000000003b023380'})
1183 update_example(node=l2, method='deprecations', params={'enable': True})
1184 update_example(node=l2, method='deprecations', params={'enable': False})
1185 getlog_res1 = l2.rpc.getlog(level='unusual')
1186 getlog_res1['log'] = getlog_res1['log'][0:5]
1187 update_example(node=l2, method='getlog', params={'level': 'unusual'}, response=getlog_res1)
1188 update_example(node=l2, method='notifications', params={'enable': True})
1189 update_example(node=l2, method='notifications', params={'enable': False})
1190 update_example(node=l2, method='check', params={'command_to_check': 'sendpay', 'route': [{'amount_msat': 1011, 'id': l3.info['id'], 'delay': 20, 'channel': c23_2}, {'amount_msat': 1000, 'id': l4.info['id'], 'delay': 10, 'channel': c34_2}], 'payment_hash': '0000000000000000000000000000000000000000000000000000000000000000'})
1191 update_example(node=l2, method='check', params={'command_to_check': 'dev', 'subcommand': 'slowcmd', 'msec': 1000})
1192 update_example(node=l6, method='check', params={'command_to_check': 'recover', 'hsmsecret': '6c696768746e696e672d31000000000000000000000000000000000000000000'})
1193 update_example(node=l2, method='plugin', params={'subcommand': 'start', 'plugin': os.path.join(CWD, 'tests/plugins/allow_even_msgs.py')})
1194 update_example(node=l2, method='plugin', params={'subcommand': 'stop', 'plugin': os.path.join(CWD, 'tests/plugins/allow_even_msgs.py')})
1195 update_example(node=l2, method='plugin', params=['list'])
1196 update_example(node=l2, method='sendcustommsg', params={'node_id': l3.info['id'], 'msg': '77770012'})
1197
1198 # Wallet Utils
1199 address_l21 = update_example(node=l2, method='newaddr', params={})
1200 address_l22 = update_example(node=l2, method='newaddr', params={'addresstype': 'p2tr'})
1201 withdraw_l21 = update_example(node=l2, method='withdraw', params={'destination': address_l21['bech32'], 'satoshi': 555555})
1202
1203 bitcoind.generate_block(4, wait_for_mempool=[withdraw_l21['txid']])
1204 sync_blockheight(bitcoind, [l2])
1205
1206 funds_l2 = l2.rpc.listfunds()
1207 utxos = [f"{funds_l2['outputs'][2]['txid']}:{funds_l2['outputs'][2]['output']}"]
1208 example_utxos = ['utxo' + ('02' * 30) + ':1']
1209 withdraw_l22 = update_example(node=l2, method='withdraw', params={'destination': address_l22['p2tr'], 'satoshi': 'all', 'feerate': '20000perkb', 'minconf': 0, 'utxos': utxos})
1210 bitcoind.generate_block(4, wait_for_mempool=[withdraw_l22['txid']])
1211 multiwithdraw_res1 = update_example(node=l2, method='multiwithdraw', params={'outputs': [{l1.rpc.newaddr('bech32')['bech32']: '2222000msat'}, {l1.rpc.newaddr('bech32')['bech32']: '3333000msat'}]})
1212 multiwithdraw_res2 = update_example(node=l2, method='multiwithdraw', params={'outputs': [{l1.rpc.newaddr('p2tr')['p2tr']: 1000}, {l1.rpc.newaddr('bech32')['bech32']: 1000}, {l2.rpc.newaddr()['bech32']: 1000}, {l3.rpc.newaddr()['bech32']: 1000}, {l3.rpc.newaddr()['bech32']: 1000}, {l4.rpc.newaddr('p2tr')['p2tr']: 1000}, {l1.rpc.newaddr('bech32')['bech32']: 1000}]})
1213 l2.rpc.connect(l4.info['id'], 'localhost', l4.port)
1214 l2.rpc.connect(l5.info['id'], 'localhost', l5.port)
1215 update_example(node=l2, method='disconnect', params={'id': l4.info['id'], 'force': False})
1216 update_example(node=l2, method='disconnect', params={'id': l5.info['id'], 'force': True})
1217 update_example(node=l2, method='parsefeerate', params=['unilateral_close'])
1218 update_example(node=l2, method='parsefeerate', params=['9999perkw'])
1219 update_example(node=l2, method='parsefeerate', params=[10000])
1220 update_example(node=l2, method='parsefeerate', params=['urgent'])
1221 update_example(node=l2, method='feerates', params={'style': 'perkw'})
1222 update_example(node=l2, method='feerates', params={'style': 'perkb'})
1223 update_example(node=l2, method='signmessage', params={'message': 'this is a test!'})
1224 update_example(node=l2, method='signmessage', params={'message': 'message for you'})
1225 update_example(node=l2, method='checkmessage', params={'message': 'testcase to check new rpc error', 'zbase': 'd66bqz3qsku5fxtqsi37j11pci47ydxa95iusphutggz9ezaxt56neh77kxe5hyr41kwgkncgiu94p9ecxiexgpgsz8daoq4tw8kj8yx', 'pubkey': '03be3b0e9992153b1d5a6e1623670b6c3663f72ce6cf2e0dd39c0a373a7de5a3b7'})
1226 update_example(node=l2, method='checkmessage', params={'message': 'this is a test!', 'zbase': 'd6tqaeuonjhi98mmont9m4wag7gg4krg1f4txonug3h31e9h6p6k6nbwjondnj46dkyausobstnk7fhyy998bhgc1yr98dfmhb4k54d7'})
1227 addr = l2.rpc.newaddr('bech32')['bech32']

Callers 1

test_generate_examplesFunction · 0.85

Calls 15

sync_blockheightFunction · 0.90
MillisatoshiClass · 0.90
update_exampleFunction · 0.85
getlogMethod · 0.80
joinMethod · 0.80
generate_blockMethod · 0.80
addpsbtoutputMethod · 0.80
fundpsbtMethod · 0.80
unreserveinputsMethod · 0.80
to_btcMethod · 0.80
reserveinputsMethod · 0.80
signpsbtMethod · 0.80

Tested by 1

test_generate_examplesFunction · 0.68