mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
script: change htlc output scripts if option_anchor_outputs.
For the moment, everyone passes "false". Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
edf60b4f9e
commit
05c3a9bf12
@ -516,11 +516,32 @@ u8 *bitcoin_wscript_to_local(const tal_t *ctx, u16 to_self_delay,
|
||||
* OP_ENDIF
|
||||
* OP_ENDIF
|
||||
*/
|
||||
/* BOLT-a12da24dd0102c170365124782b46d9710950ac1 #3:
|
||||
* Or, with `option_anchor_outputs`:
|
||||
*
|
||||
* # To remote node with revocation key
|
||||
* OP_DUP OP_HASH160 <RIPEMD160(SHA256(revocationpubkey))> OP_EQUAL
|
||||
* OP_IF
|
||||
* OP_CHECKSIG
|
||||
* OP_ELSE
|
||||
* <remote_htlcpubkey> OP_SWAP OP_SIZE 32 OP_EQUAL
|
||||
* OP_NOTIF
|
||||
* # To local node via HTLC-timeout transaction (timelocked).
|
||||
* OP_DROP 2 OP_SWAP <local_htlcpubkey> 2 OP_CHECKMULTISIG
|
||||
* OP_ELSE
|
||||
* # To remote node with preimage.
|
||||
* OP_HASH160 <RIPEMD160(payment_hash)> OP_EQUALVERIFY
|
||||
* OP_CHECKSIG
|
||||
* OP_ENDIF
|
||||
* 1 OP_CHECKSEQUENCEVERIFY OP_DROP
|
||||
* OP_ENDIF
|
||||
*/
|
||||
u8 *bitcoin_wscript_htlc_offer_ripemd160(const tal_t *ctx,
|
||||
const struct pubkey *localhtlckey,
|
||||
const struct pubkey *remotehtlckey,
|
||||
const struct ripemd160 *payment_ripemd,
|
||||
const struct pubkey *revocationkey)
|
||||
const struct pubkey *revocationkey,
|
||||
bool option_anchor_outputs)
|
||||
{
|
||||
u8 *script = tal_arr(ctx, u8, 0);
|
||||
struct ripemd160 ripemd;
|
||||
@ -552,6 +573,11 @@ u8 *bitcoin_wscript_htlc_offer_ripemd160(const tal_t *ctx,
|
||||
add_op(&script, OP_EQUALVERIFY);
|
||||
add_op(&script, OP_CHECKSIG);
|
||||
add_op(&script, OP_ENDIF);
|
||||
if (option_anchor_outputs) {
|
||||
add_number(&script, 1);
|
||||
add_op(&script, OP_CHECKSEQUENCEVERIFY);
|
||||
add_op(&script, OP_DROP);
|
||||
}
|
||||
add_op(&script, OP_ENDIF);
|
||||
|
||||
return script;
|
||||
@ -561,14 +587,16 @@ u8 *bitcoin_wscript_htlc_offer(const tal_t *ctx,
|
||||
const struct pubkey *localhtlckey,
|
||||
const struct pubkey *remotehtlckey,
|
||||
const struct sha256 *payment_hash,
|
||||
const struct pubkey *revocationkey)
|
||||
const struct pubkey *revocationkey,
|
||||
bool option_anchor_outputs)
|
||||
{
|
||||
struct ripemd160 ripemd;
|
||||
|
||||
ripemd160(&ripemd, payment_hash->u.u8, sizeof(payment_hash->u));
|
||||
return bitcoin_wscript_htlc_offer_ripemd160(ctx, localhtlckey,
|
||||
remotehtlckey,
|
||||
&ripemd, revocationkey);
|
||||
&ripemd, revocationkey,
|
||||
option_anchor_outputs);
|
||||
}
|
||||
|
||||
/* BOLT #3:
|
||||
@ -597,12 +625,34 @@ u8 *bitcoin_wscript_htlc_offer(const tal_t *ctx,
|
||||
* OP_ENDIF
|
||||
* OP_ENDIF
|
||||
*/
|
||||
/* BOLT-a12da24dd0102c170365124782b46d9710950ac1 #3:
|
||||
* Or, with `option_anchor_outputs`:
|
||||
*
|
||||
* # To remote node with revocation key
|
||||
* OP_DUP OP_HASH160 <RIPEMD160(SHA256(revocationpubkey))> OP_EQUAL
|
||||
* OP_IF
|
||||
* OP_CHECKSIG
|
||||
* OP_ELSE
|
||||
* <remote_htlcpubkey> OP_SWAP OP_SIZE 32 OP_EQUAL
|
||||
* OP_IF
|
||||
* # To local node via HTLC-success transaction.
|
||||
* OP_HASH160 <RIPEMD160(payment_hash)> OP_EQUALVERIFY
|
||||
* 2 OP_SWAP <local_htlcpubkey> 2 OP_CHECKMULTISIG
|
||||
* OP_ELSE
|
||||
* # To remote node after timeout.
|
||||
* OP_DROP <cltv_expiry> OP_CHECKLOCKTIMEVERIFY OP_DROP
|
||||
* OP_CHECKSIG
|
||||
* OP_ENDIF
|
||||
* 1 OP_CHECKSEQUENCEVERIFY OP_DROP
|
||||
* OP_ENDIF
|
||||
*/
|
||||
u8 *bitcoin_wscript_htlc_receive_ripemd(const tal_t *ctx,
|
||||
const struct abs_locktime *htlc_abstimeout,
|
||||
const struct pubkey *localhtlckey,
|
||||
const struct pubkey *remotehtlckey,
|
||||
const struct ripemd160 *payment_ripemd,
|
||||
const struct pubkey *revocationkey)
|
||||
const struct pubkey *revocationkey,
|
||||
bool option_anchor_outputs)
|
||||
{
|
||||
u8 *script = tal_arr(ctx, u8, 0);
|
||||
struct ripemd160 ripemd;
|
||||
@ -637,6 +687,11 @@ u8 *bitcoin_wscript_htlc_receive_ripemd(const tal_t *ctx,
|
||||
add_op(&script, OP_DROP);
|
||||
add_op(&script, OP_CHECKSIG);
|
||||
add_op(&script, OP_ENDIF);
|
||||
if (option_anchor_outputs) {
|
||||
add_number(&script, 1);
|
||||
add_op(&script, OP_CHECKSEQUENCEVERIFY);
|
||||
add_op(&script, OP_DROP);
|
||||
}
|
||||
add_op(&script, OP_ENDIF);
|
||||
|
||||
return script;
|
||||
@ -647,14 +702,16 @@ u8 *bitcoin_wscript_htlc_receive(const tal_t *ctx,
|
||||
const struct pubkey *localhtlckey,
|
||||
const struct pubkey *remotehtlckey,
|
||||
const struct sha256 *payment_hash,
|
||||
const struct pubkey *revocationkey)
|
||||
const struct pubkey *revocationkey,
|
||||
bool option_anchor_outputs)
|
||||
{
|
||||
struct ripemd160 ripemd;
|
||||
|
||||
ripemd160(&ripemd, payment_hash->u.u8, sizeof(payment_hash->u));
|
||||
return bitcoin_wscript_htlc_receive_ripemd(ctx, htlc_abstimeout,
|
||||
localhtlckey, remotehtlckey,
|
||||
&ripemd, revocationkey);
|
||||
&ripemd, revocationkey,
|
||||
option_anchor_outputs);
|
||||
}
|
||||
|
||||
/* BOLT #3:
|
||||
|
@ -86,7 +86,8 @@ u8 *bitcoin_wscript_htlc_offer(const tal_t *ctx,
|
||||
const struct pubkey *localhtlckey,
|
||||
const struct pubkey *remotehtlckey,
|
||||
const struct sha256 *payment_hash,
|
||||
const struct pubkey *revocationkey);
|
||||
const struct pubkey *revocationkey,
|
||||
bool option_anchor_outputs);
|
||||
u8 **bitcoin_witness_htlc_timeout_tx(const tal_t *ctx,
|
||||
const struct bitcoin_signature *localsig,
|
||||
const struct bitcoin_signature *remotesig,
|
||||
@ -96,7 +97,8 @@ u8 *bitcoin_wscript_htlc_receive(const tal_t *ctx,
|
||||
const struct pubkey *localkey,
|
||||
const struct pubkey *remotekey,
|
||||
const struct sha256 *payment_hash,
|
||||
const struct pubkey *revocationkey);
|
||||
const struct pubkey *revocationkey,
|
||||
bool option_anchor_outputs);
|
||||
u8 **bitcoin_witness_htlc_success_tx(const tal_t *ctx,
|
||||
const struct bitcoin_signature *localsig,
|
||||
const struct bitcoin_signature *remotesig,
|
||||
@ -108,13 +110,15 @@ u8 *bitcoin_wscript_htlc_offer_ripemd160(const tal_t *ctx,
|
||||
const struct pubkey *localhtlckey,
|
||||
const struct pubkey *remotehtlckey,
|
||||
const struct ripemd160 *payment_ripemd,
|
||||
const struct pubkey *revocationkey);
|
||||
const struct pubkey *revocationkey,
|
||||
bool option_anchor_outputs);
|
||||
u8 *bitcoin_wscript_htlc_receive_ripemd(const tal_t *ctx,
|
||||
const struct abs_locktime *htlc_abstimeout,
|
||||
const struct pubkey *localkey,
|
||||
const struct pubkey *remotekey,
|
||||
const struct ripemd160 *payment_ripemd,
|
||||
const struct pubkey *revocationkey);
|
||||
const struct pubkey *revocationkey,
|
||||
bool option_anchor_outputs);
|
||||
|
||||
/* BOLT #3 HTLC-success/HTLC-timeout output */
|
||||
u8 *bitcoin_wscript_htlc_tx(const tal_t *ctx,
|
||||
|
@ -43,7 +43,7 @@ static void add_offered_htlc_out(struct bitcoin_tx *tx, size_t n,
|
||||
struct amount_sat amount = amount_msat_to_sat_round_down(htlc->amount);
|
||||
|
||||
ripemd160(&ripemd, htlc->rhash.u.u8, sizeof(htlc->rhash.u.u8));
|
||||
wscript = htlc_offered_wscript(tx, &ripemd, keyset);
|
||||
wscript = htlc_offered_wscript(tx, &ripemd, keyset, false /* FIXME-anchor */);
|
||||
p2wsh = scriptpubkey_p2wsh(tx, wscript);
|
||||
bitcoin_tx_add_output(tx, p2wsh, wscript, amount);
|
||||
SUPERVERBOSE("# HTLC %" PRIu64 " offered %s wscript %s\n", htlc->id,
|
||||
@ -61,7 +61,7 @@ static void add_received_htlc_out(struct bitcoin_tx *tx, size_t n,
|
||||
struct amount_sat amount;
|
||||
|
||||
ripemd160(&ripemd, htlc->rhash.u.u8, sizeof(htlc->rhash.u.u8));
|
||||
wscript = htlc_received_wscript(tx, &ripemd, &htlc->expiry, keyset);
|
||||
wscript = htlc_received_wscript(tx, &ripemd, &htlc->expiry, keyset, false /* FIXME-anchor */);
|
||||
p2wsh = scriptpubkey_p2wsh(tx, wscript);
|
||||
amount = amount_msat_to_sat_round_down(htlc->amount);
|
||||
|
||||
|
@ -247,23 +247,23 @@ static void add_htlcs(struct bitcoin_tx ***txs,
|
||||
|
||||
if (htlc_owner(htlc) == side) {
|
||||
ripemd160(&ripemd, htlc->rhash.u.u8, sizeof(htlc->rhash.u.u8));
|
||||
wscript = htlc_offered_wscript(tmpctx, &ripemd, keyset);
|
||||
wscript = htlc_offered_wscript(tmpctx, &ripemd, keyset, false /* FIXME-anchor */);
|
||||
tx = htlc_timeout_tx(*txs, chainparams, &txid, i,
|
||||
wscript,
|
||||
htlc->amount,
|
||||
htlc->expiry.locktime,
|
||||
channel->config[!side].to_self_delay,
|
||||
feerate_per_kw,
|
||||
keyset);
|
||||
keyset, false /* FIXME-anchor */);
|
||||
} else {
|
||||
ripemd160(&ripemd, htlc->rhash.u.u8, sizeof(htlc->rhash.u.u8));
|
||||
wscript = htlc_received_wscript(tmpctx, &ripemd, &htlc->expiry, keyset);
|
||||
wscript = htlc_received_wscript(tmpctx, &ripemd, &htlc->expiry, keyset, false /* FIXME-anchor */);
|
||||
tx = htlc_success_tx(*txs, chainparams, &txid, i,
|
||||
wscript,
|
||||
htlc->amount,
|
||||
channel->config[!side].to_self_delay,
|
||||
feerate_per_kw,
|
||||
keyset);
|
||||
keyset, false /* FIXME-anchor */);
|
||||
}
|
||||
|
||||
/* Append to array. */
|
||||
|
@ -206,7 +206,8 @@ static void report_htlcs(const struct bitcoin_tx *tx,
|
||||
const struct pubkey *remotekey,
|
||||
const struct pubkey *remote_htlckey,
|
||||
const struct pubkey *remote_revocation_key,
|
||||
u32 feerate_per_kw)
|
||||
u32 feerate_per_kw,
|
||||
bool option_anchor_outputs)
|
||||
{
|
||||
size_t i, n;
|
||||
struct bitcoin_txid txid;
|
||||
@ -249,27 +250,30 @@ static void report_htlcs(const struct bitcoin_tx *tx,
|
||||
local_htlckey,
|
||||
remote_htlckey,
|
||||
&htlc->rhash,
|
||||
remote_revocation_key);
|
||||
remote_revocation_key,
|
||||
option_anchor_outputs);
|
||||
htlc_tx[i] = htlc_timeout_tx(htlc_tx, tx->chainparams,
|
||||
&txid, i, wscript[i],
|
||||
htlc->amount,
|
||||
htlc->expiry.locktime,
|
||||
to_self_delay,
|
||||
feerate_per_kw,
|
||||
&keyset);
|
||||
&keyset, option_anchor_outputs);
|
||||
} else {
|
||||
wscript[i] = bitcoin_wscript_htlc_receive(tmpctx,
|
||||
&htlc->expiry,
|
||||
local_htlckey,
|
||||
remote_htlckey,
|
||||
&htlc->rhash,
|
||||
remote_revocation_key);
|
||||
remote_revocation_key,
|
||||
option_anchor_outputs);
|
||||
htlc_tx[i] = htlc_success_tx(htlc_tx, tx->chainparams,
|
||||
&txid, i, wscript[i],
|
||||
htlc->amount,
|
||||
to_self_delay,
|
||||
feerate_per_kw,
|
||||
&keyset);
|
||||
&keyset,
|
||||
option_anchor_outputs);
|
||||
}
|
||||
sign_tx_input(htlc_tx[i], 0,
|
||||
NULL,
|
||||
@ -307,7 +311,8 @@ static void report_htlcs(const struct bitcoin_tx *tx,
|
||||
&htlc->rhash,
|
||||
remote_revocation_key,
|
||||
&localhtlcsig,
|
||||
&remotehtlcsig[i]);
|
||||
&remotehtlcsig[i],
|
||||
option_anchor_outputs);
|
||||
} else {
|
||||
htlc_success_tx_add_witness(htlc_tx[i],
|
||||
&htlc->expiry,
|
||||
@ -316,7 +321,8 @@ static void report_htlcs(const struct bitcoin_tx *tx,
|
||||
&localhtlcsig,
|
||||
&remotehtlcsig[i],
|
||||
htlc->r,
|
||||
remote_revocation_key);
|
||||
remote_revocation_key,
|
||||
option_anchor_outputs);
|
||||
}
|
||||
printf("output htlc_%s_tx %"PRIu64": %s\n",
|
||||
htlc_owner(htlc) == LOCAL ? "timeout" : "success",
|
||||
@ -341,6 +347,7 @@ static void report(struct bitcoin_tx *tx,
|
||||
const struct pubkey *remote_htlckey,
|
||||
const struct pubkey *remote_revocation_key,
|
||||
u32 feerate_per_kw,
|
||||
bool option_anchor_outputs,
|
||||
const struct htlc **htlc_map)
|
||||
{
|
||||
char *txhex;
|
||||
@ -377,7 +384,8 @@ static void report(struct bitcoin_tx *tx,
|
||||
x_remote_htlcsecretkey,
|
||||
remotekey, remote_htlckey,
|
||||
remote_revocation_key,
|
||||
feerate_per_kw);
|
||||
feerate_per_kw,
|
||||
option_anchor_outputs);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
@ -482,6 +490,7 @@ int main(int argc, const char *argv[])
|
||||
u64 commitment_number, cn_obscurer;
|
||||
struct amount_msat to_local, to_remote;
|
||||
const struct htlc **htlcs, **htlc_map, **htlc_map2, **inv_htlcs;
|
||||
bool option_anchor_outputs = false;
|
||||
|
||||
chainparams = chainparams_for_network("bitcoin");
|
||||
|
||||
@ -771,6 +780,7 @@ int main(int argc, const char *argv[])
|
||||
&remote_htlckey,
|
||||
&remote_revocation_key,
|
||||
feerate_per_kw,
|
||||
option_anchor_outputs,
|
||||
htlc_map);
|
||||
|
||||
/* BOLT #3:
|
||||
@ -828,6 +838,7 @@ int main(int argc, const char *argv[])
|
||||
&remote_htlckey,
|
||||
&remote_revocation_key,
|
||||
feerate_per_kw,
|
||||
option_anchor_outputs,
|
||||
htlc_map);
|
||||
|
||||
do {
|
||||
@ -905,6 +916,7 @@ int main(int argc, const char *argv[])
|
||||
&remote_htlckey,
|
||||
&remote_revocation_key,
|
||||
feerate_per_kw-1,
|
||||
option_anchor_outputs,
|
||||
htlc_map);
|
||||
|
||||
printf("\n"
|
||||
@ -942,6 +954,7 @@ int main(int argc, const char *argv[])
|
||||
&remote_htlckey,
|
||||
&remote_revocation_key,
|
||||
feerate_per_kw,
|
||||
option_anchor_outputs,
|
||||
htlc_map);
|
||||
|
||||
assert(newtx->wtx->num_outputs != tx->wtx->num_outputs);
|
||||
@ -1001,6 +1014,7 @@ int main(int argc, const char *argv[])
|
||||
&remote_htlckey,
|
||||
&remote_revocation_key,
|
||||
feerate_per_kw,
|
||||
option_anchor_outputs,
|
||||
htlc_map);
|
||||
break;
|
||||
}
|
||||
|
@ -14,7 +14,8 @@ static struct bitcoin_tx *htlc_tx(const tal_t *ctx,
|
||||
const struct pubkey *revocation_pubkey,
|
||||
const struct pubkey *local_delayedkey,
|
||||
struct amount_sat htlc_fee,
|
||||
u32 locktime)
|
||||
u32 locktime,
|
||||
bool option_anchor_outputs)
|
||||
{
|
||||
/* BOLT #3:
|
||||
* * locktime: `0` for HTLC-success, `cltv_expiry` for HTLC-timeout
|
||||
@ -38,15 +39,16 @@ static struct bitcoin_tx *htlc_tx(const tal_t *ctx,
|
||||
*/
|
||||
assert(tx->wtx->version == 2);
|
||||
|
||||
/* BOLT #3:
|
||||
/* BOLT-a12da24dd0102c170365124782b46d9710950ac1 #3:
|
||||
* * txin count: 1
|
||||
* * `txin[0]` outpoint: `txid` of the commitment transaction and
|
||||
* `output_index` of the matching HTLC output for the HTLC
|
||||
* transaction
|
||||
* * `txin[0]` sequence: `0`
|
||||
* * `txin[0]` sequence: `0` (set to `1` for `option_anchor_outputs`)
|
||||
*/
|
||||
amount = amount_msat_to_sat_round_down(msat);
|
||||
bitcoin_tx_add_input(tx, commit_txid, commit_output_number, 0,
|
||||
bitcoin_tx_add_input(tx, commit_txid, commit_output_number,
|
||||
option_anchor_outputs ? 1 : 0,
|
||||
NULL, amount, NULL, commit_wscript);
|
||||
|
||||
/* BOLT #3:
|
||||
@ -80,7 +82,8 @@ struct bitcoin_tx *htlc_success_tx(const tal_t *ctx,
|
||||
struct amount_msat htlc_msatoshi,
|
||||
u16 to_self_delay,
|
||||
u32 feerate_per_kw,
|
||||
const struct keyset *keyset)
|
||||
const struct keyset *keyset,
|
||||
bool option_anchor_outputs)
|
||||
{
|
||||
/* BOLT #3:
|
||||
* * locktime: `0` for HTLC-success, `cltv_expiry` for HTLC-timeout
|
||||
@ -90,7 +93,9 @@ struct bitcoin_tx *htlc_success_tx(const tal_t *ctx,
|
||||
to_self_delay,
|
||||
&keyset->self_revocation_key,
|
||||
&keyset->self_delayed_payment_key,
|
||||
htlc_success_fee(feerate_per_kw), 0);
|
||||
htlc_success_fee(feerate_per_kw),
|
||||
0,
|
||||
option_anchor_outputs);
|
||||
}
|
||||
|
||||
/* Fill in the witness for HTLC-success tx produced above. */
|
||||
@ -101,7 +106,8 @@ void htlc_success_tx_add_witness(struct bitcoin_tx *htlc_success,
|
||||
const struct bitcoin_signature *localhtlcsig,
|
||||
const struct bitcoin_signature *remotehtlcsig,
|
||||
const struct preimage *payment_preimage,
|
||||
const struct pubkey *revocationkey)
|
||||
const struct pubkey *revocationkey,
|
||||
bool option_anchor_outputs)
|
||||
{
|
||||
struct sha256 hash;
|
||||
u8 *wscript, **witness;
|
||||
@ -110,7 +116,8 @@ void htlc_success_tx_add_witness(struct bitcoin_tx *htlc_success,
|
||||
wscript = bitcoin_wscript_htlc_receive(htlc_success,
|
||||
htlc_abstimeout,
|
||||
localhtlckey, remotehtlckey,
|
||||
&hash, revocationkey);
|
||||
&hash, revocationkey,
|
||||
option_anchor_outputs);
|
||||
|
||||
witness = bitcoin_witness_htlc_success_tx(htlc_success,
|
||||
localhtlcsig, remotehtlcsig,
|
||||
@ -128,7 +135,8 @@ struct bitcoin_tx *htlc_timeout_tx(const tal_t *ctx,
|
||||
u32 cltv_expiry,
|
||||
u16 to_self_delay,
|
||||
u32 feerate_per_kw,
|
||||
const struct keyset *keyset)
|
||||
const struct keyset *keyset,
|
||||
bool option_anchor_outputs)
|
||||
{
|
||||
/* BOLT #3:
|
||||
* * locktime: `0` for HTLC-success, `cltv_expiry` for HTLC-timeout
|
||||
@ -137,7 +145,9 @@ struct bitcoin_tx *htlc_timeout_tx(const tal_t *ctx,
|
||||
commit_wscript, htlc_msatoshi, to_self_delay,
|
||||
&keyset->self_revocation_key,
|
||||
&keyset->self_delayed_payment_key,
|
||||
htlc_timeout_fee(feerate_per_kw), cltv_expiry);
|
||||
htlc_timeout_fee(feerate_per_kw),
|
||||
cltv_expiry,
|
||||
option_anchor_outputs);
|
||||
}
|
||||
|
||||
/* Fill in the witness for HTLC-timeout tx produced above. */
|
||||
@ -147,12 +157,14 @@ void htlc_timeout_tx_add_witness(struct bitcoin_tx *htlc_timeout,
|
||||
const struct sha256 *payment_hash,
|
||||
const struct pubkey *revocationkey,
|
||||
const struct bitcoin_signature *localhtlcsig,
|
||||
const struct bitcoin_signature *remotehtlcsig)
|
||||
const struct bitcoin_signature *remotehtlcsig,
|
||||
bool option_anchor_outputs)
|
||||
{
|
||||
u8 **witness;
|
||||
u8 *wscript = bitcoin_wscript_htlc_offer(htlc_timeout,
|
||||
localhtlckey, remotehtlckey,
|
||||
payment_hash, revocationkey);
|
||||
payment_hash, revocationkey,
|
||||
option_anchor_outputs);
|
||||
|
||||
witness = bitcoin_witness_htlc_timeout_tx(htlc_timeout, localhtlcsig,
|
||||
remotehtlcsig, wscript);
|
||||
@ -162,24 +174,28 @@ void htlc_timeout_tx_add_witness(struct bitcoin_tx *htlc_timeout,
|
||||
|
||||
u8 *htlc_offered_wscript(const tal_t *ctx,
|
||||
const struct ripemd160 *ripemd,
|
||||
const struct keyset *keyset)
|
||||
const struct keyset *keyset,
|
||||
bool option_anchor_outputs)
|
||||
{
|
||||
return bitcoin_wscript_htlc_offer_ripemd160(ctx,
|
||||
&keyset->self_htlc_key,
|
||||
&keyset->other_htlc_key,
|
||||
ripemd,
|
||||
&keyset->self_revocation_key);
|
||||
&keyset->self_revocation_key,
|
||||
option_anchor_outputs);
|
||||
}
|
||||
|
||||
u8 *htlc_received_wscript(const tal_t *ctx,
|
||||
const struct ripemd160 *ripemd,
|
||||
const struct abs_locktime *expiry,
|
||||
const struct keyset *keyset)
|
||||
const struct keyset *keyset,
|
||||
bool option_anchor_outputs)
|
||||
{
|
||||
return bitcoin_wscript_htlc_receive_ripemd(ctx,
|
||||
expiry,
|
||||
&keyset->self_htlc_key,
|
||||
&keyset->other_htlc_key,
|
||||
ripemd,
|
||||
&keyset->self_revocation_key);
|
||||
&keyset->self_revocation_key,
|
||||
option_anchor_outputs);
|
||||
}
|
||||
|
@ -73,7 +73,8 @@ struct bitcoin_tx *htlc_success_tx(const tal_t *ctx,
|
||||
struct amount_msat htlc_msatoshi,
|
||||
u16 to_self_delay,
|
||||
u32 feerate_per_kw,
|
||||
const struct keyset *keyset);
|
||||
const struct keyset *keyset,
|
||||
bool option_anchor_outputs);
|
||||
|
||||
/* Fill in the witness for HTLC-success tx produced above. */
|
||||
void htlc_success_tx_add_witness(struct bitcoin_tx *htlc_success,
|
||||
@ -83,7 +84,8 @@ void htlc_success_tx_add_witness(struct bitcoin_tx *htlc_success,
|
||||
const struct bitcoin_signature *localsig,
|
||||
const struct bitcoin_signature *remotesig,
|
||||
const struct preimage *payment_preimage,
|
||||
const struct pubkey *revocationkey);
|
||||
const struct pubkey *revocationkey,
|
||||
bool option_anchor_outputs);
|
||||
|
||||
/* Create HTLC-timeout tx to spend an offered HTLC commitment tx
|
||||
* output; doesn't fill in input witness. */
|
||||
@ -96,7 +98,8 @@ struct bitcoin_tx *htlc_timeout_tx(const tal_t *ctx,
|
||||
u32 cltv_expiry,
|
||||
u16 to_self_delay,
|
||||
u32 feerate_per_kw,
|
||||
const struct keyset *keyset);
|
||||
const struct keyset *keyset,
|
||||
bool option_anchor_outputs);
|
||||
|
||||
/* Fill in the witness for HTLC-timeout tx produced above. */
|
||||
void htlc_timeout_tx_add_witness(struct bitcoin_tx *htlc_timeout,
|
||||
@ -105,7 +108,8 @@ void htlc_timeout_tx_add_witness(struct bitcoin_tx *htlc_timeout,
|
||||
const struct sha256 *payment_hash,
|
||||
const struct pubkey *revocationkey,
|
||||
const struct bitcoin_signature *localsig,
|
||||
const struct bitcoin_signature *remotesig);
|
||||
const struct bitcoin_signature *remotesig,
|
||||
bool option_anchor_outputs);
|
||||
|
||||
|
||||
/* Generate the witness script for an HTLC the other side offered:
|
||||
@ -113,12 +117,14 @@ void htlc_timeout_tx_add_witness(struct bitcoin_tx *htlc_timeout,
|
||||
u8 *htlc_received_wscript(const tal_t *ctx,
|
||||
const struct ripemd160 *ripemd,
|
||||
const struct abs_locktime *expiry,
|
||||
const struct keyset *keyset);
|
||||
const struct keyset *keyset,
|
||||
bool option_anchor_outputs);
|
||||
|
||||
/* Generate the witness script for an HTLC this side offered:
|
||||
* scriptpubkey_p2wsh(ctx, wscript) gives the scriptpubkey */
|
||||
u8 *htlc_offered_wscript(const tal_t *ctx,
|
||||
const struct ripemd160 *ripemd,
|
||||
const struct keyset *keyset);
|
||||
const struct keyset *keyset,
|
||||
bool option_anchor_outputs);
|
||||
|
||||
#endif /* LIGHTNING_COMMON_HTLC_TX_H */
|
||||
|
@ -1686,7 +1686,7 @@ static void handle_preimage(struct tracked_output **outs,
|
||||
htlc_amount,
|
||||
to_self_delay[LOCAL],
|
||||
0,
|
||||
keyset);
|
||||
keyset, false /* FIXME-anchor */);
|
||||
set_htlc_success_fee(tx, outs[i]->remote_htlc_sig,
|
||||
outs[i]->wscript);
|
||||
hsm_sign_local_htlc_tx(tx, outs[i]->wscript, &sig);
|
||||
@ -1875,7 +1875,7 @@ static u8 **derive_htlc_scripts(const struct htlc_stub *htlcs, enum side side)
|
||||
if (htlcs[i].owner == side)
|
||||
htlc_scripts[i] = htlc_offered_wscript(htlc_scripts,
|
||||
&htlcs[i].ripemd,
|
||||
keyset);
|
||||
keyset, false /* FIXME-anchor */);
|
||||
else {
|
||||
/* FIXME: remove abs_locktime */
|
||||
struct abs_locktime ltime;
|
||||
@ -1887,7 +1887,7 @@ static u8 **derive_htlc_scripts(const struct htlc_stub *htlcs, enum side side)
|
||||
htlc_scripts[i] = htlc_received_wscript(htlc_scripts,
|
||||
&htlcs[i].ripemd,
|
||||
<ime,
|
||||
keyset);
|
||||
keyset, false /* FIXME-anchor */);
|
||||
}
|
||||
}
|
||||
return htlc_scripts;
|
||||
@ -1929,7 +1929,7 @@ static size_t resolve_our_htlc_ourcommit(struct tracked_output *out,
|
||||
&out->txid, out->outnum,
|
||||
htlc_scripts[matches[i]], htlc_amount,
|
||||
htlcs[matches[i]].cltv_expiry,
|
||||
to_self_delay[LOCAL], 0, keyset);
|
||||
to_self_delay[LOCAL], 0, keyset, false /* FIXME-anchor */);
|
||||
|
||||
if (set_htlc_timeout_fee(tx, out->remote_htlc_sig,
|
||||
htlc_scripts[matches[i]]))
|
||||
|
@ -87,13 +87,15 @@ u8 fromwire_u8(const u8 **cursor UNNEEDED, size_t *max UNNEEDED)
|
||||
/* Generated stub for htlc_offered_wscript */
|
||||
u8 *htlc_offered_wscript(const tal_t *ctx UNNEEDED,
|
||||
const struct ripemd160 *ripemd UNNEEDED,
|
||||
const struct keyset *keyset UNNEEDED)
|
||||
const struct keyset *keyset UNNEEDED,
|
||||
bool option_anchor_outputs UNNEEDED)
|
||||
{ fprintf(stderr, "htlc_offered_wscript called!\n"); abort(); }
|
||||
/* Generated stub for htlc_received_wscript */
|
||||
u8 *htlc_received_wscript(const tal_t *ctx UNNEEDED,
|
||||
const struct ripemd160 *ripemd UNNEEDED,
|
||||
const struct abs_locktime *expiry UNNEEDED,
|
||||
const struct keyset *keyset UNNEEDED)
|
||||
const struct keyset *keyset UNNEEDED,
|
||||
bool option_anchor_outputs UNNEEDED)
|
||||
{ fprintf(stderr, "htlc_received_wscript called!\n"); abort(); }
|
||||
/* Generated stub for htlc_success_tx */
|
||||
struct bitcoin_tx *htlc_success_tx(const tal_t *ctx UNNEEDED,
|
||||
@ -104,7 +106,8 @@ struct bitcoin_tx *htlc_success_tx(const tal_t *ctx UNNEEDED,
|
||||
struct amount_msat htlc_msatoshi UNNEEDED,
|
||||
u16 to_self_delay UNNEEDED,
|
||||
u32 feerate_per_kw UNNEEDED,
|
||||
const struct keyset *keyset UNNEEDED)
|
||||
const struct keyset *keyset UNNEEDED,
|
||||
bool option_anchor_outputs UNNEEDED)
|
||||
{ fprintf(stderr, "htlc_success_tx called!\n"); abort(); }
|
||||
/* Generated stub for master_badmsg */
|
||||
void master_badmsg(u32 type_expected UNNEEDED, const u8 *msg)
|
||||
@ -344,9 +347,10 @@ struct bitcoin_tx *htlc_timeout_tx(const tal_t *ctx,
|
||||
u32 cltv_expiry,
|
||||
u16 to_self_delay UNNEEDED,
|
||||
u32 feerate_per_kw UNNEEDED,
|
||||
const struct keyset *keyset UNNEEDED)
|
||||
const struct keyset *keyset UNNEEDED,
|
||||
bool option_anchor_outputs)
|
||||
{
|
||||
struct bitcoin_tx *tx;
|
||||
struct bitcoin_tx *tx;
|
||||
struct amount_sat in_amount;
|
||||
|
||||
tx = bitcoin_tx_from_hex(ctx, "0200000001a02a38c6ec5541963704a2a035b3094b18d69cc25cc7419d75e02894618329720000000000000000000191ea3000000000002200208bfadb3554f41cc06f00de0ec2e2f91e36ee45b5006a1f606146784755356ba532f10800",
|
||||
|
@ -88,13 +88,15 @@ u8 fromwire_u8(const u8 **cursor UNNEEDED, size_t *max UNNEEDED)
|
||||
/* Generated stub for htlc_offered_wscript */
|
||||
u8 *htlc_offered_wscript(const tal_t *ctx UNNEEDED,
|
||||
const struct ripemd160 *ripemd UNNEEDED,
|
||||
const struct keyset *keyset UNNEEDED)
|
||||
const struct keyset *keyset UNNEEDED,
|
||||
bool option_anchor_outputs UNNEEDED)
|
||||
{ fprintf(stderr, "htlc_offered_wscript called!\n"); abort(); }
|
||||
/* Generated stub for htlc_received_wscript */
|
||||
u8 *htlc_received_wscript(const tal_t *ctx UNNEEDED,
|
||||
const struct ripemd160 *ripemd UNNEEDED,
|
||||
const struct abs_locktime *expiry UNNEEDED,
|
||||
const struct keyset *keyset UNNEEDED)
|
||||
const struct keyset *keyset UNNEEDED,
|
||||
bool option_anchor_outputs UNNEEDED)
|
||||
{ fprintf(stderr, "htlc_received_wscript called!\n"); abort(); }
|
||||
/* Generated stub for htlc_success_tx */
|
||||
struct bitcoin_tx *htlc_success_tx(const tal_t *ctx UNNEEDED,
|
||||
@ -105,7 +107,8 @@ struct bitcoin_tx *htlc_success_tx(const tal_t *ctx UNNEEDED,
|
||||
struct amount_msat htlc_msatoshi UNNEEDED,
|
||||
u16 to_self_delay UNNEEDED,
|
||||
u32 feerate_per_kw UNNEEDED,
|
||||
const struct keyset *keyset UNNEEDED)
|
||||
const struct keyset *keyset UNNEEDED,
|
||||
bool option_anchor_outputs UNNEEDED)
|
||||
{ fprintf(stderr, "htlc_success_tx called!\n"); abort(); }
|
||||
/* Generated stub for htlc_timeout_tx */
|
||||
struct bitcoin_tx *htlc_timeout_tx(const tal_t *ctx UNNEEDED,
|
||||
@ -117,7 +120,8 @@ struct bitcoin_tx *htlc_timeout_tx(const tal_t *ctx UNNEEDED,
|
||||
u32 cltv_expiry UNNEEDED,
|
||||
u16 to_self_delay UNNEEDED,
|
||||
u32 feerate_per_kw UNNEEDED,
|
||||
const struct keyset *keyset UNNEEDED)
|
||||
const struct keyset *keyset UNNEEDED,
|
||||
bool option_anchor_outputs UNNEEDED)
|
||||
{ fprintf(stderr, "htlc_timeout_tx called!\n"); abort(); }
|
||||
/* Generated stub for master_badmsg */
|
||||
void master_badmsg(u32 type_expected UNNEEDED, const u8 *msg)
|
||||
|
Loading…
Reference in New Issue
Block a user