Closed hoangong closed 1 year ago
Hi @lisicky From what I see, cardano-cli 1.35.4 generated tx witness differently (no 8200
prefix).
You can use these command to generate txw.signed
file and compare the output.
./cardano-cli transaction build-raw \
--tx-in ... \
--tx-out ....\
--fee 300000 \
--out-file tx.raw \
--certificate-file pool-registration.cert \
--certificate-file stake.cert \
--certificate-file delegation.cert
./cardano-cli transaction witness \
--tx-body-file tx.raw \
--signing-key-file cold.skey \
--testnet-magic 1 \
--out-file txw.signed
The output from 1.35.4 has error when parse Vkeywitness. This is the code:
const txWitness = "825820c0c92edecfd493b36e0253fe8ada5f3a2a0567318d7f9dc79c400f53866eeb94584090f4b238ffe510199e421eaf03575ca82a03b55f8b1fb8e33f80b3703e51f38cb0b7f8a668d79c328ad2f98e65600ef66b4b70e16640247507673d0d5d34a202"; // this is cbor from txw.signed from cli 1.35.4
const witness = cbor.encode(cbor.decodeAllSync(txWitness)[0][1]);
const encodedWitness = ada.Vkeywitness.from_bytes(witness); // this line throw error "Deserialization failed in Vkeywitness because: Invalid cbor: not the right type, expected `Array' byte received `Bytes'."
If I put "8200" prefix to txWitness, it works fine. what I expect is ada.Vkeywitness.from_bytes can read txWitness that is generated from cardano-cli 1.35.4
@hoangong Could you tell me what you are doing by that line ? Does it work before ?
const witness = cbor.encode(cbor.decodeAllSync(txWitness)[0][1]);
I have checked deserialization with your cbor and it works. You can use from_hex
like in an example below.
Vkeywitness::from_hex("825820c0c92edecfd493b36e0253fe8ada5f3a2a0567318d7f9dc79c400f53866eeb94584090f4b238ffe510199e421eaf03575ca82a03b55f8b1fb8e33f80b3703e51f38cb0b7f8a668d79c328ad2f98e65600ef66b4b70e16640247507673d0d5d34a202");
@lisicky Thank for quick reply. from_hex
works with output from cli 1.35.4
Vkeywitness::from_hex("825820c0c92edecfd493b36e0253fe8ada5f3a2a0567318d7f9dc79c400f53866eeb94584090f4b238ffe510199e421eaf03575ca82a03b55f8b1fb8e33f80b3703e51f38cb0b7f8a668d79c328ad2f98e65600ef66b4b70e16640247507673d0d5d34a202");
but not with output from cli 1.35.3
Vkeywitness::from_hex("8200825820c0c92edecfd493b36e0253fe8ada5f3a2a0567318d7f9dc79c400f53866eeb94584090f4b238ffe510199e421eaf03575ca82a03b55f8b1fb8e33f80b3703e51f38cb0b7f8a668d79c328ad2f98e65600ef66b4b70e16640247507673d0d5d34a202"); // Deserialization failed in Vkeywitness.vkey because: Invalid cbor: not the right type, expected `Bytes' byte received `UnsignedInteger'.
@hoangong Seems cli 1.35.3 gives cbor in not from cddl format. CSL supports cbor in format that is described in the Alonzo and babbage cddl.
This happens since version 1.35.4 where the default tx build is babbage-era
This is Vkeywitness from alonzo era:
and this is from babbage era
I could manually add two bytes
8200
prefix to the babbage era version to make it works. Is it something serializer should take into account?