Skip to content

fix: Fix unmatched cheque lockHash - #2390

Merged
Keith-CY merged 2 commits into
nervosnetwork:developfrom
yanguoyu:fix-nomatch-cheque-lockhash
May 26, 2022
Merged

fix: Fix unmatched cheque lockHash#2390
Keith-CY merged 2 commits into
nervosnetwork:developfrom
yanguoyu:fix-nomatch-cheque-lockhash

Conversation

@yanguoyu

Copy link
Copy Markdown
Contributor

No description provided.

@Keith-CY
Keith-CY requested review from Cedar67, Keith-CY and qiweiii May 20, 2022 06:41
@Keith-CY

Keith-CY commented May 20, 2022

Copy link
Copy Markdown
Contributor

Could you describe the bug in a little detail cuz it's too brief in the issue that I'm not clear about it.

@yanguoyu

yanguoyu commented May 20, 2022

Copy link
Copy Markdown
Contributor Author

Could you describe the bug in a little detail cuz it's too brief in the issue that I'm not clear about it.

Detail on this issue.

@Keith-CY

Copy link
Copy Markdown
Contributor

Could you describe the bug in a little detail cuz it's too brief in the issue that I'm not clear about it.
Detail on this issue.

I've viewed the issue but am not clear about the error.

    const chequeCellTmp = Output.fromObject({
      capacity: BigInt(162 * 10 ** 8).toString(),
      lock: assetAccountInfo.generateChequeScript('0'.repeat(40), '0'.repeat(40)),
      type: assetAccountInfo.generateSudtScript(assetAccount.tokenID)
    })
   // ...
    const chequeCell = Output.fromObject({
      ...chequeCellTmp,
      data: BufferUtils.writeBigUInt128LE(BigInt(gatheredSudtInputResult.amount)),
      lock: assetAccountInfo.generateChequeScript(
        receiverLockScript.computeHash(),
        senderDefaultCell.lock!.computeHash()
      )
    })

chequeCellTmp is used as a placeholder of a cheque cell and its lock will be overridden by

assetAccountInfo.generateChequeScript(
  receiverLockScript.computeHash(),
  senderDefaultCell.lock!.computeHash()
)

and finally turns into

{
  capacity: BigInt(162 * 10 ** 8).toString(),
  lock: assetAccountInfo.generateChequeScript(
    receiverLockScript.computeHash(),
    senderDefaultCell.lock!.computeHash()
  ),
  type: assetAccountInfo.generateSudtScript(assetAccount.tokenID),
  data: BufferUtils.writeBigUInt128LE(BigInt(gatheredSudtInputResult.amount)),
}

Which property is not correct

@yanguoyu

Copy link
Copy Markdown
Contributor Author

Could you describe the bug in a little detail cuz it's too brief in the issue that I'm not clear about it.
Detail on this issue.

I've viewed the issue but am not clear about the error.

    const chequeCellTmp = Output.fromObject({
      capacity: BigInt(162 * 10 ** 8).toString(),
      lock: assetAccountInfo.generateChequeScript('0'.repeat(40), '0'.repeat(40)),
      type: assetAccountInfo.generateSudtScript(assetAccount.tokenID)
    })
   // ...
    const chequeCell = Output.fromObject({
      ...chequeCellTmp,
      data: BufferUtils.writeBigUInt128LE(BigInt(gatheredSudtInputResult.amount)),
      lock: assetAccountInfo.generateChequeScript(
        receiverLockScript.computeHash(),
        senderDefaultCell.lock!.computeHash()
      )
    })

chequeCellTmp is used as a placeholder of a cheque cell and its lock will be overridden by

assetAccountInfo.generateChequeScript(
  receiverLockScript.computeHash(),
  senderDefaultCell.lock!.computeHash()
)

and finally turns into

{
  capacity: BigInt(162 * 10 ** 8).toString(),
  lock: assetAccountInfo.generateChequeScript(
    receiverLockScript.computeHash(),
    senderDefaultCell.lock!.computeHash()
  ),
  type: assetAccountInfo.generateSudtScript(assetAccount.tokenID),
  data: BufferUtils.writeBigUInt128LE(BigInt(gatheredSudtInputResult.amount)),
}

Which property is not correct

Output's lockHash is computed by chequeCellTmp's lock, but not computed by chequeCell 's lock. So I set chequeCell's lockHash undefined, so it can be computed again.

@Keith-CY

Copy link
Copy Markdown
Contributor

Could you describe the bug in a little detail cuz it's too brief in the issue that I'm not clear about it.
Detail on this issue.

I've viewed the issue but am not clear about the error.

    const chequeCellTmp = Output.fromObject({
      capacity: BigInt(162 * 10 ** 8).toString(),
      lock: assetAccountInfo.generateChequeScript('0'.repeat(40), '0'.repeat(40)),
      type: assetAccountInfo.generateSudtScript(assetAccount.tokenID)
    })
   // ...
    const chequeCell = Output.fromObject({
      ...chequeCellTmp,
      data: BufferUtils.writeBigUInt128LE(BigInt(gatheredSudtInputResult.amount)),
      lock: assetAccountInfo.generateChequeScript(
        receiverLockScript.computeHash(),
        senderDefaultCell.lock!.computeHash()
      )
    })

chequeCellTmp is used as a placeholder of a cheque cell and its lock will be overridden by

assetAccountInfo.generateChequeScript(
  receiverLockScript.computeHash(),
  senderDefaultCell.lock!.computeHash()
)

and finally turns into

{
  capacity: BigInt(162 * 10 ** 8).toString(),
  lock: assetAccountInfo.generateChequeScript(
    receiverLockScript.computeHash(),
    senderDefaultCell.lock!.computeHash()
  ),
  type: assetAccountInfo.generateSudtScript(assetAccount.tokenID),
  data: BufferUtils.writeBigUInt128LE(BigInt(gatheredSudtInputResult.amount)),
}

Which property is not correct

Output's lockHash is computed by chequeCellTmp's lock, but not computed by chequeCell 's lock. So I set chequeCell's lockHash undefined, so it can be computed again.

Got it

@Keith-CY
Keith-CY merged commit d31f721 into nervosnetwork:develop May 26, 2022
@Keith-CY Keith-CY mentioned this pull request Jun 9, 2022
@yanguoyu
yanguoyu deleted the fix-nomatch-cheque-lockhash branch June 16, 2022 06:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants