NeoxaChain / Neoxa

Neoxa is an innovative Proof of Work cryptocurrency that seamlessly merges the realms of gaming and cryptocurrency.
https://neoxa.net/
MIT License
55 stars 30 forks source link

RPC: decoderawtransaction returns decode failed error, when trying to decode created transaction by createrawtransaction #31

Closed ciricc closed 2 months ago

ciricc commented 10 months ago
root@02388f6d5d73:/app# neoxa-cli createrawtransaction "[]" "{\"GJeEoPQPXjxxfkdBzQ23FSGWBN26iB9P9q\":0.1}"
02000000000180969800000000001976a91408c27af242eb49e3cfd279c927c6707d1fd5d39388ac00000000
root@02388f6d5d73:/app# neoxa-cli decoderawtransaction "02000000000180969800000000001976a91408c27af242eb49e3cfd279c927c6707d1fd5d39388ac00000000"
error code: -22
error message:
TX decode failed

Software:

root@02388f6d5d73:/app# neoxa-cli -version
Neoxa Core RPC client version v5.1.1.4-ec8b257-dirty

root@02388f6d5d73:/app# neoxad -version
Neoxa Core Daemon version v5.1.1.4-ec8b257-dirty
Copyright (C) 2023 The Neoxa Core developers
Copyright (C) 2014-2023 The Dash Core developers
Copyright (C) 2009-2023 The Bitcoin Core developers

Please contribute if you find Neoxa Core useful. Visit <https://neoxa.net> for
further information about the software.
The source code is available from <https://github.com/NeoxaChain/Neoxa>.

This is experimental software.
Distributed under the MIT software license, see the accompanying file COPYING
or <https://opensource.org/licenses/MIT>

This product includes software developed by the OpenSSL Project for use in the
OpenSSL Toolkit <https://www.openssl.org> and cryptographic software written by
Eric Young and UPnP software written by Thomas Bernard.
0x00ASTRA commented 10 months ago

Hey @ciricc it looks like your trying to generate a transaction to send 0.1 NEOX to GJeEoPQPXjxxfkdBzQ23FSGWBN26iB9P9q and are running into some trouble. No worries, there seems to be a slight issue with the inputs to your transaction. Error code -22 indicates that there is an issue with the structure of the transaction. Since you are trying to send NEOX to that address, you need to provide the transaction with a valid UTXO input.

For example:

neoxa-cli createrawtransaction "[{\"txid\": \"73d23debd79b11b81152cb2a4571bb02a68c3128c12820534609769c81836385\",\"vout\": 0}]" "{\"GNcbu5GuZKMUui8A9eZxGXhJurgSixNRfT\": 0.01}"

Now when I go to decode the transaction:

{
  "txid": "4296a14aa234fbac6589defd641a31b4d37d47b07f8c0cb7f2423221f99c86d9",
  "hash": "4296a14aa234fbac6589defd641a31b4d37d47b07f8c0cb7f2423221f99c86d9",
  "version": 2,
  "type": 0,
  "size": 85,
  "locktime": 0,
  "vin": [
    {
      "txid": "73d23debd79b11b81152cb2a4571bb02a68c3128c12820534609769c81836385",
      "vout": 0,
      "scriptSig": {
        "asm": "",
        "hex": ""
      },
      "sequence": 4294967295
    }
  ],
  "vout": [
    {
      "value": 0.01000000,
      "valueSat": 1000000,
      "n": 0,
      "scriptPubKey": {
        "asm": "OP_DUP OP_HASH160 3453c363ed2d12f8f4450a3754c81f784aeb002e OP_EQUALVERIFY OP_CHECKSIG",
        "hex": "76a9143453c363ed2d12f8f4450a3754c81f784aeb002e88ac",
        "reqSigs": 1,
        "type": "pubkeyhash",
        "addresses": [
          "GNcbu5GuZKMUui8A9eZxGXhJurgSixNRfT"
        ]
      }
    }
  ],
  "hex": "0200000001856383819c760946532028c128318ca602bb71452acb5211b8119bd7eb3dd2730000000000ffffffff0140420f00000000001976a9143453c363ed2d12f8f4450a3754c81f784aeb002e88ac00000000"
}

You can list unspent UTXOs with:

neoxa-cli listunspent

Reference: UTXO Create A Raw Transaction

ciricc commented 10 months ago

No worries, there seems to be a slight issue with the inputs to your transaction. Error code -22 indicates that there is an issue with the structure of the transaction

Thank you for your reply! I want to use createrawtransaction with fundrawtransaction after. But with this issue i can't. What's my case? I wrote Bitcoin compatible transaction processer, which using bitcoin's RPC API and another compatible blockchains (like Neoxa), but only in the Neoxa now i have this problem.

I think that is the bug, because i read documentation of fundrawtransaction method. There is this message:

Examples:

Create a transaction with no inputs
> neoxa-cli createrawtransaction "[]" "{\"myaddress\":0.01}"

Add sufficient unsigned inputs to meet the output value
> neoxa-cli fundrawtransaction "rawtransactionhex"

Sign the transaction
> neoxa-cli signrawtransaction "fundedtransactionhex"

Send the transaction
> neoxa-cli sendrawtransaction "signedtransactionhex"

So, now i cna't use fundrawtransaction method in any way because when i use it, it tries decode transaction by decoderawtransaction method and returns me an error.