caivega / ipfslib

Other
2 stars 1 forks source link

S2 - jt_signTransaction(9545):发行可增发的代币,但是发行数额为负数,结果发行成功 #138

Closed zyd82 closed 3 years ago

zyd82 commented 3 years ago

1、用jt_signTransaction发行一个可增发的代币,返回长哈希

{
    "jsonrpc": "2.0",
    "method": "jt_signTransaction",
    "params": [
        {
            "type": "IssueCoin",
            "from": "jPdx7mG595P6CowtGYbxRkik9HdWUWtB2J",
            "secret": "shhquPeZm7uQ6Rvjrqn6L2cR6H33u",
            "name": "ZYDDD Token",
            "symbol": "ZIZT",
            "decimals": "8",
            "total_supply": "-1100000",
            "flags": 65536,
            "local": true
        }
    ],
    "id": 1
}

2、用jt_sendRawTransaction发送该哈希,返回交易成功哈希

{{
    "id": 1,
    "jsonrpc": "2.0",
    "result": [
        "EB1D4FE4B8664FADD2C779E825A18B2637A9FB81B3815F36EA6DFB9E47FF2313"
    ]
}

3、用jt_getTransactionByHash查询上面的交易哈希,返回如下

{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "TransactionType": "IssueCoin",
        "Flags": 2147549184,
        "Account": "jPdx7mG595P6CowtGYbxRkik9HdWUWtB2J",
        "Sequence": 8,
        "Fee": "10",
        "SigningPubKey": "034153EEBB406B3593AA7F31A4908E56ED820031DB87F4F2E868FB8E1686D5E1E3",
        "TxnSignature": "304402201E22EA4C91D96D5DB04F27249A9F30DE97503984ABEF2521140E53C4B2FBF33A022046E3E0C5ED0FEBCA5AB3359634ED977B99646E97564DACB4DB29BAC21504DBC7",
        "hash": "EB1D4FE4B8664FADD2C779E825A18B2637A9FB81B3815F36EA6DFB9E47FF2313",
        "Name": "ZYDDD Token",
        "Decimals": 8,
        "TotalSupply": {
            "value": "-1100000",
            "currency": "ZIZT",
            "issuer": "jPdx7mG595P6CowtGYbxRkik9HdWUWtB2J"
        },
        "Owner": "jPdx7mG595P6CowtGYbxRkik9HdWUWtB2J",
        "date": 660817100,
        "inLedger": 112844,
        "ledger_index": 112844,
        "meta": {
            "AffectedNodes": [
                {
                    "ModifiedNode": {
                        "FinalFields": {
                            "Hash": "0000000000000000000000000000000000000000000000000000000000000000",
                            "Account": "jhCVwTcg5aYWMMdfDmwqYxBr5NMA1PDfyg",
                            "Sequence": 0,
                            "Balance": "7569600"
                        },
                        "LedgerEntryType": "AccountRoot",
                        "PreviousFields": {
                            "Hash": "0000000000000000000000000000000000000000000000000000000000000000",
                            "Account": "jhCVwTcg5aYWMMdfDmwqYxBr5NMA1PDfyg",
                            "Sequence": 0,
                            "Balance": "7569590"
                        }
                    }
                },
                {
                    "ModifiedNode": {
                        "FinalFields": {
                            "Hash": "0000000000000000000000000000000000000000000000000000000000000000",
                            "Account": "jPdx7mG595P6CowtGYbxRkik9HdWUWtB2J",
                            "Sequence": 8,
                            "Balance": "20070"
                        },
                        "LedgerEntryType": "AccountRoot",
                        "PreviousFields": {
                            "Hash": "0000000000000000000000000000000000000000000000000000000000000000",
                            "Account": "jPdx7mG595P6CowtGYbxRkik9HdWUWtB2J",
                            "Sequence": 7,
                            "Balance": "20080"
                        }
                    }
                },
                {
                    "CreatedNode": {
                        "LedgerEntryType": "AccountRoot",
                        "NewFields": {
                            "Hash": "0000000000000000000000000000000000000000000000000000000000000000",
                            "Account": "jPdx7mG595P6CowtGYbxRkik9HdWUWtB2J",
                            "Sequence": 8,
                            "Balance": {
                                "value": "-1100000",
                                "currency": "ZIZT",
                                "issuer": "jPdx7mG595P6CowtGYbxRkik9HdWUWtB2J"
                            }
                        }
                    }
                },
                {
                    "CreatedNode": {
                        "LedgerEntryType": "CurrencyRoot",
                        "NewFields": {
                            "Hash": "0000000000000000000000000000000000000000000000000000000000000000",
                            "Flags": 65536,
                            "Account": "jPdx7mG595P6CowtGYbxRkik9HdWUWtB2J",
                            "Sequence": 1,
                            "Name": "ZYDDD Token",
                            "Decimals": 8,
                            "TotalSupply": {
                                "value": "-1100000",
                                "currency": "ZIZT",
                                "issuer": "jPdx7mG595P6CowtGYbxRkik9HdWUWtB2J"
                            }
                        }
                    }
                }
            ],
            "TransactionIndex": 0,
            "TransactionResult": "tesSUCCESS"
        }
    }
}

4、用jt_getAccount查询钱包jPdx7mG595P6CowtGYbxRkik9HdWUWtB2J的KKT全局币,其余额为-1100000。

{
    "jsonrpc": "2.0",
    "method": "jt_getAccount",
    "params": [
        "jPdx7mG595P6CowtGYbxRkik9HdWUWtB2J",
        "ZIZT",
        "jPdx7mG595P6CowtGYbxRkik9HdWUWtB2J"
    ],
    "id": 1
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "Account": "jPdx7mG595P6CowtGYbxRkik9HdWUWtB2J",
        "Balance": {
            "currency": "ZIZT",
            "issuer": "jPdx7mG595P6CowtGYbxRkik9HdWUWtB2J",
            "value": "-1100000"
        },
        "Hash": "0000000000000000000000000000000000000000000000000000000000000000",
        "LedgerEntryType": "AccountRoot",
        "Sequence": 9
    }
}

5、jt_sendTransaction也存在同样的问题

foreso-GitHub commented 3 years ago

这个case自动测试有,但用的是数字而不是字符串,系统能监测出。看来还要增加一条新的case,total_supply使用字符串。

请求:

{
    "jsonrpc": "2.0",
    "method": "jt_sendTransaction",
    "params": [
        {
            "from": "j4eGRtcnTovDhsM3iL4oBTjxREgGfx9kXK",
            "secret": "shaBd2VU4he1ipHdbL2dqSoee58MJ",
            "type": "IssueCoin",
            "name": "TestCoin1607507795",
            "symbol": "1fd09f54",
            "decimals": "8",
            "total_supply": -10000000,
            "local": false,
            "flags": 0
        }
    ],
    "id": 1
}

结果:

{
    "id": 1,
    "jsonrpc": "2.0",
    "message": {
        "reason": "1 errors",
        "result": [
            {
                "error": "Invalid Number:  Reason: strconv.ParseUint: parsing \"\": invalid syntax",
                "message": {
                    "decimals": "8",
                    "flags": 0,
                    "from": "j4eGRtcnTovDhsM3iL4oBTjxREgGfx9kXK",
                    "local": false,
                    "name": "TestCoin1607507795",
                    "symbol": "1fd09f54",
                    "total_supply": -10000000,
                    "type": "IssueCoin"
                },
                "status": -278
            }
        ]
    },
    "result": [
        ""
    ],
    "status": -278
}
caivega commented 3 years ago

这个case自动测试有,但用的是数字而不是字符串,系统能监测出。看来还要增加一条新的case,total_supply使用字符串。

请求:

{
    "jsonrpc": "2.0",
    "method": "jt_sendTransaction",
    "params": [
        {
            "from": "j4eGRtcnTovDhsM3iL4oBTjxREgGfx9kXK",
            "secret": "shaBd2VU4he1ipHdbL2dqSoee58MJ",
            "type": "IssueCoin",
            "name": "TestCoin1607507795",
            "symbol": "1fd09f54",
            "decimals": "8",
            "total_supply": -10000000,
            "local": false,
            "flags": 0
        }
    ],
    "id": 1
}

结果:

{
    "id": 1,
    "jsonrpc": "2.0",
    "message": {
        "reason": "1 errors",
        "result": [
            {
                "error": "Invalid Number:  Reason: strconv.ParseUint: parsing \"\": invalid syntax",
                "message": {
                    "decimals": "8",
                    "flags": 0,
                    "from": "j4eGRtcnTovDhsM3iL4oBTjxREgGfx9kXK",
                    "local": false,
                    "name": "TestCoin1607507795",
                    "symbol": "1fd09f54",
                    "total_supply": -10000000,
                    "type": "IssueCoin"
                },
                "status": -278
            }
        ]
    },
    "result": [
        ""
    ],
    "status": -278
}

现在应该除了sequence, 其他的数字基本上都已经是字符串方式提交了,之前有bug讨论这个问题

caivega commented 3 years ago

已经修复,下一个build验证

foreso-GitHub commented 3 years ago

现在应该除了sequence, 其他的数字基本上都已经是字符串方式提交了,之前有bug讨论这个问题

对,应该是2个不同的错误。对应的script已经更新。 这两种不同的错误后面还是要根据出错信息进行进一步准确判断。

caivega commented 3 years ago

我刚才又在本地的20201208版本上,是可以还原这个问题的,但是在新的20201209版本上这个问题是解决的。。。可能是我使用的步骤不对?

注:每天的版本更新次数可能有几个,不过只有最后一个记录显示(共识周期为一天:)),20201209版本以这个shasum为准,e13440cfe317f8e64723aeb598f88d522012696f

caivega commented 3 years ago

刚才更新了一个版本,增加程序自身的hash到jt_version中,比如今天的版本是v0.5.3 dev-20201210-194c2505539ab9c905afaa72f622eb947e1c7aa3

zyd82 commented 3 years ago

v0.5.3-dev-20210113-5aa567d27f68102434021e72cbd0bad2349ae99e版本验证通过。