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

How to find namespace name in a tx which is not part of the wallet? #13

Closed
kawww opened this issue Mar 1, 2020 · 11 comments
Closed

How to find namespace name in a tx which is not part of the wallet? #13

kawww opened this issue Mar 1, 2020 · 11 comments
Labels
question Further information is requested

Comments

@kawww
Copy link

kawww commented Mar 1, 2020

If I send someone a txid, how does he use the wallet to find the namespace name?

I can use gettransaction to get "details" if the tx is part of the wallet.

gettransaction cb1cb15cecf1956d3ef4b8bab356a1119b5cf3b92afb905f501c0054ab541c7b

{
  "amount": 0.00000000,
  "fee": -0.00769011,
  "confirmations": 540,
  "blockhash": "6bb86f21207ab3fc4ebd0eddfc8aa99c05d1efabc8558ff7c9e3724c19c5c5fd",
  "blockindex": 1,
  "blocktime": 1582962935,
  "txid": "cb1cb15cecf1956d3ef4b8bab356a1119b5cf3b92afb905f501c0054ab541c7b",
  "walletconflicts": [
  ],
  "time": 1582962926,
  "timereceived": 1582962926,
  "bip125-replaceable": "no",
  "details": [
    {
      "account": "",
      "address": "VZjBLD3uBiQ5qLhHYryHWW7oLLoXMKPaZN",
      "keva": "update: NPPtp2dXRvvdi3K6pgiDAJZsVYzLK49RFZ",
      "category": "send",
      "amount": 0.00000000,
      "vout": 0,
      "fee": -0.01769011,
      "abandoned": false
    }
  ]

But others only could use getrawtransaction, and no "details".

getrawtransaction cb1cb15cecf1956d3ef4b8bab356a1119b5cf3b92afb905f501c0054ab541c7b 1

Is there any other ways to get namespace name?

Now ravencoin support upload ipfx hash/txid to the blockchain, I think if everyone can check txid to visit namespace. It's both good for keva and rvn.

And send namespace to each other on the blochchain is possable.

@kevacoin-project kevacoin-project added the question Further information is requested label Mar 1, 2020
@kawww
Copy link
Author

kawww commented Mar 1, 2020

Now I know OP_UNKNOWN in the getrawtransaction is the namespace key value... I can use hex2bin to get key and value, but namespace is not words.

"vout": [
    {
      "value": 0.01000000,
      "n": 0,
      "scriptPubKey": {
        "asm": "OP_UNKNOWN 3526305f5f2a99103a91694b96460c0d4ff506c601 50726f647563742057617272616e7479 50726f647563742057617272616e74793a20466f722077617272616e747920696e666f726d6174696f6e2061626f757420746869732070726f647563742c20706c6561736520636c69636b2068657265 OP_2DROP OP_DROP OP_HASH160 fd0a64716ea9776fdd6f27222c35a7fd3f8bc87f OP_EQUAL",

3526305f5f2a99103a91694b96460c0d4ff506c601

maybe namespace

50726f647563742057617272616e7479

key

50726f647563742057617272616e74793a20466f722077617272616e747920696e666f726d6174696f6e2061626f757420746869732070726f647563742c20706c6561736520636c69636b2068657265

value

@kevacoin-project
Copy link
Owner

You are almost right:

Namespace: 3526305f5f2a99103a91694b96460c0d4ff506c601
Key: 50726f647563742057617272616e7479
Value: 50726f647563742057617 ...

I guess you enable "txindex=1" in kevacoin.conf.
We can make it much easier to read by properly parsing the script (so that there is no OP_UNKNOWN).

@kawww
Copy link
Author

kawww commented Mar 1, 2020

You are almost right:

Namespace: 3526305f5f2a99103a91694b96460c0d4ff506c601
Key: 50726f647563742057617272616e7479
Value: 50726f647563742057617 ...

I guess you enable "txindex=1" in kevacoin.conf.
We can make it much easier to read by properly parsing the script (so that there is no OP_UNKNOWN).

Thanks, so how to decoded Namespace: 3526305f5f2a99103a91694b96460c0d4ff506c601?

Now I can use hex to ascii decoded key and value http://mcraigweaver.com/ascii.htm

but Namespace is strange and different with key and value.

Now I find another way to get namespace that I can add namespace in value and read value data. But If Namespace can be decodeded, I think it's better.

@kevacoin-project
Copy link
Owner

If you convert the hex string 3526305f5f2a99103a91694b96460c0d4ff506c601 into binary string, and do a Base58Check encoding on the binary string, you can get back the namespace.

What programming language are you using? This can be done very easily using Javascript. E.g.
https://github.com/bitcoinjs/bs58check

@kevacoin-project
Copy link
Owner

var bs58check = require('bs58check')

var data = Buffer.from('3526305f5f2a99103a91694b96460c0d4ff506c601', 'hex');
console.log(bs58check.encode(data))

@kevacoin-project
Copy link
Owner

For PHP:
https://github.com/furqansiddiqui/base58check-php

I haven't tried this ...

@kevacoin-project
Copy link
Owner

I have fixed the keva operation decoding in the master branch:
14b7390

@kawww
Copy link
Author

kawww commented Mar 1, 2020

If you convert the hex string 3526305f5f2a99103a91694b96460c0d4ff506c601 into binary string, and do a Base58Check encoding on the binary string, you can get back the namespace.

What programming language are you using? This can be done very easily using Javascript. E.g.
https://github.com/bitcoinjs/bs58check

Thanks very much, I use php and I will check how to use php to decoded. I think encoded this namespace is not necessary too..

@kawww
Copy link
Author

kawww commented Mar 1, 2020

For PHP:
https://github.com/furqansiddiqui/base58check-php

I haven't tried this ...

ok got it~ 😄

@kawww kawww closed this as completed Mar 23, 2020
@kawww
Copy link
Author

kawww commented May 20, 2020

var bs58check = require('bs58check')

var data = Buffer.from('3526305f5f2a99103a91694b96460c0d4ff506c601', 'hex');
console.log(bs58check.encode(data))

I tried to use php to encode these hex, and finally success.

but...I think the namespace hex in tx is not enough.

for example

blog namespace is NgKBKkBAJMtzsuit85TpTpo5Xj6UQUg1wr

tx 08009579d3f34ff83d3650417b192915f3443d79d4beab188e796524ec1f4f64

so I get namespace hex

OP_KEVA_PUT 35dfc637022a506c2640445445e326c6c2f9fc4538

I use https://github.com/dcentrica/bitcoin-base58check to encode

$data2=hex2bin("35dfc637022a506c2640445445e326c6c2f9fc4538");
$base58Check = new Base58Check('bitcoin');
$data = $base58Check->encode($data2);
echo $data;

4K9GhJdTd6ZDbSBDN1JsJAkmARdYK

I use bitcoin-encoder http://lenschulwitz.com/base58 get 4K9GhJdTd6ZDbSBDN1JsJAkmARdYK too.

I use this bitcoin-encoder to decode NgKBKkBAJMtzsuit85TpTpo5Xj6UQUg1wr got

35dfc637022a506c2640445445e326c6c2f9fc45385ed8fdd5

so the real hex is longer than the hex in tx.

35dfc637022a506c2640445445e326c6c2f9fc4538

I use another https://www.better-converter.com/Encoders-Decoders/Base58Check-to-Hexadecimal-Decoder get full hex too.

So I think it is not possiable to encode the hex to get namespace address if hex is not enough.

35dfc637022a506c2640445445e326c6c2f9fc4538 5e d8 fd d5
35dfc637022a506c2640445445e326c6c2f9fc4538

maybe 5e d8 fd d5 is for checking, but how to get it?

I use full hex 35dfc637022a506c2640445445e326c6c2f9fc45385ed8fdd5 to get namespace name ok.

$data2=hex2bin("35dfc637022a506c2640445445e326c6c2f9fc45385ed8fdd5");
$base58Check = new Base58Check('bitcoin');
$data = $base58Check->encode($data2);
echo $data;

NgKBKkBAJMtzsuit85TpTpo5Xj6UQUg1wr

@kawww kawww reopened this May 20, 2020
@kawww
Copy link
Author

kawww commented Aug 30, 2020

finnaly sovled https://stackoverflow.com/questions/58782314/how-to-generate-trx-wallet-without-using-api

this github include php base58check code and easy to use.

Base58Check::encode("35dfc637022a506c2640445445e326c6c2f9fc4538", false , 0 , false);

@kawww kawww closed this as completed Aug 30, 2020
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