Code Monkey home page Code Monkey logo

Comments (18)

ZDust172 avatar ZDust172 commented on September 17, 2024 1

@jinglescode @pyropy Hi, how exactly are you guys signing the transactions in the CLI before signing it with Nami? I am attempting a similar method in #147 but the CLI still rejects my transaction.

I have pair of some random keys that I use to sign the tx, then load signed tx to nami via cardano-serialization-lib.

Thanks for the quick reply! So you're just doing cardano-cli transaction sign --tx-body-file {FILE} --signing-key-file payment.skey then copying the generated hex CBOR into cardano.signTx()? If so I'm very puzzled by the 'InvalidWitnessUTXOW' error message I get as I'm doing exactly the same.

from nami.

pyropy avatar pyropy commented on September 17, 2024 1

Reference

@ZDust172 Here's my blogpost on how to load signed tx https://srdjanstankovic.com/2021/12/24/how-to-sign-and-submit-cardano-cli-transaction-using-nami-wallet.html

from nami.

ZDust172 avatar ZDust172 commented on September 17, 2024 1

Reference

@ZDust172 Here's my blogpost on how to load signed tx https://srdjanstankovic.com/2021/12/24/how-to-sign-and-submit-cardano-cli-transaction-using-nami-wallet.html

Thanks! This should be a really helpful resource for others. I eventually opted to doing it a different way avoiding the cli altogether using the method here:

Emurgo/cardano-serialization-lib#303

from nami.

alessandrokonrad avatar alessandrokonrad commented on September 17, 2024

What function are you using the cardano-cli? The TransactionWitnessSet is a wrapper around the actual vkey witness. I haven't tried it in the cli yet, but it's definitely correct what Nami returns you. It's based on top of the serialization-lib.

from nami.

jinglescode avatar jinglescode commented on September 17, 2024

@alessandrokonrad thanks for you reply. Using cardanoo-cli transaction assemble I'm combining the cbor taken from TransactionWitnessSet taken from cardano.signTx(), adding the cbor into a file that looks like that:

{
    "type": "TxWitness MaryEra",
    "description": "",
    "cborHex": "CBOR TAKEN FROM TransactionWitnessSet"
}

With cardanoo-cli transaction assemble, adding other witnesses generated by cardano cli transaction witness.

from nami.

rooooooooob avatar rooooooooob commented on September 17, 2024

it's possibly related to IntersectMBO/cardano-node#3370 but I haven't looked into it so it might be unrelated since that issue was from cardano-cli -> cardano-serialization-lib not the other way around

from nami.

jinglescode avatar jinglescode commented on September 17, 2024

it's possibly related to input-output-hk/cardano-node#3370 but I haven't looked into it so it might be unrelated since that issue was from cardano-cli -> cardano-serialization-lib not the other way around

Hi @rooooooooob, any workaround on this? I'm implementing partial signing as described here.

After executing, cardano.signTx(tx, partialSign=true), the hex encoded cbor string I got from TransactionWitnessSet; can I copy the cbor string into this .witness file with the follow format?:

{
    "type": "TxWitness MaryEra",
    "description": "",
    "cborHex": "CBOR TAKEN FROM TransactionWitnessSet"
}

Do I have to manipulate the cbor string first? Does the TransactionWitnessSet cbor from the serialization library match the required input from cardano-cli?

And lastly using cardano-cli transaction assemble:

cardano-cli transaction assemble     
--tx-body-file tx.draft     
--witness-file transaction_witness_generated_by_cli.witness 
--witness-file transaction_witness_from_above_json_file.witness      
--out-file tx.signed

Error I'm getting:

TextEnvelope decode error: DecoderErrorDeserialiseFailure "Shelley Witness" (DeserialiseFailure 0 "expected list len")

from nami.

pyropy avatar pyropy commented on September 17, 2024

@jinglescode Have you managed to assemble those two transactions in the end?

from nami.

rooooooooob avatar rooooooooob commented on September 17, 2024

@jinglescode can you please post the output (hex string for cbor or whatever format it's in) from the CLI that you're trying to parse?

from nami.

pyropy avatar pyropy commented on September 17, 2024

I've managed to assemble witness returned from nami and tx built from cli.

What you need to do is to take vkeys and wrap them in array like so [0, [vkeys]] and then encode it to cbor once again.

from nami.

jinglescode avatar jinglescode commented on September 17, 2024

I've managed to assemble witness returned from nami and tx built from cli.

What you need to do is to take vkeys and wrap them in array like so [0, [vkeys]] and then encode it to cbor once again.

I tried that, and this is how it looks like.

window.cardano.signTx(cborHex, true).then((signedTx) => {

  const array_to_cli = []; // to create `[0, [vkeys]]`
  array_to_cli.push(0);

  const decoded = cbor.decode(signedTx);
  for (let i of decoded) {
    array_to_cli.push(i);
  }

  const signed_cbor_from_nami = cbor.encode(array_to_cli).toString('hex');
});

Put signed_cbor_from_nami into the witness file, so cardano-cli can consume:

{
    "type": "TxWitness MaryEra",
    "description": "",
    "cborHex": "CBOR TAKEN FROM signed_cbor_from_nami"
}

And then:

Command failed: transaction sign-witness  Error: buyer_witness_set_from_nami_signTx.witness: TextEnvelope decode error: DecoderErrorDeserialiseFailure "Shelley Witness" (DeserialiseFailure 0 "expected list len")

What I'm doing wrong here? Any advice will be helpful.

from nami.

pyropy avatar pyropy commented on September 17, 2024

@jinglescode You actually get keywitness-set returned when signing transaction that holds vkeys, which are needed to assemble witness object. Here's an example:

  const encodedTxVkeyWitnesses = await wallet.signTx(encodedTx, true);

  const txVkeyWitnesses = wasm.TransactionWitnessSet.from_bytes(
    Buffer.from(encodedTxVkeyWitnesses, "hex")
  );

  // extract vkeys from witness set as bytes
  const vkeysBytes = Buffer.from(
      txVkeyWitnesses.vkeys()?.get(0).to_bytes() as Uint8Array
    ).toString('hex');


  const vkeysDecoded = cbor.decode(vkeysBytes)
  const witness = [0, vkeysDecoded]
  const witnessCbor = cbor.encode(witness)

from nami.

rooooooooob avatar rooooooooob commented on September 17, 2024

@pyropy

What you need to do is to take vkeys and wrap them in array like so [0, [vkeys]] and then encode it to cbor once again.

With both being arrays? In alzono.cddl we have

transaction_witness_set =
  { ? 0: [* vkeywitness ]
  , ? 1: [* native_script ]
  , ? 2: [* bootstrap_witness ]
  , ? 3: [* plutus_script ] ;New
  , ? 4: [* plutus_data ] ;New
  , ? 5: [* redeemer ] ;New
  }

which should be a map not an array. In the cardano-serialization-lib we implemented off the binary spec which implements it as a map not an array.

Can someone please post CBOR (can be hex string or whatever format you can post here) of what is working and what isn't working so I can look into it? It seems to me like it's just map vs array but I would like to examine the CBOR see if that's the only difference. Thanks.

from nami.

jinglescode avatar jinglescode commented on September 17, 2024

Edit:

Hey @rooooooooob, here is the CBOR from cardano.signTx(encodedTx, true) after applying @pyropy method:
82008258209b8e0e4205180b4a2ac3511b39435e7e472c6cd817c1f05aaa7545c4b816601a584036b135996644821b84ccd31ad0b8ee07ef9b16eca8046aec96e8e756c0fcef293aeb0cd78866823239de10f98e5f9ddf223b814aaf2140183777d4fc742a3009

This works!

from nami.

ZDust172 avatar ZDust172 commented on September 17, 2024

@jinglescode @pyropy Hi, how exactly are you guys signing the transactions in the CLI before signing it with Nami? I am attempting a similar method in #147 but the CLI still rejects my transaction.

from nami.

pyropy avatar pyropy commented on September 17, 2024

@jinglescode @pyropy Hi, how exactly are you guys signing the transactions in the CLI before signing it with Nami? I am attempting a similar method in #147 but the CLI still rejects my transaction.

I have pair of some random keys that I use to sign the tx, then load signed tx to nami via cardano-serialization-lib.

from nami.

pyropy avatar pyropy commented on September 17, 2024

@jinglescode @pyropy Hi, how exactly are you guys signing the transactions in the CLI before signing it with Nami? I am attempting a similar method in #147 but the CLI still rejects my transaction.

I have pair of some random keys that I use to sign the tx, then load signed tx to nami via cardano-serialization-lib.

Thanks for the quick reply! So you're just doing cardano-cli transaction sign --tx-body-file {FILE} --signing-key-file payment.skey then copying the generated hex CBOR into cardano.signTx()? If so I'm very puzzled by the 'InvalidWitnessUTXOW' error message I get as I'm doing exactly the same.

I'm gonna write a blogpost today to explain in detail what I'm doing.

from nami.

mateusap1 avatar mateusap1 commented on September 17, 2024

Very helpful blogpost @pyropy. I'm still getting an error though:

transaction submit error ShelleyTxValidationError ShelleyBasedEraAlonzo (ApplyTxError [UtxowFailure (PPViewHashesDontMatch (SJust (SafeHash \"e84ed35a172ed46da854a132db880a608f73e0e61d385c9475a5b14fe4b9e4a9\")) SNothing),UtxowFailure (WrappedShelleyEraFailure (MissingScriptWitnessesUTXOW (fromList [ScriptHash \"1ef6f56f2e174d5e0328f24aa30d55b81f3bf871361f9280dd4090c2\"]))),UtxowFailure (WrappedShelleyEraFailure (UtxoFailure (UtxosFailure (CollectErrors [NoRedeemer (Minting (PolicyID {policyID = ScriptHash \"1ef6f56f2e174d5e0328f24aa30d55b81f3bf871361f9280dd4090c2\"})),NoWitness (ScriptHash \"1ef6f56f2e174d5e0328f24aa30d55b81f3bf871361f9280dd4090c2\")]))))])

I think it has to do with the fact that my transaction requires a redeemer and a datum, but shouldn't those elements be included in the tx body it self? Or do I need to somehow add it to the witness using the serialization lib?

from nami.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.