add test, update schemas, fix warning_custom_fallbacks

This commit is contained in:
Chris Guida 2023-10-26 14:04:54 +10:30 committed by Rusty Russell
parent 54ef84e891
commit 88ac2dcb7e
17 changed files with 571 additions and 340 deletions

View File

@ -388,6 +388,10 @@
"Connect.features": 2,
"Connect.id": 1
},
"CreateinvoicePaid_outpoint": {
"CreateInvoice.paid_outpoint.outnum": 2,
"CreateInvoice.paid_outpoint.txid": 1
},
"CreateinvoiceRequest": {
"CreateInvoice.invstring": 1,
"CreateInvoice.label": 2,
@ -405,6 +409,7 @@
"CreateInvoice.label": 1,
"CreateInvoice.local_offer_id": 13,
"CreateInvoice.paid_at": 11,
"CreateInvoice.paid_outpoint": 17,
"CreateInvoice.pay_index": 9,
"CreateInvoice.payer_note": 14,
"CreateInvoice.payment_hash": 4,
@ -989,6 +994,7 @@
"ListInvoices.invoices[].label": 1,
"ListInvoices.invoices[].local_offer_id": 9,
"ListInvoices.invoices[].paid_at": 13,
"ListInvoices.invoices[].paid_outpoint": 18,
"ListInvoices.invoices[].pay_index": 11,
"ListInvoices.invoices[].payer_note": 10,
"ListInvoices.invoices[].payment_hash": 3,
@ -996,6 +1002,10 @@
"ListInvoices.invoices[].status": 4,
"ListInvoices.invoices[].updated_index": 17
},
"ListinvoicesInvoicesPaid_outpoint": {
"ListInvoices.invoices[].paid_outpoint.outnum": 2,
"ListInvoices.invoices[].paid_outpoint.txid": 1
},
"ListinvoicesRequest": {
"ListInvoices.index": 5,
"ListInvoices.invstring": 2,
@ -1567,6 +1577,10 @@
"UtxoPsbt.psbt": 1,
"UtxoPsbt.reservations[]": 6
},
"WaitanyinvoicePaid_outpoint": {
"WaitAnyInvoice.paid_outpoint.outnum": 2,
"WaitAnyInvoice.paid_outpoint.txid": 1
},
"WaitanyinvoiceRequest": {
"WaitAnyInvoice.lastpay_index": 1,
"WaitAnyInvoice.timeout": 2
@ -1581,6 +1595,7 @@
"WaitAnyInvoice.expires_at": 5,
"WaitAnyInvoice.label": 1,
"WaitAnyInvoice.paid_at": 11,
"WaitAnyInvoice.paid_outpoint": 15,
"WaitAnyInvoice.pay_index": 9,
"WaitAnyInvoice.payment_hash": 3,
"WaitAnyInvoice.payment_preimage": 12,
@ -1594,6 +1609,10 @@
"WaitblockheightResponse": {
"WaitBlockHeight.blockheight": 1
},
"WaitinvoicePaid_outpoint": {
"WaitInvoice.paid_outpoint.outnum": 2,
"WaitInvoice.paid_outpoint.txid": 1
},
"WaitinvoiceRequest": {
"WaitInvoice.label": 1
},
@ -1607,6 +1626,7 @@
"WaitInvoice.expires_at": 5,
"WaitInvoice.label": 1,
"WaitInvoice.paid_at": 11,
"WaitInvoice.paid_outpoint": 15,
"WaitInvoice.pay_index": 9,
"WaitInvoice.payment_hash": 3,
"WaitInvoice.payment_preimage": 12,
@ -1833,6 +1853,18 @@
"added": "pre-v0.10.1",
"deprecated": false
},
"CreateInvoice.paid_outpoint": {
"added": "v23.11",
"deprecated": false
},
"CreateInvoice.paid_outpoint.outnum": {
"added": "v23.11",
"deprecated": false
},
"CreateInvoice.paid_outpoint.txid": {
"added": "v23.11",
"deprecated": false
},
"CreateInvoice.pay_index": {
"added": "pre-v0.10.1",
"deprecated": false
@ -3753,6 +3785,18 @@
"added": "pre-v0.10.1",
"deprecated": false
},
"ListInvoices.invoices[].paid_outpoint": {
"added": "v23.11",
"deprecated": false
},
"ListInvoices.invoices[].paid_outpoint.outnum": {
"added": "v23.11",
"deprecated": false
},
"ListInvoices.invoices[].paid_outpoint.txid": {
"added": "v23.11",
"deprecated": false
},
"ListInvoices.invoices[].pay_index": {
"added": "pre-v0.10.1",
"deprecated": false
@ -5525,6 +5569,18 @@
"added": "pre-v0.10.1",
"deprecated": false
},
"WaitAnyInvoice.paid_outpoint": {
"added": "v23.11",
"deprecated": false
},
"WaitAnyInvoice.paid_outpoint.outnum": {
"added": "v23.11",
"deprecated": false
},
"WaitAnyInvoice.paid_outpoint.txid": {
"added": "v23.11",
"deprecated": false
},
"WaitAnyInvoice.pay_index": {
"added": "pre-v0.10.1",
"deprecated": false
@ -5601,6 +5657,18 @@
"added": "pre-v0.10.1",
"deprecated": false
},
"WaitInvoice.paid_outpoint": {
"added": "v23.11",
"deprecated": false
},
"WaitInvoice.paid_outpoint.outnum": {
"added": "v23.11",
"deprecated": false
},
"WaitInvoice.paid_outpoint.txid": {
"added": "v23.11",
"deprecated": false
},
"WaitInvoice.pay_index": {
"added": "pre-v0.10.1",
"deprecated": false

Binary file not shown.

BIN
cln-grpc/src/convert.rs generated

Binary file not shown.

BIN
cln-rpc/src/model.rs generated

Binary file not shown.

File diff suppressed because one or more lines are too long

View File

@ -323,6 +323,13 @@ def connect2py(m):
})
def createinvoice_paid_outpoint2py(m):
return remove_default({
"txid": hexlify(m.txid), # PrimitiveField in generate_composite
"outnum": m.outnum, # PrimitiveField in generate_composite
})
def createinvoice2py(m):
return remove_default({
"label": m.label, # PrimitiveField in generate_composite
@ -432,6 +439,13 @@ def listdatastore2py(m):
})
def listinvoices_invoices_paid_outpoint2py(m):
return remove_default({
"txid": hexlify(m.txid), # PrimitiveField in generate_composite
"outnum": m.outnum, # PrimitiveField in generate_composite
})
def listinvoices_invoices2py(m):
return remove_default({
"label": m.label, # PrimitiveField in generate_composite
@ -577,6 +591,13 @@ def listnodes2py(m):
})
def waitanyinvoice_paid_outpoint2py(m):
return remove_default({
"txid": hexlify(m.txid), # PrimitiveField in generate_composite
"outnum": m.outnum, # PrimitiveField in generate_composite
})
def waitanyinvoice2py(m):
return remove_default({
"label": m.label, # PrimitiveField in generate_composite
@ -596,6 +617,13 @@ def waitanyinvoice2py(m):
})
def waitinvoice_paid_outpoint2py(m):
return remove_default({
"txid": hexlify(m.txid), # PrimitiveField in generate_composite
"outnum": m.outnum, # PrimitiveField in generate_composite
})
def waitinvoice2py(m):
return remove_default({
"label": m.label, # PrimitiveField in generate_composite

View File

@ -45,6 +45,9 @@ On success, an object is returned, containing:
- **pay\_index** (u64, optional): Incrementing id for when this was paid (**status** *paid* only)
- **amount\_received\_msat** (msat, optional): Amount actually received (**status** *paid* only)
- **paid\_at** (u64, optional): UNIX timestamp of when invoice was paid (**status** *paid* only)
- **paid\_outpoint** (object, optional): Outpoint this invoice was paid with (**status** *paid* only) *(added v23.11)*:
- **txid** (txid): ID of the transaction that paid the invoice (**status** *paid* only) *(added v23.11)*
- **outnum** (u32): The 0-based output number of the transaction that paid the invoice (**status** *paid* only) *(added v23.11)*
- **payment\_preimage** (secret, optional): the proof of payment: SHA256 of this **payment\_hash**
- **local\_offer\_id** (hex, optional): the *id* of our offer which created this invoice (**experimental-offers** only). (always 64 characters)
- **invreq\_payer\_note** (string, optional): the optional *invreq\_payer\_note* from invoice\_request which created this invoice (**experimental-offers** only).
@ -77,4 +80,4 @@ RESOURCES
Main web site: <https://github.com/ElementsProject/lightning>
[comment]: # ( SHA256STAMP:2d2180c9e903e2b79d5ddb2b0cf995b1f7aa27b0f9bb1f6e19252b94dcd46ef1)
[comment]: # ( SHA256STAMP:51966a70e3eaa77c703fbd8d00cfb3f7f7602b50149ba6cb8fa0fc115cf05450)

View File

@ -47,6 +47,9 @@ If **status** is "paid":
- **amount\_received\_msat** (msat): the amount actually received (could be slightly greater than *amount\_msat*, since clients may overpay)
- **paid\_at** (u64): UNIX timestamp of when it was paid
- **payment\_preimage** (secret): proof of payment
- **paid\_outpoint** (object, optional): Outpoint this invoice was paid with *(added v23.11)*:
- **txid** (txid): ID of the transaction that paid the invoice *(added v23.11)*
- **outnum** (u32): The 0-based output number of the transaction that paid the invoice *(added v23.11)*
[comment]: # (GENERATE-FROM-SCHEMA-END)
@ -65,4 +68,4 @@ RESOURCES
Main web site: <https://github.com/ElementsProject/lightning>
[comment]: # ( SHA256STAMP:e698b0e345ed4912b7699b43f2571a4cc3bb4ae909efeb631b02dd94a87e765c)
[comment]: # ( SHA256STAMP:7e4b1182ba879bea892d143b53cdc31350a9668c734c6bb8f86ab9b6e3f0b06e)

View File

@ -88,7 +88,6 @@ a foreign key.
[comment]: # (GENERATE-DOC-START)
The following tables are currently supported:
- `bkpr_accountevents` (see lightning-bkpr-listaccountevents(7))
- `account` (type `string`, sqltype `TEXT`)
- `type` (type `string`, sqltype `TEXT`)
@ -211,6 +210,8 @@ The following tables are currently supported:
- `pay_index` (type `u64`, sqltype `INTEGER`)
- `amount_received_msat` (type `msat`, sqltype `INTEGER`)
- `paid_at` (type `u64`, sqltype `INTEGER`)
- `paid_outpoint_txid` (type `txid`, sqltype `BLOB`, from JSON object `paid_outpoint`)
- `paid_outpoint_outnum` (type `u32`, sqltype `INTEGER`, from JSON object `paid_outpoint`)
- `payment_preimage` (type `secret`, sqltype `BLOB`)
- `nodes` indexed by `nodeid` (see lightning-listnodes(7))
@ -515,4 +516,4 @@ RESOURCES
---------
Main web site: <https://github.com/ElementsProject/lightning>
[comment]: # ( SHA256STAMP:2f77078555f16a9dbee5f068d4d0ba18727aeb378be674cd96bf7c1554a74ce5)
[comment]: # ( SHA256STAMP:b14fce571cf85639c460c59ddec117ce1cb23bd219618730b164ea3cc979b1aa)

View File

@ -53,6 +53,9 @@ If **status** is "paid":
- **amount\_received\_msat** (msat): the amount actually received (could be slightly greater than *amount\_msat*, since clients may overpay)
- **paid\_at** (u64): UNIX timestamp of when it was paid
- **payment\_preimage** (secret): proof of payment
- **paid\_outpoint** (object, optional): Outpoint this invoice was paid with *(added v23.11)*:
- **txid** (txid): ID of the transaction that paid the invoice *(added v23.11)*
- **outnum** (u32): The 0-based output number of the transaction that paid the invoice *(added v23.11)*
[comment]: # (GENERATE-FROM-SCHEMA-END)
@ -77,4 +80,4 @@ RESOURCES
Main web site: <https://github.com/ElementsProject/lightning>
[comment]: # ( SHA256STAMP:a0ace35f11efcdfbac39ef830cd7b2b6c8f48816c5512d7d2300edb9463aa4e6)
[comment]: # ( SHA256STAMP:4c8ba0c4aec4f9507588fcbe35c07c0a9761a65b78664afafe228c18b306f8c4)

View File

@ -35,6 +35,9 @@ If **status** is "paid":
- **amount\_received\_msat** (msat): the amount actually received (could be slightly greater than *amount\_msat*, since clients may overpay)
- **paid\_at** (u64): UNIX timestamp of when it was paid
- **payment\_preimage** (secret): proof of payment
- **paid\_outpoint** (object, optional): Outpoint this invoice was paid with *(added v23.11)*:
- **txid** (txid): ID of the transaction that paid the invoice *(added v23.11)*
- **outnum** (u32): The 0-based output number of the transaction that paid the invoice *(added v23.11)*
[comment]: # (GENERATE-FROM-SCHEMA-END)
@ -62,4 +65,4 @@ RESOURCES
Main web site: <https://github.com/ElementsProject/lightning>
[comment]: # ( SHA256STAMP:a0ace35f11efcdfbac39ef830cd7b2b6c8f48816c5512d7d2300edb9463aa4e6)
[comment]: # ( SHA256STAMP:4c8ba0c4aec4f9507588fcbe35c07c0a9761a65b78664afafe228c18b306f8c4)

View File

@ -65,6 +65,28 @@
"type": "u64",
"description": "UNIX timestamp of when invoice was paid (**status** *paid* only)"
},
"paid_outpoint": {
"type": "object",
"description": "Outpoint this invoice was paid with (**status** *paid* only)",
"added": "v23.11",
"additionalProperties": false,
"required": [
"txid",
"outnum"
],
"properties": {
"txid": {
"added": "v23.11",
"type": "txid",
"description": "ID of the transaction that paid the invoice (**status** *paid* only)"
},
"outnum": {
"added": "v23.11",
"type": "u32",
"description": "The 0-based output number of the transaction that paid the invoice (**status** *paid* only)"
}
}
},
"payment_preimage": {
"type": "secret",
"description": "the proof of payment: SHA256 of this **payment_hash**"

View File

@ -121,6 +121,28 @@
"type": "u64",
"description": "UNIX timestamp of when it was paid"
},
"paid_outpoint": {
"type": "object",
"description": "Outpoint this invoice was paid with",
"added": "v23.11",
"additionalProperties": false,
"required": [
"txid",
"outnum"
],
"properties": {
"txid": {
"added": "v23.11",
"type": "txid",
"description": "ID of the transaction that paid the invoice"
},
"outnum": {
"added": "v23.11",
"type": "u32",
"description": "The 0-based output number of the transaction that paid the invoice"
}
}
},
"payment_preimage": {
"type": "secret",
"description": "proof of payment"

View File

@ -102,6 +102,28 @@
"type": "u64",
"description": "UNIX timestamp of when it was paid"
},
"paid_outpoint": {
"type": "object",
"description": "Outpoint this invoice was paid with",
"added": "v23.11",
"additionalProperties": false,
"required": [
"txid",
"outnum"
],
"properties": {
"txid": {
"added": "v23.11",
"type": "txid",
"description": "ID of the transaction that paid the invoice"
},
"outnum": {
"added": "v23.11",
"type": "u32",
"description": "The 0-based output number of the transaction that paid the invoice"
}
}
},
"payment_preimage": {
"type": "secret",
"description": "proof of payment"

View File

@ -102,6 +102,28 @@
"type": "u64",
"description": "UNIX timestamp of when it was paid"
},
"paid_outpoint": {
"type": "object",
"description": "Outpoint this invoice was paid with",
"added": "v23.11",
"additionalProperties": false,
"required": [
"txid",
"outnum"
],
"properties": {
"txid": {
"added": "v23.11",
"type": "txid",
"description": "ID of the transaction that paid the invoice"
},
"outnum": {
"added": "v23.11",
"type": "u32",
"description": "The 0-based output number of the transaction that paid the invoice"
}
}
},
"payment_preimage": {
"type": "secret",
"description": "proof of payment"

View File

@ -909,6 +909,28 @@ def test_listinvoices_index(node_factory, executor):
assert only_one(l2.rpc.listinvoices(index='updated', start=i, limit=1)['invoices'])['label'] == str(70 + 1 - i)
def test_unified_invoices(node_factory, executor, bitcoind):
l1, l2 = node_factory.line_graph(2, opts={'invoices-onchain-fallback': None})
amount_sat = 1000
inv = l1.rpc.invoice(amount_sat * 1000, "inv1", "test_unified_invoices")
b11 = l1.rpc.decodepay(inv['bolt11'])
assert len(b11['fallbacks']) == 1
# Pay invoice on-chain
addr = b11['fallbacks'][0]['addr']
# save txid
txid = bitcoind.rpc.sendtoaddress(addr, amount_sat / 10**8)
# confirm spend
bitcoind.generate_block(1)
res = l1.rpc.waitinvoice('inv1')
assert(txid == res['paid_outpoint']['txid'])
def test_expiry_startup_crash(node_factory, bitcoind):
"""We crash trying to expire invoice on startup"""
l1 = node_factory.get_node()

View File

@ -3608,6 +3608,10 @@ def test_sql(node_factory, bitcoind):
'type': 'msat'},
{'name': 'paid_at',
'type': 'u64'},
{'name': 'paid_outpoint_txid',
'type': 'txid'},
{'name': 'paid_outpoint_outnum',
'type': 'u32'},
{'name': 'payment_preimage',
'type': 'secret'}]},
'offers': {