Browse Source

Remove unused script functions now we use witness.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 9 years ago
parent
commit
f4e94147a7
  1. 46
      bitcoin/script.c
  2. 14
      bitcoin/script.h
  3. 15
      bitcoin/tx.c
  4. 7
      bitcoin/tx.h
  5. 11
      find_p2sh_out.c
  6. 7
      find_p2sh_out.h

46
bitcoin/script.c

@ -152,13 +152,6 @@ static u8 *stack_number(const tal_t *ctx, unsigned int num)
return tal_dup_arr(ctx, u8, &val, 1, 0);
}
static void add_push_sig(u8 **scriptp, const struct bitcoin_signature *sig)
{
u8 *der = stack_sig(*scriptp, sig);
add_push_bytes(scriptp, der, tal_count(der));
tal_free(der);
}
/* FIXME: permute? */
/* Is a < b? (If equal we don't care) */
static bool key_less(const struct pubkey *a, const struct pubkey *b)
@ -420,30 +413,6 @@ u8 *p2wpkh_scriptcode(const tal_t *ctx, const struct pubkey *key)
return script;
}
u8 *scriptsig_p2sh_2of2(const tal_t *ctx,
const struct bitcoin_signature *sig1,
const struct bitcoin_signature *sig2,
const struct pubkey *key1,
const struct pubkey *key2)
{
u8 *script = tal_arr(ctx, u8, 0);
u8 *redeemscript;
/* OP_CHECKMULTISIG has an out-by-one bug, which MBZ */
add_number(&script, 0);
/* sig order should match key order. */
if (key_less(key1, key2)) {
add_push_sig(&script, sig1);
add_push_sig(&script, sig2);
} else {
add_push_sig(&script, sig2);
add_push_sig(&script, sig1);
}
redeemscript = bitcoin_redeem_2of2(script, key1, key2);
add_push_bytes(&script, redeemscript, tal_count(redeemscript));
return script;
}
bool is_p2sh(const u8 *script, size_t script_len)
{
if (script_len != 23)
@ -493,21 +462,6 @@ u8 *bitcoin_redeem_secret_or_delay(const tal_t *ctx,
return script;
}
u8 *scriptsig_p2sh_secret(const tal_t *ctx,
const void *secret, size_t secret_len,
const struct bitcoin_signature *sig,
const u8 *redeemscript,
size_t redeem_len)
{
u8 *script = tal_arr(ctx, u8, 0);
add_push_sig(&script, sig);
add_push_bytes(&script, secret, secret_len);
add_push_bytes(&script, redeemscript, redeem_len);
return script;
}
u8 **bitcoin_witness_secret(const tal_t *ctx,
const void *secret, size_t secret_len,
const struct bitcoin_signature *sig,

14
bitcoin/script.h

@ -86,20 +86,6 @@ u8 **bitcoin_witness_secret(const tal_t *ctx,
const struct bitcoin_signature *sig,
const u8 *witnessscript);
/* Create an input script to accept pay to pubkey */
u8 *scriptsig_p2sh_2of2(const tal_t *ctx,
const struct bitcoin_signature *sig1,
const struct bitcoin_signature *sig2,
const struct pubkey *key1,
const struct pubkey *key2);
/* Create an input script to solve by secret */
u8 *scriptsig_p2sh_secret(const tal_t *ctx,
const void *secret, size_t secret_len,
const struct bitcoin_signature *sig,
const u8 *redeemscript,
size_t redeem_len);
/* Is this a pay to script hash? */
bool is_p2sh(const u8 *script, size_t script_len);

15
bitcoin/tx.c

@ -293,26 +293,11 @@ u8 *linearize_tx(const tal_t *ctx, const struct bitcoin_tx *tx)
return arr;
}
u8 *linearize_tx_force_extended(const tal_t *ctx,
const struct bitcoin_tx *tx)
{
u8 *arr = tal_arr(ctx, u8, 0);
add_tx(tx, add_linearize, &arr, true);
return arr;
}
static void add_measure(const void *data, size_t len, void *lenp)
{
*(size_t *)lenp += len;
}
size_t measure_tx_len(const struct bitcoin_tx *tx)
{
size_t len = 0;
add_tx(tx, add_measure, &len, uses_witness(tx));
return len;
}
size_t measure_tx_cost(const struct bitcoin_tx *tx)
{
size_t non_witness_len = 0, witness_len = 0;

7
bitcoin/tx.h

@ -49,13 +49,6 @@ void sha256_tx_for_sig(struct sha256_double *h, const struct bitcoin_tx *tx,
/* Linear bytes of tx. */
u8 *linearize_tx(const tal_t *ctx, const struct bitcoin_tx *tx);
/* Force linearization in extended form; useful if 0 inputs. */
u8 *linearize_tx_force_extended(const tal_t *ctx,
const struct bitcoin_tx *tx);
/* Get length of tx in bytes. */
size_t measure_tx_len(const struct bitcoin_tx *tx);
/* Get cost of tx in (x4 of non-witness bytecount). */
size_t measure_tx_cost(const struct bitcoin_tx *tx);

11
find_p2sh_out.c

@ -21,17 +21,6 @@ static u32 find_output(const struct bitcoin_tx *tx, const u8 *scriptpubkey)
return i;
}
u32 find_p2sh_out(const struct bitcoin_tx *tx, const u8 *redeemscript)
{
/* This is the scriptPubKey commit tx will have */
u8 *p2sh = scriptpubkey_p2sh(NULL, redeemscript);
u32 i;
i = find_output(tx, p2sh);
tal_free(p2sh);
return i;
}
u32 find_p2wsh_out(const struct bitcoin_tx *tx, const u8 *witnessscript)
{
/* This is the scriptPubKey commit tx will have */

7
find_p2sh_out.h

@ -5,11 +5,6 @@
struct bitcoin_tx;
/* Normally we'd simply remember which output of the anchor or commit
* tx is the one which pays to this script. But for these examples,
* we have to figure it out by recreating the output and matching. */
u32 find_p2sh_out(const struct bitcoin_tx *tx, const u8 *redeemscript);
/* Similar routine for finding a specific p2wsh output. */
/* Routine for finding a specific p2wsh output. */
u32 find_p2wsh_out(const struct bitcoin_tx *tx, const u8 *witnessscript);
#endif /* LIGHTNING_FIND_P2SH_OUT_H */

Loading…
Cancel
Save