@@ -271,6 +271,30 @@ static inline enum channel_state channel_state_in_db(enum channel_state s)
271271 fatal ("%s: %u is invalid" , __func__ , s );
272272}
273273
274+ /* /!\ This is a DB ENUM, please do not change the numbering of any
275+ * already defined elements (adding is ok) /!\ */
276+ enum addrtype {
277+ ADDR_BECH32 = 2 ,
278+ ADDR_P2TR = 4 ,
279+ ADDR_ALL = (ADDR_BECH32 + ADDR_P2TR )
280+ };
281+
282+ static inline enum addrtype wallet_addrtype_in_db (enum addrtype t )
283+ {
284+ switch (t ) {
285+ case ADDR_BECH32 :
286+ BUILD_ASSERT (ADDR_BECH32 == 2 );
287+ return t ;
288+ case ADDR_P2TR :
289+ BUILD_ASSERT (ADDR_P2TR == 4 );
290+ return t ;
291+ case ADDR_ALL :
292+ BUILD_ASSERT (ADDR_ALL == 6 );
293+ return t ;
294+ }
295+ fatal ("%s: %u is invalid" , __func__ , t );
296+ }
297+
274298/* A database backed shachain struct. The datastructure is
275299 * writethrough, reads are performed from an in-memory version, all
276300 * writes are passed through to the DB. */
@@ -567,10 +591,18 @@ bool wallet_can_spend(struct wallet *w,
567591/**
568592 * wallet_get_newindex - get a new index from the wallet.
569593 * @ld: (in) lightning daemon
594+ * @addrtype: (in) addess types we will publish for this
570595 *
571596 * Returns -1 on error (key exhaustion).
572597 */
573- s64 wallet_get_newindex (struct lightningd * ld );
598+ s64 wallet_get_newindex (struct lightningd * ld , enum addrtype addrtype );
599+
600+ /**
601+ * wallet_get_addrtype - get the address types for this key.
602+ * @wallet: (in) wallet
603+ * @keyidx: what address types we've published.
604+ */
605+ enum addrtype wallet_get_addrtype (struct wallet * w , u64 keyidx );
574606
575607/**
576608 * wallet_shachain_add_hash -- wallet wrapper around shachain_add_hash
0 commit comments