Commit Graph

2535 Commits

Author SHA1 Message Date
Rusty Russell 63390a58b0 db: log a message to say whether we created or updated db.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-01-02 13:21:25 +01:00
Rusty Russell 1e51275792 lightningd: don't save wallet_channel twice on creation.
peer_channel_new() does exactly that already.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-01-02 13:21:25 +01:00
Rusty Russell b7e8ee4445 test_lightningd: make sure onchaind recognizes outputs in htlc onchain tests.
We stopped too early; we should continue and make sure it all goes well.

This means we have to fix them to be deterministic: by generating 2
blocks at once in test_htlc_in_timeout, we raced between fulfill and
timeout on the HTLC.  Now it's always fulfilled.

Also, fixed confusing comments: l1 doesn't drop to chain.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-01-02 13:21:25 +01:00
Rusty Russell 7e062fd637 onchaind: don't assert() when htlc fulfilled twice.
In the normal (peer-to-peer) path, the HTLC state prevents us fulfilling
twice, but this goes out the window with onchain HTLCs.

The actual assert which caught it was lightningd/pay.c:70 (payment_succeeded)
in the test_htlc_in_timeout test, after the next commit.

So add an assert earlier (in fulfill_our_htlc_out) and check in the
one caller where it can be true.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-01-02 13:21:25 +01:00
Rusty Russell 72a52b0b59 onchaind: fix label on HTLC timeout tx.
OUR_HTLC_TIMEOUT_TO_US = normal tx, used to timeout htlc in their commit tx.
OUR_HTLC_TIMEOUT_TX = dual-sig tx with delay, used to timeout htlc in our commit tx.

Only one test looks at that string, so fix that too.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-01-02 13:21:25 +01:00
Christian Decker fff7efaf97 gossipd: Remove annoying trace 2018-01-02 01:35:59 +00:00
Christian Decker 3923109f51 gossipd: Replace lookup by short_channel_id by endpoint lookup
Sometimes we could get into a situation in which we knew the channel
but couldn't find it via the short_channel_id. That'd result in a
replacement which triggered an assert.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-01-02 01:35:59 +00:00
ZmnSCPxj f2f116d613 lightningd: Add missing final cleanups. 2018-01-02 01:31:04 +00:00
Christian Decker 3af2dcba6a gossip: Fix a typo in the add_channel_direction logic
Signed-off-by: Christian Decker <decker.christian@gmail.com>
Reported-by: William Casarin @jb55
2018-01-02 01:20:34 +00:00
practicalswift aae991f28d Add missing call to va_end()
Each invocation of va_start() must be matched by a corresponding
invocation of va_end() in the same function.
2018-01-02 01:19:03 +00:00
practicalswift c6b5e72e3b Pass bool true instead of "true" to json_add_bool(..., bool value) 2018-01-02 01:18:42 +00:00
practicalswift db362e2e23 Remove redundant assignments 2018-01-02 00:38:20 +00:00
ZmnSCPxj 280c0e53ef test_lightningd.py: Add test for waitinvoice. 2018-01-02 00:36:16 +00:00
ZmnSCPxj 8e3c97762e invoice: Properly implement waitinvoice.
Fixes: #444
2018-01-02 00:36:16 +00:00
ZmnSCPxj 773f7524dd invoice: Factor out invoice deletion code.
In preparation for adding a deletion trigger for
invoice waiters on individual invoices.
2018-01-02 00:36:16 +00:00
ZmnSCPxj 7f24e36dd9 test_lightningd.py: Test paying invoice in reverse order of creation. 2018-01-01 23:13:31 +00:00
ZmnSCPxj 1de339eff6 invoice: Use wallet_invoice_nextpaid in waitanyinvoice implementation.
Fixes: #442
2018-01-01 23:13:31 +00:00
ZmnSCPxj 993d5dc75a wallet: Implement wallet_invoice_nextpaid.
wallet_invoice_nextpaid is used to iterate over paid invoices,
and will be used to fix waitanyinvoice command.
2018-01-01 23:13:31 +00:00
ZmnSCPxj ea1cea6366 wallet: Minor testing of pay_index column. 2018-01-01 23:13:31 +00:00
ZmnSCPxj 3dd50d6219 wallet: Add pay_index column to database for paid invoice ordering. 2018-01-01 23:13:31 +00:00
practicalswift d50fb131b6 Avoid passing uninitialized value dummy with uninitialized field addrlen to {initiator,responder}_handshake_ 2017-12-30 12:28:24 +01:00
practicalswift 6c50d70e68 Remove trailing semicolons in Python code 2017-12-28 19:29:58 +01:00
practicalswift f84828be36 Avoid writing uninitialized value data->realm in serialize_hop_data(...) (via create_onionpacket(...)) 2017-12-28 16:09:46 +01:00
practicalswift 84dd65485c Remove duplicate includes 2017-12-28 16:09:24 +01:00
practicalswift f9b8a007d5 Remove unused imports 2017-12-28 16:05:15 +01:00
practicalswift 5123c4e059 Fix access to undefined variable 2017-12-28 16:05:15 +01:00
practicalswift bfce5b41f9 Fix typo (a vs. an) 2017-12-28 16:04:38 +01:00
practicalswift aee3661b35 Fix typos (repeated words) 2017-12-28 16:04:38 +01:00
Rusty Russell 3ae7b9f0fb bitcoin: add formatting hook for printing bitcoin blockids
lightningd(12615): Adding block UNKNOWN TYPE bitcoin_blkid

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-12-25 12:33:22 +01:00
Christian Decker a44e1e456f pytest: remove useless debugging print 2017-12-23 14:51:33 +01:00
Christian Decker 71c62e726e fixup! pytest: Temporarily disable test_reconnect_normal due to flakyness 2017-12-23 06:15:33 +00:00
Christian Decker 45691a50b8 pytest: Temporarily disable test_reconnect_normal due to flakyness
The test_reconnect_normal test is failing rather consistently on 32bit
architectures, disabling to reduce noise. Issue #468 tracks progress.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2017-12-23 06:15:33 +00:00
Christian Decker 2a7ba010c3 pytest: Use the bitcoind config file to read RPC params from
With python-bitcoinlib==0.9.0 it appears that the URL based auth
information is no longer used, so we fall back to reading the config
file for the bitcoind daemon instead.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2017-12-23 06:15:33 +00:00
Rusty Russell 047a2ea043 gossip: don't use assert around code with side effects.
The use of status_failed() requires a stubs update, which fails
with unnamed parameters, so tweak the status.h header as well.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-12-22 15:47:17 +01:00
Christian Decker 0db821e2cf routing: Fix the announcement detection for channel_announcements
If we side-load a channel, using local-add or the removed JSON-RPC
call, then we could end up in a situation in which a channel is
present, but has no associated channel_announcement. The presence of
the channel_announcement was used to identify new channels, so this
could lead to channels always being considered new. This then caused
the announcements being added to the queue always, resulting in
channel_updates preceeding the announcement.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2017-12-22 15:47:17 +01:00
Christian Decker 83caf1fdab routing: Add tracking of eviction for broadcasts
We should never be evicting channel_announcements because a) they were
deeply buried and should not change the short_channel_id/tag, b) they
are static.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2017-12-22 15:47:17 +01:00
Christian Decker 1b28220b64 Revert "broadcast: don't reorder channel_announce when we get the real one."
This reverts commit f293ff0a6a.
2017-12-22 15:47:17 +01:00
Christian Decker ab620c5068 travis: Enable pytest-test-groups to split tests across several runs
Adds two new environment variables TEST_GROUP_COUNT and TEST_GROUP to
split the integration tests into groups and run only a selected group.

This allows us to increase the TEST_GROUP_COUNT and add a new
TEST_GROUP to avoid bumping up against the time limit when running in
valgrind.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2017-12-21 22:43:24 +00:00
Christian Decker 1a91786def travis: Use env-file to pass in environment variables
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2017-12-21 22:43:24 +00:00
Christian Decker 0574d68c97 docker: Added pytest-groups plugin to builder image 2017-12-21 22:43:24 +00:00
Rusty Russell 6debaccfd5 chaintopology: only do callbacks once chain has settled.
This is only important for testing, where we add 100 blocks at once
and time out under valgrind.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-12-21 14:33:27 +01:00
Rusty Russell 887e9dcc44 travis: reenable check-source (without BOLT text).
We've been slipping, so fix up minor issues too so it compiles.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-12-21 14:33:27 +01:00
Rusty Russell 0650653658 bitcoind: delete chaintips code.
We don't need it any more, with the simpler topology approach.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-12-21 14:33:27 +01:00
Rusty Russell 1d9a8e5484 chaintopology: load forwards, not backwards.
We used to load the new tip and work backwards until we joined up with
the previous tip.  That consumed quite a lot of memory if there were
many blocks.

Instead, just poll on blocknum+1, and grab it once that succeeds.  If
prev is different from what we expect (reorg), we free the current tip
and try again.

We could theoretically miss a reorg which is the same length (2 block
reorg with more work due to difficulty adjustment), but even if that
happened we'd catch up on the next block.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-12-21 14:33:27 +01:00
Rusty Russell 6f6d7a5e44 chaintopology: get fees using a timer, not on each block.
It definitely changes when we get a block, but it also changes between
blocks as mempool fills.  So put it on its own timer.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-12-21 14:33:27 +01:00
Rusty Russell 985a0b431f getblockhash: don't get upset if we fail.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-12-21 14:33:27 +01:00
Rusty Russell 810abb6b21 bitcoin: create new wrapper type bitcoin_blkid, log backward endianness.
It's just a sha256_double, but importantly when we convert it to a
string (in type_to_string, which is used in logging) we use
bitcoin_blkid_to_hex() so it's reversed as people expect.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-12-21 11:05:38 +00:00
Rusty Russell 0237e0b28c bitcoin: create new wrapper type bitcoin_txid, log backward endianness.
It's just a sha256_double, but importantly when we convert it to a
string (in type_to_string, which is used in logging) we use
bitcoin_txid_to_hex() so it's reversed as people expect.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-12-21 11:05:38 +00:00
Rusty Russell ed2158c334 Revert "Functions for encoding reversed hex"
This reverts commit ef5678956d2eedf9904ce32f12f6367bc26c59e7.
2017-12-21 11:05:38 +00:00
Rusty Russell 553ebc936b json: add json_add_txid.
I prefer the typesafety of specific functions, rather than having the
caller know that txids are traditionally reversed in bitcoin.

And we already have a bitcoin_txid_to_hex() function for this.

Closes: #411
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-12-21 11:05:38 +00:00