mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
wallet: Use newindex primitive to generate change key index
Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
parent
3e0efb6f8d
commit
e4e9e22fe8
@ -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…
Reference in New Issue
Block a user