diff --git a/lightningd/build_utxos.c b/lightningd/build_utxos.c index 85ba22946..93557dc2a 100644 --- a/lightningd/build_utxos.c +++ b/lightningd/build_utxos.c @@ -15,7 +15,6 @@ const struct utxo **build_utxos(const tal_t *ctx, u64 *change_satoshis, u32 *change_keyindex) { u64 fee_estimate = 0; - u64 bip32_max_index = db_get_intvar(ld->wallet->db, "bip32_max_index", 0); const struct utxo **utxos = wallet_select_coins(ctx, ld->wallet, satoshi_out, feerate_per_kw, outputscriptlen, @@ -30,8 +29,7 @@ const struct utxo **build_utxos(const tal_t *ctx, *change_satoshis = 0; *change_keyindex = 0; } else { - *change_keyindex = bip32_max_index + 1; - db_set_intvar(ld->wallet->db, "bip32_max_index", *change_keyindex); + *change_keyindex = wallet_get_newindex(ld); } return utxos; }