Commit Graph

1999 Commits

Author SHA1 Message Date
Rusty Russell fc24c71196 tests/test_lightningd.py: add async option for pay command.
We'll need this for testing nodes going down during payment.

However, there's no good way to silence the threads that I can tell,
so we get a nasty backtrace from it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-08-20 13:06:41 +09:30
Rusty Russell 8e0c19c76a lightningd: add dev-fail command to inject permenant failure.
A couple of double-free bugs founnd doing this, too.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-08-20 13:06:41 +09:30
Rusty Russell 524e56cf56 dev_disconnect: support '*N' syntax for disconnecting on the N'th occurance.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-08-20 13:06:41 +09:30
Rusty Russell 99581bd709 dev_disconnect: support 'permfail' line to permanently fail peer.
The master daemon checks for this after a subdaemon dies.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-08-20 13:06:41 +09:30
Rusty Russell f5f8ca5352 onchain/onchain_wire: routines to marshal/unmarshal htlc stubs.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-08-20 13:06:41 +09:30
Rusty Russell 0ab1fb3688 wire: add ripemd marshal/unmarshal routines.
This is for htlc stubs.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-08-20 13:06:41 +09:30
Rusty Russell f765e0e846 bip32: marshal/unmarshal routines.
Neater than using a u8 array as we do now.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-08-20 13:06:41 +09:30
Rusty Russell bcc9ed9aa6 lightningd/htlc_wire: marshal/unmashal bitcoin tx.
We want to keep the last valid tx, and its signature, for broadcast.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-08-20 13:06:41 +09:30
Rusty Russell a4f290daba htlc_wire: marshal/unmarshal shachain object.
We want to hand it to onchaind.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-08-20 13:06:41 +09:30
Rusty Russell aa23a2a93f generate-wire.py: handle unmarshalling of a single varlen_struct
We previously only handled it in arrays.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-08-20 13:06:41 +09:30
Rusty Russell 217df2d2e8 channeld: fix shutdown when we have to complete HTLCs.
We need to check if we exit after sending a revoke_and_ack, otherwise
channeld ends up getting the closing_signed packet.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-08-20 13:06:41 +09:30
Rusty Russell f5624af965 lightningd: fix error packet we send due to permanent error.
tal_strdup() doesn't set tal_count(), so we end up sending an ERROR
packet with an empty message.  Wrap this and get it right.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-08-20 13:06:41 +09:30
Rusty Russell ce24731da9 lightningd: use internal_error rather than freeing peer.
Should never free peer directly: we need to log error, etc.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-08-20 13:06:41 +09:30
Rusty Russell 709991fed1 subd: fix case where we replycb calls peer_internal_error().
It frees the sd, destroy_subd() frees sd->conn, then we call io_close(conn).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-08-20 13:06:41 +09:30
Rusty Russell 1ad960413d test_lightningd: fix valgrind detection on children.
I tracked down a bug, and couldn't figure out why valgrind wasn't
finding it.

From man valgrind:

       --log-file=<filename>
           Specifies that Valgrind should send all of its messages to the
           specified file. If the file name is empty, it causes an abort.
           There are three special format specifiers that can be used in the
           file name.

           %p is replaced with the current process ID. This is very useful for
           program that invoke multiple processes. WARNING: If you use
           --trace-children=yes and your program invokes multiple processes OR
           your program forks without calling exec afterwards, and you don't
           use this specifier (or the %q specifier below), the Valgrind output
           from all those processes will go into one file, possibly jumbled
           up, and possibly incomplete.

"possibly incomplete" indeed!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-08-20 13:06:41 +09:30
Christian Decker 3e42485ddb fix: Typo in the error message for adding an output to DB
Fixes #216

Reported-by: @jl777
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2017-08-18 14:40:34 +02:00
Christian Decker 6dbd99ddc6 gossip: Fix a race condition between release_peer and fail_peer
There was a race condition that would cause an assertion to segfault
if a call to release_peer was interleaved with a fail_peer. The
release_peer was making the peer non-local, which was then causing the
assertion in fail_peer to fail. Now we just have 3 cases: not found,
local, and non-local.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2017-08-17 10:31:55 +09:30
Christian Decker 9ad8365589 pytest: Split test_disconnect
These were in part reusing some of the nodes, and creating new
instances for other, so I split them to avoid having cross pollution
between the tests.
2017-08-17 10:31:55 +09:30
Christian Decker f085a474b2 fix: Only add cli_args if we have some defined
This was causing calls to `bitcoin-cli` to fail on mainnet since it
was interpreting the empty string as the RPC method to call.
2017-08-13 13:57:48 +09:30
Christian Decker f802e98e73 doc: Fix sendpay instructions
They were telling people to use the `<amount>`, but that's encoded in
the route already. Instead the final parameter is the `<rhash>` which
is the only piece of information missing for the transfer.

Reported-by: Toshiro Takahashi @toshirot
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2017-08-12 12:08:11 +02:00
Christian Decker fc59d8e227 doc: Add bitcoind dependency to INSTALL and send to background 2017-08-10 16:10:16 +02:00
Christian Decker 1ac10716be wallet: Add closing parameters to channel state
I must have missed these before, so adding them now.
2017-08-10 12:34:58 +09:30
Christian Decker 1070bbccde wallet: Add channel_config persistence to channel persistence
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2017-08-10 12:34:58 +09:30
Christian Decker f2382884b6 wallet: Add roundtrip test for channel_config persistence
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2017-08-10 12:34:58 +09:30
Christian Decker cc5af13e05 wallet: Implement channel_config persistence 2017-08-10 12:34:58 +09:30
Christian Decker 6f441d3cd2 wallet: Add a CRU(D) test for wallet_channels
Simple roundtrip testing which writes to DB, reads it back in and
checks for equality.
2017-08-10 12:34:58 +09:30
Christian Decker af62c9ca97 wallet: Insert/Update channels into database
Definitely not as nice as it could be, but it works for now. This is
primarily intended as a simple dump method that just saves everything
to the database. We will later use smaller incremental updates to
update specific things. wallet_channel_save serves both to insert as
well as update.
2017-08-10 12:34:58 +09:30
Christian Decker cfe87b16c3 db: Do not exit transaction on failure
Automatically exiting the DB transaction upon any failure is strange
since it'll kill any later attempt to commit. The commit itself should
be used to verify that everything was ok.
2017-08-10 12:34:58 +09:30
Christian Decker a5b425faad wallet: Implement loading of stored channels from DB
Ugliest code I've written in a while, but it seems to do the trick.
2017-08-10 12:34:58 +09:30
Christian Decker ca00ec0bb8 htlc: Include htlc_wire.h in peer_htlcs.h to avoid forward decl 2017-08-10 12:34:58 +09:30
Christian Decker fa6e53bb08 Move short_channel_id primitive into bitcoin
Not really a bitcoin primitive but the place where we keep all the
small stuff currently.
2017-08-10 12:34:58 +09:30
Christian Decker 5912c68185 db: Add a hexval helper to decode hex values from db into fields
This is going to be handy pretty soon. Channels are almost fully
blobs...
2017-08-10 12:34:58 +09:30
Christian Decker de822b7ea0 git: Ignore closing daemon 2017-08-10 12:34:58 +09:30
Christian Decker 33ffb53d9e db: Added schema for peers and channels 2017-08-10 12:34:58 +09:30
Christian Decker 85d2256898 wallet: Use persistent shachain for remote secrets 2017-08-10 12:34:58 +09:30
Christian Decker 1ff64ef07c wallet: Implement delete for wallet_shachain 2017-08-10 12:34:58 +09:30
Christian Decker 416d6bf860 db: Enable foreign keys and cascade on shachain delete
Should make maintenance a bit easier.
2017-08-10 12:34:58 +09:30
Christian Decker 8b7efd01d7 wallet: Created a simple persisted shachain unit-test
This exercises the create, read and update functionality of the
persisted shachain.
2017-08-10 12:34:58 +09:30
Christian Decker 34baf05973 wallet: Implement shachain persistence
This needed a rather annoying hack since sqlite3 can only store
integers up to 2^63, so I just squash it down/invert it, and hope that
we never ever have more than 2^63 updates.
2017-08-10 12:34:58 +09:30
Christian Decker b0c64909e7 wallet: Added database schema for shachain persistence 2017-08-10 12:34:58 +09:30
Christian Decker 28cc92cd15 gossip: Use bit 3 (mask 0x08) to signal initial routing sync
After quite some back and forth we seem to finally agree on the bit
3 (mask 0x08) to signal optional initial_routing_sync.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2017-08-09 10:01:33 +09:30
Christian Decker fbe3a017a9 gossip: Fix crash of getroute if we don't know any channels
This happens when we either have no channel open, or didn't announce
the channel. This patch just fails the getroute request. I'll later
add the non-broadcast announcement for local channels that should fix
this for unannounced channels.
2017-08-08 10:23:29 +09:30
Rusty Russell 40895e4550 Update to match spec: "BOLT7: Reorder feature bitmaps in order to allow future changes"
aka. a257554456cda98afd1532c302c0e5e84de0455e

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-08-03 14:26:41 +02:00
Rusty Russell 2b7c091e70 closing: update to match proposal to restart negotiation on reconnect.
This simplifies significantly, as we don't need to remember what we offered.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-08-02 11:45:30 +09:30
Christian Decker b1ded66d35 fix: Mispelled word in the README.md
Fixes #198

Reported-by: Toshiro Takahashi @toshirot
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2017-07-31 13:45:13 +02:00
Christian Decker 35847206b2 fix: Allow pings while waiting for the channel to lock
This was causing failures on testnet where confirmations are not
immediate.

Reported-by: Fabrice Drouin @sstone
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2017-07-22 09:52:14 +09:30
Christian Decker 2bf92c9063 peer: Check localfeatures and globalfeatures against what we support (#195)
We support a number of features already, so failing connections
whenever we see an even bit set is not a good idea. This turned out to
kill our connections to eclair.

Also, the spec says that the LSB / bit 0 is to be counted as index 0, and
therefore even. So we need to check the lower of each 2-bit-tuple not
the higher one.
2017-07-16 10:38:26 +09:30
Christian Decker 75de4476f3 cleanup: Addressing comments from #165
Thanks @rustyrussell for the feedback :-)
2017-07-15 13:51:48 +02:00
Christian Decker 7dc693963d script: Consolidate scripts to use pubkey_to_hash160 2017-07-15 10:19:33 +09:30
sstone f371b6df20 sphinx: fix payload amount encoding
it was changed to 64 bits
2017-07-14 19:27:33 +02:00