Describe the bug
I've noticed a strange behaviour of the get_balance API.
To Reproduce
Creating a new wallet and sending some funds to it produces the following balance:
spendable: 0
total: 10000
immature: 0
confirmed: 0
trusted pending: 0
untrusted pending: 10000
Since the spendable balance is 0 I assumed it was not possible to send funds, but still I've been able to spend the funds and bdk now reports the following balance:
spendable: 8859
total: 8859
immature: 0
confirmed: 0
trusted pending: 8859
untrusted pending: 0
Maybe this is not a bug and is just a matter of naming, but to me spendable should reflect the amount of funds that is possible to spend.
Expected behavior
I see that you documented spendable as the "sum of trusted_pending and confirmed coins", so IMO a more fitting name could be safe_to_spend balance.
Moreover we probably need also a spendable balance defined as the sum of funds that can be spent, that I think will be the sum of all balances except the immature one.
Build environment
- BDK tag/commit:
v0.24.0
- OS+version:
debian 11
- Rust/Cargo version:
1.65.0
- Rust/Cargo target:
x86_64-unknown-linux-gnu
Describe the bug
I've noticed a strange behaviour of the
get_balanceAPI.To Reproduce
Creating a new wallet and sending some funds to it produces the following balance:
Since the spendable balance is
0I assumed it was not possible to send funds, but still I've been able to spend the funds and bdk now reports the following balance:Maybe this is not a bug and is just a matter of naming, but to me
spendableshould reflect the amount of funds that is possible to spend.Expected behavior
I see that you documented
spendableas the "sum of trusted_pending and confirmed coins", so IMO a more fitting name could besafe_to_spendbalance.Moreover we probably need also a
spendablebalance defined as the sum of funds that can be spent, that I think will be the sum of all balances except theimmatureone.Build environment
v0.24.0debian 111.65.0x86_64-unknown-linux-gnu