Skip to content

Send method doesn't work because of wrong witnesses placeholders generated #7

@e00dan

Description

@e00dan
  • I'm submitting a ...
    [x] bug report
    [ ] feature request
    [ ] question about the decisions made in the repository
    [ ] question about how to use this project

  • Summary

pwCore.send() method with RawProvider and privateKey that was just added in 0.4.0-alpha.6 seems to be broken. Especially the part that is failing with:

"... source: Inputs[0].Lock, cause: ValidationFailure(-31): the exit code is per script specific ...".

I'm using pwCore method (it abstracts away generating signature): https://gist.github.com/Kuzirashi/ddbcd1b56f6325077a12a27943f0d154

  • Other information

The problem seems to be length of witnessArgs passed to @lay2/pw-core/build/main/models/transaction.js. Broken (current state):

{
  witnessArgs: [
    {
      lock: '0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
      input_type: '',
      output_type: ''
    }
  ],
  witnesses: [ '0x' ]
}
// ... then witnesses placeholders are generated wrong because of this and it makes transaction fail \/

witnesses: [
    '0x5600000010000000560000005600000042000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
  ]

It should be instead:

{
  witnessArgs: [
    {
      lock: '0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
      input_type: '',
      output_type: ''
    }
  ],
  witnesses: [ '0x' ]
}
// =>
witnesses: [
    '0x55000000100000005500000055000000410000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
  ]

From what I see this is the fix (transaction is committed to chain instead of error):
image

this.witnessArgs = witnessArgs.map(arg => ({ ...arg, lock: arg.lock.slice(0, arg.lock.length - 2) })); // FIX

Full tx structure:
image

After above fix I was able to successfully send from CKB address to ETH address on L1 using this script: https://gist.github.com/Kuzirashi/2f13e487645fd4d74503957429d21afc

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions