mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
db: store option_static_remotekey for each channel.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
5203847025
commit
11ee089d4b
@ -177,7 +177,8 @@ struct channel *new_channel(struct peer *peer, u64 dbid,
|
||||
const struct pubkey *future_per_commitment_point,
|
||||
u32 feerate_base,
|
||||
u32 feerate_ppm,
|
||||
const u8 *remote_upfront_shutdown_script)
|
||||
const u8 *remote_upfront_shutdown_script,
|
||||
bool option_static_remotekey)
|
||||
{
|
||||
struct channel *channel = tal(peer->ld, struct channel);
|
||||
|
||||
@ -248,6 +249,7 @@ struct channel *new_channel(struct peer *peer, u64 dbid,
|
||||
channel->feerate_ppm = feerate_ppm;
|
||||
channel->remote_upfront_shutdown_script
|
||||
= tal_steal(channel, remote_upfront_shutdown_script);
|
||||
channel->option_static_remotekey = option_static_remotekey;
|
||||
|
||||
list_add_tail(&peer->channels, &channel->list);
|
||||
tal_add_destructor(channel, destroy_channel);
|
||||
|
@ -117,6 +117,9 @@ struct channel {
|
||||
|
||||
/* If they used option_upfront_shutdown_script. */
|
||||
const u8 *remote_upfront_shutdown_script;
|
||||
|
||||
/* Was this negotiated with `option_static_remotekey? */
|
||||
bool option_static_remotekey;
|
||||
};
|
||||
|
||||
struct channel *new_channel(struct peer *peer, u64 dbid,
|
||||
@ -165,7 +168,8 @@ struct channel *new_channel(struct peer *peer, u64 dbid,
|
||||
u32 feerate_base,
|
||||
u32 feerate_ppm,
|
||||
/* NULL or stolen */
|
||||
const u8 *remote_upfront_shutdown_script);
|
||||
const u8 *remote_upfront_shutdown_script,
|
||||
bool option_static_remotekey);
|
||||
|
||||
void delete_channel(struct channel *channel);
|
||||
|
||||
|
@ -237,7 +237,8 @@ wallet_commit_channel(struct lightningd *ld,
|
||||
NULL,
|
||||
ld->config.fee_base,
|
||||
ld->config.fee_per_satoshi,
|
||||
remote_upfront_shutdown_script);
|
||||
remote_upfront_shutdown_script,
|
||||
false);
|
||||
|
||||
/* Now we finally put it in the database. */
|
||||
wallet_channel_insert(ld->wallet, channel);
|
||||
|
@ -457,6 +457,9 @@ static struct migration dbmigrations[] = {
|
||||
" WHERE short_channel_id IS NOT NULL;"), NULL },
|
||||
{SQL("UPDATE payments SET failchannel = REPLACE(failchannel, ':', 'x')"
|
||||
" WHERE failchannel IS NOT NULL;"), NULL },
|
||||
/* option_static_remotekey is nailed at creation time. */
|
||||
{SQL("ALTER TABLE channels ADD COLUMN option_static_remotekey"
|
||||
" DEFAULT FALSE;"), NULL },
|
||||
};
|
||||
|
||||
/* Leak tracking. */
|
||||
|
@ -909,7 +909,8 @@ static struct channel *wallet_stmt2channel(struct wallet *w, struct db_stmt *stm
|
||||
future_per_commitment_point,
|
||||
db_column_int(stmt, 42),
|
||||
db_column_int(stmt, 43),
|
||||
db_column_arr(tmpctx, stmt, 44, u8));
|
||||
db_column_arr(tmpctx, stmt, 44, u8),
|
||||
db_column_int(stmt, 45));
|
||||
return chan;
|
||||
}
|
||||
|
||||
@ -980,6 +981,7 @@ static bool wallet_channels_load_active(struct wallet *w)
|
||||
", feerate_base"
|
||||
", feerate_ppm"
|
||||
", remote_upfront_shutdown_script"
|
||||
", option_static_remotekey"
|
||||
" FROM channels WHERE state < ?;"));
|
||||
db_bind_int(stmt, 0, CLOSED);
|
||||
db_query_prepared(stmt);
|
||||
@ -1241,7 +1243,8 @@ void wallet_channel_save(struct wallet *w, struct channel *chan)
|
||||
" msatoshi_to_us_max=?,"
|
||||
" feerate_base=?,"
|
||||
" feerate_ppm=?,"
|
||||
" remote_upfront_shutdown_script=?"
|
||||
" remote_upfront_shutdown_script=?,"
|
||||
" option_static_remotekey=?"
|
||||
" WHERE id=?"));
|
||||
db_bind_u64(stmt, 0, chan->their_shachain.id);
|
||||
if (chan->scid)
|
||||
@ -1288,7 +1291,8 @@ void wallet_channel_save(struct wallet *w, struct channel *chan)
|
||||
tal_count(chan->remote_upfront_shutdown_script));
|
||||
else
|
||||
db_bind_null(stmt, 27);
|
||||
db_bind_u64(stmt, 28, chan->dbid);
|
||||
db_bind_int(stmt, 28, chan->option_static_remotekey);
|
||||
db_bind_u64(stmt, 29, chan->dbid);
|
||||
db_exec_prepared_v2(take(stmt));
|
||||
|
||||
wallet_channel_config_save(w, &chan->channel_info.their_config);
|
||||
|
Loading…
Reference in New Issue
Block a user