From e8f43ef6ca19d86e2a8929e0b657a3570f3f7ed8 Mon Sep 17 00:00:00 2001 From: Ken Sedgwick Date: Thu, 9 Dec 2021 10:05:58 -0800 Subject: [PATCH] wallet: make wallet_can_spend non-static because needed --- wallet/wallet.c | 4 ++-- wallet/wallet.h | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/wallet/wallet.c b/wallet/wallet.c index 98d650ba6..4d13d01bb 100644 --- a/wallet/wallet.c +++ b/wallet/wallet.c @@ -615,8 +615,8 @@ bool wallet_add_onchaind_utxo(struct wallet *w, return true; } -static bool wallet_can_spend(struct wallet *w, const u8 *script, - u32 *index, bool *output_is_p2sh) +bool wallet_can_spend(struct wallet *w, const u8 *script, + u32 *index, bool *output_is_p2sh) { struct ext_key ext; u64 bip32_max_index = db_get_intvar(w->db, "bip32_max_index", 0); diff --git a/wallet/wallet.h b/wallet/wallet.h index 619cb464b..ad73893ca 100644 --- a/wallet/wallet.h +++ b/wallet/wallet.h @@ -490,6 +490,19 @@ void wallet_unreserve_utxo(struct wallet *w, struct utxo *utxo, struct utxo *wallet_utxo_get(const tal_t *ctx, struct wallet *w, const struct bitcoin_outpoint *outpoint); +/** + * wallet_can_spend - Do we have the private key matching this scriptpubkey? + * + * FIXME: This is very slow with lots of inputs! + * + * @w: (in) wallet holding the pubkeys to check against (privkeys are on HSM) + * @script: (in) the script to check + * @index: (out) the bip32 derivation index that matched the script + * @output_is_p2sh: (out) whether the script is a p2sh, or p2wpkh + */ +bool wallet_can_spend(struct wallet *w, const u8 *script, + u32 *index, bool *output_is_p2sh); + /** * wallet_get_newindex - get a new index from the wallet. * @ld: (in) lightning daemon