lease_rates: add csv lock to modify anchor scripts

This commit is contained in:
niftynei
2021-06-16 12:44:51 -05:00
committed by neil saitug
parent e992b54410
commit c9d2748081
11 changed files with 72 additions and 22 deletions

View File

@@ -51,9 +51,10 @@ bool try_subtract_fee(enum side opener, enum side side,
u8 *to_self_wscript(const tal_t *ctx,
u16 to_self_delay,
u32 csv,
const struct keyset *keyset)
{
return bitcoin_wscript_to_local(ctx, to_self_delay,
return bitcoin_wscript_to_local(ctx, to_self_delay, csv,
&keyset->self_revocation_key,
&keyset->self_delayed_payment_key);
}
@@ -87,6 +88,7 @@ struct bitcoin_tx *initial_commit_tx(const tal_t *ctx,
u64 obscured_commitment_number,
struct wally_tx_output *direct_outputs[NUM_SIDES],
enum side side,
u32 csv_lock,
bool option_anchor_outputs,
char** err_reason)
{
@@ -208,7 +210,9 @@ struct bitcoin_tx *initial_commit_tx(const tal_t *ctx,
* output](#to_local-output).
*/
if (amount_msat_greater_eq_sat(self_pay, dust_limit)) {
u8 *wscript = to_self_wscript(tmpctx, to_self_delay, keyset);
u8 *wscript = to_self_wscript(tmpctx,
to_self_delay, csv_lock,
keyset);
amount = amount_msat_to_sat_round_down(self_pay);
int pos = bitcoin_tx_add_output(
tx, scriptpubkey_p2wsh(tx, wscript), wscript, amount);
@@ -242,7 +246,7 @@ struct bitcoin_tx *initial_commit_tx(const tal_t *ctx,
amount = amount_msat_to_sat_round_down(other_pay);
if (option_anchor_outputs) {
scriptpubkey = scriptpubkey_p2wsh(tmpctx,
anchor_to_remote_redeem(tmpctx, &keyset->other_payment_key, 1));
anchor_to_remote_redeem(tmpctx, &keyset->other_payment_key, csv_lock));
} else {
scriptpubkey = scriptpubkey_p2wpkh(tmpctx,
&keyset->other_payment_key);