diff --git a/Makefile b/Makefile index c65a54488..7bdc1414f 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ CCANDIR := ccan # Where we keep the BOLT RFCs BOLTDIR := ../lightning-rfc/ -BOLTVERSION := 046f5acb1619bccf167e5539f144433495f1486b +BOLTVERSION := 4f91f0bb2a9c176dda019f9c0618c10f9fa0acfd # If you don't have (working) valgrind. #NO_VALGRIND := 1 diff --git a/bitcoin/script.c b/bitcoin/script.c index 22f5bd24d..83273dd35 100644 --- a/bitcoin/script.c +++ b/bitcoin/script.c @@ -528,10 +528,10 @@ u8 **bitcoin_to_local_spend_revocation(const tal_t *ctx, * OP_IF * OP_CHECKSIG * OP_ELSE - * OP_SWAP OP_SIZE 32 OP_EQUAL + * OP_SWAP OP_SIZE 32 OP_EQUAL * OP_NOTIF * # To me via HTLC-timeout transaction (timelocked). - * OP_DROP 2 OP_SWAP 2 OP_CHECKMULTISIG + * OP_DROP 2 OP_SWAP 2 OP_CHECKMULTISIG * OP_ELSE * # To you with preimage. * OP_HASH160 OP_EQUALVERIFY @@ -540,8 +540,8 @@ u8 **bitcoin_to_local_spend_revocation(const tal_t *ctx, * OP_ENDIF */ u8 *bitcoin_wscript_htlc_offer_ripemd160(const tal_t *ctx, - const struct pubkey *localkey, - const struct pubkey *remotekey, + const struct pubkey *localhtlckey, + const struct pubkey *remotehtlckey, const struct ripemd160 *payment_ripemd, 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_CHECKSIG); add_op(&script, OP_ELSE); - add_push_key(&script, remotekey); + add_push_key(&script, remotehtlckey); add_op(&script, OP_SWAP); add_op(&script, OP_SIZE); add_number(&script, 32); @@ -565,7 +565,7 @@ u8 *bitcoin_wscript_htlc_offer_ripemd160(const tal_t *ctx, add_op(&script, OP_DROP); add_number(&script, 2); add_op(&script, OP_SWAP); - add_push_key(&script, localkey); + add_push_key(&script, localhtlckey); add_number(&script, 2); add_op(&script, OP_CHECKMULTISIG); 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, - const struct pubkey *localkey, - const struct pubkey *remotekey, + const struct pubkey *localhtlckey, + const struct pubkey *remotehtlckey, const struct sha256 *payment_hash, const struct pubkey *revocationkey) { struct ripemd160 ripemd; 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); } @@ -606,12 +607,12 @@ u8 *bitcoin_wscript_htlc_offer(const tal_t *ctx, * OP_IF * OP_CHECKSIG * OP_ELSE - * OP_SWAP + * OP_SWAP * OP_SIZE 32 OP_EQUAL * OP_IF * # To me via HTLC-success transaction. * OP_HASH160 OP_EQUALVERIFY - * 2 OP_SWAP 2 OP_CHECKMULTISIG + * 2 OP_SWAP 2 OP_CHECKMULTISIG * OP_ELSE * # To you after timeout. * OP_DROP 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, const struct abs_locktime *htlc_abstimeout, - const struct pubkey *localkey, - const struct pubkey *remotekey, + const struct pubkey *localhtlckey, + const struct pubkey *remotehtlckey, const struct ripemd160 *payment_ripemd, 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_CHECKSIG); add_op(&script, OP_ELSE); - add_push_key(&script, remotekey); + add_push_key(&script, remotehtlckey); add_op(&script, OP_SWAP); add_op(&script, OP_SIZE); add_number(&script, 32); @@ -649,7 +650,7 @@ u8 *bitcoin_wscript_htlc_receive_ripemd(const tal_t *ctx, add_op(&script, OP_EQUALVERIFY); add_number(&script, 2); add_op(&script, OP_SWAP); - add_push_key(&script, localkey); + add_push_key(&script, localhtlckey); add_number(&script, 2); add_op(&script, OP_CHECKMULTISIG); 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, const struct abs_locktime *htlc_abstimeout, - const struct pubkey *localkey, - const struct pubkey *remotekey, + const struct pubkey *localhtlckey, + const struct pubkey *remotehtlckey, const struct sha256 *payment_hash, 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)); return bitcoin_wscript_htlc_receive_ripemd(ctx, htlc_abstimeout, - localkey, remotekey, + localhtlckey, remotehtlckey, &ripemd, revocationkey); } @@ -684,18 +685,18 @@ u8 *bitcoin_wscript_htlc_receive(const tal_t *ctx, * ## HTLC-Timeout and HTLC-Success Transactions * *... - * * `txin[0]` witness stack: `0 ` for HTLC-Success, `0 0` for HTLC-Timeout. + * * `txin[0]` witness stack: `0 ` for HTLC-Success, `0 0` for HTLC-Timeout. */ u8 **bitcoin_witness_htlc_timeout_tx(const tal_t *ctx, - const secp256k1_ecdsa_signature *localsig, - const secp256k1_ecdsa_signature *remotesig, + const secp256k1_ecdsa_signature *localhtlcsig, + const secp256k1_ecdsa_signature *remotehtlcsig, const u8 *wscript) { u8 **witness = tal_arr(ctx, u8 *, 5); witness[0] = stack_number(witness, 0); - witness[1] = stack_sig(witness, remotesig); - witness[2] = stack_sig(witness, localsig); + witness[1] = stack_sig(witness, remotehtlcsig); + witness[2] = stack_sig(witness, localhtlcsig); witness[3] = stack_number(witness, 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, - const secp256k1_ecdsa_signature *localsig, + const secp256k1_ecdsa_signature *localhtlcsig, const secp256k1_ecdsa_signature *remotesig, const struct preimage *preimage, const u8 *wscript) @@ -712,7 +713,7 @@ u8 **bitcoin_witness_htlc_success_tx(const tal_t *ctx, witness[0] = stack_number(witness, 0); 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[4] = tal_dup_arr(witness, u8, wscript, tal_len(wscript), 0); diff --git a/bitcoin/script.h b/bitcoin/script.h index f894e9ee6..6623e14a6 100644 --- a/bitcoin/script.h +++ b/bitcoin/script.h @@ -90,8 +90,8 @@ u8 **bitcoin_to_local_spend_revocation(const tal_t *ctx, /* BOLT #3 offered/accepted HTLC outputs */ u8 *bitcoin_wscript_htlc_offer(const tal_t *ctx, - const struct pubkey *localkey, - const struct pubkey *remotekey, + const struct pubkey *localhtlckey, + const struct pubkey *remotehtlckey, const struct sha256 *payment_hash, const struct pubkey *revocationkey); 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 */ u8 *bitcoin_wscript_htlc_offer_ripemd160(const tal_t *ctx, - const struct pubkey *localkey, - const struct pubkey *remotekey, + const struct pubkey *localhtlckey, + const struct pubkey *remotehtlckey, const struct ripemd160 *payment_ripemd, const struct pubkey *revocationkey); u8 *bitcoin_wscript_htlc_receive_ripemd(const tal_t *ctx,