Commit Graph

3439 Commits

Author SHA1 Message Date
Rusty Russell 8966a175ee chaintopology: add debug message when we're adjusting due to feerate floor.
But only if we're actually going to change the feerate, otherwise we'd
log every time.

Suggested-by: @ZmnSCPxj
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-03-20 16:08:45 +01:00
Rusty Russell 2e687b9b35 chaintopology: set a fee floor to avoid creating unrelayable txs.
Naively, this would be 250 satoshi per sipa, but it's not since bitcoind's
fee calculation was not rewritten to deal with weight, but instead bolted
on using vbytes.

The resulting calculations made me cry; I dried my tears on the thorns
of BUILD_ASSERT (I know that makes no sense, but bear with me here as I'm
trying not to swear at my bitcoind colleagues right now).

Fixes: #1194
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-03-20 16:08:45 +01:00
ZmnSCPxj, ZmnSCPxj jxPCSmnZ 044705a547 peer_control: Fix a use-after-free bug. (#1237)
This bug is a classic case of being lazy:
1. peer_accept_channel() allocated its return off the input message,
   rather than taking an explicit allocation context.  This concealed the
   lifetime nature of the return.
2. The context for sanitize_error was the error itself, rather than the
   more obvious tmpctx (connect_failed does not take).

The global tmpctx removes the "efficiency" excuse for grabbing a random
object to use as context, and is also nice and explicit.

All-the-hard-work-by: @ZmnSCPxj
2018-03-19 09:27:09 +00:00
practicalswift e56eee50c8 Make sure we never pass a negative value to dup2(...) 2018-03-19 09:25:39 +00:00
practicalswift 148aaa79d5 Check hex_decode(...) return value 2018-03-19 09:25:39 +00:00
ZmnSCPxj 9efe123a0d lightningd/json: Move json helpers specific for lightningd to new module. 2018-03-19 00:27:55 +00:00
ZmnSCPxj 6391645b83 test_lightningd: Check payment fields of pay return value. 2018-03-19 00:27:55 +00:00
ZmnSCPxj 881eb80f6a payalgo: Make 'pay' return similar to 'listpayments' 2018-03-19 00:27:55 +00:00
ZmnSCPxj 3c39bcc0f7 pay: Make json_add_payment_fields accessible to other parts. 2018-03-19 00:27:55 +00:00
ZmnSCPxj 7443bf5ed5 doc: Update for latest 'pay' command. 2018-03-19 00:27:55 +00:00
ZmnSCPxj d181ecbeea payalgo: Implement retry_for for pay command. 2018-03-19 00:27:55 +00:00
ZmnSCPxj 981af478f1 payalgo: Keep and report route and route failures. 2018-03-19 00:27:55 +00:00
ZmnSCPxj 234d67da34 channel_fail_permanent: Use a channel-level error, not an all-channels error.
Fixes: #1229
2018-03-17 13:26:58 +01:00
ZmnSCPxj d49915cdd2 peer_control: Have listpeers also return channel ID. 2018-03-17 13:26:58 +01:00
ZmnSCPxj 099acb2a66 opening_control: have fundchannel also return channel_id.
For voyeurism.
2018-03-17 13:26:58 +01:00
Rusty Russell 4ffd5e213b pay: work around bug #1212 for existing databases.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-03-16 04:01:06 +00:00
Rusty Russell 1b9791f0f5 pay: delete HTLC when we delete payment.
This fixes the root cause of https://github.com/ElementsProject/lightning/issues/1212
where we deleted the payment because we wanted to retry, then retry failed
so we had an (old) HTLC without a matching payment.  We then fed that
HTLC to onchaind, which tells us it's missing, and we try to fail the
payment and deref a NULL pointer.

Fixes: #1212
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-03-16 04:01:06 +00:00
Rusty Russell d8cecf03dd test_lightningd.py: add test to trigger crash bug.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-03-16 04:01:06 +00:00
ZmnSCPxj e6de41b468 tools/rel.sh: Make POSIXLY compatible.
Fixes: #1221

We were using `\x0` to match NUL chars in the input (on the
assumption that NUL chars are "impossible" for decent LFS-compliant
systems).
However `\x0` is a GNUism.
Use the `\n` and the newline character, which is supported by (most)
POSIX sed.
2018-03-16 01:50:26 +00:00
ZmnSCPxj 7bbc1948f7 chaintopology: Add missing `block_map_del`.
We would `block_map_add` inside `add_tip`, but we never
`block_map_del` inside `remove_tip`, which is dangerous as
we actually `tal_free` the block inside `remove_tip`.

Our CI did not reliably trap this problem since block
hashes are random and rerunning the `test_blockchaintrack`
often passed spuriously.
2018-03-16 01:45:08 +00:00
ZmnSCPxj 39d8f64226 doc: Update manpages for change in return value. 2018-03-16 01:24:43 +00:00
ZmnSCPxj f2aa15ffee test_lightningd.py: Check additional fields of sendpay. 2018-03-16 01:24:43 +00:00
ZmnSCPxj 022cfccddd pay: sendpay and waitsendpay print similar to listpayments 2018-03-16 01:24:43 +00:00
ZmnSCPxj fa281d32ea pay: sendpay_result has payment on success or in-progress. 2018-03-16 01:24:43 +00:00
practicalswift 8f76581005 Use pointer to const where possible 2018-03-16 01:17:40 +00:00
practicalswift c85c2fcfe9 Fix conversion order 2018-03-16 01:17:40 +00:00
practicalswift b8846dad49 Readability: Use streq instead of strcmp 2018-03-16 01:17:40 +00:00
practicalswift 60a7720a24 Avoid passing NULL argument to memcpy 2018-03-16 01:17:40 +00:00
practicalswift f0667d239a Remove duplicate va_end(...) call. va_end(...) is the responsibility of the caller. 2018-03-16 01:17:40 +00:00
practicalswift f9bd43f266 Limit scope of variable failcode. Remove dead code. 2018-03-16 01:17:40 +00:00
practicalswift b557e7b0fc Fix misleading indentation (space before tab) 2018-03-16 01:17:40 +00:00
practicalswift 7bd1ae6b2e Fix misleading indentation (in the case of DEVELOPER) 2018-03-16 01:17:40 +00:00
practicalswift b206aed371 Remove redundant cast to same type 2018-03-16 01:17:40 +00:00
practicalswift 03e2e404f2 Mark unused parameters as such (using "UNUSED") 2018-03-16 01:17:40 +00:00
practicalswift 20ae038080 Remove redundant declaration 2018-03-16 01:17:40 +00:00
practicalswift 9970419b3a Remove redundant return from void function 2018-03-16 01:17:40 +00:00
Rusty Russell a935ae0711 doc: Link STLYE.md from HACKING.md
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-03-16 00:16:10 +00:00
Rusty Russell 08f4d48b0f Add some Style.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-03-16 00:16:10 +00:00
Rusty Russell e63b7bb539 take: allocate temporary variables off NULL.
If we're going to simply take() a pointer, don't allocate it off a random
object.  Using NULL makes our intent clear, particularly with allocating
packets we're going to take() onto a queue.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-03-16 00:16:10 +00:00
Rusty Russell 0a6e3d1e13 utils: remove tal_tmpctx altogether, use global.
In particular, we now only free tmpctx at the end of main().

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-03-16 00:16:10 +00:00
Rusty Russell 40fe5b7bac closingd: use global tmpctx.
This one is a bit more subtle than others: we can't just free it
inside the read_peer_msg() loop since we hand tmpctx in, so open-code
the two callers and it's clearer.

They're inside the only loops closingd has.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-03-16 00:16:10 +00:00
Rusty Russell f2adb76d04 test: remove obsolete directory.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-03-16 00:16:10 +00:00
Rusty Russell de5d84097e lightningd: remove ltmp context now we have tmpctx.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-03-16 00:16:10 +00:00
Rusty Russell ccc9414356 status: remove trc context now we have tmpctx.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-03-16 00:16:10 +00:00
Rusty Russell 4845445079 memleak: ignore tmpctx.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-03-16 00:16:10 +00:00
Rusty Russell ef2a063169 utils: add a global tmpctx.
I did a brief audit of tmpctx uses, and we do leak them in various
corner cases.  Fortunely, all our daemons are based on some kind of
I/O loop, so it's fairly easy to clean a global tmpctx at that point.

This makes things a bit neater, and slightly more efficient, but also
clearer: I avoided creating a tmpctx in a few places because I didn't
want to add another allocation.  With that penalty removed, I can use
it more freely and hopefully write clearer code.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-03-16 00:16:10 +00:00
Rusty Russell 41ef42ee94 memdump: fix overzealous assertions from b857b2e843
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-03-16 00:16:10 +00:00
ZmnSCPxj f9bc0353c4 devtools/onion: Add to gitignore. 2018-03-14 18:31:45 +01:00
ZmnSCPxj ed3984f444 test_lightningd.py: Modify test_payment_duplicate_uncommitted.
`pay` command will now wait for payment to succeed if the
payment has been initiated.
2018-03-14 05:33:09 +00:00
ZmnSCPxj a0c2686ebd pay: Have sendpay wait for payment to be saved.
The payment should be stored in a "timely" manner, i.e.
within 10ms.
2018-03-14 05:33:09 +00:00