Emurgo / cardano-serialization-lib

This is a library, written in Rust, for serialization & deserialization of data structures used in Cardano's Haskell implementation of Alonzo along with useful utility functions.
Other
234 stars 125 forks source link

Script Witness Not Validating error even when Witness is created. #301

Closed rumourscape closed 2 years ago

rumourscape commented 2 years ago

I am receiving a script witness validation error when submitting a transaction even though the Witness has been provided.

  const txhash = Cardano.hash_transaction(transaction.body());

  const vkeyWit = Cardano.make_vkey_witness( txhash, prvkey)

  const script = Script()
  txScripts.add(script)
  txVkeys.add(vkeyWit);

The private key used to create witness is the same with which the native script was created.

vsubhuman commented 2 years ago

I am receiving a script witness validation error when submitting a transaction even though the Witness has been provided.

What are you using to submit the transaction and what is the error you are receiving?

const script = Script()

Can you provide an example of how you are actually constructing the script? Are you making sure you are using the correct private key from the same address that is using in the script?

rumourscape commented 2 years ago

I am using this function:

function Script() {
  const lock = Cardano.TimelockExpiry.new(45299919);
  const nativeScripts = Cardano.NativeScripts.new();
  const keyash = getBaseAddress().payment_cred().to_keyhash()
  const script = Cardano.ScriptPubkey.new(keyash);
  const nativeScript = Cardano.NativeScript.new_script_pubkey(script);
  const lockScript = Cardano.NativeScript.new_timelock_expiry(lock);

  nativeScripts.add(nativeScript);
  nativeScripts.add(lockScript);

  const finalScript = Cardano.NativeScript.new_script_all(
  Cardano.ScriptAll.new(nativeScripts)
    );

  return finalScript
}

I am using ogmios to submit the tx and this is the exact error recieved.

ScriptWitnessNotValidatingError: ["9720b134a8c417ac3709c0a3462ef7bea7e2f95d5bfa3875e342ae66"]

And yes I am pretty certain I am using the same key to sign and create the address to create script.

SebastienGllmt commented 2 years ago

If you're spending from a native script, did you add it to the TransactionWitnessSet?

rumourscape commented 2 years ago

Yes I did. You can have a look at my code here: https://github.com/rumourscape/Minting-API .

pierre-andre-long commented 2 years ago

I would love to know what's going wrong as well.

rumourscape commented 2 years ago

I have found the problem and resolved the issue.

eric248550 commented 2 years ago

How did you solve this problem?

I have found the problem and resolved the issue.

rumourscape commented 2 years ago

I was creating the script with baseAddress keyhash but it should be created using the Public Keyhash.