Skip to content

Commit dc4e78a

Browse files
committed
wallet: wallet_get_addrtype should tell caller it has no info.
Turns out we don't actually use this, so easy to change the function. Signed-off-by: Rusty Russell <[email protected]>
1 parent 79cb114 commit dc4e78a

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

wallet/wallet.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -857,10 +857,10 @@ s64 wallet_get_newindex(struct lightningd *ld, enum addrtype addrtype)
857857
return newidx;
858858
}
859859

860-
enum addrtype wallet_get_addrtype(struct wallet *wallet, u64 idx)
860+
bool wallet_get_addrtype(struct wallet *wallet, u64 idx,
861+
enum addrtype *addrtype)
861862
{
862863
struct db_stmt *stmt;
863-
enum addrtype type;
864864

865865
stmt = db_prepare_v2(wallet->db,
866866
SQL("SELECT addrtype"
@@ -872,12 +872,12 @@ enum addrtype wallet_get_addrtype(struct wallet *wallet, u64 idx)
872872
/* Unknown means prior to v24.11 */
873873
if (!db_step(stmt)) {
874874
tal_free(stmt);
875-
return ADDR_P2TR|ADDR_BECH32;
875+
return false;
876876
}
877877

878-
type = wallet_addrtype_in_db(db_col_int(stmt, "addrtype"));
878+
*addrtype = wallet_addrtype_in_db(db_col_int(stmt, "addrtype"));
879879
tal_free(stmt);
880-
return type;
880+
return true;
881881
}
882882

883883
static void wallet_shachain_init(struct wallet *wallet,

wallet/wallet.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,8 +606,12 @@ s64 wallet_get_newindex(struct lightningd *ld, enum addrtype addrtype);
606606
* wallet_get_addrtype - get the address types for this key.
607607
* @wallet: (in) wallet
608608
* @keyidx: what address types we've published.
609+
* @addrtype: filled in if true.
610+
*
611+
* If we don't know, returns false.
609612
*/
610-
enum addrtype wallet_get_addrtype(struct wallet *w, u64 keyidx);
613+
bool wallet_get_addrtype(struct wallet *wallet, u64 idx,
614+
enum addrtype *addrtype);
611615

612616
/**
613617
* wallet_shachain_add_hash -- wallet wrapper around shachain_add_hash

0 commit comments

Comments
 (0)