mirror of
https://github.com/aljazceru/lightning.git
synced 2026-02-09 08:04:19 +01:00
misc: remove some unused functions.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
1
Makefile
1
Makefile
@@ -21,7 +21,6 @@ TEST_PROGRAMS := \
|
||||
test/test_onion
|
||||
|
||||
BITCOIN_SRC := \
|
||||
bitcoin/address.c \
|
||||
bitcoin/base58.c \
|
||||
bitcoin/locktime.c \
|
||||
bitcoin/pubkey.c \
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
#include "address.h"
|
||||
#include "pubkey.h"
|
||||
#include <ccan/crypto/sha256/sha256.h>
|
||||
#include <ccan/mem/mem.h>
|
||||
|
||||
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));
|
||||
}
|
||||
@@ -4,13 +4,8 @@
|
||||
#include <ccan/crypto/ripemd160/ripemd160.h>
|
||||
#include <ccan/short_types/short_types.h>
|
||||
|
||||
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 */
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user