Commit Graph

12985 Commits

Author SHA1 Message Date
Michael Schmoock 00431779a6 pytest: add connection test for gratuitous transient failure message.
[Cleaned up a little to avoid the case where both sides race to reconnect --RR ]
2023-04-06 07:06:26 +09:30
Rusty Russell 3c83aed9d1 doc: fix commando-listrunes SHA256SUM line.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-04-05 09:41:04 +02:00
Chris Guida 1507e87197 fix helloworld.py example in README for pyln-client 2023-04-05 15:28:32 +09:30
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
Michael Schmoock 04ea37d88f pygossmap: rename GossipStoreHeader to GossipStoreMsgHeader
Changelog-Added: pyln-client: Improvements on the gossmap implementation
2023-04-05 06:13:08 +09:30
Michael Schmoock 6e46a63c57 pygossmap: adds statistic and filter module
Includes a lot of useful filters and statistical methods.

To see a gossip_store summary:
```
s = GossmapStats(g)
s.print_stats()
```
2023-04-05 06:13:08 +09:30
Michael Schmoock f1b6047d69 pygossmap: store features for nodes and channels
also makes them acessible using bitmask functions
2023-04-05 06:13:08 +09:30
Michael Schmoock 3130f4ec27 pygossmap: read .disabled from channel_flags 2023-04-05 06:13:08 +09:30
Michael Schmoock 6a16a31a98 pygossmap: parse node addresses and other data 2023-04-05 06:13:08 +09:30
Michael Schmoock 9409f2f1ea pygossmap: adds get_neighbors and get_neighbors_hc flodding method 2023-04-05 06:13:08 +09:30
Michael Schmoock 5a9a3d83c9 pygossmap: adds get_halfchannel 2023-04-05 06:13:08 +09:30
Michael Schmoock d50722d26b pygossmap: adds a more complete mesh testcase 2023-04-05 06:13:08 +09:30
Michael Schmoock eb9cb5ef31 pygossmap: adds missing __str__, __eq__ and __hash__
Also caches certain __hash__ and __str__ operations,
This way graph operations can be done quicker.
2023-04-05 06:13:08 +09:30
Michael Schmoock be60f2ac33 pygossmap: adds GossmapHalfchannel to module exports 2023-04-05 06:13:08 +09:30
Michael Schmoock 3f651b08d5 pygossmap: cleanups and optimizations
- moves offset into GossipHeader hdr which is passed to all constuctors
 - reads .flags as u16 instead of extracting it from the .length, see 0274d88ba
 - adds zombie and ratelimit flag to GossipHeader
 - bytes_read start at 0 instead of 1 which is more correct,
   the one byte is then corrected for when setting the offset of new header.
 - bytes_read is increased in pull_bytes as this is the only place where
   something is read
 - use new style for various format-strings
2023-04-05 06:13:08 +09:30
Michael Schmoock 882cafd3c7 pytest: adds skipped test_create_gossip_mesh
This can be adapted and used to create test gossip stores.
The test is just skipped by design as it would fail on intention.
2023-04-05 06:13:08 +09:30
Michael Schmoock fb0027e314 pyln-testing: fundbalancedchannel default total_capacity to FUNDAMOUNT 2023-04-05 06:13:08 +09:30
Michael Schmoock 407d4d2922 pyln-testing: remove deprecated fund_channel
This method is no longer used in cln nor in the plugins repo.

Changelog-None
2023-04-05 06:13:08 +09:30
Michael Schmoock f4b8a401cd pyln-proto: shorten ShortChannelId.from_str() 2023-04-05 06:13:08 +09:30
Rusty Russell 5787e18e69 fuzz: fix check-src/includes when fuzzing enabled.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-04-05 06:12:24 +09:30
Rusty Russell b6a3f93b75 channeld: don't asort(NULL).
It's defined to be nonull:

```
channeld/channeld.c:2381:2: runtime error: null pointer passed as argument 1, which is declared to never be null
/usr/include/stdlib.h:856:3: note: nonnull attribute specified here
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior channeld/channeld.c:2381:2 in 
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-04-05 06:12:24 +09:30
Rusty Russell 37971fb61f plugins/pay: fix capacity bias.
With the warning that we were trying to put "inf" into a u64, we can
see that this calculation was wrong to use integers!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-04-05 06:12:24 +09:30
Rusty Russell 1f8a4bed39 bitcoin/script: don't memcmp NULL.
Stupid, stupid C committee.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-04-05 06:12:24 +09:30
Rusty Russell 2005ca436e common/gossmap: don't memcpy NULL, 0, and don't add 0 to NULL pointer.
Of course, NULL and length 0 are natural partners, but We Can't Have Nice Things.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-04-05 06:12:24 +09:30
Rusty Russell 3be36a66e3 configure: support sanitizers properly.
For example, if we use -fsanitize=undefined, we can't do unaligned
integer access, but since we didn't test with the sanitizer flags, we
didn't know this, and set `HAVE_UNALIGNED_ACCESS=1`.

Also, add -fno-sanitize-recover= in developer mode, so we actually
fail binaries if something is detected.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-04-05 06:12:24 +09:30
Rusty Russell 801c678cb9 ccan: update to include versions which pass -fsanitize=address and -fsanitize=undefined
Most importantly, configurator used to use bitshifts on signed
integers which -fsanitize=undefined caught.

But also, tal played fast and loose with typing and aliases, which was
a signficant amount of rework.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-04-05 06:12:24 +09:30
Matt Morehouse 5ea1fade60 fuzz: fix invalid pubkey error
pubkey_from_hexstr() was failing, which we didn't notice because we
weren't checking the return value. The problem was that we were passing
it a strlen that was half the actual length.

Relevant error:

  [libsecp256k1] illegal argument: !secp256k1_fe_is_zero(&ge->x)

  ==417723== ERROR: libFuzzer: deadly signal
    #7 0x7f5deaacc7fb in abort
    #8 0x51b0b0 in secp256k1_default_illegal_callback_fn secp256k1.c
    #9 0x51bd8e in secp256k1_ec_pubkey_serialize
    #10 0x4e235b in pubkey_to_der bitcoin/pubkey.c:29:7
    #11 0x4e2941 in pubkey_cmp bitcoin/pubkey.c:89:2
    #12 0x4e333d in bitcoin_redeem_2of2 bitcoin/script.c:144:6
    #13 0x4f1396 in run tests/fuzz/fuzz-close_tx.c:78:19
2023-04-03 16:12:29 +09:30
Shahana Farooqui 61b063440c tests: commando-blacklist 2023-04-01 14:07:23 +10:30
Shahana Farooqui 9d7afba357 tests: commando-listrunes 2023-04-01 14:07:23 +10:30
Shahana Farooqui 3e310a3d3e doc: commando-listrunes & commando-blacklist 2023-04-01 14:07:23 +10:30
Shahana Farooqui af2c1f1881 doc: schemas for commando-listrunes & commando-blacklist 2023-04-01 14:07:23 +10:30
ShahanaFarooqui ecb173738a commando: add restrictions information in listrune command 2023-04-01 14:07:23 +10:30
ShahanaFarooqui 7ad04a9949 commando: Save blacklist runes to datastore 2023-04-01 14:07:23 +10:30
Rusty Russell a4ed3ae72e commando: make blacklist effective.
Actually check them when we're going to use a rune.
2023-04-01 14:07:23 +10:30
ShahanaFarooqui fb865291b6 commando: blacklist support
Does not yet persist the blacklist.
Changelog-Added: Plugins: `commando-blacklist` command to disable select runes.
2023-04-01 14:07:23 +10:30
ShahanaFarooqui 183fbb4c14 commando: listrunes command
Changelog-Added: Plugins: `commando-listrunes` command to show issued runes.
2023-04-01 14:07:23 +10:30
ShahanaFarooqui 080a4dd86c commando: save runes as we generate them
In preparation for the listrunes command.
2023-04-01 14:07:23 +10:30
ShahanaFarooqui 415b7d5d7d gitignore: Somebody uses vscode: make their life easier! 2023-04-01 14:07:23 +10:30
Rusty Russell 2cb96a8d77 wallet: don't silently load invalid last_tx psbts.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-03-31 09:16:25 +10:30
Rusty Russell 5bb0270492 wallet: fix up PSBTs as a migration.
In the now-misnamed "last_tx" field.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-03-31 09:16:25 +10:30
Rusty Russell f1fa75fa06 wallet/test/run-psbt_fixup.c: test for psbt fixups.
Should do nothing to normal ones, but fix up old invalids ones.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-03-31 09:16:25 +10:30
Rusty Russell 7174d06a70 wallet/psbt_fixup: routine to fix invalid PBSTs which modern libwally won't load.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-03-31 09:16:25 +10:30
Vincenzo Palazzo 4c6966d16a docs: update autogenerate file
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2023-03-26 13:42:29 +10:30
Christian Decker f4efe6c899 docs: Add docs on code generation 2023-03-25 15:40:35 +10:30
Christian Decker 7153beff28 docs: Use admonition markup for warnings and notes 2023-03-25 15:40:35 +10:30
Christian Decker 826c746568 docs: Use blockreplace.py to include all manpages 2023-03-25 15:40:35 +10:30
Christian Decker f19792c241 docs: Remove redundant ToC in FAQs 2023-03-25 15:40:35 +10:30
Christian Decker 67a39b59e7 tools: Add yml mode to `blockreplace.py` 2023-03-25 15:40:35 +10:30
Christian Decker f1293ed0e6 docs: Add LICENSE to the About section 2023-03-25 15:40:35 +10:30
Christian Decker 458195c29f docs: Fix a number of broken links in the generated docs
Changelog-None
2023-03-25 15:40:35 +10:30