-1

I have a use case here where I want to display spendable bitcoin amount (that minus unconfirmed transaction). Is there any existing api or library that cater for that?

Let say wallet A has 10 btc. Then wallet A send few transactions that is still unconfirmed
Transaction 1 - 1 btc
Transaction 2 - 2 btc
Transaction 3 - 3 btc
All with 0.001 transaction fee

By default, when i get the wallet balance, I will get 10 btc because the transaction is still unconfirmed.

Preferrably i will also want to show that there is also 6.003 btc is still in lock for unconfirmed transaction.

I think this is a very user friendly display for user but I cannot find any pre-built library or api for it.

My use case is as follow:
1) I own the user bitcoin wallet private key
2) The bitcoin wallet is used to send transaction internally to another wallet to buy some product (without confirmation needed)
3) So, in order to prevent user double spend, I need to include additional logic of checking spendable bitcoin amount that minus outgoing unconfirmed transaction before sending.

In other words, now user have 10 btc and 6.003 in lock (as it is unconfirmed) and therefore user can only maximum send 3.997 btc. so user cannot double spend as they don't own the private key and need to send transaction through the system.

  • "By default, when i get the wallet balance, I will get 10 btc because the transaction is still unconfirmed." Where do you see such a behavior? My experience is rather that wallet's deduct sent amounts even before they're confirmed from the balance. – Murch Dec 20 '18 at 18:53

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.