caivega / ipfslib

Other
2 stars 1 forks source link

S3 - 发送带小数的swt或者代币,如果精度很高,则发送失败 #159

Closed foreso-GitHub closed 3 years ago

foreso-GitHub commented 3 years ago

发送带小数的swt或者代币,如果精度很高,则发送失败。比如SWT,发送1.000001个SWT会失败,发送1.0001个则成功。代币发送也有同样的问题,发送精度接近decimals会失败。

版本:v0.5.3-dev-20201228-2d55b2941a775a8c090b9039d57ef805dba3c516

SWT请求:

{
    "jsonrpc": "2.0",
    "id": 6,
    "method": "jt_sendTransaction",
    "params": [
        {
            "from": "jMMzgdwbBwRp8GW5U1MZekbZzu8ShhYRWZ",
            "secret": "ss5niz4G66d12aWSPSrbekCvKLPb3",
            "to": "jNzf1jaGsZTESCrxUFD6XZDkiTpjpXvH1s",
            "value": "1.00001/SWT",
            "fee": "10",
            "memos": [
                "autotest: transfer test"
            ]
        }
    ]
}
{
    "error": {
        "count": 1,
        "description": "The compound error.",
        "information": "1 errors"
    },
    "id": 6,
    "jsonrpc": "2.0",
    "result": [
        {
            "error": {
                "description": "The transaction is ill-formed.",
                "information": "error value value",
                "message": {
                    "fee": "10",
                    "from": "jMMzgdwbBwRp8GW5U1MZekbZzu8ShhYRWZ",
                    "memos": [
                        "autotest: transfer test"
                    ],
                    "to": "jNzf1jaGsZTESCrxUFD6XZDkiTpjpXvH1s",
                    "value": "1.00001/SWT"
                }
            },
            "status": -278,
            "type": "temINVALID"
        }
    ],
    "status": 1000,
    "type": "tedCOMPOUND"
}

代币请求:

{
    "jsonrpc": "2.0",
    "id": 6,
    "method": "jt_sendTransaction",
    "params": [
        {
            "from": "jMrxHzpgnLHbz9ve9nVi8mc4SGZ5mkXZk",
            "secret": "ssxdpSif5AAdiazwAdbCxDc53Ykxd",
            "to": "jNzf1jaGsZTESCrxUFD6XZDkiTpjpXvH1s",
            "value": "10.000001/5fe996bf/jMrxHzpgnLHbz9ve9nVi8mc4SGZ5mkXZk",
            "fee": "10",
            "memos": [
                "autotest: token test"
            ]
        }
    ]
}

结果:

{
    "error": {
        "count": 1,
        "description": "The compound error.",
        "information": "1 errors"
    },
    "id": 6,
    "jsonrpc": "2.0",
    "result": [
        {
            "error": {
                "description": "The transaction is ill-formed.",
                "information": "error value value",
                "message": {
                    "fee": "10",
                    "from": "jMrxHzpgnLHbz9ve9nVi8mc4SGZ5mkXZk",
                    "memos": [
                        "autotest: token test"
                    ],
                    "to": "jNzf1jaGsZTESCrxUFD6XZDkiTpjpXvH1s",
                    "value": "10.000001/5fe996bf/jMrxHzpgnLHbz9ve9nVi8mc4SGZ5mkXZk"
                }
            },
            "status": -278,
            "type": "temINVALID"
        }
    ],
    "status": 1000,
    "type": "tedCOMPOUND"
}
zyd82 commented 3 years ago

另外还发现如果发送一个decimals是6的代币时,value是"0.00001/AAT13/jPdx7mG595P6CowtGYbxRkik9HdWUWtB2J"就能成功,value是"1.00001/AAT13/jPdx7mG595P6CowtGYbxRkik9HdWUWtB2J"就失败,报错信息跟上面一样。

caivega commented 3 years ago

test case ??

类似的bug, 之前报过,正在修复中。。。

foreso-GitHub commented 3 years ago

TestCase:

caivega commented 3 years ago

已经修复,下一个build验证

foreso-GitHub commented 3 years ago

在版本v0.5.3-dev-20201229-549e506fdf4556bc9bfd675559fd201421bd3036中验证,已经修复。