Skip to content

Commit edc0eb6

Browse files
evansmjrustyrussell
authored andcommitted
bkpr: add examples for new edit description RPC calls
1 parent 7b8d484 commit edc0eb6

File tree

5 files changed

+178
-7
lines changed

5 files changed

+178
-7
lines changed

contrib/msggen/msggen/schema.json

Lines changed: 83 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2872,7 +2872,47 @@
28722872
"resources": [
28732873
"Main web site: <https://github.com/ElementsProject/lightning>"
28742874
],
2875-
"examples": []
2875+
"examples": [
2876+
{
2877+
"request": {
2878+
"id": "example:bkpr-editdescriptionbyoutpoint#1",
2879+
"method": "bkpr-editdescriptionbyoutpoint",
2880+
"params": {
2881+
"outpoint": "55edd73a01f08057e1f5f61788477c0d7551d5d1aa2f2907bf9d03b6370bbacf:1",
2882+
"description": "edited utxo description"
2883+
}
2884+
},
2885+
"response": {
2886+
"updated": [
2887+
{
2888+
"account": "wallet",
2889+
"type": "chain",
2890+
"tag": "deposit",
2891+
"credit_msat": 200000000000,
2892+
"debit_msat": 0,
2893+
"currency": "bcrt",
2894+
"outpoint": "55edd73a01f08057e1f5f61788477c0d7551d5d1aa2f2907bf9d03b6370bbacf:1",
2895+
"timestamp": 1724554221,
2896+
"blockheight": 105,
2897+
"description": "edited utxo description"
2898+
}
2899+
]
2900+
}
2901+
},
2902+
{
2903+
"request": {
2904+
"id": "example:bkpr-editdescriptionbyoutpoint#2",
2905+
"method": "bkpr-editdescriptionbyoutpoint",
2906+
"params": {
2907+
"outpoint": "6472b4c9d39d8478ed9c848df7a62a512d953a4b2e6e7b09902d76a7bbb761ca:1",
2908+
"description": "edited utxo description"
2909+
}
2910+
},
2911+
"response": {
2912+
"updated": []
2913+
}
2914+
}
2915+
]
28762916
},
28772917
"lightning-bkpr-editdescriptionbypaymentid.json": {
28782918
"$schema": "../rpc-schema-draft.json",
@@ -3135,7 +3175,48 @@
31353175
"resources": [
31363176
"Main web site: <https://github.com/ElementsProject/lightning>"
31373177
],
3138-
"examples": []
3178+
"examples": [
3179+
{
3180+
"request": {
3181+
"id": "example:bkpr-editdescriptionbypaymentid#1",
3182+
"method": "bkpr-editdescriptionbypaymentid",
3183+
"params": {
3184+
"payment_id": "6ff673c6ae3527726cf200274426db79f93054a3cbbc4b3787d1afc2d65565a7",
3185+
"description": "edited invoice description"
3186+
}
3187+
},
3188+
"response": {
3189+
"updated": [
3190+
{
3191+
"account": "a397dd9b3e44afcb67f3f3ce1d649b74a8ade63e35505985e4cc1828634f69a2",
3192+
"type": "channel",
3193+
"tag": "invoice",
3194+
"credit_msat": 500000000,
3195+
"debit_msat": 0,
3196+
"currency": "bcrt",
3197+
"payment_id": "6ff673c6ae3527726cf200274426db79f93054a3cbbc4b3787d1afc2d65565a7",
3198+
"part_id": 0,
3199+
"timestamp": 1724554257,
3200+
"description": "edited invoice description",
3201+
"is_rebalance": false
3202+
}
3203+
]
3204+
}
3205+
},
3206+
{
3207+
"request": {
3208+
"id": "example:bkpr-editdescriptionbypaymentid#2",
3209+
"method": "bkpr-editdescriptionbypaymentid",
3210+
"params": {
3211+
"payment_id": "c97b61113636256111835c0204d70111c42f19069cefdc659849a6afc6b595a4",
3212+
"description": "edited invoice description"
3213+
}
3214+
},
3215+
"response": {
3216+
"updated": []
3217+
}
3218+
}
3219+
]
31393220
},
31403221
"lightning-bkpr-inspect.json": {
31413222
"$schema": "../rpc-schema-draft.json",

doc/schemas/lightning-bkpr-editdescriptionbyoutpoint.json

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"debit_msat",
4646
"currency",
4747
"timestamp",
48-
"description"
48+
"description"
4949
],
5050
"properties": {
5151
"account": {
@@ -127,7 +127,7 @@
127127
"description": [
128128
"A description of this outpoint."
129129
]
130-
},
130+
},
131131
"outpoint": {
132132
"type": "string",
133133
"description": [
@@ -266,5 +266,44 @@
266266
"Main web site: <https://github.com/ElementsProject/lightning>"
267267
],
268268
"examples": [
269+
{
270+
"request": {
271+
"id": "example:bkpr-editdescriptionbyoutpoint#1",
272+
"method": "bkpr-editdescriptionbyoutpoint",
273+
"params": {
274+
"outpoint": "55edd73a01f08057e1f5f61788477c0d7551d5d1aa2f2907bf9d03b6370bbacf:1",
275+
"description": "edited utxo description"
276+
}
277+
},
278+
"response": {
279+
"updated": [
280+
{
281+
"account": "wallet",
282+
"type": "chain",
283+
"tag": "deposit",
284+
"credit_msat": 200000000000,
285+
"debit_msat": 0,
286+
"currency": "bcrt",
287+
"outpoint": "55edd73a01f08057e1f5f61788477c0d7551d5d1aa2f2907bf9d03b6370bbacf:1",
288+
"timestamp": 1724554221,
289+
"blockheight": 105,
290+
"description": "edited utxo description"
291+
}
292+
]
293+
}
294+
},
295+
{
296+
"request": {
297+
"id": "example:bkpr-editdescriptionbyoutpoint#2",
298+
"method": "bkpr-editdescriptionbyoutpoint",
299+
"params": {
300+
"outpoint": "6472b4c9d39d8478ed9c848df7a62a512d953a4b2e6e7b09902d76a7bbb761ca:1",
301+
"description": "edited utxo description"
302+
}
303+
},
304+
"response": {
305+
"updated": []
306+
}
307+
}
269308
]
270309
}

doc/schemas/lightning-bkpr-editdescriptionbypaymentid.json

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"debit_msat",
4646
"currency",
4747
"timestamp",
48-
"description"
48+
"description"
4949
],
5050
"properties": {
5151
"account": {
@@ -260,5 +260,45 @@
260260
"Main web site: <https://github.com/ElementsProject/lightning>"
261261
],
262262
"examples": [
263+
{
264+
"request": {
265+
"id": "example:bkpr-editdescriptionbypaymentid#1",
266+
"method": "bkpr-editdescriptionbypaymentid",
267+
"params": {
268+
"payment_id": "6ff673c6ae3527726cf200274426db79f93054a3cbbc4b3787d1afc2d65565a7",
269+
"description": "edited invoice description"
270+
}
271+
},
272+
"response": {
273+
"updated": [
274+
{
275+
"account": "a397dd9b3e44afcb67f3f3ce1d649b74a8ade63e35505985e4cc1828634f69a2",
276+
"type": "channel",
277+
"tag": "invoice",
278+
"credit_msat": 500000000,
279+
"debit_msat": 0,
280+
"currency": "bcrt",
281+
"payment_id": "6ff673c6ae3527726cf200274426db79f93054a3cbbc4b3787d1afc2d65565a7",
282+
"part_id": 0,
283+
"timestamp": 1724554257,
284+
"description": "edited invoice description",
285+
"is_rebalance": false
286+
}
287+
]
288+
}
289+
},
290+
{
291+
"request": {
292+
"id": "example:bkpr-editdescriptionbypaymentid#2",
293+
"method": "bkpr-editdescriptionbypaymentid",
294+
"params": {
295+
"payment_id": "c97b61113636256111835c0204d70111c42f19069cefdc659849a6afc6b595a4",
296+
"description": "edited invoice description"
297+
}
298+
},
299+
"response": {
300+
"updated": []
301+
}
302+
}
263303
]
264304
}

plugins/bkpr/bookkeeper.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ static struct command_result *json_edit_desc_utxo(struct command *cmd,
502502
struct chain_event **chain_events;
503503

504504
if (!param(cmd, buf, params,
505-
p_req("identifier", param_outpoint, &outpoint),
505+
p_req("outpoint", param_outpoint, &outpoint),
506506
p_req("description", param_string, &new_desc),
507507
NULL))
508508
return command_param_failed();

tests/autogenerate-rpc-examples.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,18 @@ def generate_bookkeeper_examples(l2, l3, c23_chan_id):
483483
update_example(node=l3, method='bkpr-listaccountevents', params={})
484484
update_example(node=l3, method='bkpr-listaccountevents', params=[c23_chan_id])
485485
update_example(node=l3, method='bkpr-listincome', params={})
486-
update_example(node=l3, method='bkpr-listincome', params={'consolidate_fees': False})
486+
487+
# listincome and editing descriptions
488+
listincome_result = update_example(node=l3, method='bkpr-listincome', params={'consolidate_fees': False})
489+
invoice = next((event for event in listincome_result['income_events'] if 'payment_id' in event), None)
490+
utxo_event = next((event for event in listincome_result['income_events'] if 'outpoint' in event), None)
491+
update_example(node=l3, method='bkpr-editdescriptionbypaymentid', params={'payment_id': invoice['payment_id'], 'description': 'edited invoice description'})
492+
# Try to edit a payment_id that does not exist
493+
update_example(node=l3, method='bkpr-editdescriptionbypaymentid', params={'payment_id': 'c97b61113636256111835c0204d70111c42f19069cefdc659849a6afc6b595a4', 'description': 'edited invoice description'})
494+
update_example(node=l3, method='bkpr-editdescriptionbyoutpoint', params={'outpoint': utxo_event['outpoint'], 'description': 'edited utxo description'})
495+
# Try to edit an outpoint that does not exist
496+
update_example(node=l3, method='bkpr-editdescriptionbyoutpoint', params={'outpoint': '6472b4c9d39d8478ed9c848df7a62a512d953a4b2e6e7b09902d76a7bbb761ca:1', 'description': 'edited utxo description'})
497+
487498
logger.info('Bookkeeper Done!')
488499
except TaskFinished:
489500
raise

0 commit comments

Comments
 (0)