CashScript / cashscript

⚖️ Easily write and interact with Bitcoin Cash smart contracts
https://cashscript.org
MIT License
115 stars 80 forks source link

Found a bug when calculating NFT inputs and outputs #149

Closed wafeishushu closed 1 year ago

wafeishushu commented 1 year ago

File: .../node_modules/cashscript/dist/Transaction.js Function: setInputsAndOutputs() Line: 224

if (JSON.stringify(listNftsOutputs[i]) === JSON.stringify(nftInput)) {
    listNftsOutputs.splice(i, 1);
    unusedNfts = unusedNfts.filter((nft) => nft !== nftInput);
    break;
}

Although I wrote the correct inputs and outputs, the inputs are judged to be unusedNfts in this condition, like:

1: listNftsInputs [
  {
    commitment: '05',
    capability: 'none',
    category: 'a7c25f1713935dbe5024339abe4e6b33b9b8e510fda4ae2bdef6e8de8be019ba'
  },
  {
    commitment: '00',
    capability: 'none',
    category: 'a7c25f1713935dbe5024339abe4e6b33b9b8e510fda4ae2bdef6e8de8be019ba'
  }
]
2: listNftsOutputs [
  {
    capability: 'none',
    commitment: '05',
    category: 'a7c25f1713935dbe5024339abe4e6b33b9b8e510fda4ae2bdef6e8de8be019ba'
  },
  {
    capability: 'none',
    commitment: '00',
    category: 'a7c25f1713935dbe5024339abe4e6b33b9b8e510fda4ae2bdef6e8de8be019ba'
  }
]
3: unusedNfts [
  {
    commitment: '05',
    capability: 'none',
    category: 'a7c25f1713935dbe5024339abe4e6b33b9b8e510fda4ae2bdef6e8de8be019ba'
  },
  {
    commitment: '00',
    capability: 'none',
    category: 'a7c25f1713935dbe5024339abe4e6b33b9b8e510fda4ae2bdef6e8de8be019ba'
  }
]
rkalis commented 1 year ago

Hi @wafeishushu, thank you for reporting this bug. I was able to reproduce it locally and I pushed a fix in the new version 0.8.1. This new version should fix the bug. If the issue still persists for you, please feel free to re-open.