mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-12 18:49:42 +01:00
Revert "core: Add a function check if a script is P2WSH without allocating"
The is_xxx script functions already perform these checks for us without
allocating. They currently expect their memory to be tal-allocated,
which is why a copy is made. However:
- The memory already *is* tal-allocated since wally is configured to do so.
- The tal-dependency is artifical and is removed in a future commit in
this PR.
This reverts commit c329756723
.
Signed-off-by: Jon Griffiths <jon_p_griffiths@yahoo.com>
This commit is contained in:
parent
0578069a7a
commit
5dd8d933d5
4 changed files with 3 additions and 21 deletions
|
@ -10,6 +10,9 @@
|
||||||
#include <common/utils.h>
|
#include <common/utils.h>
|
||||||
#include <sodium/randombytes.h>
|
#include <sodium/randombytes.h>
|
||||||
|
|
||||||
|
/* To push 0-75 bytes onto stack. */
|
||||||
|
#define OP_PUSHBYTES(val) (val)
|
||||||
|
|
||||||
/* Bitcoin's OP_HASH160 is RIPEMD(SHA256()) */
|
/* Bitcoin's OP_HASH160 is RIPEMD(SHA256()) */
|
||||||
static void hash160(struct ripemd160 *redeemhash, const void *mem, size_t len)
|
static void hash160(struct ripemd160 *redeemhash, const void *mem, size_t len)
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,9 +13,6 @@ struct ripemd160;
|
||||||
struct rel_locktime;
|
struct rel_locktime;
|
||||||
struct abs_locktime;
|
struct abs_locktime;
|
||||||
|
|
||||||
/* To push 0-75 bytes onto stack. */
|
|
||||||
#define OP_PUSHBYTES(val) (val)
|
|
||||||
|
|
||||||
/* tal_count() gives the length of the script. */
|
/* tal_count() gives the length of the script. */
|
||||||
u8 *bitcoin_redeem_2of2(const tal_t *ctx,
|
u8 *bitcoin_redeem_2of2(const tal_t *ctx,
|
||||||
const struct pubkey *key1,
|
const struct pubkey *key1,
|
||||||
|
|
10
bitcoin/tx.c
10
bitcoin/tx.c
|
@ -324,16 +324,6 @@ const u8 *bitcoin_tx_output_get_script(const tal_t *ctx,
|
||||||
return cln_wally_tx_output_get_script(ctx, output);
|
return cln_wally_tx_output_get_script(ctx, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool bitcoin_tx_output_script_is_p2wsh(const struct bitcoin_tx *tx, int outnum)
|
|
||||||
{ const struct wally_tx_output *output;
|
|
||||||
assert(outnum < tx->wtx->num_outputs);
|
|
||||||
output = &tx->wtx->outputs[outnum];
|
|
||||||
|
|
||||||
return output->script_len == BITCOIN_SCRIPTPUBKEY_P2WSH_LEN &&
|
|
||||||
output->script[0] == OP_0 &&
|
|
||||||
output->script[1] == OP_PUSHBYTES(sizeof(struct sha256));
|
|
||||||
}
|
|
||||||
|
|
||||||
u8 *bitcoin_tx_output_get_witscript(const tal_t *ctx, const struct bitcoin_tx *tx,
|
u8 *bitcoin_tx_output_get_witscript(const tal_t *ctx, const struct bitcoin_tx *tx,
|
||||||
int outnum)
|
int outnum)
|
||||||
{
|
{
|
||||||
|
|
|
@ -154,14 +154,6 @@ void bitcoin_tx_output_set_amount(struct bitcoin_tx *tx, int outnum,
|
||||||
*/
|
*/
|
||||||
const u8 *bitcoin_tx_output_get_script(const tal_t *ctx, const struct bitcoin_tx *tx, int outnum);
|
const u8 *bitcoin_tx_output_get_script(const tal_t *ctx, const struct bitcoin_tx *tx, int outnum);
|
||||||
|
|
||||||
/**
|
|
||||||
* Return `true` if the given output is a P2WSH output.
|
|
||||||
*
|
|
||||||
* This is useful if you want to peek at the script, without having to
|
|
||||||
* extract it first.
|
|
||||||
*/
|
|
||||||
bool bitcoin_tx_output_script_is_p2wsh(const struct bitcoin_tx *tx, int outnum);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper to get the script of a script's output as a tal_arr
|
* Helper to get the script of a script's output as a tal_arr
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue