lightningd: keep local_basepoints and local_funding_pubkey.

For now we can always regenerate them, but eventually they'll be given
to us by the HSM.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2018-07-23 11:53:02 +09:30
committed by Christian Decker
parent 289e39a0a3
commit f456fdfab1
7 changed files with 49 additions and 24 deletions

View File

@@ -198,24 +198,22 @@ u32 feerate_max(struct lightningd *ld)
static void sign_last_tx(struct channel *channel)
{
u8 *funding_wscript;
struct pubkey local_funding_pubkey;
struct secrets secrets;
secp256k1_ecdsa_signature sig;
assert(!channel->last_tx->input[0].witness);
derive_basepoints(&channel->seed, &local_funding_pubkey, NULL, &secrets,
NULL);
derive_basepoints(&channel->seed, NULL, NULL, &secrets, NULL);
funding_wscript = bitcoin_redeem_2of2(tmpctx,
&local_funding_pubkey,
&channel->local_funding_pubkey,
&channel->channel_info.remote_fundingkey);
/* Need input amount for signing */
channel->last_tx->input[0].amount = tal_dup(channel->last_tx->input, u64,
&channel->funding_satoshi);
sign_tx_input(channel->last_tx, 0, NULL, funding_wscript,
&secrets.funding_privkey,
&local_funding_pubkey,
&channel->local_funding_pubkey,
&sig);
channel->last_tx->input[0].witness
@@ -223,7 +221,7 @@ static void sign_last_tx(struct channel *channel)
&channel->last_sig,
&sig,
&channel->channel_info.remote_fundingkey,
&local_funding_pubkey);
&channel->local_funding_pubkey);
}
static void remove_sig(struct bitcoin_tx *signed_tx)