core-lightning/doc
Vincenzo Palazzo b92b9f074d delpay: delete the payment by status from the db
There are cases (difficult to reproduce with a test) where
a payment will fail one time and succeed later.

As far I understand in this case the groupid field of the payment
is the same, and the only thing that change is the status, so
our logic inside the delpay is ambiguous where it is not
possible to delete a payment as described in https://github.com/ElementsProject/lightning/issues/6114

A sequence of commands that explain the problem is

```
$ lc -k listpays payment_hash=H
{
   "pays": [
      {
         "bolt11": "I",
         "destination": "redacted",
         "payment_hash": "H",
         "status": "complete",
         "created_at": redacted,
         "completed_at": redacted,
         "preimage": "P",
         "amount_msat": "redacted",
         "amount_sent_msat": "redacted"
      }
   ]
}
$ lc delpay H complete
{
   "code": 211,
   "message": "Payment with hash H has failed status but it should be complete"
}
```

In this case, the delpay is not able to delete a payment because the
listpays is returning only the succeeded one, so by running the
listsendpays we may see the following result where our delpay logic
will be stuck because it works to ensure that all the payments stored
in the database has the status specified by the user

```
➜  VincentSSD clightning --testnet listsendpays -k payment_hash=7fc74bedbb78f2f3330155d919a54e730cf19c11bc73e96c027f5cd4a34e53f4
{
   "payments": [
      {
         "id": 322,
         "payment_hash": "7fc74bedbb78f2f3330155d919a54e730cf19c11bc73e96c027f5cd4a34e53f4",
         "groupid": 1,
         "partid": 1,
         "destination": "030b686a163aa2bba03cebb8bab7778fac251536498141df0a436d688352d426f6",
         "amount_msat": 300,
         "amount_sent_msat": 1664,
         "created_at": 1679510203,
         "completed_at": 1679510205,
         "status": "failed",
         "bolt11": "lntb1pjpkj4xsp52trda39rfpe7qtqahx8jjplhnj3tatxy8rh6sc6afgvmdz7n0llspp50lr5hmdm0re0xvcp2hv3nf2wwvx0r8q3h3e7jmqz0awdfg6w206qdp0w3jhxarfdenjqargv5sxgetvwpshjgrzw4njqun9wphhyaqxqyjw5qcqp2rzjqtp28uqy77te96ylt7ek703h4ayldljsf8rnlztgf3p8mg7pd0qzwf8a3yqqpdqqqyqqqqt2qqqqqqgqqc9qxpqysgqgeya2lguaj6sflc4hx2d89jvah8mw9uax4j77d8rzkut3rkm0554x37fc7gy92ws9l76yprdva2lalrs7fqjp9lcx40zuty8gca0g5spme3dup"
      },
      {
         "id": 323,
         "payment_hash": "7fc74bedbb78f2f3330155d919a54e730cf19c11bc73e96c027f5cd4a34e53f4",
         "groupid": 1,
         "partid": 2,
         "destination": "030b686a163aa2bba03cebb8bab7778fac251536498141df0a436d688352d426f6",
         "amount_msat": 300,
         "amount_sent_msat": 3663,
         "created_at": 1679510205,
         "completed_at": 1679510207,
         "status": "failed"
      },
      {
         "id": 324,
         "payment_hash": "7fc74bedbb78f2f3330155d919a54e730cf19c11bc73e96c027f5cd4a34e53f4",
         "groupid": 1,
         "partid": 3,
         "destination": "030b686a163aa2bba03cebb8bab7778fac251536498141df0a436d688352d426f6",
         "amount_msat": 300,
         "amount_sent_msat": 3663,
         "created_at": 1679510207,
         "completed_at": 1679510209,
         "status": "failed"
      },
      {
         "id": 325,
         "payment_hash": "7fc74bedbb78f2f3330155d919a54e730cf19c11bc73e96c027f5cd4a34e53f4",
         "groupid": 1,
         "partid": 4,
         "destination": "030b686a163aa2bba03cebb8bab7778fac251536498141df0a436d688352d426f6",
         "amount_msat": 300,
         "amount_sent_msat": 4663,
         "created_at": 1679510209,
         "completed_at": 1679510221,
         "status": "complete",
         "payment_preimage": "43f746f2d28d4902489cbde9b3b8f3d04db5db7e973f8a55b7229ce774bf33a7"
      }
   ]
}
```

This commit solves the problem by forcing the delete query in the
database to specify status too, and work around this kind of
ambiguous case.

Fixes: f52ff07558 (lightningd: allow delpay to delete a specific payment.)
Reported-by: Antoine Poinsot <darosior@protonmail.com>
Link: https://github.com/ElementsProject/lightning/issues/6114
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
Co-Developed-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Fixed: delpay be more pedantic about delete logic by allowing
delete payments by status directly on the database.
2023-04-05 06:15:47 +09:30
..
dev docs: Add docs on code generation 2023-03-25 15:40:35 +10:30
reference docs: Structure the files in mkdocs 2023-03-25 15:40:35 +10:30
release-notes doc: Fixed typo in the release notes 2018-06-18 12:45:00 +02:00
schemas doc: schemas for commando-listrunes & commando-blacklist 2023-04-01 14:07:23 +10:30
user docs: Structure the files in mkdocs 2023-03-25 15:40:35 +10:30
.gitignore doc: document the sql command. 2023-01-30 15:15:41 -06:00
BACKUP.md docs: Use admonition markup for warnings and notes 2023-03-25 15:40:35 +10:30
bitcoin.bib bitcoin.bib: Add Satoshi paper URL and date 2018-03-04 03:22:32 +01:00
CHANGELOG.md docs: Add configuration for the sphinx documentation generator 2019-02-18 02:42:29 +00:00
commit-tx.eps Add documentation. 2015-07-18 10:46:53 +09:30
commit-tx.svg Add documentation. 2015-07-18 10:46:53 +09:30
conf.py doc: sphinx-build fix external links (urls), language warning and broken footnote 2022-12-19 19:00:39 +01:00
deployable-lightning.lyx udpate broken link 2018-06-08 17:56:48 +02:00
deployable-lightning.pdf Regenerate PDF. 2015-11-20 06:45:19 +10:30
dual-anchor-diag1.eps Add documentation. 2015-07-18 10:46:53 +09:30
dual-anchor-diag1.svg Add documentation. 2015-07-18 10:46:53 +09:30
dual-anchor-diag2.eps Add documentation. 2015-07-18 10:46:53 +09:30
dual-anchor-diag2.svg Add documentation. 2015-07-18 10:46:53 +09:30
dual-anchor-diag3.eps Add documentation. 2015-07-18 10:46:53 +09:30
dual-anchor-diag3.svg Add documentation. 2015-07-18 10:46:53 +09:30
dual-anchor-diag4.eps doc: fix flaw in escape transactions. 2015-07-20 14:07:25 +09:30
dual-anchor-diag4.svg doc: fix flaw in escape transactions. 2015-07-20 14:07:25 +09:30
dual-anchor-final.eps doc: fix flaw in escape transactions. 2015-07-20 14:07:25 +09:30
dual-anchor-final.svg doc: fix flaw in escape transactions. 2015-07-20 14:07:25 +09:30
dual-anchor-take2.svg Add documentation. 2015-07-18 10:46:53 +09:30
dual-anchor.svg Add documentation. 2015-07-18 10:46:53 +09:30
FAQ.md docs: Remove redundant ToC in FAQs 2023-03-25 15:40:35 +10:30
FUZZING.md configure: support sanitizers properly. 2023-04-05 06:12:24 +09:30
GOSSIP_STORE.md doc/GOSSIP_STORE.md: document the gossip_store file format. 2022-09-24 15:22:27 +09:30
HACKING.md doc: update references to old BOLTs repo. 2022-09-29 16:10:57 +09:30
htlc.eps Add documentation. 2015-07-18 10:46:53 +09:30
htlc.svg Add documentation. 2015-07-18 10:46:53 +09:30
index.md docs: Structure the files in mkdocs 2023-03-25 15:40:35 +10:30
index.rst doc: commando-listrunes & commando-blacklist 2023-04-01 14:07:23 +10:30
INSTALL.md Need sudo for make install 2023-02-05 15:41:19 +10:30
LICENSE.md docs: Add LICENSE to the About section 2023-03-25 15:40:35 +10:30
lightning-addgossip.7.md tools/fromschema.py: don't try to handle more complex cases. 2023-01-30 15:15:41 -06:00
lightning-autoclean-once.7.md tools/fromschema.py: don't try to handle more complex cases. 2023-01-30 15:15:41 -06:00
lightning-autoclean-status.7.md tools/fromschema.py: don't try to handle more complex cases. 2023-01-30 15:15:41 -06:00
lightning-batching.7.md tools/fromschema.py: don't try to handle more complex cases. 2023-01-30 15:15:41 -06:00
lightning-bkpr-channelsapy.7.md tools/fromschema.py: don't try to handle more complex cases. 2023-01-30 15:15:41 -06:00
lightning-bkpr-dumpincomecsv.7.md tools/fromschema.py: don't try to handle more complex cases. 2023-01-30 15:15:41 -06:00
lightning-bkpr-inspect.7.md tools/fromschema.py: don't try to handle more complex cases. 2023-01-30 15:15:41 -06:00
lightning-bkpr-listaccountevents.7.md tools/fromschema.py: don't try to handle more complex cases. 2023-01-30 15:15:41 -06:00
lightning-bkpr-listbalances.7.md tools/fromschema.py: don't try to handle more complex cases. 2023-01-30 15:15:41 -06:00
lightning-bkpr-listincome.7.md tools/fromschema.py: don't try to handle more complex cases. 2023-01-30 15:15:41 -06:00
lightning-check.7.md tools/fromschema.py: don't try to handle more complex cases. 2023-01-30 15:15:41 -06:00
lightning-checkmessage.7.md tools/fromschema.py: don't try to handle more complex cases. 2023-01-30 15:15:41 -06:00
lightning-cli.1.md cli: add -c/--commando support. 2023-01-11 11:13:27 +10:30
lightning-close.7.md tools/fromschema.py: don't try to handle more complex cases. 2023-01-30 15:15:41 -06:00
lightning-commando-blacklist.7.md doc: commando-listrunes & commando-blacklist 2023-04-01 14:07:23 +10:30
lightning-commando-listrunes.7.md doc: commando-listrunes & commando-blacklist 2023-04-01 14:07:23 +10:30
lightning-commando-rune.7.md doc: commando-listrunes & commando-blacklist 2023-04-01 14:07:23 +10:30
lightning-commando.7.md doc: escape more naughty underscores 2022-12-12 15:34:00 +10:30
lightning-connect.7.md tools/fromschema.py: don't try to handle more complex cases. 2023-01-30 15:15:41 -06:00
lightning-createinvoice.7.md doc: Correct createinvoice's invstring description 2023-02-06 15:54:32 -06:00
lightning-createonion.7.md doc/schemas: remove unnecessary length restrictions. 2023-01-30 15:15:41 -06:00
lightning-datastore.7.md tools/fromschema.py: don't try to handle more complex cases. 2023-01-30 15:15:41 -06:00
lightning-decode.7.md doc/schemas: fix old deprecations. 2023-01-30 15:15:41 -06:00
lightning-decodepay.7.md doc/schemas: fix old deprecations. 2023-01-30 15:15:41 -06:00
lightning-deldatastore.7.md tools/fromschema.py: don't try to handle more complex cases. 2023-01-30 15:15:41 -06:00
lightning-delexpiredinvoice.7.md tools/fromschema.py: don't try to handle more complex cases. 2023-01-30 15:15:41 -06:00
lightning-delforward.7.md tools/fromschema.py: don't try to handle more complex cases. 2023-01-30 15:15:41 -06:00
lightning-delinvoice.7.md doc/schemas: fix old deprecations. 2023-01-30 15:15:41 -06:00
lightning-delpay.7.md delpay: delete the payment by status from the db 2023-04-05 06:15:47 +09:30
lightning-disableinvoicerequest.7.md doc: add documentation for invoicerequest commands. 2023-03-09 06:56:06 -06:00
lightning-disableoffer.7.md doc: use specific types in schema rather than "hex". 2023-01-30 15:15:41 -06:00
lightning-disconnect.7.md tools/fromschema.py: don't try to handle more complex cases. 2023-01-30 15:15:41 -06:00
lightning-emergencyrecover.7.md doc: Add documentation for new RPCs and a FIXME: in fromschema.py 2022-07-14 12:24:48 -05:00
lightning-feerates.7.md tools/fromschema.py: don't try to handle more complex cases. 2023-01-30 15:15:41 -06:00
lightning-fetchinvoice.7.md doc: update documentation for fetchinvoice(7) and offer(7). 2023-03-09 06:56:06 -06:00
lightning-fundchannel.7.md tools/fromschema.py: don't try to handle more complex cases. 2023-01-30 15:15:41 -06:00
lightning-fundchannel_cancel.7.md tools/fromschema.py: don't try to handle more complex cases. 2023-01-30 15:15:41 -06:00
lightning-fundchannel_complete.7.md tools/fromschema.py: don't try to handle more complex cases. 2023-01-30 15:15:41 -06:00
lightning-fundchannel_start.7.md tools/fromschema.py: don't try to handle more complex cases. 2023-01-30 15:15:41 -06:00
lightning-funderupdate.7.md tools/fromschema.py: don't try to handle more complex cases. 2023-01-30 15:15:41 -06:00
lightning-fundpsbt.7.md fundpsbt: add option to filter out wrapped p2sh inputs 2023-02-04 15:31:16 +10:30
lightning-getinfo.7.md global: remove deprecated non-msat-named msat fields. 2023-03-18 15:55:49 +10:30
lightning-getlog.7.md tools/fromschema.py: don't try to handle more complex cases. 2023-01-30 15:15:41 -06:00
lightning-getroute.7.md global: remove deprecated non-msat-named msat fields. 2023-03-18 15:55:49 +10:30
lightning-help.7.md tools/fromschema.py: don't try to handle more complex cases. 2023-01-30 15:15:41 -06:00
lightning-hsmtool.8.md doc: drive-by spelling corrections 2022-12-12 15:34:00 +10:30
lightning-invoice.7.md doc/schemas: remove unnecessary length restrictions. 2023-01-30 15:15:41 -06:00
lightning-invoicerequest.7.md doc: add documentation for invoicerequest commands. 2023-03-09 06:56:06 -06:00
lightning-keysend.7.md doc/schemas: fix old deprecations. 2023-01-30 15:15:41 -06:00
lightning-listchannels.7.md doc/schemas: fix old deprecations. 2023-01-30 15:15:41 -06:00
lightning-listclosedchannels.7.md lightningd: add listclosedchannels command. 2023-03-25 15:28:02 +10:30
lightning-listconfigs.7.md options: create enable/disable option for peer storage. 2023-02-08 08:37:59 -06:00
lightning-listdatastore.7.md tools/fromschema.py: don't try to handle more complex cases. 2023-01-30 15:15:41 -06:00
lightning-listforwards.7.md doc/schemas: fix old deprecations. 2023-01-30 15:15:41 -06:00
lightning-listfunds.7.md docs: update autogenerate file 2023-03-26 13:42:29 +10:30
lightning-listhtlcs.7.md tools/fromschema.py: don't try to handle more complex cases. 2023-01-30 15:15:41 -06:00
lightning-listinvoicerequests.7.md doc: add documentation for invoicerequest commands. 2023-03-09 06:56:06 -06:00
lightning-listinvoices.7.md doc/schemas: fix old deprecations. 2023-01-30 15:15:41 -06:00
lightning-listnodes.7.md tools/fromschema.py: don't try to handle more complex cases. 2023-01-30 15:15:41 -06:00
lightning-listoffers.7.md doc: use specific types in schema rather than "hex". 2023-01-30 15:15:41 -06:00
lightning-listpays.7.md doc: use specific types in schema rather than "hex". 2023-01-30 15:15:41 -06:00
lightning-listpeerchannels.7.md listpeerchannels: add channel_type, both in hex and as array of names. 2023-03-25 15:28:02 +10:30
lightning-listpeers.7.md lightningd: remove deprecated local_msat, remote_msat from listpeers. 2023-03-18 15:55:49 +10:30
lightning-listsendpays.7.md doc/schemas: fix old deprecations. 2023-01-30 15:15:41 -06:00
lightning-listsqlschemas.7.md typo fixes found by @niftynei 2023-01-30 15:15:41 -06:00
lightning-listtransactions.7.md doc/schemas: fix old deprecations. 2023-01-30 15:15:41 -06:00
lightning-makesecret.7.md doc/schemas: remove unnecessary length restrictions. 2023-01-30 15:15:41 -06:00
lightning-multifundchannel.7.md tools/fromschema.py: don't try to handle more complex cases. 2023-01-30 15:15:41 -06:00
lightning-multiwithdraw.7.md tools/fromschema.py: don't try to handle more complex cases. 2023-01-30 15:15:41 -06:00
lightning-newaddr.7.md tools/fromschema.py: don't try to handle more complex cases. 2023-01-30 15:15:41 -06:00
lightning-notifications.7.md tools/fromschema.py: don't try to handle more complex cases. 2023-01-30 15:15:41 -06:00
lightning-offer.7.md doc: update documentation for fetchinvoice(7) and offer(7). 2023-03-09 06:56:06 -06:00
lightning-openchannel_abort.7.md tools/fromschema.py: don't try to handle more complex cases. 2023-01-30 15:15:41 -06:00
lightning-openchannel_bump.7.md df: wire up peer's "require-confirmed-inputs" 2023-02-07 21:03:36 -06:00
lightning-openchannel_init.7.md df: wire up peer's "require-confirmed-inputs" 2023-02-07 21:03:36 -06:00
lightning-openchannel_signed.7.md tools/fromschema.py: don't try to handle more complex cases. 2023-01-30 15:15:41 -06:00
lightning-openchannel_update.7.md df: wire up peer's "require-confirmed-inputs" 2023-02-07 21:03:36 -06:00
lightning-parsefeerate.7.md tools/fromschema.py: don't try to handle more complex cases. 2023-01-30 15:15:41 -06:00
lightning-pay.7.md doc/schemas: fix old deprecations. 2023-01-30 15:15:41 -06:00
lightning-ping.7.md tools/fromschema.py: don't try to handle more complex cases. 2023-01-30 15:15:41 -06:00
lightning-plugin.7.md tools/fromschema.py: don't try to handle more complex cases. 2023-01-30 15:15:41 -06:00
lightning-preapproveinvoice.7.md tools/fromschema.py: don't try to handle more complex cases. 2023-01-30 15:15:41 -06:00
lightning-preapprovekeysend.7.md tools/fromschema.py: don't try to handle more complex cases. 2023-01-30 15:15:41 -06:00
lightning-recoverchannel.7.md doc: Add documentation for new RPCs and a FIXME: in fromschema.py 2022-07-14 12:24:48 -05:00
lightning-reserveinputs.7.md tools/fromschema.py: don't try to handle more complex cases. 2023-01-30 15:15:41 -06:00
lightning-sendcustommsg.7.md tools/fromschema.py: don't try to handle more complex cases. 2023-01-30 15:15:41 -06:00
lightning-sendinvoice.7.md doc: fix modern usage of sendinvoice (changed in v22.11) 2023-03-09 06:56:06 -06:00
lightning-sendonion.7.md doc/schemas: fix old deprecations. 2023-01-30 15:15:41 -06:00
lightning-sendonionmessage.7.md tools/fromschema.py: don't try to handle more complex cases. 2023-01-30 15:15:41 -06:00
lightning-sendpay.7.md doc/schemas: fix old deprecations. 2023-01-30 15:15:41 -06:00
lightning-sendpsbt.7.md tools/fromschema.py: don't try to handle more complex cases. 2023-01-30 15:15:41 -06:00
lightning-setchannel.7.md tools/fromschema.py: don't try to handle more complex cases. 2023-01-30 15:15:41 -06:00
lightning-setpsbtversion.7.md Add PSBT version setting RPC to aid with debugging and compatibility 2023-03-23 16:10:55 +10:30
lightning-signinvoice.7.md lightningd: Add signinvoice to sign a BOLT11 invoice. 2023-02-06 15:54:32 -06:00
lightning-signmessage.7.md tools/fromschema.py: don't try to handle more complex cases. 2023-01-30 15:15:41 -06:00
lightning-signpsbt.7.md tools/fromschema.py: don't try to handle more complex cases. 2023-01-30 15:15:41 -06:00
lightning-sql.7.md plugins/sql: add listclosedchannels 2023-03-25 15:28:02 +10:30
lightning-staticbackup.7.md doc: Typo 2022-08-19 10:27:09 -04:00
lightning-stop.7.md tools/fromschema.py: don't try to handle more complex cases. 2023-01-30 15:15:41 -06:00
lightning-txdiscard.7.md tools/fromschema.py: don't try to handle more complex cases. 2023-01-30 15:15:41 -06:00
lightning-txprepare.7.md tools/fromschema.py: don't try to handle more complex cases. 2023-01-30 15:15:41 -06:00
lightning-txsend.7.md tools/fromschema.py: don't try to handle more complex cases. 2023-01-30 15:15:41 -06:00
lightning-unreserveinputs.7.md tools/fromschema.py: don't try to handle more complex cases. 2023-01-30 15:15:41 -06:00
lightning-upgradewallet.7.md upgradewallet: JSONRPC call to update p2sh outputs to a native segwit 2023-02-04 15:31:16 +10:30
lightning-utxopsbt.7.md tools/fromschema.py: don't try to handle more complex cases. 2023-01-30 15:15:41 -06:00
lightning-waitanyinvoice.7.md doc/schemas: fix old deprecations. 2023-01-30 15:15:41 -06:00
lightning-waitblockheight.7.md tools/fromschema.py: don't try to handle more complex cases. 2023-01-30 15:15:41 -06:00
lightning-waitinvoice.7.md doc/schemas: fix old deprecations. 2023-01-30 15:15:41 -06:00
lightning-waitsendpay.7.md doc/schemas: fix old deprecations. 2023-01-30 15:15:41 -06:00
lightning-withdraw.7.md tools/fromschema.py: don't try to handle more complex cases. 2023-01-30 15:15:41 -06:00
lightningd-config.5.md options: create enable/disable option for peer storage. 2023-02-08 08:37:59 -06:00
lightningd-rpc.7.md doc: escape more naughty underscores 2022-12-12 15:34:00 +10:30
lightningd.8.md doc: escape more naughty underscores 2022-12-12 15:34:00 +10:30
ln-draft-fig1.eps doc: add figures from LN draft (thanks Joseph!). 2015-07-20 14:07:40 +09:30
ln-draft-fig2.eps doc: add figures from LN draft (thanks Joseph!). 2015-07-20 14:07:40 +09:30
Makefile doc: commando-listrunes & commando-blacklist 2023-04-01 14:07:23 +10:30
MAKING-RELEASES.md doc: update release procedure 2023-03-17 14:26:56 +10:30
PLUGINS.md docs: Fix a number of broken links in the generated docs 2023-03-25 15:40:35 +10:30
reckless.7.md doc: escape more naughty underscores 2022-12-12 15:34:00 +10:30
REPRODUCIBLE.md doc: update release procedure 2023-03-17 14:26:56 +10:30
requirements.txt docs: Switch to mkdocs for documentation 2023-03-25 15:40:35 +10:30
STYLE.md Changelog-None 2022-08-22 11:21:19 -04:00
TOR.md doc: announce-addr-discovered config switch 2023-01-25 14:37:56 +01:00
undoc-flags.json lightningd: allow extra tlv types in non-experimental mode. 2022-09-22 17:19:11 +09:30