Christian Decker
5daa5bd61e
paymod: Fix the onion payload construction
...
I wrongly used a pointer to the array that'd move on append, so an extra
dereference was required here.
2020-07-07 23:25:45 +02:00
Christian Decker
0aa5c197ec
pytest: Fix tests broken by the pay and paystatus changes
...
This commit collects the changes required to the tests caused by the changes
to the `pay` and `paystatus` commands. They are also rather good hints as to
what these changes entail.
2020-07-07 23:25:45 +02:00
Christian Decker
2ac87c1490
paymod: Reorder paymod arguments to match pay
...
We've been adding modifiers and arguments out of order, and we need the
arguments order to match up if we want `paymod` to be a drop-in replacement.
2020-07-07 23:25:45 +02:00
Christian Decker
da8eb6fb4c
paymod: Expose riskfactor and wire through to getroute
2020-07-07 23:25:45 +02:00
Christian Decker
d8b8a0b31e
paymod: Add label to sendonion calls
...
These get reflected in the `listsendpays` command, and are quite useful.
2020-07-07 23:25:45 +02:00
Christian Decker
2649de54f2
paymod: Do not wait for a blockheight if we're already there
...
We want to differentiate a wrong block-height from other failure reasons, such
as an unknown `payment_hash`, so we skip the `waitblockheight` if we're
already at the correct height.
2020-07-07 23:25:45 +02:00
Christian Decker
5601a1ab21
paymod: Add a deadline to the pay command and retry modifier
2020-07-07 23:25:45 +02:00
Christian Decker
f557955515
paymod: Consolidate parsing RPC results in libplugin
...
We handle these in a number of different ways, and regularly get the parsing
and logic for optional fields wrong, so let's consolidate them here.
2020-07-07 23:25:45 +02:00
Christian Decker
4b3e849ce9
paymod: Add function to set the current step
...
This is necessary otherwise we would not be calling modifiers for the newly
set state which can lead to unexpected results.
2020-07-07 23:25:45 +02:00
Christian Decker
4aed45e98d
paymod: Add attempts array to pay
return value
2020-07-07 23:25:45 +02:00
Christian Decker
030633bb28
paymod: Add a human readable failreason to payments
...
This makes it easier to stash a human readable failure message in an attempt.
2020-07-07 23:25:45 +02:00
Christian Decker
2ef130e427
paymod: Apply and unapply routes to the channel hints
...
Add/remove the HTLC amount from the channel hints so concurrent getroute calls
have the correct exclusions. This can sometimes underflow, if we're unlucky
and call getroute too closely, but that's not a big issue, it can only result
in a failed MPP attempt too many, nothing fatal, and it'll get corrected based
on the result returned by the failing node.
2020-07-07 23:25:45 +02:00
Christian Decker
cb00cbac7c
paymod: Add support for the msatoshi override argument
2020-07-07 23:25:45 +02:00
Christian Decker
2331cd62e1
paymod: Add user-provided label back into the paystatus result
2020-07-07 23:25:45 +02:00
Christian Decker
215a0ada8b
paymod: Update the route constraints as we apply routes and mods
...
These are primarily the fee and cltv constraints that we need to keep up to
date in order to give modifiers a correct view of what is and what isn't
allowed.
2020-07-07 23:25:45 +02:00
Christian Decker
935578e567
paymod: Exclude most expensive/slowest chan if limits are exceeded
2020-07-07 23:25:45 +02:00
Christian Decker
4648d2867f
paymod: Compute fee and CLTV delta limits for a payment
...
So far we got away with not caring about these but since we're implementing
modifiers that impact these limits, we better keep track of them.
2020-07-07 23:25:45 +02:00
Christian Decker
e71bdf9ed8
paymod: Wrap the getroute request in a struct
...
Keeping the arguments in their non-serialized form allows us to amend them as
we apply modifiers and learn new information.
2020-07-07 23:25:45 +02:00
Christian Decker
1b057f025c
paymod: Let the payment know the local ID
...
This is necessary for the routehint modifier.
2020-07-07 23:25:45 +02:00
Christian Decker
097cb8d3a0
paymod: Exclude nodes that we found to be faulty
2020-07-07 23:25:45 +02:00
Christian Decker
2f0e535b81
paymod: Add reason why a payment was attempted
...
This is a slight change in interface in that the string no longer spells out
that a specific node was excluded.
2020-07-07 23:25:45 +02:00
Christian Decker
3a35dd34ac
paymod: Add the contents of paystatus
...
This proved to be rather difficult given the tight coupling of the old structs
and the output of the command.
2020-07-07 23:25:45 +02:00
Christian Decker
2e88249a7b
paymod: Make the transition to FAILED a function call
...
We need to set some variables as well, and the transition to FAILED is a bit
special in that quite some modifiers will skip into FAILED.
2020-07-07 23:25:45 +02:00
ZmnSCPxj jxPCSnmZ
4a89819cdd
plugins/Makefile: Change plugins build procedure.
...
Changelog-None
2020-07-07 21:32:31 +02:00
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
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
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
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
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
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
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