Commit Graph

8035 Commits

Author SHA1 Message Date
Christian Decker 1ef0ca51b0 ci: Add pytest-sentry so we have a place to collect failing tests 2020-07-06 17:08:45 +02:00
Christian Decker 324d39bb6b docker: Add python3 to the docker image
Most user-contributed plugins are written in python, and not having it
available in the docker image is rather annoying to work around. So we just
add that tiny dependency to the image.

Fixes #3765
2020-07-06 17:08:45 +02:00
ZmnSCPxj jxPCSnmZ a6374ad431 openingd/openingd.c: Fix a mild deviation from BOLT#2.
Fixes: #3815

Changelog-Fixed: Fixed a deviation from BOLT#2: if both nodes advertised `option_upfront_shutdown_script` feature: MUST include ... a zero-length `shutdown_scriptpubkey`.
2020-07-06 14:53:49 +00:00
Rusty Russell fc2561fd9e pytest: fix test breakage added by d0c85033d2
By setting nLocktime to the current block, the reorg test
"test_funding_reorg_remote_lags" actually drops the funding transaction
entirely when a reorg happens.

Except the 1 in 10 cases where nLocktime is randomly set to 1-10
blocks earlier.

This implies, strongly, that we hit "restart" too often on Travis.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-07-06 14:55:14 +09:30
Christian Decker 7981f4c4d9 paymod: Extract the channel hints update into its own function
We could end up with multiple channel hints, which is a bit wasteful. We now
look for existing ones before adding a new one, and if one exists we use the
more restrictive parameters.

Suggested-by: Lisa Neigut <@niftynei>
2020-07-02 11:54:12 +02:00
Christian Decker ddb0424a4d paymod: Remove the dummy payment modifier
It was there only for demonstration purposes, and is no longer useful.
2020-07-02 11:54:12 +02:00
Christian Decker fc714bf2df paymod: Fill in the `pay` return value 2020-07-02 11:54:12 +02:00
Christian Decker 9aff885828 paymod Collect the final failure when aggregating the tree results
We're lucky that we can distinguish the severity of the failure based on the
failcode, so we bubble up the one with the maximum failcode, and let callers
inspect details if they need more information.
2020-07-02 11:54:12 +02:00
Christian Decker 2acb86bfe3 paymod: Consider new payments when checking if an attempt is ongoing
Without this the flapping behavior tested in `test_pay_retry` would reappear.
2020-07-02 11:54:12 +02:00
Christian Decker 7a266b8239 paymod: Make payment_tree_result public to users can query state 2020-07-02 11:54:12 +02:00
Christian Decker fbd8cf1495 paymod: Keep a copy of the serialized bolt11 in the root payment
We frequently query by the bolt11 string, so keeping it around saves us from
having to parse the query or serialize the parsed one.
2020-07-02 11:54:12 +02:00
Christian Decker 895542c6f1 paymod: Simplify retry mod logic and add abort logic 2020-07-02 11:54:12 +02:00
Christian Decker 73fc10e25f paymod: Parse error from waitsendpay and exclude failed chans 2020-07-02 11:54:12 +02:00
Christian Decker 81dce4096e pytest: Fix up test_pay_no_secret to wait for node_announcements
This was racy since we didn't know whether the peer supports TLV payloads yet
so we defaulted to legacy, which doesn't support secrets.
2020-07-02 11:54:12 +02:00
Christian Decker 9d7a48d0f4 pay: Key the MPP payments based on the payment_hash not the bolt11
This allows us to drive the payment from outside, and still get the
aggregation that we want.
2020-07-02 11:54:12 +02:00
Christian Decker be9b55fcb5 pyln: Add a traceback if a hook or rpc method fails 2020-07-02 11:54:12 +02:00
Christian Decker b5c9dcab5a pytest: Fix up the payload replacement test
There is a race between `getroute` learning that our peer accepts TLVs and us
initiating the payment. Waiting for announcements ensures we always use TLVs,
matching our expectation in the test / plugin.
2020-07-02 11:54:12 +02:00
Christian Decker 957a3a01b9 json: Add helper to decode sha256 hashes 2020-07-02 11:54:12 +02:00
Christian Decker 0b85b983ac paymod: Teach the retry_mod not to insist when it's futile
An important life lesson: if there is no path to happiness, then trying harder
will still not get you there.
2020-07-02 11:54:12 +02:00
Christian Decker 10f231bcb5 paymod: Include excludes resulting from channel_hints for getrotue 2020-07-02 11:54:12 +02:00
Christian Decker c2538392e9 json: Add helper to serialize short_channel_id_dir
We'll need it in the next commit to exclude channels and their directions.
2020-07-02 11:54:12 +02:00
Christian Decker 5e3134083e paymod: Add a local_channel_hints modifier to collect local channels
We can have quite detailed information about our local channels, so call
`listpeers` before the `getroute` call on the root payment, to seed that
information in the channel_hints.
2020-07-02 11:54:12 +02:00
Christian Decker b1e9f4923b paymod: Add the final cltv delta to the getroute call 2020-07-02 11:54:12 +02:00
Christian Decker 6fbfe24e3e paymod: Add a COMPAT_090 flag
Since we end up consolidating some of the return values for `pay` and
`paystatus` and change the public interface we need to add the compatibility
flag and guard the switchover behind it.
2020-07-02 11:54:12 +02:00
ZmnSCPxj jxPCSnmZ deabab8934 lightningd/opening_control.c: `fundchannel_cancel` no longer requires a `channel_id` argument.
Fixes: #3785

Changelog-Changed: `fundchannel_cancel` no longer requires its undocumented `channel_id` argument after `fundchannel_complete`.
2020-07-02 01:10:59 +00:00
niftynei 2ab41af8e2 rm pullpush: cleans up unused methods for push/pull
most likely unused since the switch to libwally for internal blockchain
things.

these method names were clashing with ones that are to be introduced
with some libwally cleanups, so getting rid of them pre-emptively keeps
us libwally compatible
2020-07-01 19:50:02 -05:00
niftynei 8185474bfb liquid-compat: update coinmove check to be liquid compatible
🎉 :waterfall:
2020-07-01 19:50:02 -05:00
niftynei ba6e4b6ef2 tests: mark as regtest only 2020-07-01 19:50:02 -05:00
niftynei 20193496bb tests: use chain's directory for finding sqlite3 file (works for liquid-regtests)
Move hardcoded 'regtest' to chainparams one
2020-07-01 19:50:02 -05:00
niftynei ad6ca610b8 bugfix: tx_parts omits two byte counts in serialization 2020-07-01 19:50:02 -05:00
niftynei 77946bd9fe fromwire: return NULL if array empty
libwally's API requires us to pass in NULL pointers if the array size is
zero, so we update our array from wire-er to comply with this
requirement

[ Added fix to avoid tal_resize() of NULL -- RR ]
2020-07-01 19:50:02 -05:00
ZmnSCPxj jxPCSnmZ d0c85033d2 wallet/walletrpc.c: `txprepare`d transactions now use current tip blockheight by default.
Changelog-Changed: `txprepare` now prepares transactions whose `nLockTime` is set to the tip blockheight, instead of using 0. `fundchannel` will use `nLockTime` set to the tip blockheight as well.
2020-07-01 15:17:33 +00:00
Christian Decker 6af5ab9504 paymod: Move onion payload construction into its own function
Suggested-by: Rusty Russell <@rustyrussell>
2020-07-01 12:19:02 +02:00
Christian Decker b15876c112 paymod: Implement TLV onion payload generation 2020-07-01 12:19:02 +02:00
Christian Decker c0b30ac907 wiregen: Add enums for TLV types so we can call them by their name
Suggested-by: Lisa Neigut <@niftynei>
Signed-off-by: Christian Decker <@cdecker>
2020-07-01 12:19:02 +02:00
Christian Decker cb9debc229 tlv: Add generic getters and setters for tlvstream
Trying to rework the TLV streams to have a more homogenous interface to work
with. This is by no means a complete implementation, just the groundwork that
is going to be used by the wire code generator to generate the specific
accessors, but it's enough so we can manipulate TLV streams in the onion and
later just switch to the generated ones.
2020-07-01 12:19:02 +02:00
Christian Decker 958eb41cbb paymod: Do not pass cmd to sub-payments, plugin suffices
We were passing the `cmd` instance around where `plugin` suffices (used to
start RPC calls and logs).
2020-07-01 12:19:02 +02:00
Christian Decker df94ec35ba paymod: Do not reply to the same JSON-RPC command multiple times 2020-07-01 12:19:02 +02:00
Christian Decker c35df400b2 paymod: Maintain a list of current and past payments
We need to keep them around so we can inspect them later. We'll also need a
background cleanup every once in a while to free some memory. More on that in
a future commit.
2020-07-01 12:19:02 +02:00
Christian Decker 8207b4eac8 paymod: Use reasonable partids
We were just handwaving the partid generation, which broke some tests that
expected the first payment attempt to always have partid=0, so here we just
track the partids assigned in the payment tree, starting at 0.
2020-07-01 12:19:02 +02:00
Christian Decker 04c9c5e0d1 paymod: Collect and return results of a tree of partial payments
The status of what started as a simple JSON-RPC call is now spread across an
entire tree of partial payments and payment attempts. So we collect the status
in a single struct in order to report back success of failure.
2020-07-01 12:19:02 +02:00
Christian Decker 4fec969062 paymod: Parse and store the waitsendpay result
This is necessary so we can later aggregate across an entire tree of attempts
and report success or failure to the RPC caller.
2020-07-01 12:19:02 +02:00
Christian Decker 6fb81bf203 paymod: Call waitsendpay on the sendonion we just queued 2020-07-01 12:19:02 +02:00
Christian Decker d8ebe6fbcd paymod: Parse createonion result and call sendonion 2020-07-01 12:19:02 +02:00
Christian Decker d37b8548fb paymod: Call `createonion` to generate the onion and associated data
After we gave each modifier a chance to have its say, we can now proceed to
generate the onion that's going to be sent in the next step.
2020-07-01 12:19:02 +02:00
Christian Decker 5f32cfe9cd paymod: Implement legacy onion payload computation
This is just for testing for now, TLV payload computation will come next. We
stage all the payloads in deserialized form so modifiers can modify them more
easily and serialize them only before actually calling `createonion`.
2020-07-01 12:19:02 +02:00
Christian Decker 9d36e49770 doc: Fix a documentation error in sendonion
Te `sendonion` docs where claiming that the `first_hop` needs to specify a
`channel_id` whereas it should really be the `node_id` of the peer we are
trying to contact.
2020-07-01 12:19:02 +02:00
Christian Decker 5ef7297e51 paymod: Add a `getinfo` call on payment_start to get the blockheight
This is necessary so we can build the absolute locktimes in the next step. For
now just fetch the blockheight on each (sub-)payment, later we can reuse the
root blockheight if it ends up using too much traffic.
2020-07-01 12:19:02 +02:00
Christian Decker 3c3e2c9c8f paymod: Implement getroute call 2020-07-01 12:19:02 +02:00
Christian Decker ce0025c95c paymod: Implement bubbling results up the hierarchy of payments
A payment is considered finished if it is in a final state (success or
failure) or all its sub-payments are finished. If that's the case we notify
`payment_finished` and bubble up through `payment_child_finished`, eventually
bubbling up to the root, which can then report success of failure back to the
RPC command that initiated the whole process.
2020-07-01 12:19:02 +02:00