coins: have `we_fulfilled` be fully 'ternary'
note that 'null' 'we_fulfilled's are going to be legacy from this release forward.
This commit is contained in:
parent
8537e77ac7
commit
aab9893661
|
@ -158,7 +158,7 @@ struct htlc_in *new_htlc_in(const tal_t *ctx,
|
||||||
hin->badonion = 0;
|
hin->badonion = 0;
|
||||||
hin->failonion = NULL;
|
hin->failonion = NULL;
|
||||||
hin->preimage = NULL;
|
hin->preimage = NULL;
|
||||||
hin->we_filled = false;
|
hin->we_filled = NULL;
|
||||||
|
|
||||||
hin->received_time = time_now();
|
hin->received_time = time_now();
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ struct htlc_in {
|
||||||
/* Only set if blinding != NULL */
|
/* Only set if blinding != NULL */
|
||||||
struct secret blinding_ss;
|
struct secret blinding_ss;
|
||||||
/* true if we supplied the preimage */
|
/* true if we supplied the preimage */
|
||||||
bool we_filled;
|
bool *we_filled;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct htlc_out {
|
struct htlc_out {
|
||||||
|
|
|
@ -59,7 +59,8 @@ void htlc_set_fulfill(struct htlc_set *set, const struct preimage *preimage)
|
||||||
tal_del_destructor2(set->htlcs[i], htlc_set_hin_destroyed, set);
|
tal_del_destructor2(set->htlcs[i], htlc_set_hin_destroyed, set);
|
||||||
|
|
||||||
/* mark that we filled -- needed for tagging coin mvt */
|
/* mark that we filled -- needed for tagging coin mvt */
|
||||||
set->htlcs[i]->we_filled = true;
|
set->htlcs[i]->we_filled = tal(set->htlcs[i], bool);
|
||||||
|
*set->htlcs[i]->we_filled = true;
|
||||||
fulfill_htlc(set->htlcs[i], preimage);
|
fulfill_htlc(set->htlcs[i], preimage);
|
||||||
}
|
}
|
||||||
tal_free(set);
|
tal_free(set);
|
||||||
|
|
|
@ -95,9 +95,10 @@ static bool htlc_out_update_state(struct channel *channel,
|
||||||
"out"))
|
"out"))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
bool we_filled = false;
|
||||||
wallet_htlc_update(channel->peer->ld->wallet, hout->dbid, newstate,
|
wallet_htlc_update(channel->peer->ld->wallet, hout->dbid, newstate,
|
||||||
hout->preimage, 0, hout->failonion,
|
hout->preimage, 0, hout->failonion,
|
||||||
hout->failmsg, false);
|
hout->failmsg, &we_filled);
|
||||||
|
|
||||||
hout->hstate = newstate;
|
hout->hstate = newstate;
|
||||||
return true;
|
return true;
|
||||||
|
@ -186,11 +187,12 @@ static void failmsg_update_reply(struct subd *gossipd,
|
||||||
cbdata->hin->shared_secret,
|
cbdata->hin->shared_secret,
|
||||||
failmsg);
|
failmsg);
|
||||||
|
|
||||||
|
bool we_filled = false;
|
||||||
wallet_htlc_update(gossipd->ld->wallet,
|
wallet_htlc_update(gossipd->ld->wallet,
|
||||||
cbdata->hin->dbid, cbdata->hin->hstate,
|
cbdata->hin->dbid, cbdata->hin->hstate,
|
||||||
cbdata->hin->preimage,
|
cbdata->hin->preimage,
|
||||||
cbdata->hin->badonion,
|
cbdata->hin->badonion,
|
||||||
cbdata->hin->failonion, NULL, false);
|
cbdata->hin->failonion, NULL, &we_filled);
|
||||||
|
|
||||||
failed_htlc = mk_failed_htlc(tmpctx,
|
failed_htlc = mk_failed_htlc(tmpctx,
|
||||||
cbdata->hin, cbdata->hin->failonion);
|
cbdata->hin, cbdata->hin->failonion);
|
||||||
|
@ -853,7 +855,8 @@ htlc_accepted_hook_try_resolve(struct htlc_accepted_hook_payload *request,
|
||||||
towire_u16(&unknown_details, 0x400f);
|
towire_u16(&unknown_details, 0x400f);
|
||||||
local_fail_in_htlc(hin, take(unknown_details));
|
local_fail_in_htlc(hin, take(unknown_details));
|
||||||
} else {
|
} else {
|
||||||
hin->we_filled = true;
|
hin->we_filled = tal(hin, bool);
|
||||||
|
*hin->we_filled = true;
|
||||||
fulfill_htlc(hin, payment_preimage);
|
fulfill_htlc(hin, payment_preimage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1244,6 +1247,7 @@ static void fulfill_our_htlc_out(struct channel *channel, struct htlc_out *hout,
|
||||||
const struct preimage *preimage)
|
const struct preimage *preimage)
|
||||||
{
|
{
|
||||||
struct lightningd *ld = channel->peer->ld;
|
struct lightningd *ld = channel->peer->ld;
|
||||||
|
bool we_filled = false;
|
||||||
|
|
||||||
assert(!hout->preimage);
|
assert(!hout->preimage);
|
||||||
hout->preimage = tal_dup(hout, struct preimage, preimage);
|
hout->preimage = tal_dup(hout, struct preimage, preimage);
|
||||||
|
@ -1251,7 +1255,7 @@ static void fulfill_our_htlc_out(struct channel *channel, struct htlc_out *hout,
|
||||||
|
|
||||||
wallet_htlc_update(ld->wallet, hout->dbid, hout->hstate,
|
wallet_htlc_update(ld->wallet, hout->dbid, hout->hstate,
|
||||||
hout->preimage, 0, hout->failonion,
|
hout->preimage, 0, hout->failonion,
|
||||||
hout->failmsg, false);
|
hout->failmsg, &we_filled);
|
||||||
/* Update channel stats */
|
/* Update channel stats */
|
||||||
wallet_channel_stats_incr_out_fulfilled(ld->wallet,
|
wallet_channel_stats_incr_out_fulfilled(ld->wallet,
|
||||||
channel->dbid,
|
channel->dbid,
|
||||||
|
@ -1418,9 +1422,11 @@ void onchain_failed_our_htlc(const struct channel *channel,
|
||||||
/* Force state to something which expects a failure, and save to db */
|
/* Force state to something which expects a failure, and save to db */
|
||||||
hout->hstate = RCVD_REMOVE_HTLC;
|
hout->hstate = RCVD_REMOVE_HTLC;
|
||||||
htlc_out_check(hout, __func__);
|
htlc_out_check(hout, __func__);
|
||||||
|
|
||||||
|
bool we_filled = false;
|
||||||
wallet_htlc_update(ld->wallet, hout->dbid, hout->hstate,
|
wallet_htlc_update(ld->wallet, hout->dbid, hout->hstate,
|
||||||
hout->preimage, 0, hout->failonion,
|
hout->preimage, 0, hout->failonion,
|
||||||
hout->failmsg, false);
|
hout->failmsg, &we_filled);
|
||||||
|
|
||||||
if (hout->am_origin) {
|
if (hout->am_origin) {
|
||||||
assert(why != NULL);
|
assert(why != NULL);
|
||||||
|
|
|
@ -1844,7 +1844,7 @@ void wallet_htlc_update(struct wallet *wallet, const u64 htlc_dbid,
|
||||||
enum onion_type badonion,
|
enum onion_type badonion,
|
||||||
const struct onionreply *failonion,
|
const struct onionreply *failonion,
|
||||||
const u8 *failmsg,
|
const u8 *failmsg,
|
||||||
bool we_filled)
|
bool *we_filled)
|
||||||
{
|
{
|
||||||
struct db_stmt *stmt;
|
struct db_stmt *stmt;
|
||||||
|
|
||||||
|
@ -1882,7 +1882,7 @@ void wallet_htlc_update(struct wallet *wallet, const u64 htlc_dbid,
|
||||||
db_bind_null(stmt, 4);
|
db_bind_null(stmt, 4);
|
||||||
|
|
||||||
if (we_filled)
|
if (we_filled)
|
||||||
db_bind_int(stmt, 5, 1);
|
db_bind_int(stmt, 5, *we_filled);
|
||||||
else
|
else
|
||||||
db_bind_null(stmt, 5);
|
db_bind_null(stmt, 5);
|
||||||
|
|
||||||
|
@ -1956,7 +1956,11 @@ static bool wallet_stmt2htlc_in(struct channel *channel,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
in->we_filled = !db_column_is_null(stmt, 13);
|
if (!db_column_is_null(stmt, 13)) {
|
||||||
|
in->we_filled = tal(in, bool);
|
||||||
|
*in->we_filled = db_column_int(stmt, 13);
|
||||||
|
} else
|
||||||
|
in->we_filled = NULL;
|
||||||
|
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
|
@ -616,7 +616,7 @@ void wallet_htlc_update(struct wallet *wallet, const u64 htlc_dbid,
|
||||||
enum onion_type badonion,
|
enum onion_type badonion,
|
||||||
const struct onionreply *failonion,
|
const struct onionreply *failonion,
|
||||||
const u8 *failmsg,
|
const u8 *failmsg,
|
||||||
bool we_filled);
|
bool *we_filled);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* wallet_htlcs_load_in_for_channel - Load incoming HTLCs associated with chan from DB.
|
* wallet_htlcs_load_in_for_channel - Load incoming HTLCs associated with chan from DB.
|
||||||
|
|
Loading…
Reference in New Issue