Skip to content

tonlib.getBlockTransactions return error when result contains error string #122

@cresports

Description

@cresports
//Tonlib.java line 457
if (StringUtils.isEmpty(response) || response.contains("error")) {
        if (!StringUtils.isEmpty(response)) {
          log.info(response);
        }

        if (++retry > receiveRetryTimes) {
          throw new Error(
              "Error in tonlib.receive(), "
                  + receiveRetryTimes
                  + " times was not able retrieve result from lite-server.");
        }

I've found a bug in line 457 of Tonlib.java
If the response here contains the string "error", the program will enter error handling logic. However, if the normally returned data results just happen to contain the string "error", it does not mean that an error occurred.

For example, call Tonlib.getBlockTransactions: one hash string contains string error: "hash": "OhAtutGPha1qBFI29xJIyoAerrorokz5Gf8Dc1CH3Fs="

{
    "@type": "blocks.transactions",
    "id":
    {
        "@type": "ton.blockIdExt",
        "workchain": 0,
        "shard": "-2305843009213693952",
        "seqno": 52102245,
        "root_hash": "bIxbMrC9Sojmli/6LKygC+z4UQgFoIYeUNXPWJDfGJg=",
        "file_hash": "h4e+zB/ShJSfohoAmpAyu6sApnZGQpwuz1ircF/6Knc="
    },
    "req_count": 2000,
    "incomplete": false,
    "transactions":
    [
        {
            "@type": "blocks.shortTxId",
            "mode": 7,
            "account": "yQNTb+ITch+VusOEAj0OsSsUbRSfFKq+yMrvBqBqinE=",
            "lt": "56623173000001",
            "hash": "8XbrhtXW6v3iBXMLqQXTZTndI0u9zrv6e4+2u/kX8kI="
        },
        {
            "@type": "blocks.shortTxId",
            "mode": 7,
            "account": "z36iNe1vZRftzpgCbvdhjp9tgaEzHU5lunGOLNFfgK0=",
            "lt": "56623173000001",
            "hash": "ch07LSkTI/p5Ki+jM6Z60tbVSQAUVisk774XAl5kDp8="
        },
        {
            "@type": "blocks.shortTxId",
            "mode": 7,
            "account": "z36iNe1vZRftzpgCbvdhjp9tgaEzHU5lunGOLNFfgK0=",
            "lt": "56623173000003",
            "hash": "3LmSib2YelBWbwMMG1gFcvjyjf3GiNr+mH9wjXetBjA="
        },
        {
            "@type": "blocks.shortTxId",
            "mode": 7,
            "account": "1LZFbXAFmQiwRQRWCI7LC395ZZmvtRJqri8G6V379AM=",
            "lt": "56623173000001",
            "hash": "zerNiEwJu/8iXr0M/ZiK1o3XFhH15k9ZDVSvdH+c4sM="
        },
        {
            "@type": "blocks.shortTxId",
            "mode": 7,
            "account": "76BTxxBZDmnxa951ucqF1vtcggmNpgRqq0TRadObDtc=",
            "lt": "56623173000001",
            "hash": "IQcFgXVbYN292s0L3OWDogai/FXRm7e1sheVuedkpz8="
        },
        {
            "@type": "blocks.shortTxId",
            "mode": 7,
            "account": "/VlkpbO+oJgF0cLztwcnBtp8/6c5GOS1GMSydiBYz/k=",
            "lt": "56623173000001",
            "hash": "OhAtutGPha1qBFI29xJIyoAerrorokz5Gf8Dc1CH3Fs="//hash contains string `error`
        }
    ],
    "@extra": "57408aa2-dc03-4f3b-ab60-82b84fe48ecd"
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions