Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pay plugin #2215

Merged
merged 26 commits into from
Jan 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
0ad5e8f
plugin/libplugin: API for C plugins.
rustyrussell Jan 15, 2019
fdd6c19
plugins: minimal 'pay' plugin.
rustyrussell Jan 15, 2019
fe060e8
contrib/pylightning: temporarily convert to use plugin/pay for tests.
rustyrussell Jan 15, 2019
02c6e7b
plugins/pay: retry on failure in a loop.
rustyrussell Jan 15, 2019
ff07bfd
pytest: test that pay command retries.
rustyrussell Jan 15, 2019
aca0525
plugins/pay: exclude local channels with insufficient current capacity.
rustyrussell Jan 15, 2019
6b10321
plugins/pay: implement maxfeepercent, maxdelay and exemptfee.
rustyrussell Jan 15, 2019
141f96a
plugins/pay: get our own id during init phase.
rustyrussell Jan 15, 2019
6917b28
plugins/pay: get max-locktime-blocks at init for setting default.
rustyrussell Jan 15, 2019
afbc09c
plugins/pay: use final_cltc from bolt11 invoice.
rustyrussell Jan 15, 2019
25de544
pytest: test that we correctly use routeboost information from bolt11…
rustyrussell Jan 15, 2019
88509ec
plugins/pay: implement routeboost hints, naive version.
rustyrussell Jan 15, 2019
8989aa5
pytest: test more-than-one-hop route hints.
rustyrussell Jan 15, 2019
63169d8
plugins/pay: retry when routehint fails.
rustyrussell Jan 15, 2019
8619443
plugins/pay: add shadow CLTV calculation.
rustyrussell Jan 15, 2019
eec424e
plugins/pay: store history of payment attempts (non-persisent).
rustyrussell Jan 15, 2019
a81d011
plugins/pay: add paystatus command to get gory details of payments.
rustyrussell Jan 15, 2019
1bc9db9
pay: remove inbuilt command in favor of plugin.
rustyrussell Jan 15, 2019
4285df8
getroute: add direction to route returned.
rustyrussell Jan 15, 2019
406b424
plugins/pay: eliminate worst channel if we go over fee / delay thresh…
rustyrussell Jan 15, 2019
c2073ee
plugins/pay: paystatus should explicitly describe why it is making ea…
rustyrussell Jan 15, 2019
5b29b27
pytest: fix spurious valgrind output.
rustyrussell Jan 15, 2019
ecdcc18
libplugin: mention error field in error message.
rustyrussell Jan 16, 2019
569f081
plugins/pay: clarify field names
rustyrussell Jan 16, 2019
f3e3489
plugins/pay: simplify listpeers_done code a little.
rustyrussell Jan 16, 2019
f0ac0da
plugins/pay: add comment on why we don't use an empty string
rustyrussell Jan 16, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Added

- plugins: fully enabled, and ready for you to write some!
- plugins: `pay` is now a plugin.
- lightning-cli: `help <cmd>` finds man pages even if `make install` not run.
- JSON API: `waitsendpay` now has an `erring_direction` field.
- JSON API: `listpeers` now has a `direction` field in `channels`.
- JSON API: `listchannels` now takes a `source` option to filter by node id.
- JSON API: New command `paystatus` gives detailed information on `pay` commands.

### Changed

Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ include lightningd/Makefile
include cli/Makefile
include doc/Makefile
include devtools/Makefile
include plugins/Makefile

# Git doesn't maintain timestamps, so we only regen if git says we should.
CHANGED_FROM_GIT = [ x"`git log $@ | head -n1`" != x"`git log $< | head -n1`" -o x"`git diff $<`" != x"" ]
Expand Down
4 changes: 2 additions & 2 deletions common/daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,10 @@ void daemon_shutdown(void)
wally_cleanup(0);
}

void daemon_maybe_debug(int argc, char *argv[])
void daemon_maybe_debug(char *argv[])
{
#if DEVELOPER
for (int i = 1; i < argc; i++) {
for (int i = 1; argv[i]; i++) {
if (!streq(argv[i], "--debugger"))
continue;

Expand Down
2 changes: 1 addition & 1 deletion common/daemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ int daemon_poll(struct pollfd *fds, nfds_t nfds, int timeout);
void daemon_shutdown(void);

/* Kick in a debugger if they set --debugger */
void daemon_maybe_debug(int argc, char *argv[]);
void daemon_maybe_debug(char *argv[]);

struct backtrace_state *backtrace_state;

Expand Down
4 changes: 2 additions & 2 deletions common/status.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ void status_send(const u8 *msg TAKES)
{
report_logging_io("SIGUSR1");
if (status_fd >= 0) {
int type =fromwire_peektype(msg);
if (!wire_sync_write(status_fd, msg))
err(1, "Writing out status %i", type);
/* No point printing error if lightningd is dead. */
exit(1);
} else {
daemon_conn_send(status_conn, msg);
}
Expand Down
2 changes: 1 addition & 1 deletion common/subdaemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void subdaemon_setup(int argc, char *argv[])
logging_io = true;
}

daemon_maybe_debug(argc, argv);
daemon_maybe_debug(argv);

#if DEVELOPER
for (int i = 1; i < argc; i++) {
Expand Down
1 change: 1 addition & 0 deletions gossipd/routing.c
Original file line number Diff line number Diff line change
Expand Up @@ -1561,6 +1561,7 @@ struct route_hop *get_route(const tal_t *ctx, struct routing_state *rstate,
hops[i].nodeid = n->id;
hops[i].amount = total_amount;
hops[i].delay = total_delay;
hops[i].direction = idx;
total_amount += connection_fee(c, total_amount);
total_delay += c->delay;
n = other_node(n, route[i]);
Expand Down
1 change: 1 addition & 0 deletions gossipd/routing.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ get_channel(const struct routing_state *rstate,

struct route_hop {
struct short_channel_id channel_id;
int direction;
struct pubkey nodeid;
u64 amount;
u32 delay;
Expand Down
1 change: 0 additions & 1 deletion lightningd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ LIGHTNINGD_SRC := \
lightningd/opening_control.c \
lightningd/options.c \
lightningd/pay.c \
lightningd/payalgo.c \
lightningd/peer_control.c \
lightningd/peer_htlcs.c \
lightningd/ping.c \
Expand Down
3 changes: 3 additions & 0 deletions lightningd/gossip_msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,16 @@ void fromwire_route_hop(const u8 **pptr, size_t *max, struct route_hop *entry)
{
fromwire_pubkey(pptr, max, &entry->nodeid);
fromwire_short_channel_id(pptr, max, &entry->channel_id);
entry->direction = fromwire_u8(pptr, max);
entry->amount = fromwire_u64(pptr, max);
entry->delay = fromwire_u32(pptr, max);
}

void towire_route_hop(u8 **pptr, const struct route_hop *entry)
{
towire_pubkey(pptr, &entry->nodeid);
towire_short_channel_id(pptr, &entry->channel_id);
towire_u8(pptr, entry->direction);
towire_u64(pptr, entry->amount);
towire_u32(pptr, entry->delay);
}
Expand Down
1 change: 1 addition & 0 deletions lightningd/json.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ json_add_route_hop(struct json_stream *r, char const *n,
json_add_pubkey(r, "id", &h->nodeid);
json_add_short_channel_id(r, "channel",
&h->channel_id);
json_add_num(r, "direction", h->direction);
json_add_u64(r, "msatoshi", h->amount);
json_add_num(r, "delay", h->delay);
json_object_end(r);
Expand Down
5 changes: 4 additions & 1 deletion lightningd/pay.c
Original file line number Diff line number Diff line change
Expand Up @@ -1004,13 +1004,14 @@ static struct command_result *json_sendpay(struct command *cmd,
u64 *amount;
struct pubkey *id;
struct short_channel_id *channel;
unsigned *delay;
unsigned *delay, *direction;

if (!param(cmd, buffer, t,
p_req("msatoshi", param_u64, &amount),
p_req("id", param_pubkey, &id),
p_req("delay", param_number, &delay),
p_req("channel", param_short_channel_id, &channel),
p_opt("direction", param_number, &direction),
NULL))
return command_param_failed();

Expand All @@ -1020,6 +1021,8 @@ static struct command_result *json_sendpay(struct command *cmd,
route[n_hops].nodeid = *id;
route[n_hops].delay = *delay;
route[n_hops].channel_id = *channel;
/* FIXME: Actually ignored by sending code! */
route[n_hops].direction = direction ? *direction : 0;
n_hops++;
}

Expand Down
Loading