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 on LTC #778

Closed
cipig opened this issue Dec 20, 2020 · 8 comments · Fixed by #797
Closed

dust on LTC #778

cipig opened this issue Dec 20, 2020 · 8 comments · Fixed by #797
Assignees

Comments

@cipig
Copy link
Member

cipig commented Dec 20, 2020

We have a psoblem with dust tx, especially on LTC. Here are 4 examples from the last 24h:
https://dexapi.cipig.net/public/error.php?uuid=57ea5bbc-1ece-4701-b85b-eca26d97f24d
https://dexapi.cipig.net/public/error.php?uuid=772124c1-1be8-4c0d-9ff7-cf37cdd1166f
https://dexapi.cipig.net/public/error.php?uuid=a6faae98-58ba-4de7-9916-6baafa9c9df8
https://dexapi.cipig.net/public/error.php?uuid=69179a27-2ab0-4a3d-ac1a-fad511f36435

All failed with TakerPaymentTransactionFailed.

Found this document that explains dust on LTC:
https://theliteschool.com/lsc/staging-core-releases-and-litecoin-dust

Can we please try to fix this?

@artemii235
Copy link
Member

artemii235 commented Dec 22, 2020

@cipig Hi, thanks for creating the issue and posting the link to the LTC dust explanation! According to doc LTC has a 5460 litoshis dust threshold, all transactions from failed swaps have change output below this threshold. Could you please check that transactions with outputs below 5460 litoshis are rejected and transactions with output above 5460 are accepted?

@cipig
Copy link
Member Author

cipig commented Dec 22, 2020

Don't know how to create such a tx to test, so i had a look at some LTC swaps on AtomicDEX from the last 7 days.
This here were all successful and change output is > 5460 on TakerFee and TakerPayment (taker_coin is LTC):
cce171a7-8311-4d1c-85bd-400649bf985d
c4045daa-7af1-4270-8334-6118565f0a06
2f8ee544-cf1d-4cf3-a670-de8ab37a744d
6eea10cf-b104-4cdb-b764-7b23f8163461
da6b6c9d-5a20-427d-bada-b06d37d323ad
b6d9ac4b-4870-4b1e-b9a9-e3fa342a3ea4

I also looked at the failed ones on TakerPayment and their TakerFee also have change > 5460 whereas their failed TakerPayment is lower 5460.

@artemii235
Copy link
Member

Don't know how to create such a tx to test

You can try to call MM2 withdraw to your own address using the 0.00005459 amount, it will create a transaction with an output of 5459 litoshis.

@cipig
Copy link
Member Author

cipig commented Dec 22, 2020

ok, withdraw of 0.00005459 leads to dust error on broadcast:

{"error":"rpc:235] lp_coins:864] utxo_common:1066] JsonRpcError { client_info: \"coin: LTC\", request: JsonRpcRequest { jsonrpc: \"1.0\", id: \"117765\", method: \"sendrawtransaction\", params: [String(\"01000000012a4b8fd516db0ab75706319a74b411b1d39cbadea73ae53d094ddfb730e63c23000000006a4730440220405c7f9dd62f11d2b60b94ad98eaa68b174bdc6b1829aaf1a87508b728c0b45302200efda5bfe4b63a230b7be236d362b90a83a2bd9972dcea471a5cc96bfaa913360121031bb83b58ec130e28e0a6d5d2acf2eb01b0d3f1670e021d47d31db8a858219da8ffffffff0253150000000000001976a914c3f710deb7320b0efa6edb14e3ebeeb9155fa90d88acdeac8e01000000001976a914c3f710deb7320b0efa6edb14e3ebeeb9155fa90d88ac07cee15f\")] }, error: Transport(\"rpc_clients:440] Rpc request JsonRpcRequest { jsonrpc: \\\"1.0\\\", id: \\\"117765\\\", method: \\\"sendrawtransaction\\\", params: [String(\\\"01000000012a4b8fd516db0ab75706319a74b411b1d39cbadea73ae53d094ddfb730e63c23000000006a4730440220405c7f9dd62f11d2b60b94ad98eaa68b174bdc6b1829aaf1a87508b728c0b45302200efda5bfe4b63a230b7be236d362b90a83a2bd9972dcea471a5cc96bfaa913360121031bb83b58ec130e28e0a6d5d2acf2eb01b0d3f1670e021d47d31db8a858219da8ffffffff0253150000000000001976a914c3f710deb7320b0efa6edb14e3ebeeb9155fa90d88acdeac8e01000000001976a914c3f710deb7320b0efa6edb14e3ebeeb9155fa90d88ac07cee15f\\\")] } failed with HTTP status code 500 Internal Server Error, response body: {\\\"result\\\":null,\\\"error\\\":{\\\"code\\\":-26,\\\"message\\\":\\\"dust (code 64)\\\"},\\\"id\\\":\\\"117765\\\"}\\n\") }"}

this are the outputs of the failed tx:

  "vout": [
    {
      "value": 0.00005459,
      "n": 0,
      "scriptPubKey": {
        "asm": "OP_DUP OP_HASH160 c3f710deb7320b0efa6edb14e3ebeeb9155fa90d OP_EQUALVERIFY OP_CHECKSIG",
        "hex": "76a914c3f710deb7320b0efa6edb14e3ebeeb9155fa90d88ac",
        "reqSigs": 1,
        "type": "pubkeyhash",
        "addresses": [
          "Ld6814QT6fyChvvX3gmhNHbRDyiMBvPr9s"
        ]
      }
    },
    {
      "value": 0.26127582,
      "n": 1,
      "scriptPubKey": {
        "asm": "OP_DUP OP_HASH160 c3f710deb7320b0efa6edb14e3ebeeb9155fa90d OP_EQUALVERIFY OP_CHECKSIG",
        "hex": "76a914c3f710deb7320b0efa6edb14e3ebeeb9155fa90d88ac",
        "reqSigs": 1,
        "type": "pubkeyhash",
        "addresses": [
          "Ld6814QT6fyChvvX3gmhNHbRDyiMBvPr9s"
        ]
      }
    }
  ]
}

and withdraw of 5460 shows no error and the tx is broadcasted: https://blockchair.com/litecoin/transaction/c70f1c2b1dea0a5ab9524ea8877b0de4cb01d80478085961d652186bfd4f4dee

@artemii235 artemii235 self-assigned this Dec 22, 2020
@artemii235
Copy link
Member

I see, we need to handle this 5460 dust threshold separately for LTC then. I plan to add the dust_amount to the coins config for this purpose. The MM2 structs for UTXO coins have this field already, but it is hardcoded as of now, we need to take it from config instead.

@sergeyboyko0791 sergeyboyko0791 linked a pull request Feb 1, 2021 that will close this issue
@artemii235
Copy link
Member

artemii235 commented Feb 3, 2021

@cipig Sergey added dust param to coins config along with another task. Can you test it, please?
It is set in satoshis, for example: "dust": 72800.

@artemii235 artemii235 reopened this Feb 3, 2021
@cipig
Copy link
Member Author

cipig commented Feb 3, 2021

I tested it with EMC2 and it works fine. Dust is set to 54600, txfee is fixed to 100000 and this is the MakerPayment tx
https://chainz.cryptoid.info/emc2/tx.dws?0ee05f96ec482c64ee7581de6c6e8aa5d6798b211ae37146d167d2e1631b48a2.htm
The buy call was with \"volume\":0.00777010, the balance of the Maker was 0.009316.
Before the fix, it would have failed because 0.009316 - 0.0077701 - 0.001 = 0.00054590, now the swap worked and the 0.00054590 change was added to txfee. The balance on maker after swap is exact 0.
Now i need to find all the dust settings of our UTXO coins and configure them in coins file :-)

@cipig cipig closed this as completed Feb 3, 2021
@artemii235
Copy link
Member

Great, thanks for testing!

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

Successfully merging a pull request may close this issue.

2 participants