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

Key "3" decoded as "Q" symbol #24

Closed
ghost opened this issue Jun 30, 2021 · 6 comments
Closed

Key "3" decoded as "Q" symbol #24

ghost opened this issue Jun 30, 2021 · 6 comments
Labels
question Further information is requested

Comments

@ghost
Copy link

ghost commented Jun 30, 2021

I'm writing a content researching script. All working well there, but I've detected a strange behavior on parsing a block 308648, txid:
40bb0060b91a0b2f333b17a0da1f3dae92d9f52a904f241401f0f6cb355d37e5

What is the reason? In the wallet it is "3" and in the API response it's "Q"
(I'm using remote API by https://explorer.kevacoin.org/info to interact with the blockchain, may be issue of this service)

The script and all the decoding process presented here (but it's no problem with the literal key names):
https://github.com/kvazar-network/crawler-api-node/blob/main/crawler.php

@ghost
Copy link
Author

ghost commented Jun 30, 2021

It seems I've deleted an example on testing the previous issue. Anyway check the subject please.
Here is created a new one:
e7ef09905a533d33c25374fa09735a356c74c944de29dfbafc7199e4d5816cb2

@ghost
Copy link
Author

ghost commented Jul 1, 2021

Today, I have following errors in the script debug, some data can't be decoded to the plain text (block 852 for example):

Warning: hex2bin(): Input string must be hexadecimal string in /crawler-api-node/crawler.php on line 99

add namespace NaYeBgWHcrgCR26shgmNRyBDWdfU7iQhyo

PHP Notice:  SQLSTATE[HY000]: General error: 1366 Incorrect string value: '\x97\x14' for column 'key' at row 1 in /crawler-api-node/library/mysql.php on line 150``` 

@ghost
Copy link
Author

ghost commented Jul 9, 2021

I've found, that by calling to API using function keva_filter - the data returning without errors. But when I parse the raw transaction, it contains wrong encoding, for example:

https://explorer.kevacoin.org/api/getrawtransaction?txid=e7ef09905a533d33c25374fa09735a356c74c944de29dfbafc7199e4d5816cb2&decrypt=1

OP_KEVA_PUT 356a893ac5dbc64229a0700d63b019c72e5227644d 51 6973737565202332342074657374 OP_2DROP OP_DROP OP_HASH160 11dfd4642cfb603dace16aee8c8fb14da4a3d4d2 OP_EQUAL

Where 51 - is the "Q" symbol but should be the "3". Decoding mode issue?

kevacoin-cli keva_filter NVdHCy89xRKXWUG9tXBFz9e5N4JjksACoA ""
[
  {
    "key": "3",
    "value": "issue #24 test",
    "txid": "e7ef09905a533d33c25374fa09735a356c74c944de29dfbafc7199e4d5816cb2",
    "vout": 0,
    "height": 354206
  },
  {
    "key": "same 1",
    "value": "1",
    "txid": "a835a8b5a0eeab29f5719baf2c7bf08a535b9b4a6976bc4bfc62822b43e6eb33",
    "vout": 0,
    "height": 359517
  },
  {
    "key": "_KEVA_NS_",
    "value": "new name",
    "txid": "2024ef51fcf20820f6c0e2e6f74afa8f2396fbbc458ccd19687e2d3641efc880",
    "vout": 1,
    "height": 354223
  },
  {
    "key": "e7ef09905a533d33c25374fa09735a356c74c944de29dfbafc7199e4d5816cb2",
    "value": "test comment",
    "txid": "fa9ceeff4275f57db317d49a97961c60e3625c43950c9a8b665a09a0e4e6e86f",
    "vout": 1,
    "height": 354541
  }
]

@kevacoin-project
Copy link
Owner

Sorry for the late reply. Here "51" in the output of transaction decoding is decimal value, not hexadecimal value. In fact, every number that is smaller than 0xFFFFFFFF will be represented as decimal value. The behaviour is inherited from Bitcoin.

Since 51 is decimal, it represents "3" in ASCII table.

@kevacoin-project kevacoin-project added the question Further information is requested label Jul 10, 2021
@ghost
Copy link
Author

ghost commented Jul 11, 2021

Thank you for reply!

I have fixed the problem by following solution, maybe will helpful for PHP devs:

function decodeString($string) {

  if (is_numeric($string) && $string < 0xFFFFFFFF) {
    return mb_chr($string, 'ASCII');
  } else {
    return hex2bin($string);
  }
}

@d47081
Copy link

d47081 commented Feb 15, 2024

Also, there is lot of hidden records in kevacoin wallet:

raw: 1952543276
bool(false)
UTF-8: bool(false)
ASCII:bool(false)
AUTO:
---
block:289919
ns:NWn2wUdctLvoatDuqFmcfxEuJmFx9EbSre

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants