bitcoin/scripts: use htlckey instead of localkey.

Basically a namechange in the argument list.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2017-11-15 14:37:45 +10:30 committed by Christian Decker
parent 44e45348f2
commit 88ec8df329
3 changed files with 31 additions and 30 deletions

View File

@ -6,7 +6,7 @@ CCANDIR := ccan
# Where we keep the BOLT RFCs # Where we keep the BOLT RFCs
BOLTDIR := ../lightning-rfc/ BOLTDIR := ../lightning-rfc/
BOLTVERSION := 046f5acb1619bccf167e5539f144433495f1486b BOLTVERSION := 4f91f0bb2a9c176dda019f9c0618c10f9fa0acfd
# If you don't have (working) valgrind. # If you don't have (working) valgrind.
#NO_VALGRIND := 1 #NO_VALGRIND := 1

View File

@ -528,10 +528,10 @@ u8 **bitcoin_to_local_spend_revocation(const tal_t *ctx,
* OP_IF * OP_IF
* OP_CHECKSIG * OP_CHECKSIG
* OP_ELSE * OP_ELSE
* <remotekey> OP_SWAP OP_SIZE 32 OP_EQUAL * <remote_htlckey> OP_SWAP OP_SIZE 32 OP_EQUAL
* OP_NOTIF * OP_NOTIF
* # To me via HTLC-timeout transaction (timelocked). * # To me via HTLC-timeout transaction (timelocked).
* OP_DROP 2 OP_SWAP <localkey> 2 OP_CHECKMULTISIG * OP_DROP 2 OP_SWAP <local_htlckey> 2 OP_CHECKMULTISIG
* OP_ELSE * OP_ELSE
* # To you with preimage. * # To you with preimage.
* OP_HASH160 <RIPEMD160(payment_hash)> OP_EQUALVERIFY * OP_HASH160 <RIPEMD160(payment_hash)> OP_EQUALVERIFY
@ -540,8 +540,8 @@ u8 **bitcoin_to_local_spend_revocation(const tal_t *ctx,
* OP_ENDIF * OP_ENDIF
*/ */
u8 *bitcoin_wscript_htlc_offer_ripemd160(const tal_t *ctx, u8 *bitcoin_wscript_htlc_offer_ripemd160(const tal_t *ctx,
const struct pubkey *localkey, const struct pubkey *localhtlckey,
const struct pubkey *remotekey, const struct pubkey *remotehtlckey,
const struct ripemd160 *payment_ripemd, const struct ripemd160 *payment_ripemd,
const struct pubkey *revocationkey) const struct pubkey *revocationkey)
{ {
@ -556,7 +556,7 @@ u8 *bitcoin_wscript_htlc_offer_ripemd160(const tal_t *ctx,
add_op(&script, OP_IF); add_op(&script, OP_IF);
add_op(&script, OP_CHECKSIG); add_op(&script, OP_CHECKSIG);
add_op(&script, OP_ELSE); add_op(&script, OP_ELSE);
add_push_key(&script, remotekey); add_push_key(&script, remotehtlckey);
add_op(&script, OP_SWAP); add_op(&script, OP_SWAP);
add_op(&script, OP_SIZE); add_op(&script, OP_SIZE);
add_number(&script, 32); add_number(&script, 32);
@ -565,7 +565,7 @@ u8 *bitcoin_wscript_htlc_offer_ripemd160(const tal_t *ctx,
add_op(&script, OP_DROP); add_op(&script, OP_DROP);
add_number(&script, 2); add_number(&script, 2);
add_op(&script, OP_SWAP); add_op(&script, OP_SWAP);
add_push_key(&script, localkey); add_push_key(&script, localhtlckey);
add_number(&script, 2); add_number(&script, 2);
add_op(&script, OP_CHECKMULTISIG); add_op(&script, OP_CHECKMULTISIG);
add_op(&script, OP_ELSE); add_op(&script, OP_ELSE);
@ -581,15 +581,16 @@ u8 *bitcoin_wscript_htlc_offer_ripemd160(const tal_t *ctx,
} }
u8 *bitcoin_wscript_htlc_offer(const tal_t *ctx, u8 *bitcoin_wscript_htlc_offer(const tal_t *ctx,
const struct pubkey *localkey, const struct pubkey *localhtlckey,
const struct pubkey *remotekey, const struct pubkey *remotehtlckey,
const struct sha256 *payment_hash, const struct sha256 *payment_hash,
const struct pubkey *revocationkey) const struct pubkey *revocationkey)
{ {
struct ripemd160 ripemd; struct ripemd160 ripemd;
ripemd160(&ripemd, payment_hash->u.u8, sizeof(payment_hash->u)); ripemd160(&ripemd, payment_hash->u.u8, sizeof(payment_hash->u));
return bitcoin_wscript_htlc_offer_ripemd160(ctx, localkey, remotekey, return bitcoin_wscript_htlc_offer_ripemd160(ctx, localhtlckey,
remotehtlckey,
&ripemd, revocationkey); &ripemd, revocationkey);
} }
@ -606,12 +607,12 @@ u8 *bitcoin_wscript_htlc_offer(const tal_t *ctx,
* OP_IF * OP_IF
* OP_CHECKSIG * OP_CHECKSIG
* OP_ELSE * OP_ELSE
* <remotekey> OP_SWAP * <remote_htlckey> OP_SWAP
* OP_SIZE 32 OP_EQUAL * OP_SIZE 32 OP_EQUAL
* OP_IF * OP_IF
* # To me via HTLC-success transaction. * # To me via HTLC-success transaction.
* OP_HASH160 <RIPEMD160(payment_hash)> OP_EQUALVERIFY * OP_HASH160 <RIPEMD160(payment_hash)> OP_EQUALVERIFY
* 2 OP_SWAP <localkey> 2 OP_CHECKMULTISIG * 2 OP_SWAP <local_htlckey> 2 OP_CHECKMULTISIG
* OP_ELSE * OP_ELSE
* # To you after timeout. * # To you after timeout.
* OP_DROP <cltv_expiry> OP_CHECKLOCKTIMEVERIFY OP_DROP * OP_DROP <cltv_expiry> OP_CHECKLOCKTIMEVERIFY OP_DROP
@ -621,8 +622,8 @@ u8 *bitcoin_wscript_htlc_offer(const tal_t *ctx,
*/ */
u8 *bitcoin_wscript_htlc_receive_ripemd(const tal_t *ctx, u8 *bitcoin_wscript_htlc_receive_ripemd(const tal_t *ctx,
const struct abs_locktime *htlc_abstimeout, const struct abs_locktime *htlc_abstimeout,
const struct pubkey *localkey, const struct pubkey *localhtlckey,
const struct pubkey *remotekey, const struct pubkey *remotehtlckey,
const struct ripemd160 *payment_ripemd, const struct ripemd160 *payment_ripemd,
const struct pubkey *revocationkey) const struct pubkey *revocationkey)
{ {
@ -637,7 +638,7 @@ u8 *bitcoin_wscript_htlc_receive_ripemd(const tal_t *ctx,
add_op(&script, OP_IF); add_op(&script, OP_IF);
add_op(&script, OP_CHECKSIG); add_op(&script, OP_CHECKSIG);
add_op(&script, OP_ELSE); add_op(&script, OP_ELSE);
add_push_key(&script, remotekey); add_push_key(&script, remotehtlckey);
add_op(&script, OP_SWAP); add_op(&script, OP_SWAP);
add_op(&script, OP_SIZE); add_op(&script, OP_SIZE);
add_number(&script, 32); add_number(&script, 32);
@ -649,7 +650,7 @@ u8 *bitcoin_wscript_htlc_receive_ripemd(const tal_t *ctx,
add_op(&script, OP_EQUALVERIFY); add_op(&script, OP_EQUALVERIFY);
add_number(&script, 2); add_number(&script, 2);
add_op(&script, OP_SWAP); add_op(&script, OP_SWAP);
add_push_key(&script, localkey); add_push_key(&script, localhtlckey);
add_number(&script, 2); add_number(&script, 2);
add_op(&script, OP_CHECKMULTISIG); add_op(&script, OP_CHECKMULTISIG);
add_op(&script, OP_ELSE); add_op(&script, OP_ELSE);
@ -666,8 +667,8 @@ u8 *bitcoin_wscript_htlc_receive_ripemd(const tal_t *ctx,
u8 *bitcoin_wscript_htlc_receive(const tal_t *ctx, u8 *bitcoin_wscript_htlc_receive(const tal_t *ctx,
const struct abs_locktime *htlc_abstimeout, const struct abs_locktime *htlc_abstimeout,
const struct pubkey *localkey, const struct pubkey *localhtlckey,
const struct pubkey *remotekey, const struct pubkey *remotehtlckey,
const struct sha256 *payment_hash, const struct sha256 *payment_hash,
const struct pubkey *revocationkey) const struct pubkey *revocationkey)
{ {
@ -675,7 +676,7 @@ u8 *bitcoin_wscript_htlc_receive(const tal_t *ctx,
ripemd160(&ripemd, payment_hash->u.u8, sizeof(payment_hash->u)); ripemd160(&ripemd, payment_hash->u.u8, sizeof(payment_hash->u));
return bitcoin_wscript_htlc_receive_ripemd(ctx, htlc_abstimeout, return bitcoin_wscript_htlc_receive_ripemd(ctx, htlc_abstimeout,
localkey, remotekey, localhtlckey, remotehtlckey,
&ripemd, revocationkey); &ripemd, revocationkey);
} }
@ -684,18 +685,18 @@ u8 *bitcoin_wscript_htlc_receive(const tal_t *ctx,
* ## HTLC-Timeout and HTLC-Success Transactions * ## HTLC-Timeout and HTLC-Success Transactions
* *
*... *...
* * `txin[0]` witness stack: `0 <remotesig> <localsig> <payment_preimage>` for HTLC-Success, `0 <remotesig> <localsig> 0` for HTLC-Timeout. * * `txin[0]` witness stack: `0 <remotehtlcsig> <localhtlcsig> <payment_preimage>` for HTLC-Success, `0 <remotehtlcsig> <localhtlcsig> 0` for HTLC-Timeout.
*/ */
u8 **bitcoin_witness_htlc_timeout_tx(const tal_t *ctx, u8 **bitcoin_witness_htlc_timeout_tx(const tal_t *ctx,
const secp256k1_ecdsa_signature *localsig, const secp256k1_ecdsa_signature *localhtlcsig,
const secp256k1_ecdsa_signature *remotesig, const secp256k1_ecdsa_signature *remotehtlcsig,
const u8 *wscript) const u8 *wscript)
{ {
u8 **witness = tal_arr(ctx, u8 *, 5); u8 **witness = tal_arr(ctx, u8 *, 5);
witness[0] = stack_number(witness, 0); witness[0] = stack_number(witness, 0);
witness[1] = stack_sig(witness, remotesig); witness[1] = stack_sig(witness, remotehtlcsig);
witness[2] = stack_sig(witness, localsig); witness[2] = stack_sig(witness, localhtlcsig);
witness[3] = stack_number(witness, 0); witness[3] = stack_number(witness, 0);
witness[4] = tal_dup_arr(witness, u8, wscript, tal_len(wscript), 0); witness[4] = tal_dup_arr(witness, u8, wscript, tal_len(wscript), 0);
@ -703,7 +704,7 @@ u8 **bitcoin_witness_htlc_timeout_tx(const tal_t *ctx,
} }
u8 **bitcoin_witness_htlc_success_tx(const tal_t *ctx, u8 **bitcoin_witness_htlc_success_tx(const tal_t *ctx,
const secp256k1_ecdsa_signature *localsig, const secp256k1_ecdsa_signature *localhtlcsig,
const secp256k1_ecdsa_signature *remotesig, const secp256k1_ecdsa_signature *remotesig,
const struct preimage *preimage, const struct preimage *preimage,
const u8 *wscript) const u8 *wscript)
@ -712,7 +713,7 @@ u8 **bitcoin_witness_htlc_success_tx(const tal_t *ctx,
witness[0] = stack_number(witness, 0); witness[0] = stack_number(witness, 0);
witness[1] = stack_sig(witness, remotesig); witness[1] = stack_sig(witness, remotesig);
witness[2] = stack_sig(witness, localsig); witness[2] = stack_sig(witness, localhtlcsig);
witness[3] = stack_preimage(witness, preimage); witness[3] = stack_preimage(witness, preimage);
witness[4] = tal_dup_arr(witness, u8, wscript, tal_len(wscript), 0); witness[4] = tal_dup_arr(witness, u8, wscript, tal_len(wscript), 0);

View File

@ -90,8 +90,8 @@ u8 **bitcoin_to_local_spend_revocation(const tal_t *ctx,
/* BOLT #3 offered/accepted HTLC outputs */ /* BOLT #3 offered/accepted HTLC outputs */
u8 *bitcoin_wscript_htlc_offer(const tal_t *ctx, u8 *bitcoin_wscript_htlc_offer(const tal_t *ctx,
const struct pubkey *localkey, const struct pubkey *localhtlckey,
const struct pubkey *remotekey, const struct pubkey *remotehtlckey,
const struct sha256 *payment_hash, const struct sha256 *payment_hash,
const struct pubkey *revocationkey); const struct pubkey *revocationkey);
u8 **bitcoin_witness_htlc_timeout_tx(const tal_t *ctx, u8 **bitcoin_witness_htlc_timeout_tx(const tal_t *ctx,
@ -112,8 +112,8 @@ u8 **bitcoin_witness_htlc_success_tx(const tal_t *ctx,
/* Underlying functions for penalties, where we only keep ripemd160 */ /* Underlying functions for penalties, where we only keep ripemd160 */
u8 *bitcoin_wscript_htlc_offer_ripemd160(const tal_t *ctx, u8 *bitcoin_wscript_htlc_offer_ripemd160(const tal_t *ctx,
const struct pubkey *localkey, const struct pubkey *localhtlckey,
const struct pubkey *remotekey, const struct pubkey *remotehtlckey,
const struct ripemd160 *payment_ripemd, const struct ripemd160 *payment_ripemd,
const struct pubkey *revocationkey); const struct pubkey *revocationkey);
u8 *bitcoin_wscript_htlc_receive_ripemd(const tal_t *ctx, u8 *bitcoin_wscript_htlc_receive_ripemd(const tal_t *ctx,