Commit Graph

4328 Commits

Author SHA1 Message Date
practicalswift 2c7170b858 Remove unused adjust_feerange(...) parameters: struct crypto_state *cs + const struct channel_id *channel_id 2018-08-01 13:09:16 +09:30
practicalswift 2627d0c33b Remove unused send_offer(...) parameter: const u8 *funding_wscript 2018-08-01 13:09:16 +09:30
William Casarin 6195839783 lightningd: show selected network defaults in usage
This gives the network options a chance to load from arguments before usage
exits, so that the proper defaults are shown.

This didn't work:

  lightningd --mainnet --help

before it showed testnet defaults, now it shows mainnet defaults.

Signed-off-by: William Casarin <jb55@jb55.com>
2018-08-01 13:08:02 +09:30
practicalswift ba4282f935 Don't advertise features we don't have in run-sphinx 2018-07-31 16:30:56 +02:00
practicalswift b5682a773b Remove dead stores 2018-07-31 12:45:02 +02:00
practicalswift 09ec0ae990 Return true or false from sqlite3_bind_* based on result from SQLite instead of always returning true 2018-07-31 12:44:44 +02:00
Mark Beckwith 1fca7ab562 Added json_tok_sha256 (#1779)
Added json_tok_sha256

Converted json_tok_tok over a few places.

[ Folded: fixed spacing ]
Signed-off-by: Mark Beckwith <wythe@intrig.com>
2018-07-31 04:11:01 +00:00
Christian Decker d3edfc8028 onion: Print the extracted channel_update and onionreply to debug
This adds one line with the onion and the channel_update we extract from
it. This in turn allows us to check that the channel_update in the onion is not
type prefixed, and that we patch it correctly before passing it to gossipd.
2018-07-30 21:19:04 +00:00
Christian Decker 6bbea741d1 pay: Strip the type prefix from nested channel_updates
This is the counterpart for the previous commit, stripping the type prefix
channel_update, to be consistent with lnd and eclair which do it like this.
2018-07-30 21:19:04 +00:00
Christian Decker f449f9d3ef onion: Make sure we understand the channel_update in the onionreply
As was pointed out by @robtex we have underspecified the format of the nested
`channel_update` in the onionreply: lnd and eclair inserted the raw
channel_update without the type prefix, while we went for the full wire format,
including the type prefix. While we agreed that with the type it is more
flexible, and consistent, we decided to adapt to the majority and at least be
compatibly broken.

This commit takes care of being able to interpret either format correctly. It's
not perfect since signatures can happen to start with 0x0102 (the channel_update
type) but that'll happen only once ever 65k failures.
2018-07-30 21:19:04 +00:00
Rusty Russell 52303029aa fundchannel: cap 'all' at 2^24-1 satoshi.
The easiest way to do this is to play with the 'wallet_tx' semantics
and have 'amount' have meaning even when 'all_funds' is set.

Note that we change the string 'Cannot afford funding transaction' to
'Cannot afford transaction' as this code is also used for withdrawls.

Inspired-by: molz on #c-lightning
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-07-30 11:46:41 +02:00
Rusty Russell e3d95f3768 Update common on CCAN_TAL_DEBUG
We don't need this any more: every CCAN object has a valid tal_bytelen().

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-07-30 11:31:17 +02:00
Rusty Russell 480e32a236 channeld: don't resize tal_fmt() output.
This fixed a previous bug, but now tal/str makes this guaranteee.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-07-30 11:31:17 +02:00
Rusty Russell 5179025977 ccan: upgrade to new ccan/tal and ccan/tal/str.
The visible changes are:
1. tal_len() is renamed to tal_bytelen() for clarity.
2. tal allocations *always* know their length.
3. tal/str routines always set the length to strlen() + 1.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-07-30 11:31:17 +02:00
Rusty Russell 337075dc8c tal: don't access low-level tal functions.
In several places we use low-level tal functions because we want the
label to be something other than the default.  ccan/tal is adding
tal_*_label so replace them and shim it for now.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-07-30 11:31:17 +02:00
Rusty Russell 5cf34d6618 Remove tal_len, use tal_count() or tal_bytelen().
tal_count() is used where there's a type, even if it's char or u8, and
tal_bytelen() is going to replace tal_len() for clarity: it's only needed
where a pointer is void.

We shim tal_bytelen() for now.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-07-30 11:31:17 +02:00
Rusty Russell eae9b81099 json: json_add_hex_talarr for common case of dumping a tal object in hex.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-07-30 11:31:17 +02:00
Rusty Russell d752a0099c gossip_msg: make sure alias is NUL-terminated.
Valgrind error file: valgrind-errors.772802
==772802== Invalid read of size 1
==772802==    at 0x4C32D04: strlen (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==772802==    by 0x14479C: escape (json_escaped.c:41)
==772802==    by 0x144B6C: json_escape (json_escaped.c:117)
==772802==    by 0x118518: json_getnodes_reply (gossip_control.c:209)
==772802==    by 0x139394: sd_msg_reply (subd.c:281)
==772802==    by 0x139972: sd_msg_read (subd.c:418)
==772802==    by 0x17ABB1: next_plan (io.c:59)
==772802==    by 0x17B6A9: do_plan (io.c:387)
==772802==    by 0x17B6E7: io_ready (io.c:397)
==772802==    by 0x17D2C8: io_loop (poll.c:310)
==772802==    by 0x121973: main (lightningd.c:450)
==772802==  Address 0x6fe5168 is 0 bytes after a block of size 72 alloc'd
==772802==    at 0x4C2FB0F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==772802==    by 0x18843E: allocate (tal.c:245)
==772802==    by 0x18899D: tal_alloc_ (tal.c:421)
==772802==    by 0x188B5E: tal_alloc_arr_ (tal.c:464)
==772802==    by 0x119BAB: fromwire_gossip_getnodes_entry (gossip_msg.c:35)
==772802==    by 0x15CCD6: fromwire_gossip_getnodes_reply (gen_gossip_wire.c:111)
==772802==    by 0x118436: json_getnodes_reply (gossip_control.c:192)
==772802==    by 0x139394: sd_msg_reply (subd.c:281)
==772802==    by 0x139972: sd_msg_read (subd.c:418)
==772802==    by 0x17ABB1: next_plan (io.c:59)
==772802==    by 0x17B6A9: do_plan (io.c:387)
==772802==    by 0x17B6E7: io_ready (io.c:397)

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-07-30 11:31:17 +02:00
Christian Decker fbbc5899e4 invoices: Make the invoice_details more idiomatic
This seems like a premature optimization: it tried to cut down the number of
allocations by reusing the same `struct invoice_details` while iterating through
a number of results. But this sidesteps the checks by `valgrind` and we'd miss a
missing field that was set by the previous iteration.

Reported-by: @rustyrussell
Signed-off-by: Christian Decker <@cdecker>
2018-07-30 03:04:45 +00:00
Christian Decker 259a69994d json-rpc: Retrieve the invoice description in listinvoices 2018-07-30 03:04:45 +00:00
Christian Decker 7f45947523 wallet: Store the description in the database for invoices 2018-07-30 03:04:45 +00:00
Christian Decker 687f171e17 json-rpc: Add description to `listpayments` and similar 2018-07-30 03:04:45 +00:00
Christian Decker 6bbe5b60f6 wallet: Extract the payment fields into a define
`wallet_stmt2payment` always expects the same fields in the same order, so we
should make sure that we always fetch them in that order and all of them.
2018-07-30 03:04:45 +00:00
Christian Decker bc7393bb64 pay: Reduce nesting and fix minor type inconsistency 2018-07-30 03:04:45 +00:00
Christian Decker 1738107598 json-rpc: Add description argument to `sendpay` 2018-07-30 03:04:45 +00:00
Christian Decker ab223c2ade pay: Pass description to send_payment
Extract the description from the bolt11 string and store it in the database.
2018-07-30 03:04:45 +00:00
Christian Decker 60e0eec967 wallet: Store payment description in the database 2018-07-30 03:04:45 +00:00
Christian Decker ff5ca37f3c wallet: Add descriptions to invoice and payment structs 2018-07-30 03:04:45 +00:00
Christian Decker 7119a02932 db: Add description fields to invoices and payments 2018-07-30 03:04:45 +00:00
Christian Decker 55d450ff00 pay: Exempt a fee from the maxfeepercent rule it is still tiny
Several users have noticed that they cannot pay satoshis.place or similar places
that have tiny payment amounts if they are not directly connected. This is due
to the forwarding fee dominating the transferred amount.

This commit adds a new option, exempting tiny fees (up to 5 satoshis by default)
from having to pass the maxfeepercent flag. While we could have told users to
tweak maxfeepercent I think it is usefull to have a default exemption.

[Squashed --RR]
2018-07-30 01:05:43 +00:00
Simon Vrouwe a235c1fa67 add more detail to log messages about feerate estimates 2018-07-29 20:12:21 +02:00
Mark Beckwith 1851ebbc56 programer -> developer
Signed-off-by: Mark Beckwith <wythe@intrig.com>
2018-07-29 16:27:38 +02:00
Mark Beckwith 428da65fb1 renamed error code
Signed-off-by: Mark Beckwith <wythe@intrig.com>
2018-07-29 16:27:38 +02:00
Mark Beckwith 381c32af75 Remove sigaction from run-param
Developer errors result in command_fail being called
just like other errors.  The bad_programmer() Test is now updated
and passing.

Signed-off-by: Mark Beckwith <wythe@intrig.com>
2018-07-29 16:27:38 +02:00
Mark Beckwith 2ca1786931 Added check_fail function to run-param
Just a utility function to check that command_fail was called.

Signed-off-by: Mark Beckwith <wythe@intrig.com>
2018-07-29 16:27:38 +02:00
Mark Beckwith b7203b0c0c Remove Developer Asserts from param.c
They now just call command_fail() and cause param() to return false.
Temporarily disabled all the run-param.c tests that redirect
asserts so CI would still pass.

Signed-off-by: Mark Beckwith <wythe@intrig.com>
2018-07-29 16:27:38 +02:00
Rusty Russell 65103ac426 pytest: give more time for test_closing_torture.
The logs in various Travis failures show that it takes 20 seconds just for
closingd to read the init message.  As a result, the close times out (default
is 30 seconds).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-07-29 16:23:27 +02:00
Rusty Russell 9e14d6cf04 Remove all JSON commands and fields deprecated before 0.6.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-07-29 16:22:01 +02:00
Rusty Russell 8ee21bc352 Remove deprecated closing support from closingd.
This was changed in the spec in January, and bd1aa935b added it 2018-02-02.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-07-29 16:22:01 +02:00
Rusty Russell ab331f79a0 Add and fill in CHANGELOG.md
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-07-29 16:22:01 +02:00
Jordan Baczuk 0b597f671a added (or remotely) to README 2018-07-28 05:02:51 +00:00
Christian Decker 3783281fdd git: Ignore the connectd test binaries 2018-07-28 01:40:08 +00:00
Rusty Russell be3b782cb4 pytest: add test for update being decoded from onion error.
This actually tests that we correctly process an error packet, and
disable the channel.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-07-27 14:12:00 +02:00
Rusty Russell 36730ddb6d gossipd: dev-suppress-gossip.
Useful for testing that we only get an update via the error message.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-07-27 14:12:00 +02:00
Rusty Russell 162879d6a2 channeld: use fulfilled_htlc and failed_htlc msgs in single htlc case.
We use these for receiving arrays at init time, we should also use them
for fulfull/fail of HTLCs in normal operation.  That we we benefit from all
those assertions.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-07-27 14:12:00 +02:00
Rusty Russell f76203727d htlc_wire: be stricter in marshaling/unmarshaling struct failed_htlc.
There are three cases:
1. failcode is 0, scid is NULL, failreason is the onion to fwd.
2. failcode is non-zero, but UPDATE bit not set.  scid is NULL, failreason NULL.
3. failcode has UPDATE bit set.  scid is non-NULL, failreason is NULL.

Assert these on marshaling, and only send the parts we need so unmarshal is
always canonical.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-07-27 14:12:00 +02:00
Rusty Russell 3c651f19a8 channeld: send correct channel_update when reporting failure.
The master tells us the short_channel_id of the outgoing channel, and
channeld is supposed to get the corresponding channel_update from gossipd.
Instead, it got the channel_update for the *local* channel and ignored
that one.
2018-07-27 14:12:00 +02:00
Rusty Russell 1119dd5577 channeld: always receive and maintain short_channel_id of failing channel.
The master tells us the short_channel_id of the outgoing channel when
failing an HTLC, but channeld didn't store it anywhere.  It also
didn't tell channeld the short_channel_id in the case where we're
reconnecting and it's feeding us an array of failed htlcs.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-07-27 14:12:00 +02:00
Rusty Russell 73b3782943 gossipd: send latest update in error message, even if delayed.
We delay internally to reduce broadcastig route flap, but errors are
a special case: we want to send the latest, otherwise we might send an
old (non-disabled) update.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-07-27 14:12:00 +02:00
Rusty Russell 3c66d5fa03 gossipd: add flag for locally disabling channel.
We used to just manually set ROUTING_FLAGS_DISABLED, but that means we
then suppressed the real channel_update because we thought it was a
duplicate!

So use a local flag: set it for the channel when the peer disconnects,
and clear it when channeld sends a local update.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-07-27 14:12:00 +02:00