mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 21:35:11 +01:00
db: add support for remote end specify option_upfront_shutdown_script.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
aa9284eaa3
commit
7ead29b695
@ -173,7 +173,8 @@ struct channel *new_channel(struct peer *peer, u64 dbid,
|
||||
const struct pubkey *local_funding_pubkey,
|
||||
const struct pubkey *future_per_commitment_point,
|
||||
u32 feerate_base,
|
||||
u32 feerate_ppm)
|
||||
u32 feerate_ppm,
|
||||
const u8 *remote_upfront_shutdown_script)
|
||||
{
|
||||
struct channel *channel = tal(peer->ld, struct channel);
|
||||
|
||||
@ -240,6 +241,8 @@ struct channel *new_channel(struct peer *peer, u64 dbid,
|
||||
= tal_steal(channel, future_per_commitment_point);
|
||||
channel->feerate_base = feerate_base;
|
||||
channel->feerate_ppm = feerate_ppm;
|
||||
channel->remote_upfront_shutdown_script
|
||||
= tal_steal(channel, remote_upfront_shutdown_script);
|
||||
|
||||
list_add_tail(&peer->channels, &channel->list);
|
||||
tal_add_destructor(channel, destroy_channel);
|
||||
|
@ -113,6 +113,9 @@ struct channel {
|
||||
|
||||
/* Feerate per channel */
|
||||
u32 feerate_base, feerate_ppm;
|
||||
|
||||
/* If they used option_upfront_shutdown_script. */
|
||||
const u8 *remote_upfront_shutdown_script;
|
||||
};
|
||||
|
||||
struct channel *new_channel(struct peer *peer, u64 dbid,
|
||||
@ -159,7 +162,9 @@ struct channel *new_channel(struct peer *peer, u64 dbid,
|
||||
const struct pubkey *local_funding_pubkey,
|
||||
const struct pubkey *future_per_commitment_point,
|
||||
u32 feerate_base,
|
||||
u32 feerate_ppm);
|
||||
u32 feerate_ppm,
|
||||
/* NULL or stolen */
|
||||
const u8 *remote_upfront_shutdown_script);
|
||||
|
||||
void delete_channel(struct channel *channel);
|
||||
|
||||
|
@ -225,7 +225,8 @@ wallet_commit_channel(struct lightningd *ld,
|
||||
&uc->local_funding_pubkey,
|
||||
NULL,
|
||||
ld->config.fee_base,
|
||||
ld->config.fee_per_satoshi);
|
||||
ld->config.fee_per_satoshi,
|
||||
NULL);
|
||||
|
||||
/* Now we finally put it in the database. */
|
||||
wallet_channel_insert(ld->wallet, channel);
|
||||
|
@ -379,6 +379,7 @@ static struct migration dbmigrations[] = {
|
||||
{ "ALTER TABLE channel_htlcs ADD received_time INTEGER", NULL },
|
||||
{ "ALTER TABLE forwarded_payments ADD received_time INTEGER", NULL },
|
||||
{ "ALTER TABLE forwarded_payments ADD resolved_time INTEGER", NULL },
|
||||
{ "ALTER TABLE channels ADD remote_upfront_shutdown_script BLOB;", NULL },
|
||||
};
|
||||
|
||||
/* Leak tracking. */
|
||||
|
@ -685,6 +685,7 @@ static struct channel *wallet_stmt2channel(const tal_t *ctx, struct wallet *w, s
|
||||
ok &= sqlite3_column_pubkey(stmt, 24, &channel_info.old_remote_per_commit);
|
||||
channel_info.feerate_per_kw[LOCAL] = sqlite3_column_int(stmt, 25);
|
||||
channel_info.feerate_per_kw[REMOTE] = sqlite3_column_int(stmt, 26);
|
||||
|
||||
wallet_channel_config_load(w, sqlite3_column_int64(stmt, 4),
|
||||
&channel_info.their_config);
|
||||
|
||||
@ -738,8 +739,8 @@ static struct channel *wallet_stmt2channel(const tal_t *ctx, struct wallet *w, s
|
||||
&local_basepoints, &local_funding_pubkey,
|
||||
future_per_commitment_point,
|
||||
sqlite3_column_int(stmt, 42),
|
||||
sqlite3_column_int(stmt, 43));
|
||||
|
||||
sqlite3_column_int(stmt, 43),
|
||||
sqlite3_column_arr(tmpctx, stmt, 44, u8));
|
||||
return chan;
|
||||
}
|
||||
|
||||
@ -764,7 +765,7 @@ static const char *channel_fields =
|
||||
/*36*/ "min_possible_feerate, max_possible_feerate, "
|
||||
/*38*/ "msatoshi_to_us_min, msatoshi_to_us_max, future_per_commitment_point, "
|
||||
/*41*/ "last_sent_commit, "
|
||||
/*42*/ "feerate_base, feerate_ppm";
|
||||
/*42*/ "feerate_base, feerate_ppm, remote_upfront_shutdown_script";
|
||||
|
||||
bool wallet_channels_load_active(const tal_t *ctx, struct wallet *w)
|
||||
{
|
||||
@ -984,7 +985,8 @@ void wallet_channel_save(struct wallet *w, struct channel *chan)
|
||||
" msatoshi_to_us_min=?,"
|
||||
" msatoshi_to_us_max=?,"
|
||||
" feerate_base=?,"
|
||||
" feerate_ppm=?"
|
||||
" feerate_ppm=?,"
|
||||
" remote_upfront_shutdown_script=?"
|
||||
" WHERE id=?");
|
||||
sqlite3_bind_int64(stmt, 1, chan->their_shachain.id);
|
||||
if (chan->scid)
|
||||
@ -1026,7 +1028,13 @@ void wallet_channel_save(struct wallet *w, struct channel *chan)
|
||||
sqlite3_bind_amount_msat(stmt, 25, chan->msat_to_us_max);
|
||||
sqlite3_bind_int(stmt, 26, chan->feerate_base);
|
||||
sqlite3_bind_int(stmt, 27, chan->feerate_ppm);
|
||||
sqlite3_bind_int64(stmt, 28, chan->dbid);
|
||||
if (chan->remote_upfront_shutdown_script)
|
||||
sqlite3_bind_blob(stmt, 28, chan->remote_upfront_shutdown_script,
|
||||
tal_count(chan->remote_upfront_shutdown_script),
|
||||
SQLITE_TRANSIENT);
|
||||
else
|
||||
sqlite3_bind_null(stmt, 28);
|
||||
sqlite3_bind_int64(stmt, 29, chan->dbid);
|
||||
db_exec_prepared(w->db, stmt);
|
||||
|
||||
wallet_channel_config_save(w, &chan->channel_info.their_config);
|
||||
|
Loading…
Reference in New Issue
Block a user