Browse Source

onchaind: Pass genesis hash to onchaind so it knows the chainparams

It'll be creating quite a few transactions and we will have to know which
params to use.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
pull/2938/head
Christian Decker 6 years ago
committed by Rusty Russell
parent
commit
15e73e3dc3
  1. 4
      lightningd/onchain_control.c
  2. 1
      onchaind/onchain_wire.csv
  3. 2
      onchaind/onchaind.c
  4. 2
      onchaind/test/run-grind_feerate.c

4
lightningd/onchain_control.c

@ -438,6 +438,7 @@ enum watch_result onchaind_funding_spent(struct channel *channel,
struct pubkey final_key;
int hsmfd;
u32 feerate;
const struct chainparams *chainparams;
channel_fail_permanent(channel, "Funding transaction spent");
@ -507,8 +508,11 @@ enum watch_result onchaind_funding_spent(struct channel *channel,
feerate = feerate_floor();
}
chainparams = get_chainparams(channel->peer->ld);
msg = towire_onchain_init(channel,
&channel->their_shachain.chain,
&chainparams->genesis_blockhash,
channel->funding,
&channel->channel_info.old_remote_per_commit,
&channel->channel_info.remote_per_commit,

1
onchaind/onchain_wire.csv

@ -5,6 +5,7 @@
# Begin! Here's the onchain tx which spends funding tx, followed by all HTLCs.
msgtype,onchain_init,5001
msgdata,onchain_init,shachain,shachain,
msgdata,onchain_init,chain_hash,bitcoin_blkid,
msgdata,onchain_init,funding_amount_satoshi,amount_sat,
# Remote per commit point for committed tx.
msgdata,onchain_init,old_remote_per_commitment_point,pubkey,

Can't render this file because it has a wrong number of fields in line 5.

2
onchaind/onchaind.c

@ -2501,6 +2501,7 @@ int main(int argc, char *argv[])
bool *tell_if_missing, *tell_immediately;
u32 tx_blockheight;
struct pubkey *possible_remote_per_commitment_point;
struct bitcoin_blkid chain_hash;
subdaemon_setup(argc, argv);
@ -2511,6 +2512,7 @@ int main(int argc, char *argv[])
msg = wire_sync_read(tmpctx, REQ_FD);
if (!fromwire_onchain_init(tmpctx, msg,
&shachain,
&chain_hash,
&funding,
&old_remote_per_commit_point,
&remote_per_commit_point,

2
onchaind/test/run-grind_feerate.c

@ -43,7 +43,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, struct amount_sat *funding_amount_satoshi 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 *feerate_per_kw 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 *funder UNNEEDED, struct basepoints *local_basepoints UNNEEDED, struct basepoints *remote_basepoints UNNEEDED, struct bitcoin_tx **tx 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 fromwire_onchain_init(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct shachain *shachain UNNEEDED, struct bitcoin_blkid *chain_hash UNNEEDED, struct amount_sat *funding_amount_satoshi 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 *feerate_per_kw 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 *funder UNNEEDED, struct basepoints *local_basepoints UNNEEDED, struct basepoints *remote_basepoints UNNEEDED, struct bitcoin_tx **tx 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)
{ 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)

Loading…
Cancel
Save