mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-21 16:14:23 +01:00
daemon/wallet: supply a p2wpkh address (as P2SH address).
This is an address that bitcoind will happily pay to, but we know it's a witness output so our inputs to the anchor are immalleable. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -40,23 +40,21 @@ void wallet_add_signed_input(struct lightningd_state *dstate,
|
||||
struct bitcoin_signature sig;
|
||||
assert(input_num < tx->input_count);
|
||||
|
||||
redeemscript = bitcoin_redeem_single(tx, &w->pubkey);
|
||||
redeemscript = bitcoin_redeem_p2wpkh(tx, &w->pubkey);
|
||||
|
||||
sig.stype = SIGHASH_ALL;
|
||||
sign_tx_input(dstate->secpctx, tx, input_num,
|
||||
redeemscript, tal_count(redeemscript),
|
||||
NULL,
|
||||
p2wpkh_scriptcode(redeemscript, &w->pubkey),
|
||||
&w->privkey,
|
||||
&w->pubkey,
|
||||
&sig.sig);
|
||||
|
||||
tx->input[input_num].script
|
||||
= scriptsig_p2sh_single_sig(tx->input,
|
||||
redeemscript,
|
||||
tal_count(redeemscript),
|
||||
&sig);
|
||||
tx->input[input_num].script_length
|
||||
= tal_count(tx->input[input_num].script);
|
||||
bitcoin_witness_p2sh_p2wpkh(tx->input,
|
||||
&tx->input[input_num],
|
||||
&sig,
|
||||
&w->pubkey);
|
||||
tal_free(redeemscript);
|
||||
}
|
||||
|
||||
struct wallet *wallet_can_spend(struct lightningd_state *dstate,
|
||||
@@ -85,7 +83,7 @@ static void json_newaddr(struct command *cmd,
|
||||
struct sha256 h;
|
||||
|
||||
new_keypair(cmd->dstate, &w->privkey, &w->pubkey);
|
||||
redeemscript = bitcoin_redeem_single(cmd, &w->pubkey);
|
||||
redeemscript = bitcoin_redeem_p2wpkh(cmd, &w->pubkey);
|
||||
sha256(&h, redeemscript, tal_count(redeemscript));
|
||||
ripemd160(&w->p2sh, h.u.u8, sizeof(h));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user