Browse Source

wallet: Use newindex primitive to generate change key index

Signed-off-by: Christian Decker <decker.christian@gmail.com>
ppa-0.6.1
Christian Decker 7 years ago
parent
commit
e4e9e22fe8
  1. 4
      lightningd/build_utxos.c

4
lightningd/build_utxos.c

@ -15,7 +15,6 @@ const struct utxo **build_utxos(const tal_t *ctx,
u64 *change_satoshis, u32 *change_keyindex) u64 *change_satoshis, u32 *change_keyindex)
{ {
u64 fee_estimate = 0; u64 fee_estimate = 0;
u64 bip32_max_index = db_get_intvar(ld->wallet->db, "bip32_max_index", 0);
const struct utxo **utxos = const struct utxo **utxos =
wallet_select_coins(ctx, ld->wallet, satoshi_out, feerate_per_kw, wallet_select_coins(ctx, ld->wallet, satoshi_out, feerate_per_kw,
outputscriptlen, outputscriptlen,
@ -30,8 +29,7 @@ const struct utxo **build_utxos(const tal_t *ctx,
*change_satoshis = 0; *change_satoshis = 0;
*change_keyindex = 0; *change_keyindex = 0;
} else { } else {
*change_keyindex = bip32_max_index + 1; *change_keyindex = wallet_get_newindex(ld);
db_set_intvar(ld->wallet->db, "bip32_max_index", *change_keyindex);
} }
return utxos; return utxos;
} }

Loading…
Cancel
Save