Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InsufficientMoneyException: Insufficient money, missing 0.0000001 BTC #4327

Closed
eigentsmis opened this issue Jun 20, 2020 · 8 comments · Fixed by #4345
Closed

InsufficientMoneyException: Insufficient money, missing 0.0000001 BTC #4327

eigentsmis opened this issue Jun 20, 2020 · 8 comments · Fixed by #4345

Comments

@eigentsmis
Copy link

eigentsmis commented Jun 20, 2020

Version: 1.3.5
Created an offer to sell BTC and after sending the funds from an external wallet to fund the offer and then trying to go ahead with the creation of the offer I got the following error message.
I've also attached the relevant portion of the log.

CreateOfferError

createOfferError.log

@ghost
Copy link

ghost commented Jun 20, 2020

Thanks for submitting this. Unfortunately the log provided does not help much, just Insufficient money, missing 0.0000001 BTC. We need to know how this occurs. What are the steps to reproduce this? What amounts do I need to enter in the offer, what amount do I have to fund my wallet, are there any other pre-conditions. Does it happen consistently?

@eigentsmis
Copy link
Author

There's not much else relevant in the log besides what I attached.
Steps to create the error were:

  1. Create a 0.01 BTC sell offer and pay trade fees with BSQ (didn't test with BTC for paying fees at the time so not sure if paying strictly with BSQ has a direct impact on this error scenario)
  2. Send funds from external wallet
  3. Review and create offer
  4. Error message pops up.
  5. Retried a few times step 3. but same error popped up so I had to cancel the offer and the funds appeared in my Bisq wallet (as expected)

Tried same steps again after restarting the app and same error scenario happened.
I've then sent all my Bisq funds to my external wallet and also resynced SPV chain.
After these steps it finally worked and I was able to create the offer.

@eigentsmis
Copy link
Author

Jun-20 15:30:49.936 [JavaFX Application Thread] INFO b.c.p.f.FeeService: BTC tx fee: txFeePerByte=10
Jun-20 15:35:50.050 [JavaFX Application Thread] INFO b.c.p.f.FeeService: BTC tx fee: txFeePerByte=10
Jun-20 15:40:50.104 [JavaFX Application Thread] INFO b.c.p.f.FeeService: BTC tx fee: txFeePerByte=10
[RESTARTED BISQ APP]
Jun-20 15:42:46.273 [JavaFX Application Thread] INFO b.c.p.f.FeeService: BTC tx fee: txFeePerByte=10
[BUG OCCURS at 15:44]
Jun-20 15:47:45.457 [JavaFX Application Thread] INFO b.c.p.f.FeeService: BTC tx fee: txFeePerByte=10

@eigentsmis
Copy link
Author

eigentsmis commented Jun 22, 2020

Why is the fee estimation done twice when creating an offer?
It seems that first it's done before funding the offer and afterwards it's done a second time after the user funded the offer and is ready to create it.

Upon further inspection of my log I see this estimate first:
Fee estimation resulted in a tx size of 557 bytes and a tx fee of 5570 Sat
I then fund the offer and try to finalize the offer and I see this new estimation in the log:
Fee estimation resulted in a tx size of 558 bytes and a tx fee of 5580 Sat
Hence the error message will pop up due to the "missing" 10 sats

@eigentsmis
Copy link
Author

eigentsmis commented Jun 22, 2020

When the initial transaction size estimation is done I see two inputs:
in PUSHDATA(71)
in PUSHDATA(72)
When the second estimation is done I also see two inputs but one is now 72 instead of 71
in PUSHDATA(72)
in PUSHDATA(72)
What could cause this discrepancy?
Could it be that one of the two estimations was done based on an already existent UTXO from my Bisq wallet instead of the new one where I sent the funds to fund the offer?

@ghost
Copy link

ghost commented Jun 22, 2020

After many many hours of repetition I got it to happen twice. Interestingly enough both times it happened first thing after starting bisq. What @eigentsmis has posted above matches what I'm seeing. After the offer has been funded, the fee estimation can return a tx size 1 or 2 bytes longer, this is due to scriptsig length varying.

#4266 would fix this because it uses the initial fee estimation instead of estimating again after funding.

Log files.

missingTenSats_eg1.txt
missingTenSats_eg2.txt

@eigentsmis
Copy link
Author

eigentsmis commented Jun 23, 2020

Super that you got it to reproduce!
Great find with the scriptsig length variation!
If those probabilities of signature sizes are correct though, should this issue not happen more often?
I'll take a look over your fix and hopefully test it out to confirm it solves this issue.

@ghost
Copy link

ghost commented Jun 24, 2020

I've been attempting to understand this some more:

  • Why does this not happen more often? The two times fee estimation is called, (before and after funding), all the parameters are identical. If any parameters to fee estimation are changed, the transaction will change (transaction malleability), resulting in the chance of the fee estimation changing.

  • Issue only occurs on the first offer after Bisq is started. Because initially the dummy output address used by fee estimation
    coincides with the funding address of the offer. After funding, the address is marked used and a new dummy address is chosen for the second fee estimation pass. This causes the scriptsigs to change and possibly become 1 byte longer, which requires a higher fee. At that point you get the missing funds exception.

  • But why only once after a restart? Well it seems that the dummy address for fee estimation is colliding with the offer funding address, first time only. If they were different this problem would never happen. So an alternate fix to Create order using the same tx fee specified at funding #4266 would be to use a better dummy fee estimation address (maybe a hardcoded one) that has no risk of changing.

Steps to reproduce the problem consistently:

  • open a terminal showing the current bisq log messages, e.g. tail -f ~/.local/share/Bisq/bisq.log
  • have two UTXOs in your bisq wallet: 0.016 and 0.001 BTC. If wallet was empty it would use a hard-coded fee estimate instead.
  • restart bisq
  • create an offer to sell 0.01 BTC, any price e.g. spot, fees paid in BTC, and hit Next Step
  • check in the log that the output addresses shown in the fee estimate matches the trade wallet address shown on the funding screen. This only happens for the first executed offer.
  • check in the log for Fee estimation resulted in a tx size of 406 bytes. If it is 407 or 408 then cancel, go back, try again with a minimally larger amount, e.g. 0.0101 BTC. (Each time you try with a different amount the fee estimation will change).
  • fund the offer exact amount from external wallet
  • click the red button Review offer and check the log again. Fee estimation resulted in a tx size of 408 bytes (or 407). As long as it is higher than before it will error out upon confirming the offer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant