Skip to content

Commit

Permalink
wallet: allow saving forwarding scid even if we don't have amount.
Browse files Browse the repository at this point in the history
They're not logically connected: we can know where they wanted to
go, but we didn't send it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
  • Loading branch information
rustyrussell committed Jun 21, 2022
1 parent 0dc874d commit 61b7b7f
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions wallet/wallet.c
Original file line number Diff line number Diff line change
Expand Up @@ -4325,22 +4325,26 @@ void wallet_forwarded_payment_add(struct wallet *w, const struct htlc_in *in,
") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);"));
db_bind_u64(stmt, 0, in->dbid);

if (out) {
db_bind_u64(stmt, 1, out->dbid);
db_bind_u64(stmt, 3, out->key.channel->scid->u64);
db_bind_amount_msat(stmt, 5, &out->msat);
} else {
/* FORWARD_LOCAL_FAILED may occur before we get htlc_out */
/* FORWARD_LOCAL_FAILED may occur before we get htlc_out */
if (!out || !scid_out) {
assert(failcode != 0);
assert(state == FORWARD_LOCAL_FAILED);
db_bind_null(stmt, 1);
db_bind_null(stmt, 3);
db_bind_null(stmt, 5);
}

if (out)
db_bind_u64(stmt, 1, out->dbid);
else
db_bind_null(stmt, 1);
db_bind_u64(stmt, 2, in->key.channel->scid->u64);

if (scid_out)
db_bind_u64(stmt, 3, scid_out->u64);
else
db_bind_null(stmt, 3);
db_bind_amount_msat(stmt, 4, &in->msat);
if (out)
db_bind_amount_msat(stmt, 5, &out->msat);
else
db_bind_null(stmt, 5);

db_bind_int(stmt, 6, wallet_forward_status_in_db(state));
db_bind_timeabs(stmt, 7, in->received_time);
Expand Down

0 comments on commit 61b7b7f

Please sign in to comment.