atomiclabs / hyperdex

Grandma-Friendly Atomic Swaps
MIT License
152 stars 60 forks source link

Cannot withdraw entire balance of Komodo (KMD) #302

Open VONLUEAPS opened 6 years ago

VONLUEAPS commented 6 years ago

image

Unhandled Promise Rejection Error: Couldn't create withdrawal transaction: { txid: '0000000000000000000000000000000000000000000000000000000000000000', txfee: 1000, complete: false } at errorWithObject (app://-/bundle.js:90100:46) at app://-/bundle.js:90357:11 at Generator.next () at step (app://-/bundle.js:90089:191) at app://-/bundle.js:90089:361 at

This is because the transmission fee (0.00001 KMD) was not calculated when you clicked the Max button.

lukechilds commented 6 years ago

Thanks, yeah we're aware of this, we need to properly handle this.

Only issue is it works completely differently with Bitcoin because it uses dynamic fees. It would be helpful if the API response gave us a reason why creating the TX failed, and if it's value related, what the max values we can use are.

@jl777 or @artemii235, is this something that would be simple to add?

sindresorhus commented 5 years ago

@artemii235 :arrow_up:

artemii235 commented 5 years ago

Please check mm console log when you get errors, it might give better description. It worth to add detailed error description to every API call, however it's not really possible in MM 1.0. MM2.0 will provide better error messages.

sindresorhus commented 5 years ago

@artemii235 Looking at the mm logs might help us understand it, but it wouldn't help us differentiate between errors. We need better API responses.

jorian commented 5 years ago

There exists a txfee argument in the withdraw method. This let's you set the txfee manually, even for BTC. When you want to withdraw the complete balance, make the amount as defined in the outputs array subtract the txfee.

TX fee is in satoshis.


{
    "method": "withdraw",
    "coin": "KMD",
    "txfee":5000,
    "outputs": [
        {
            "Raddress": <MAX> - txfee
        }
    ]
}
lukechilds commented 5 years ago

@n41r0j but we have no idea what fee to set because we don't know how big the transaction is before it's created. If we set a fixed amount we could easily end up with a TX that massively over paid or that takes hours to confirm.

jorian commented 5 years ago

It might be a good idea to ask @jl777 to add a subtractfeefromamount argument to the withdraw method? Or, use estimatefee on the coin and use that estimated fee as txfee argument to the withdraw method? I'm not even sure the latter is even possible without using native daemons, though.

cipig commented 5 years ago

the withdraw call in marketmaker creates a transactions with a fee set at the value of "txfee" from coins file https://github.com/cipig/coins/blob/master/coins, so the total amount of the transactions is amount you entered + txfee from coins file

lukechilds commented 5 years ago

@n41r0j

It might be a good idea to ask @jl777 to add a subtractfeefromamount argument to the withdraw method?

Yeah, that would be good. Any chance you could do that @jl777?

@cipig

the withdraw call in marketmaker creates a transactions with a fee set at the value of "txfee" from coins file cipig/coins:coins@master, so the total amount of the transactions is amount you entered + txfee from coins file

Bitcoin doesn't use those values it estimates a fee based on the current fee market.