cardano-foundation / cardano-rosetta

An implementation of Rosetta for Cardano
https://www.rosetta-api.org
Apache License 2.0
98 stars 50 forks source link

deserialize the signed transaction #565

Closed dev-dantealighieri closed 3 months ago

dev-dantealighieri commented 3 months ago

Ask a question

hi

I cannot get txhash from parse endpoint of you, and I get the following error when I try to deserialize signed transaction using cardano-serialization-lib, i used rosetta to construct and sign the transaction, what might be the problem?

"Deserialization failed in Transaction.body.TransactionBody because: Invalid cbor: not the right type, expected `Map' byte received `Text'."

thanks, dante

example signed transaction that i want to deserialize:


827901c2383461343030383138323538323063393037366466396364346238353063653132633332643965326434303163323064323037633935346138643862376137343665663666383734333665383431303130313831383235383339303138666635653430366637323861316232316635363663613833366236363165386435636339373431376562626334656631613063613631393866663565343036663732386131623231663536366361383336623636316538643563633937343137656262633465663161306361363139316130303139363765323032316130303032383561313033316166666666666666666131303038313832353832306132663332633463346333623333393430653639393532383861656230623936366632666137356134353631373139313439363636626164356138343263623735383430316238346531346364396239616465373262386333373531326265376438613335343138393238316563343837363763303839396266303830323232396439356238343234333761323234363764353937623635633930613134333561663464393162313765626235646230623631383133363632386134613266653137306166356636a16a6f7065726174696f6e7380```
Kammerlo commented 3 months ago

Hello @dev-dantealighieri, Sorry I don't how you build the transaction? You used rosetta to build this transaction? And then signed it?

Are you using the current release or already node 9.0? Could you provide me more details?

Godspeed-exe commented 3 months ago

hello @dev-dantealighieri

Rosetta actually adds extra envelopes around it's objects. If you decode (https://cbor.me) your payload, you'll see:

["84a40081825820c9076df9cd4b850ce12c32d9e2d401c20d207c954a8d8b7a746ef6f87436e841010181825839018ff5e406f728a1b21f566ca836b661e8d5cc97417ebbc4ef1a0ca6198ff5e406f728a1b21f566ca836b661e8d5cc97417ebbc4ef1a0ca6191a001967e2021a000285a1031affffffffa10081825820a2f32c4c4c3b33940e6995288aeb0b966f2fa75a4561719149666bad5a842cb758401b84e14cd9b9ade72b8c37512be7d8a354189281ec48767c0899bf0802229d95b842437a22467d597b65c90a1435af4d91b17ebb5db0b618136628a4a2fe170af5f6", {"operations": []}]

The above data structure is not a valid Cardano transaction according to the CDDL specs. But if you take the inside of this "84a400....5f6" and CBOR decode this it does return a valid format.

I've confirmed this by running the below code in CSL:

var signed_tx = "84a40081825820c9076df9cd4b850ce12c32d9e2d401c20d207c954a8d8b7a746ef6f87436e841010181825839018ff5e406f728a1b21f566ca836b661e8d5cc97417ebbc4ef1a0ca6198ff5e406f728a1b21f566ca836b661e8d5cc97417ebbc4ef1a0ca6191a001967e2021a000285a1031affffffffa10081825820a2f32c4c4c3b33940e6995288aeb0b966f2fa75a4561719149666bad5a842cb758401b84e14cd9b9ade72b8c37512be7d8a354189281ec48767c0899bf0802229d95b842437a22467d597b65c90a1435af4d91b17ebb5db0b618136628a4a2fe170af5f6"

var tx = CardanoWasm.wasm.Transaction.from_bytes(buffer.Buffer.from(signed_tx, 'hex'))

console.log(tx.body().outputs().get(0).address().to_bech32())

I hope this clarifies your issue!

dev-dantealighieri commented 3 months ago

i didn't see your reply, i solved the issue but thanks anyway!

https://github.com/cardano-foundation/cardano-rosetta/issues/566#issuecomment-2236181963