mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 09:54:16 +01:00
openingd: remember if we negotiated option_anchor_outputs, to put in the db.
And hand it through to channeld just like option_static_remotekey. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
b093856d0c
commit
edf60b4f9e
@ -64,6 +64,7 @@ msgdata,channel_init,upfront_shutdown_script,u8,upfront_shutdown_script_len
|
||||
msgdata,channel_init,remote_ann_node_sig,?secp256k1_ecdsa_signature,
|
||||
msgdata,channel_init,remote_ann_bitcoin_sig,?secp256k1_ecdsa_signature,
|
||||
msgdata,channel_init,option_static_remotekey,bool,
|
||||
msgdata,channel_init,option_anchor_outputs,bool,
|
||||
msgdata,channel_init,dev_fast_gossip,bool,
|
||||
msgdata,channel_init,dev_fail_process_onionpacket,bool,
|
||||
msgdata,channel_init,num_penalty_bases,u32,
|
||||
|
|
@ -3108,7 +3108,7 @@ static void init_channel(struct peer *peer)
|
||||
struct secret last_remote_per_commit_secret;
|
||||
secp256k1_ecdsa_signature *remote_ann_node_sig;
|
||||
secp256k1_ecdsa_signature *remote_ann_bitcoin_sig;
|
||||
bool option_static_remotekey;
|
||||
bool option_static_remotekey, option_anchor_outputs;
|
||||
struct penalty_base *pbases;
|
||||
#if !DEVELOPER
|
||||
bool dev_fail_process_onionpacket; /* Ignored */
|
||||
@ -3169,6 +3169,7 @@ static void init_channel(struct peer *peer)
|
||||
&remote_ann_node_sig,
|
||||
&remote_ann_bitcoin_sig,
|
||||
&option_static_remotekey,
|
||||
&option_anchor_outputs,
|
||||
&dev_fast_gossip,
|
||||
&dev_fail_process_onionpacket,
|
||||
&pbases)) {
|
||||
|
@ -189,7 +189,8 @@ struct channel *new_channel(struct peer *peer, u64 dbid,
|
||||
u32 feerate_base,
|
||||
u32 feerate_ppm,
|
||||
const u8 *remote_upfront_shutdown_script,
|
||||
bool option_static_remotekey)
|
||||
bool option_static_remotekey,
|
||||
bool option_anchor_outputs)
|
||||
{
|
||||
struct channel *channel = tal(peer->ld, struct channel);
|
||||
|
||||
@ -270,6 +271,7 @@ struct channel *new_channel(struct peer *peer, u64 dbid,
|
||||
channel->remote_upfront_shutdown_script
|
||||
= tal_steal(channel, remote_upfront_shutdown_script);
|
||||
channel->option_static_remotekey = option_static_remotekey;
|
||||
channel->option_anchor_outputs = option_anchor_outputs;
|
||||
channel->forgets = tal_arr(channel, struct command *, 0);
|
||||
|
||||
list_add_tail(&peer->channels, &channel->list);
|
||||
|
@ -131,6 +131,9 @@ struct channel {
|
||||
/* Was this negotiated with `option_static_remotekey? */
|
||||
bool option_static_remotekey;
|
||||
|
||||
/* Was this negotiated with `option_anchor_outputs? */
|
||||
bool option_anchor_outputs;
|
||||
|
||||
/* Any commands trying to forget us. */
|
||||
struct command **forgets;
|
||||
};
|
||||
@ -183,7 +186,8 @@ struct channel *new_channel(struct peer *peer, u64 dbid,
|
||||
u32 feerate_ppm,
|
||||
/* NULL or stolen */
|
||||
const u8 *remote_upfront_shutdown_script STEALS,
|
||||
bool option_static_remotekey);
|
||||
bool option_static_remotekey,
|
||||
bool option_anchor_outputs);
|
||||
|
||||
void delete_channel(struct channel *channel STEALS);
|
||||
|
||||
|
@ -575,6 +575,7 @@ void peer_start_channeld(struct channel *channel,
|
||||
/* Set at channel open, even if not
|
||||
* negotiated now! */
|
||||
channel->option_static_remotekey,
|
||||
channel->option_anchor_outputs,
|
||||
IFDEV(ld->dev_fast_gossip, false),
|
||||
IFDEV(dev_fail_process_onionpacket, false),
|
||||
pbases);
|
||||
|
@ -625,6 +625,7 @@ enum watch_result onchaind_funding_spent(struct channel *channel,
|
||||
channel->max_possible_feerate,
|
||||
channel->future_per_commitment_point,
|
||||
channel->option_static_remotekey,
|
||||
channel->option_anchor_outputs,
|
||||
is_replay);
|
||||
subd_send_msg(channel->owner, take(msg));
|
||||
|
||||
|
@ -180,6 +180,7 @@ wallet_commit_channel(struct lightningd *ld,
|
||||
struct amount_sat local_funding;
|
||||
s64 final_key_idx;
|
||||
bool option_static_remotekey;
|
||||
bool option_anchor_outputs;
|
||||
|
||||
/* Get a key to use for closing outputs from this tx */
|
||||
final_key_idx = wallet_get_newindex(ld);
|
||||
@ -209,7 +210,7 @@ wallet_commit_channel(struct lightningd *ld,
|
||||
/* old_remote_per_commit not valid yet, copy valid one. */
|
||||
channel_info->old_remote_per_commit = channel_info->remote_per_commit;
|
||||
|
||||
/* BOLT #2:
|
||||
/* BOLT-a12da24dd0102c170365124782b46d9710950ac1 #2:
|
||||
* 1. type: 35 (`funding_signed`)
|
||||
* 2. data:
|
||||
* * [`channel_id`:`channel_id`]
|
||||
@ -218,11 +219,11 @@ wallet_commit_channel(struct lightningd *ld,
|
||||
* #### Requirements
|
||||
*
|
||||
* Both peers:
|
||||
* - if `option_static_remotekey` was negotiated:
|
||||
* - `option_static_remotekey` applies to all commitment
|
||||
* - if `option_static_remotekey` or `option_anchor_outputs` was negotiated:
|
||||
* - `option_static_remotekey` or `option_anchor_outputs` applies to all commitment
|
||||
* transactions
|
||||
* - otherwise:
|
||||
* - `option_static_remotekey` does not apply to any commitment
|
||||
* - `option_static_remotekey` or `option_anchor_outputs` does not apply to any commitment
|
||||
* transactions
|
||||
*/
|
||||
/* i.e. We set it now for the channel permanently. */
|
||||
@ -230,6 +231,10 @@ wallet_commit_channel(struct lightningd *ld,
|
||||
= feature_negotiated(ld->our_features,
|
||||
uc->peer->their_features,
|
||||
OPT_STATIC_REMOTEKEY);
|
||||
option_anchor_outputs
|
||||
= feature_negotiated(ld->our_features,
|
||||
uc->peer->their_features,
|
||||
OPT_ANCHOR_OUTPUTS);
|
||||
|
||||
channel = new_channel(uc->peer, uc->dbid,
|
||||
NULL, /* No shachain yet */
|
||||
@ -275,7 +280,8 @@ wallet_commit_channel(struct lightningd *ld,
|
||||
ld->config.fee_base,
|
||||
ld->config.fee_per_satoshi,
|
||||
remote_upfront_shutdown_script,
|
||||
option_static_remotekey);
|
||||
option_static_remotekey,
|
||||
option_anchor_outputs);
|
||||
|
||||
/* Now we finally put it in the database. */
|
||||
wallet_channel_insert(ld->wallet, channel);
|
||||
|
@ -45,6 +45,7 @@ msgdata,onchain_init,min_possible_feerate,u32,
|
||||
msgdata,onchain_init,max_possible_feerate,u32,
|
||||
msgdata,onchain_init,possible_remote_per_commit_point,?pubkey,
|
||||
msgdata,onchain_init,option_static_remotekey,bool,
|
||||
msgdata,onchain_init,option_anchor_outputs,bool,
|
||||
msgdata,onchain_init,is_replay,bool,
|
||||
|
||||
#include <onchaind/onchain_wire.h>
|
||||
|
|
@ -80,7 +80,10 @@ static u8 **missing_htlc_msgs;
|
||||
static struct amount_msat our_msat;
|
||||
|
||||
/* Does option_static_remotekey apply to this commitment tx? */
|
||||
bool option_static_remotekey;
|
||||
static bool option_static_remotekey;
|
||||
|
||||
/* Does option_anchor_outputs apply to this commitment tx? */
|
||||
static bool option_anchor_outputs;
|
||||
|
||||
/* If we broadcast a tx, or need a delay to resolve the output. */
|
||||
struct proposed_resolution {
|
||||
@ -3225,6 +3228,7 @@ int main(int argc, char *argv[])
|
||||
&max_possible_feerate,
|
||||
&possible_remote_per_commitment_point,
|
||||
&option_static_remotekey,
|
||||
&option_anchor_outputs,
|
||||
&open_is_replay)) {
|
||||
master_badmsg(WIRE_ONCHAIN_INIT, msg);
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ bool fromwire_onchain_dev_memleak(const void *p UNNEEDED)
|
||||
bool fromwire_onchain_htlc(const void *p UNNEEDED, struct htlc_stub *htlc UNNEEDED, bool *tell_if_missing UNNEEDED, bool *tell_immediately UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_onchain_htlc called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_onchain_init */
|
||||
bool fromwire_onchain_init(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct shachain *shachain UNNEEDED, const struct chainparams **chainparams UNNEEDED, struct amount_sat *funding_amount_satoshi UNNEEDED, struct amount_msat *our_msat UNNEEDED, struct pubkey *old_remote_per_commitment_point UNNEEDED, struct pubkey *remote_per_commitment_point UNNEEDED, u32 *local_to_self_delay UNNEEDED, u32 *remote_to_self_delay UNNEEDED, u32 *delayed_to_us_feerate UNNEEDED, u32 *htlc_feerate UNNEEDED, u32 *penalty_feerate UNNEEDED, struct amount_sat *local_dust_limit_satoshi UNNEEDED, struct bitcoin_txid *our_broadcast_txid UNNEEDED, u8 **local_scriptpubkey UNNEEDED, u8 **remote_scriptpubkey UNNEEDED, struct pubkey *ourwallet_pubkey UNNEEDED, enum side *opener UNNEEDED, struct basepoints *local_basepoints UNNEEDED, struct basepoints *remote_basepoints UNNEEDED, struct tx_parts **tx_parts UNNEEDED, u32 *locktime UNNEEDED, u32 *tx_blockheight UNNEEDED, u32 *reasonable_depth UNNEEDED, secp256k1_ecdsa_signature **htlc_signature UNNEEDED, u64 *num_htlcs UNNEEDED, u32 *min_possible_feerate UNNEEDED, u32 *max_possible_feerate UNNEEDED, struct pubkey **possible_remote_per_commit_point UNNEEDED, bool *option_static_remotekey UNNEEDED, bool *is_replay UNNEEDED)
|
||||
bool fromwire_onchain_init(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct shachain *shachain UNNEEDED, const struct chainparams **chainparams UNNEEDED, struct amount_sat *funding_amount_satoshi UNNEEDED, struct amount_msat *our_msat UNNEEDED, struct pubkey *old_remote_per_commitment_point UNNEEDED, struct pubkey *remote_per_commitment_point UNNEEDED, u32 *local_to_self_delay UNNEEDED, u32 *remote_to_self_delay UNNEEDED, u32 *delayed_to_us_feerate UNNEEDED, u32 *htlc_feerate UNNEEDED, u32 *penalty_feerate UNNEEDED, struct amount_sat *local_dust_limit_satoshi UNNEEDED, struct bitcoin_txid *our_broadcast_txid UNNEEDED, u8 **local_scriptpubkey UNNEEDED, u8 **remote_scriptpubkey UNNEEDED, struct pubkey *ourwallet_pubkey UNNEEDED, enum side *opener UNNEEDED, struct basepoints *local_basepoints UNNEEDED, struct basepoints *remote_basepoints UNNEEDED, struct tx_parts **tx_parts UNNEEDED, u32 *locktime UNNEEDED, u32 *tx_blockheight UNNEEDED, u32 *reasonable_depth UNNEEDED, secp256k1_ecdsa_signature **htlc_signature UNNEEDED, u64 *num_htlcs UNNEEDED, u32 *min_possible_feerate UNNEEDED, u32 *max_possible_feerate UNNEEDED, struct pubkey **possible_remote_per_commit_point UNNEEDED, bool *option_static_remotekey UNNEEDED, bool *option_anchor_outputs UNNEEDED, bool *is_replay UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_onchain_init called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_onchain_known_preimage */
|
||||
bool fromwire_onchain_known_preimage(const void *p UNNEEDED, struct preimage *preimage UNNEEDED, bool *is_replay UNNEEDED)
|
||||
|
@ -54,7 +54,7 @@ bool fromwire_onchain_dev_memleak(const void *p UNNEEDED)
|
||||
bool fromwire_onchain_htlc(const void *p UNNEEDED, struct htlc_stub *htlc UNNEEDED, bool *tell_if_missing UNNEEDED, bool *tell_immediately UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_onchain_htlc called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_onchain_init */
|
||||
bool fromwire_onchain_init(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct shachain *shachain UNNEEDED, const struct chainparams **chainparams UNNEEDED, struct amount_sat *funding_amount_satoshi UNNEEDED, struct amount_msat *our_msat UNNEEDED, struct pubkey *old_remote_per_commitment_point UNNEEDED, struct pubkey *remote_per_commitment_point UNNEEDED, u32 *local_to_self_delay UNNEEDED, u32 *remote_to_self_delay UNNEEDED, u32 *delayed_to_us_feerate UNNEEDED, u32 *htlc_feerate UNNEEDED, u32 *penalty_feerate UNNEEDED, struct amount_sat *local_dust_limit_satoshi UNNEEDED, struct bitcoin_txid *our_broadcast_txid UNNEEDED, u8 **local_scriptpubkey UNNEEDED, u8 **remote_scriptpubkey UNNEEDED, struct pubkey *ourwallet_pubkey UNNEEDED, enum side *opener UNNEEDED, struct basepoints *local_basepoints UNNEEDED, struct basepoints *remote_basepoints UNNEEDED, struct tx_parts **tx_parts UNNEEDED, u32 *locktime UNNEEDED, u32 *tx_blockheight UNNEEDED, u32 *reasonable_depth UNNEEDED, secp256k1_ecdsa_signature **htlc_signature UNNEEDED, u64 *num_htlcs UNNEEDED, u32 *min_possible_feerate UNNEEDED, u32 *max_possible_feerate UNNEEDED, struct pubkey **possible_remote_per_commit_point UNNEEDED, bool *option_static_remotekey UNNEEDED, bool *is_replay UNNEEDED)
|
||||
bool fromwire_onchain_init(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct shachain *shachain UNNEEDED, const struct chainparams **chainparams UNNEEDED, struct amount_sat *funding_amount_satoshi UNNEEDED, struct amount_msat *our_msat UNNEEDED, struct pubkey *old_remote_per_commitment_point UNNEEDED, struct pubkey *remote_per_commitment_point UNNEEDED, u32 *local_to_self_delay UNNEEDED, u32 *remote_to_self_delay UNNEEDED, u32 *delayed_to_us_feerate UNNEEDED, u32 *htlc_feerate UNNEEDED, u32 *penalty_feerate UNNEEDED, struct amount_sat *local_dust_limit_satoshi UNNEEDED, struct bitcoin_txid *our_broadcast_txid UNNEEDED, u8 **local_scriptpubkey UNNEEDED, u8 **remote_scriptpubkey UNNEEDED, struct pubkey *ourwallet_pubkey UNNEEDED, enum side *opener UNNEEDED, struct basepoints *local_basepoints UNNEEDED, struct basepoints *remote_basepoints UNNEEDED, struct tx_parts **tx_parts UNNEEDED, u32 *locktime UNNEEDED, u32 *tx_blockheight UNNEEDED, u32 *reasonable_depth UNNEEDED, secp256k1_ecdsa_signature **htlc_signature UNNEEDED, u64 *num_htlcs UNNEEDED, u32 *min_possible_feerate UNNEEDED, u32 *max_possible_feerate UNNEEDED, struct pubkey **possible_remote_per_commit_point UNNEEDED, bool *option_static_remotekey UNNEEDED, bool *option_anchor_outputs UNNEEDED, bool *is_replay UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_onchain_init called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_onchain_known_preimage */
|
||||
bool fromwire_onchain_known_preimage(const void *p UNNEEDED, struct preimage *preimage UNNEEDED, bool *is_replay UNNEEDED)
|
||||
|
@ -1281,7 +1281,8 @@ static struct channel *wallet_stmt2channel(struct wallet *w, struct db_stmt *stm
|
||||
db_column_int(stmt, 43),
|
||||
db_column_int(stmt, 44),
|
||||
db_column_arr(tmpctx, stmt, 45, u8),
|
||||
db_column_int(stmt, 46));
|
||||
db_column_int(stmt, 46),
|
||||
db_column_int(stmt, 47));
|
||||
|
||||
return chan;
|
||||
}
|
||||
@ -1673,8 +1674,7 @@ void wallet_channel_save(struct wallet *w, struct channel *chan)
|
||||
db_bind_null(stmt, 28);
|
||||
|
||||
db_bind_int(stmt, 29, chan->option_static_remotekey);
|
||||
/* FIXME: option_anchor_outputs */
|
||||
db_bind_int(stmt, 30, false);
|
||||
db_bind_int(stmt, 30, chan->option_anchor_outputs);
|
||||
db_bind_blob(stmt, 31, chan->shutdown_scriptpubkey[LOCAL],
|
||||
tal_count(chan->shutdown_scriptpubkey[LOCAL]));
|
||||
db_bind_u64(stmt, 32, chan->dbid);
|
||||
|
Loading…
Reference in New Issue
Block a user