diff --git a/Makefile b/Makefile index 61d364bd7..7a444c0d0 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,6 @@ TEST_PROGRAMS := \ test/test_onion BITCOIN_SRC := \ - bitcoin/address.c \ bitcoin/base58.c \ bitcoin/locktime.c \ bitcoin/pubkey.c \ diff --git a/bitcoin/address.c b/bitcoin/address.c deleted file mode 100644 index 3c9e659a3..000000000 --- a/bitcoin/address.c +++ /dev/null @@ -1,12 +0,0 @@ -#include "address.h" -#include "pubkey.h" -#include -#include - -void bitcoin_address(const struct pubkey *key, struct bitcoin_address *addr) -{ - struct sha256 h; - - sha256(&h, memcheck(key->der, sizeof(key->der)), sizeof(key->der)); - ripemd160(&addr->addr, h.u.u8, sizeof(h)); -} diff --git a/bitcoin/address.h b/bitcoin/address.h index b17d1495a..38f075445 100644 --- a/bitcoin/address.h +++ b/bitcoin/address.h @@ -4,13 +4,8 @@ #include #include -struct pubkey; - /* An address is the RIPEMD160 of the SHA of the public key. */ struct bitcoin_address { struct ripemd160 addr; }; - -void bitcoin_address(const struct pubkey *key, - struct bitcoin_address *addr); #endif /* LIGHTNING_BITCOIN_ADDRESS_H */ diff --git a/bitcoin/script.c b/bitcoin/script.c index e5afd99ea..6795eb793 100644 --- a/bitcoin/script.c +++ b/bitcoin/script.c @@ -1,4 +1,3 @@ -#include "address.h" #include "locktime.h" #include "pubkey.h" #include "script.h" @@ -327,18 +326,6 @@ u8 *scriptpubkey_htlc_recv(const tal_t *ctx, return script; } -u8 *scriptsig_pay_to_pubkeyhash(const tal_t *ctx, - const struct pubkey *key, - const struct bitcoin_signature *sig) -{ - u8 *script = tal_arr(ctx, u8, 0); - - add_push_sig(&script, sig); - add_push_key(&script, key); - - return script; -} - /* Create scriptcode (fake witness, basically) for P2WPKH */ u8 *p2wpkh_scriptcode(const tal_t *ctx, const struct pubkey *key) { @@ -365,19 +352,6 @@ u8 *p2wpkh_scriptcode(const tal_t *ctx, const struct pubkey *key) return script; } -/* Assumes redeemscript contains CHECKSIG, not CHECKMULTISIG */ -u8 *scriptsig_p2sh_single_sig(const tal_t *ctx, - const u8 *redeem_script, - size_t redeem_len, - const struct bitcoin_signature *sig) -{ - u8 *script = tal_arr(ctx, u8, 0); - - add_push_sig(&script, sig); - add_push_bytes(&script, redeem_script, redeem_len); - return script; -} - u8 *scriptsig_p2sh_2of2(const tal_t *ctx, const struct bitcoin_signature *sig1, const struct bitcoin_signature *sig2, @@ -402,24 +376,6 @@ u8 *scriptsig_p2sh_2of2(const tal_t *ctx, return script; } -/* Is this a normal pay to pubkey hash? */ -bool is_pay_to_pubkey_hash(const u8 *script, size_t script_len) -{ - if (script_len != 25) - return false; - if (script[0] != OP_DUP) - return false; - if (script[1] != OP_HASH160) - return false; - if (script[2] != OP_PUSHBYTES(20)) - return false; - if (script[23] != OP_EQUALVERIFY) - return false; - if (script[24] != OP_CHECKSIG) - return false; - return true; -} - bool is_p2sh(const u8 *script, size_t script_len) { if (script_len != 23) diff --git a/bitcoin/script.h b/bitcoin/script.h index 8d736b81e..49e653d99 100644 --- a/bitcoin/script.h +++ b/bitcoin/script.h @@ -46,11 +46,6 @@ void bitcoin_witness_p2sh_p2wpkh(const tal_t *ctx, const struct bitcoin_signature *sig, const struct pubkey *key); -/* Create an input script to accept pay to pubkey */ -u8 *scriptsig_pay_to_pubkeyhash(const tal_t *ctx, - const struct pubkey *key, - const struct bitcoin_signature *sig); - /* Create scriptcode (fake witness, basically) for P2WPKH */ u8 *p2wpkh_scriptcode(const tal_t *ctx, const struct pubkey *key); @@ -85,15 +80,6 @@ u8 *scriptsig_p2sh_secret(const tal_t *ctx, const u8 *redeemscript, size_t redeem_len); -/* Create an input script which pushes sigs then redeem script. */ -u8 *scriptsig_p2sh_single_sig(const tal_t *ctx, - const u8 *redeem_script, - size_t redeem_len, - const struct bitcoin_signature *sig); - -/* Is this a normal pay to pubkey hash? */ -bool is_pay_to_pubkey_hash(const u8 *script, size_t script_len); - /* Is this a pay to script hash? */ bool is_p2sh(const u8 *script, size_t script_len); diff --git a/bitcoin/signature.c b/bitcoin/signature.c index 861dac746..ebe82d833 100644 --- a/bitcoin/signature.c +++ b/bitcoin/signature.c @@ -168,28 +168,6 @@ bool check_tx_sig(secp256k1_context *secpctx, return ret; } -bool check_2of2_sig(secp256k1_context *secpctx, - struct bitcoin_tx *tx, size_t input_num, - const u8 *redeemscript, size_t redeemscript_len, - const u8 *witness, - const struct pubkey *key1, const struct pubkey *key2, - const struct bitcoin_signature *sig1, - const struct bitcoin_signature *sig2) -{ - struct sha256_double hash; - assert(input_num < tx->input_count); - - sha256_tx_one_input(tx, input_num, redeemscript, redeemscript_len, - witness, &hash); - - /* We only use SIGHASH_ALL for the moment. */ - if (sig1->stype != SIGHASH_ALL || sig2->stype != SIGHASH_ALL) - return false; - - return check_signed_hash(secpctx, &hash, &sig1->sig, key1) - && check_signed_hash(secpctx, &hash, &sig2->sig, key2); -} - /* Stolen direct from bitcoin/src/script/sign.cpp: // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers diff --git a/bitcoin/signature.h b/bitcoin/signature.h index 768896c82..86fa599fb 100644 --- a/bitcoin/signature.h +++ b/bitcoin/signature.h @@ -51,14 +51,6 @@ bool check_tx_sig(secp256k1_context *secpctx, const struct pubkey *key, const struct bitcoin_signature *sig); -bool check_2of2_sig(secp256k1_context *secpctx, - struct bitcoin_tx *tx, size_t input_num, - const u8 *redeemscript, size_t redeemscript_len, - const u8 *witness, - const struct pubkey *key1, const struct pubkey *key2, - const struct bitcoin_signature *sig1, - const struct bitcoin_signature *sig2); - /* Signature must have low S value. */ bool sig_valid(const struct signature *s);