|
@ -260,21 +260,34 @@ struct bitcoin_tx *commit_tx(const tal_t *ctx, |
|
|
*/ |
|
|
*/ |
|
|
if (amount_msat_greater_eq_sat(other_pay, dust_limit)) { |
|
|
if (amount_msat_greater_eq_sat(other_pay, dust_limit)) { |
|
|
struct amount_sat amount = amount_msat_to_sat_round_down(other_pay); |
|
|
struct amount_sat amount = amount_msat_to_sat_round_down(other_pay); |
|
|
u8 *p2wpkh = |
|
|
u8 *scriptpubkey; |
|
|
scriptpubkey_p2wpkh(tx, &keyset->other_payment_key); |
|
|
int pos; |
|
|
/* BOLT #3:
|
|
|
|
|
|
|
|
|
/* BOLT-a12da24dd0102c170365124782b46d9710950ac1 #3:
|
|
|
* |
|
|
* |
|
|
* #### `to_remote` Output |
|
|
* #### `to_remote` Output |
|
|
* |
|
|
* |
|
|
* This output sends funds to the other peer and thus is a simple |
|
|
* If `option_anchor_outputs` applies to the commitment |
|
|
* P2WPKH to `remotepubkey`. |
|
|
* transaction, the `to_remote` output is encumbered by a one |
|
|
|
|
|
* block csv lock. |
|
|
|
|
|
* <remote_pubkey> OP_CHECKSIGVERIFY 1 OP_CHECKSEQUENCEVERIFY |
|
|
|
|
|
* |
|
|
|
|
|
*... |
|
|
|
|
|
* Otherwise, this output is a simple P2WPKH to `remotepubkey`. |
|
|
*/ |
|
|
*/ |
|
|
int pos = bitcoin_tx_add_output(tx, p2wpkh, NULL, amount); |
|
|
if (option_anchor_outputs) { |
|
|
|
|
|
scriptpubkey = scriptpubkey_p2wsh(tmpctx, |
|
|
|
|
|
anchor_to_remote_redeem(tmpctx, &keyset->other_payment_key)); |
|
|
|
|
|
} else { |
|
|
|
|
|
scriptpubkey = scriptpubkey_p2wpkh(tmpctx, |
|
|
|
|
|
&keyset->other_payment_key); |
|
|
|
|
|
} |
|
|
|
|
|
pos = bitcoin_tx_add_output(tx, scriptpubkey, NULL, amount); |
|
|
assert(pos == n); |
|
|
assert(pos == n); |
|
|
(*htlcmap)[n] = direct_outputs ? dummy_to_remote : NULL; |
|
|
(*htlcmap)[n] = direct_outputs ? dummy_to_remote : NULL; |
|
|
/* We don't assign cltvs[n]: if we use it, order doesn't matter.
|
|
|
/* We don't assign cltvs[n]: if we use it, order doesn't matter.
|
|
|
* However, valgrind will warn us something wierd is happening */ |
|
|
* However, valgrind will warn us something wierd is happening */ |
|
|
SUPERVERBOSE("# to-remote amount %s P2WPKH(%s)\n", |
|
|
SUPERVERBOSE("# to-remote amount %s key %s\n", |
|
|
type_to_string(tmpctx, struct amount_sat, |
|
|
type_to_string(tmpctx, struct amount_sat, |
|
|
&amount), |
|
|
&amount), |
|
|
type_to_string(tmpctx, struct pubkey, |
|
|
type_to_string(tmpctx, struct pubkey, |
|
|