Skip to content

Commit

Permalink
add test, update schemas, fix warning_custom_fallbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisguida authored and rustyrussell committed Oct 26, 2023
1 parent 3781993 commit c760744
Show file tree
Hide file tree
Showing 11 changed files with 133 additions and 6 deletions.
5 changes: 4 additions & 1 deletion doc/lightning-createinvoice.7.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down Expand Up @@ -77,4 +80,4 @@ RESOURCES

Main web site: <https://github.com/ElementsProject/lightning>

[comment]: # ( SHA256STAMP:2d2180c9e903e2b79d5ddb2b0cf995b1f7aa27b0f9bb1f6e19252b94dcd46ef1)
[comment]: # ( SHA256STAMP:51966a70e3eaa77c703fbd8d00cfb3f7f7602b50149ba6cb8fa0fc115cf05450)
5 changes: 4 additions & 1 deletion doc/lightning-listinvoices.7.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -65,4 +68,4 @@ RESOURCES

Main web site: <https://github.com/ElementsProject/lightning>

[comment]: # ( SHA256STAMP:e698b0e345ed4912b7699b43f2571a4cc3bb4ae909efeb631b02dd94a87e765c)
[comment]: # ( SHA256STAMP:7e4b1182ba879bea892d143b53cdc31350a9668c734c6bb8f86ab9b6e3f0b06e)
5 changes: 3 additions & 2 deletions doc/lightning-sql.7.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -515,4 +516,4 @@ RESOURCES
---------

Main web site: <https://github.com/ElementsProject/lightning>
[comment]: # ( SHA256STAMP:2f77078555f16a9dbee5f068d4d0ba18727aeb378be674cd96bf7c1554a74ce5)
[comment]: # ( SHA256STAMP:b14fce571cf85639c460c59ddec117ce1cb23bd219618730b164ea3cc979b1aa)
5 changes: 4 additions & 1 deletion doc/lightning-waitanyinvoice.7.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -77,4 +80,4 @@ RESOURCES

Main web site: <https://github.com/ElementsProject/lightning>

[comment]: # ( SHA256STAMP:a0ace35f11efcdfbac39ef830cd7b2b6c8f48816c5512d7d2300edb9463aa4e6)
[comment]: # ( SHA256STAMP:4c8ba0c4aec4f9507588fcbe35c07c0a9761a65b78664afafe228c18b306f8c4)
5 changes: 4 additions & 1 deletion doc/lightning-waitinvoice.7.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -62,4 +65,4 @@ RESOURCES

Main web site: <https://github.com/ElementsProject/lightning>

[comment]: # ( SHA256STAMP:a0ace35f11efcdfbac39ef830cd7b2b6c8f48816c5512d7d2300edb9463aa4e6)
[comment]: # ( SHA256STAMP:4c8ba0c4aec4f9507588fcbe35c07c0a9761a65b78664afafe228c18b306f8c4)
22 changes: 22 additions & 0 deletions doc/schemas/createinvoice.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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**"
Expand Down
22 changes: 22 additions & 0 deletions doc/schemas/listinvoices.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
22 changes: 22 additions & 0 deletions doc/schemas/waitanyinvoice.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
22 changes: 22 additions & 0 deletions doc/schemas/waitinvoice.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
22 changes: 22 additions & 0 deletions tests/test_invoices.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 4 additions & 0 deletions tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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': {
Expand Down

0 comments on commit c760744

Please sign in to comment.