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

'Dust' error when redeeming P2SH-B #14

Open
archived-2 opened this issue Aug 14, 2020 · 2 comments
Open

'Dust' error when redeeming P2SH-B #14

archived-2 opened this issue Aug 14, 2020 · 2 comments
Labels
question Further information is requested

Comments

@archived-2
Copy link

It looks like there is a repeatable issue with trades failing to complete. I have encountered this twice now in my two trade attempts.

Problem:
Trades get stuck in the BOB_WAITING_FOR_P2SH_B state for the seller, and the ALICE_WATCH_P2SH_B state for the buyer, when performed on the main BTC network.

Details:
I have tracked this down to an issue with BTC.getInstance().broadcastTransaction() in TradeBot.handleBobWaitingForP2shB(). This is the transaction that is attempting to redeem the P2SH-B. Electrum nodes respond with the error:

ElectrumX:461 - Response: {"error":"sendrawtransaction RPC error: {\"code\":-26,\"message\":\"dust\"}","id":30,"jsonrpc":"2.0"}

or alternatively:

Response: {"jsonrpc": "2.0", "error": {"code": 1, "message": "the transaction was rejected by network rules.\n\ndust\n

The redeem transaction is broadcast over and over, but never succeeds. To me, it looks as though the amount held in the P2SH-B is too small for the bitcoin RPC on the Electrum nodes to allow it to be broadcast. As a result, the trade is blocked from this point onwards.

Solution:
I think I will need some input from cat on how to move forward with this, but I suspect to amount sent to P2SH-B will need to be increased so that it is above the minimum value.

The amount funded to PS2H-B is defined by:
private static final long FEE_AMOUNT = 5000L;

However, it appears that the 'dust' threshold varies per Electrum client and isn't a universally known value. Simply adding more Electrum nodes may be enough, however I think we may need to increase the value to ensure the transactions to be broadcast reliably.

@archived-2
Copy link
Author

archived-2 commented Aug 14, 2020

I'm making some progress. It seems that the 'dust' amount isn't the 5000 sats that the transaction was funded with. It's actually the zero sats that the trade bot is using as the value to redeem.

Coin redeemAmount = Coin.ZERO; // The real funds are in P2SH-A

The actual dust threshold is 3000 sats per kB, and my P2SH-B transaction is 224 bytes. So I'd expect the dust threshold to always be below 1000.

As a test, I tried with Coin redeemAmount = Coin.valueOf(1000); This allowed the transaction to be broadcast, and the trade proceeded to complete.

So the problem is that we are not allowed to redeem zero sats from P2SH-B. In my case it had to be a minimum of 657 sats.

@archived-2
Copy link
Author

archived-2 commented Aug 15, 2020

One downside of the above approach of redeeming 1000 sats, is that the seller obviously receives 1000 sats more than they are expecting. See the example below - the original agreed sale amount was 0.00165000 BTC, but they received 0.00166000 BTC:

https://www.blockchain.com/btc/address/13aefhjgRcF75ef7b7BUFAHvPEz6fnbSuf

If this is a problem, we could reduce the amount funded into P2SH-A by the same amount.

@catbref catbref added the question Further information is requested label Sep 1, 2020
QuickMythril pushed a commit that referenced this issue Nov 16, 2023
Merge pull request #142 from AlphaX-Projects/master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants