mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-20 07:34:24 +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:
@@ -857,8 +857,10 @@ static void commit_tx_depth(struct peer *peer, int depth,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Don't yet know the median start time? */
|
/* Don't yet know the median start time? */
|
||||||
if (!peer->cur_commit.start_time)
|
if (!peer->cur_commit.start_time) {
|
||||||
|
log_debug(peer->log, "... but we don't know start_time");
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* FIXME: We should really use bitcoin time here. */
|
/* FIXME: We should really use bitcoin time here. */
|
||||||
if (controlled_time().ts.tv_sec > peer->cur_commit.start_time
|
if (controlled_time().ts.tv_sec > peer->cur_commit.start_time
|
||||||
@@ -866,7 +868,8 @@ static void commit_tx_depth(struct peer *peer, int depth,
|
|||||||
/* Free this watch; we're done */
|
/* Free this watch; we're done */
|
||||||
peer->cur_commit.watch = tal_free(peer->cur_commit.watch);
|
peer->cur_commit.watch = tal_free(peer->cur_commit.watch);
|
||||||
state_event(peer, ptr2int(canspend), NULL);
|
state_event(peer, ptr2int(canspend), NULL);
|
||||||
}
|
} else
|
||||||
|
log_debug(peer->log, "... still CSV locked");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: We tell bitcoind to watch all the outputs, which is overkill */
|
/* FIXME: We tell bitcoind to watch all the outputs, which is overkill */
|
||||||
|
|||||||
@@ -40,23 +40,21 @@ void wallet_add_signed_input(struct lightningd_state *dstate,
|
|||||||
struct bitcoin_signature sig;
|
struct bitcoin_signature sig;
|
||||||
assert(input_num < tx->input_count);
|
assert(input_num < tx->input_count);
|
||||||
|
|
||||||
redeemscript = bitcoin_redeem_single(tx, &w->pubkey);
|
redeemscript = bitcoin_redeem_p2wpkh(tx, &w->pubkey);
|
||||||
|
|
||||||
sig.stype = SIGHASH_ALL;
|
sig.stype = SIGHASH_ALL;
|
||||||
sign_tx_input(dstate->secpctx, tx, input_num,
|
sign_tx_input(dstate->secpctx, tx, input_num,
|
||||||
redeemscript, tal_count(redeemscript),
|
redeemscript, tal_count(redeemscript),
|
||||||
NULL,
|
p2wpkh_scriptcode(redeemscript, &w->pubkey),
|
||||||
&w->privkey,
|
&w->privkey,
|
||||||
&w->pubkey,
|
&w->pubkey,
|
||||||
&sig.sig);
|
&sig.sig);
|
||||||
|
|
||||||
tx->input[input_num].script
|
bitcoin_witness_p2sh_p2wpkh(tx->input,
|
||||||
= scriptsig_p2sh_single_sig(tx->input,
|
&tx->input[input_num],
|
||||||
redeemscript,
|
&sig,
|
||||||
tal_count(redeemscript),
|
&w->pubkey);
|
||||||
&sig);
|
tal_free(redeemscript);
|
||||||
tx->input[input_num].script_length
|
|
||||||
= tal_count(tx->input[input_num].script);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wallet *wallet_can_spend(struct lightningd_state *dstate,
|
struct wallet *wallet_can_spend(struct lightningd_state *dstate,
|
||||||
@@ -85,7 +83,7 @@ static void json_newaddr(struct command *cmd,
|
|||||||
struct sha256 h;
|
struct sha256 h;
|
||||||
|
|
||||||
new_keypair(cmd->dstate, &w->privkey, &w->pubkey);
|
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));
|
sha256(&h, redeemscript, tal_count(redeemscript));
|
||||||
ripemd160(&w->p2sh, h.u.u8, sizeof(h));
|
ripemd160(&w->p2sh, h.u.u8, sizeof(h));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user