diff --git a/lightningd/channel.c b/lightningd/channel.c index 63a9d71de..1939cf318 100644 --- a/lightningd/channel.c +++ b/lightningd/channel.c @@ -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; diff --git a/lightningd/channel.h b/lightningd/channel.h index 46118be8e..af592c83d 100644 --- a/lightningd/channel.h +++ b/lightningd/channel.h @@ -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, diff --git a/lightningd/dual_open_control.c b/lightningd/dual_open_control.c index 77324146c..09a3e35a7 100644 --- a/lightningd/dual_open_control.c +++ b/lightningd/dual_open_control.c @@ -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; diff --git a/lightningd/opening_control.c b/lightningd/opening_control.c index 2aebaec62..1cae8571b 100644 --- a/lightningd/opening_control.c +++ b/lightningd/opening_control.c @@ -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, diff --git a/wallet/db.c b/wallet/db.c index 83bdcb18a..d23c5c0c3 100644 --- a/wallet/db.c +++ b/wallet/db.c @@ -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}, }; /** diff --git a/wallet/test/run-wallet.c b/wallet/test/run-wallet.c index 0652982a6..ddbdf8d57 100644 --- a/wallet/test/run-wallet.c +++ b/wallet/test/run-wallet.c @@ -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), diff --git a/wallet/wallet.c b/wallet/wallet.c index 73e52400d..2f4c17447 100644 --- a/wallet/wallet.c +++ b/wallet/wallet.c @@ -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));