mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-15 11:59:16 +01:00
df: persist channel open preference to database
technically we don't need this info after the channel opens, but for any subsequent RBF (and maybe splice?) we need to remember what the open/accept peer signaled
This commit is contained in:
parent
3eecbaee4d
commit
f05d450098
7 changed files with 17 additions and 5 deletions
|
@ -336,6 +336,7 @@ struct channel *new_channel(struct peer *peer, u64 dbid,
|
|||
struct log *log,
|
||||
const char *transient_billboard TAKES,
|
||||
u8 channel_flags,
|
||||
bool req_confirmed_ins_remote,
|
||||
const struct channel_config *our_config,
|
||||
u32 minimum_depth,
|
||||
u64 next_index_local,
|
||||
|
@ -430,6 +431,7 @@ struct channel *new_channel(struct peer *peer, u64 dbid,
|
|||
dbid);
|
||||
} else
|
||||
channel->log = tal_steal(channel, log);
|
||||
channel->req_confirmed_ins = req_confirmed_ins_remote;
|
||||
channel->channel_flags = channel_flags;
|
||||
channel->our_config = *our_config;
|
||||
channel->minimum_depth = minimum_depth;
|
||||
|
|
|
@ -70,7 +70,6 @@ struct open_attempt {
|
|||
struct command *cmd;
|
||||
struct amount_sat funding;
|
||||
const u8 *our_upfront_shutdown_script;
|
||||
bool req_confirmed_ins;
|
||||
|
||||
/* First msg to send to dualopend (to make it create channel) */
|
||||
const u8 *open_msg;
|
||||
|
@ -120,6 +119,9 @@ struct channel {
|
|||
/* Our channel config. */
|
||||
struct channel_config our_config;
|
||||
|
||||
/* Require confirmed inputs for interactive tx */
|
||||
bool req_confirmed_ins;
|
||||
|
||||
/* Minimum funding depth (specified by us if they fund). */
|
||||
u32 minimum_depth;
|
||||
|
||||
|
@ -284,6 +286,7 @@ struct channel *new_channel(struct peer *peer, u64 dbid,
|
|||
struct log *log STEALS,
|
||||
const char *transient_billboard TAKES,
|
||||
u8 channel_flags,
|
||||
bool req_confirmed_ins_remote,
|
||||
const struct channel_config *our_config,
|
||||
u32 minimum_depth,
|
||||
u64 next_index_local,
|
||||
|
|
|
@ -2680,7 +2680,7 @@ static struct command_result *json_openchannel_update(struct command *cmd,
|
|||
type_to_string(tmpctx, struct wally_psbt,
|
||||
psbt));
|
||||
|
||||
if (channel->open_attempt->req_confirmed_ins) {
|
||||
if (channel->req_confirmed_ins) {
|
||||
struct psbt_validator *pv;
|
||||
struct command_result *ret;
|
||||
|
||||
|
|
|
@ -178,6 +178,7 @@ wallet_commit_channel(struct lightningd *ld,
|
|||
uc->log,
|
||||
take(uc->transient_billboard),
|
||||
channel_flags,
|
||||
false,
|
||||
&uc->our_config,
|
||||
uc->minimum_depth,
|
||||
1, 1, 0,
|
||||
|
@ -1397,7 +1398,8 @@ static struct channel *stub_chan(struct command *cmd,
|
|||
LOCAL,
|
||||
NULL,
|
||||
"restored from static channel backup",
|
||||
0, our_config,
|
||||
0, false,
|
||||
our_config,
|
||||
0,
|
||||
1, 1, 1,
|
||||
&funding,
|
||||
|
|
|
@ -946,6 +946,7 @@ static struct migration dbmigrations[] = {
|
|||
{SQL("ALTER TABLE payments ADD COLUMN local_invreq_id BLOB DEFAULT NULL REFERENCES invoicerequests(invreq_id);"), NULL},
|
||||
/* FIXME: Remove payments local_offer_id column! */
|
||||
{SQL("ALTER TABLE channel_funding_inflights ADD COLUMN lease_satoshi BIGINT;"), NULL},
|
||||
{SQL("ALTER TABLE channels ADD require_confirm_inputs_remote INTEGER DEFAULT 0;"), NULL},
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -1655,7 +1655,7 @@ static bool test_channel_inflight_crud(struct lightningd *ld, const tal_t *ctx)
|
|||
NULL,
|
||||
DUALOPEND_AWAITING_LOCKIN,
|
||||
LOCAL, NULL, "billboard",
|
||||
8, &our_config,
|
||||
8, false, &our_config,
|
||||
101, 1, 1, 1,
|
||||
&outpoint,
|
||||
funding_sats, AMOUNT_MSAT(0),
|
||||
|
|
|
@ -1492,6 +1492,7 @@ static struct channel *wallet_stmt2channel(struct wallet *w, struct db_stmt *stm
|
|||
NULL, /* Set up fresh log */
|
||||
"Loaded from database",
|
||||
db_col_int(stmt, "channel_flags"),
|
||||
db_col_int(stmt, "require_confirm_inputs_remote") != 0,
|
||||
&our_config,
|
||||
db_col_int(stmt, "minimum_depth"),
|
||||
db_col_u64(stmt, "next_index_local"),
|
||||
|
@ -1582,6 +1583,7 @@ static bool wallet_channels_load_active(struct wallet *w)
|
|||
", state"
|
||||
", funder"
|
||||
", channel_flags"
|
||||
", require_confirm_inputs"
|
||||
", minimum_depth"
|
||||
", next_index_local"
|
||||
", next_index_remote"
|
||||
|
@ -2210,7 +2212,8 @@ void wallet_channel_insert(struct wallet *w, struct channel *chan)
|
|||
", htlc_basepoint_local"
|
||||
", delayed_payment_basepoint_local"
|
||||
", funding_pubkey_local"
|
||||
") VALUES (?, ?, ?, ?, ?, ?, ?, ?);"));
|
||||
", require_confirm_inputs_remote"
|
||||
") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);"));
|
||||
db_bind_u64(stmt, 0, chan->peer->dbid);
|
||||
db_bind_int(stmt, 1, chan->first_blocknum);
|
||||
db_bind_int(stmt, 2, chan->dbid);
|
||||
|
@ -2220,6 +2223,7 @@ void wallet_channel_insert(struct wallet *w, struct channel *chan)
|
|||
db_bind_pubkey(stmt, 5, &chan->local_basepoints.htlc);
|
||||
db_bind_pubkey(stmt, 6, &chan->local_basepoints.delayed_payment);
|
||||
db_bind_pubkey(stmt, 7, &chan->local_funding_pubkey);
|
||||
db_bind_int(stmt, 8, chan->req_confirmed_ins);
|
||||
|
||||
db_exec_prepared_v2(take(stmt));
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue