Skip to content

Commit 76582ee

Browse files
committed
bkpr: add examples for new edit description RPC calls
1 parent cf26e66 commit 76582ee

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
@@ -2296,7 +2296,47 @@
22962296
"resources": [
22972297
"Main web site: <https://github.com/ElementsProject/lightning>"
22982298
],
2299-
"examples": []
2299+
"examples": [
2300+
{
2301+
"request": {
2302+
"id": "example:bkpr-editdescriptionbyoutpoint#1",
2303+
"method": "bkpr-editdescriptionbyoutpoint",
2304+
"params": {
2305+
"outpoint": "55edd73a01f08057e1f5f61788477c0d7551d5d1aa2f2907bf9d03b6370bbacf:1",
2306+
"description": "edited utxo description"
2307+
}
2308+
},
2309+
"response": {
2310+
"updated": [
2311+
{
2312+
"account": "wallet",
2313+
"type": "chain",
2314+
"tag": "deposit",
2315+
"credit_msat": 200000000000,
2316+
"debit_msat": 0,
2317+
"currency": "bcrt",
2318+
"outpoint": "55edd73a01f08057e1f5f61788477c0d7551d5d1aa2f2907bf9d03b6370bbacf:1",
2319+
"timestamp": 1724554221,
2320+
"blockheight": 105,
2321+
"description": "edited utxo description"
2322+
}
2323+
]
2324+
}
2325+
},
2326+
{
2327+
"request": {
2328+
"id": "example:bkpr-editdescriptionbyoutpoint#2",
2329+
"method": "bkpr-editdescriptionbyoutpoint",
2330+
"params": {
2331+
"outpoint": "6472b4c9d39d8478ed9c848df7a62a512d953a4b2e6e7b09902d76a7bbb761ca:1",
2332+
"description": "edited utxo description"
2333+
}
2334+
},
2335+
"response": {
2336+
"updated": []
2337+
}
2338+
}
2339+
]
23002340
},
23012341
"lightning-bkpr-editdescriptionbypaymentid.json": {
23022342
"$schema": "../rpc-schema-draft.json",
@@ -2559,7 +2599,48 @@
25592599
"resources": [
25602600
"Main web site: <https://github.com/ElementsProject/lightning>"
25612601
],
2562-
"examples": []
2602+
"examples": [
2603+
{
2604+
"request": {
2605+
"id": "example:bkpr-editdescriptionbypaymentid#1",
2606+
"method": "bkpr-editdescriptionbypaymentid",
2607+
"params": {
2608+
"payment_id": "6ff673c6ae3527726cf200274426db79f93054a3cbbc4b3787d1afc2d65565a7",
2609+
"description": "edited invoice description"
2610+
}
2611+
},
2612+
"response": {
2613+
"updated": [
2614+
{
2615+
"account": "a397dd9b3e44afcb67f3f3ce1d649b74a8ade63e35505985e4cc1828634f69a2",
2616+
"type": "channel",
2617+
"tag": "invoice",
2618+
"credit_msat": 500000000,
2619+
"debit_msat": 0,
2620+
"currency": "bcrt",
2621+
"payment_id": "6ff673c6ae3527726cf200274426db79f93054a3cbbc4b3787d1afc2d65565a7",
2622+
"part_id": 0,
2623+
"timestamp": 1724554257,
2624+
"description": "edited invoice description",
2625+
"is_rebalance": false
2626+
}
2627+
]
2628+
}
2629+
},
2630+
{
2631+
"request": {
2632+
"id": "example:bkpr-editdescriptionbypaymentid#2",
2633+
"method": "bkpr-editdescriptionbypaymentid",
2634+
"params": {
2635+
"payment_id": "c97b61113636256111835c0204d70111c42f19069cefdc659849a6afc6b595a4",
2636+
"description": "edited invoice description"
2637+
}
2638+
},
2639+
"response": {
2640+
"updated": []
2641+
}
2642+
}
2643+
]
25632644
},
25642645
"lightning-bkpr-inspect.json": {
25652646
"$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
@@ -500,7 +500,7 @@ static struct command_result *json_edit_desc_utxo(struct command *cmd,
500500
struct chain_event **chain_events;
501501

502502
if (!param(cmd, buf, params,
503-
p_req("identifier", param_outpoint, &outpoint),
503+
p_req("outpoint", param_outpoint, &outpoint),
504504
p_req("description", param_string, &new_desc),
505505
NULL))
506506
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)