question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Immature coinbase UTXOs counted towards balance

See original GitHub issue

Describe the bug If BTCPay is funded directly from bitcoin-cli -chain=regtest generate 6 ADDRESS_FROM_BTCPAY, the coinbase UTXOs didn’t reach maturity but the UI says balance is 300 BTC. Originally I thought sending is broken but realized that it’s actually that message.

To Reproduce the bug Steps to reproduce the reported bug:

  1. Setup regtest BTCPayServer instance
  2. Setup hot wallet
  3. Generate a deposit address for hot wallet
  4. run bitcoin-cli -chain=regtest generate 6 ADDRESS_FROM_BTCPAY
  5. Attempt to spend portion (e.g. 0.0042) of generated sats (300) - will say insufficient amount
  6. Generate 100 more blocks to a different address
  7. Attempt to spend all coins - will work

Expected behavior

The UI either reports balance without immature UTXOs and maybe additionally notes that there are immature UTXOs.

Screenshots

300-btc-is-not-enough

Your BTCPay Environment (please complete the following information):

  • BTCPay Server Version: 1.1.2
  • Deployment Method: Debian package
  • Browser: Firefox 78.11 ESR

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:14 (14 by maintainers)

github_iconTop GitHub Comments

2reactions
NicolasDoriercommented, Jul 31, 2021

I pushed a NBXplorer.Client version 4.0.1 and 2.1.54 for the docker image

@sageprogrammer you want to update NBXplorer on btcpayserver?

  • Just need to use balance.Available rather than balance.Total. (however use something like balance = balance.Available ?? balance.Total; so we make sure old version of NBX doesn’t crash btcpay)
  • Change message to your **available** balance is <available> BTC
  • If there is immature funds add a message like <immature> BTC are still immature and need additional confirmation.

No need to make a unit test imho, this is a real corner case and people having immature funds probably know what they are doing.

2reactions
sageprogrammercommented, Jul 29, 2021

@sageprogrammer the thing is immature is not unconfirmed either, it’s just immature. So basically there should be three fields: confirmed, immature, unconfirmed.

Correct, The GetBalance function in nbxplorer client will have to be changed first so that it returns confirmed, immature, unconfirmed. https://github.com/dgarage/NBXplorer/blob/853955171e8c19bffee47831a30fb4f8dc442cce/NBXplorer/Controllers/MainController.cs#L838 Then the UI can show these seperately. EDIT:Created a issue regarding this in NBXplorer https://github.com/dgarage/NBXplorer/issues/321

Read more comments on GitHub >

github_iconTop Results From Across the Web

bitcoind - How to get the immature balance of an account?
Using the listtransactions command, you can see your immature coinbase transactions listed with category immature .
Read more >
API Specification
Immature funds is the sum of UTXO's belonging to a coinbase transaction with less than 100 confirmations.
Read more >
Wallet RPCs — Dash Core latest documentation
The getbalance RPC gets the total available balance in Dash. ... immature. numeric. Optional (1 or more). Balance from immature coinbase outputs. →→...
Read more >
Bitcoin Developer Reference
All fields described below are counted towards the serialized size. ... By default, Bitcoin Core only stores complete transaction data for UTXOs and...
Read more >
Removed RPCs — Dash Core latest documentation
The getreceivedbyaccount RPC returns the total amount received by addresses in a particular account from transactions with the specified number of confirmations ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found