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

Fix the multi-part payments #3857

Merged
merged 24 commits into from
Jul 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
acc6ad6
paymod: Count all attempts, not just the ones with a result
cdecker Jul 19, 2020
33d60c1
paymod: Add a comment about how we derive errors from erring_index
cdecker Jul 19, 2020
24e9a16
paymod: Add invariant verification for constraints on shadowroute
cdecker Jul 19, 2020
68e23f4
paymod: Rewrite the shadow-route constraint enforcement
cdecker Jul 19, 2020
546c3a8
paymod: Add a log entry whenever we add a channel hint
cdecker Jul 19, 2020
a94ad3f
paymod: Consolidate step selection and changes in presplit modifier
cdecker Jul 19, 2020
b99db9e
paymod: Do not duplicate partids
cdecker Jul 19, 2020
4af4000
paymod: Fix the adaptive splitter partitioning
cdecker Jul 19, 2020
e391869
pay: fix problematic sharing of shadow route data.
rustyrussell Jul 20, 2020
fa7b2b3
pytest: fix erroneous test_pay_retry result.
rustyrussell Jul 20, 2020
92a4f39
pay: handle returned errors more gracefully.
rustyrussell Jul 20, 2020
09a8bfa
test_penalty_htlc_tx_timeout: debugging
rustyrussell Jul 20, 2020
243b5db
tests/test_pay.py: Replicate #3855.
ZmnSCPxj Jul 19, 2020
60c61c6
Fixed assertion in pay plugin
vincenzopalazzo Jul 19, 2020
25aff81
plugin: Do not automatically initialize the RPC connection in bcli
cdecker Jul 20, 2020
a6db3a1
pytest: We now have multiple attempts in test_htlc_send_timeout
cdecker Jul 20, 2020
fa4c2ff
paymod: Track how many HTLCs each channel can still add
cdecker Jul 20, 2020
4102815
paymod: Teach the presplit modifier to respect the chan HTLC limit
cdecker Jul 20, 2020
c5f32e2
paymod: Teach the adaptive splitter to respect the HTLC limit
cdecker Jul 20, 2020
2b4ad9b
paymod: Add the courtesy +1 to the CLTVs to allow for a new block
cdecker Jul 21, 2020
2e80e1c
paymod: Fix the routehints being lost when retrying
cdecker Jul 21, 2020
89cb5a6
paymod: Consolidate channel_hint creation in channel_hints_update
cdecker Jul 22, 2020
648af02
paymod: Randomly select a routehint, or none at random
cdecker Jul 22, 2020
aad62fc
paymod: Always initialize p->route
cdecker Jul 22, 2020
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
22 changes: 20 additions & 2 deletions lightningd/invoice.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,15 @@ invoice_check_payment(const tal_t *ctx,
* - MUST fail the HTLC.
* - MUST return an `incorrect_or_unknown_payment_details` error.
*/
if (!wallet_invoice_find_unpaid(ld->wallet, &invoice, payment_hash))
if (!wallet_invoice_find_unpaid(ld->wallet, &invoice, payment_hash)) {
log_debug(ld->log, "Unknown paid invoice %s",
type_to_string(tmpctx, struct sha256, payment_hash));
if (wallet_invoice_find_by_rhash(ld->wallet, &invoice, payment_hash)) {
log_debug(ld->log, "ALREADY paid invoice %s",
type_to_string(tmpctx, struct sha256, payment_hash));
}
return NULL;
}

details = wallet_invoice_details(ctx, ld->wallet, invoice);

Expand Down Expand Up @@ -342,11 +349,22 @@ invoice_check_payment(const tal_t *ctx,
if (details->msat != NULL) {
struct amount_msat twice;

if (amount_msat_less(msat, *details->msat))
if (amount_msat_less(msat, *details->msat)) {
log_debug(ld->log, "Attept to pay %s with amount %s < %s",
type_to_string(tmpctx, struct sha256,
&details->rhash),
type_to_string(tmpctx, struct amount_msat, &msat),
type_to_string(tmpctx, struct amount_msat, details->msat));
return tal_free(details);
}

if (amount_msat_add(&twice, *details->msat, *details->msat)
&& amount_msat_greater(msat, twice)) {
log_debug(ld->log, "Attept to pay %s with amount %s > %s",
type_to_string(tmpctx, struct sha256,
&details->rhash),
type_to_string(tmpctx, struct amount_msat, details->msat),
type_to_string(tmpctx, struct amount_msat, &twice));
/* BOLT #4:
*
* - if the amount paid is more than twice the amount
Expand Down
9 changes: 6 additions & 3 deletions lightningd/peer_htlcs.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,13 @@ void local_fail_in_htlc_needs_update(struct htlc_in *hin,
}

/* Helper to create (common) WIRE_INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS */
const u8 *failmsg_incorrect_or_unknown(const tal_t *ctx,
struct lightningd *ld,
const struct htlc_in *hin)
const u8 *failmsg_incorrect_or_unknown_(const tal_t *ctx,
struct lightningd *ld,
const struct htlc_in *hin,
const char *file, int line)
{
log_debug(ld->log, "WIRE_INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS: %s:%u",
file, line);
return towire_incorrect_or_unknown_payment_details(
ctx, hin->msat,
get_block_height(ld->topology));
Expand Down
10 changes: 7 additions & 3 deletions lightningd/peer_htlcs.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ void json_format_forwarding_object(struct json_stream *response, const char *fie
const struct forwarding *cur);

/* Helper to create (common) WIRE_INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS */
const u8 *failmsg_incorrect_or_unknown(const tal_t *ctx,
struct lightningd *ld,
const struct htlc_in *hin);
#define failmsg_incorrect_or_unknown(ctx, ld, hin) \
failmsg_incorrect_or_unknown_((ctx), (ld), (hin), __FILE__, __LINE__)

const u8 *failmsg_incorrect_or_unknown_(const tal_t *ctx,
struct lightningd *ld,
const struct htlc_in *hin,
const char *file, int line);
#endif /* LIGHTNING_LIGHTNINGD_PEER_HTLCS_H */
11 changes: 6 additions & 5 deletions lightningd/test/run-invoice-select-inchan.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,12 @@ char *encode_scriptpubkey_to_addr(const tal_t *ctx UNNEEDED,
const struct chainparams *chainparams UNNEEDED,
const u8 *scriptPubkey UNNEEDED)
{ fprintf(stderr, "encode_scriptpubkey_to_addr called!\n"); abort(); }
/* Generated stub for failmsg_incorrect_or_unknown */
const u8 *failmsg_incorrect_or_unknown(const tal_t *ctx UNNEEDED,
struct lightningd *ld UNNEEDED,
const struct htlc_in *hin UNNEEDED)
{ fprintf(stderr, "failmsg_incorrect_or_unknown called!\n"); abort(); }
/* Generated stub for failmsg_incorrect_or_unknown_ */
const u8 *failmsg_incorrect_or_unknown_(const tal_t *ctx UNNEEDED,
struct lightningd *ld UNNEEDED,
const struct htlc_in *hin UNNEEDED,
const char *file UNNEEDED, int line UNNEEDED)
{ fprintf(stderr, "failmsg_incorrect_or_unknown_ called!\n"); abort(); }
/* Generated stub for fatal */
void fatal(const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "fatal called!\n"); abort(); }
Expand Down
2 changes: 1 addition & 1 deletion plugins/autoclean.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ static const struct plugin_command commands[] = { {
int main(int argc, char *argv[])
{
setup_locale();
plugin_main(argv, init, PLUGIN_STATIC, NULL, commands, ARRAY_SIZE(commands),
plugin_main(argv, init, PLUGIN_STATIC, true, NULL, commands, ARRAY_SIZE(commands),
NULL, 0, NULL, 0,
plugin_option("autocleaninvoice-cycle",
"string",
Expand Down
3 changes: 2 additions & 1 deletion plugins/bcli.c
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,8 @@ int main(int argc, char *argv[])
/* Initialize our global context object here to handle startup options. */
bitcoind = new_bitcoind(NULL);

plugin_main(argv, init, PLUGIN_STATIC, NULL, commands, ARRAY_SIZE(commands),
plugin_main(argv, init, PLUGIN_STATIC, false /* Do not init RPC on startup*/,
NULL, commands, ARRAY_SIZE(commands),
NULL, 0, NULL, 0,
plugin_option("bitcoin-datadir",
"string",
Expand Down
2 changes: 1 addition & 1 deletion plugins/fundchannel.c
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,6 @@ static const struct plugin_command commands[] = { {
int main(int argc, char *argv[])
{
setup_locale();
plugin_main(argv, init, PLUGIN_RESTARTABLE, NULL, commands,
plugin_main(argv, init, PLUGIN_RESTARTABLE, true, NULL, commands,
ARRAY_SIZE(commands), NULL, 0, NULL, 0, NULL);
}
2 changes: 1 addition & 1 deletion plugins/keysend.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ int main(int argc, char *argv[])
features.bits[i] = tal_arr(NULL, u8, 0);
set_feature_bit(&features.bits[NODE_ANNOUNCE_FEATURE], KEYSEND_FEATUREBIT);

plugin_main(argv, init, PLUGIN_STATIC, &features, commands,
plugin_main(argv, init, PLUGIN_STATIC, true, &features, commands,
ARRAY_SIZE(commands), NULL, 0, hooks, ARRAY_SIZE(hooks),
NULL);
}
Loading