cashninjas/ninjas.cash

Allow multiple user-inputs in minting transaction

mr-zwets opened this issue · 0 comments

The cashscript code for the minting smart contract allows for the user to add multiple inputs.

  // Get userInput for mint
  const userAddress = await getUserAddress();
  const userUtxos = await electrumServer.getUtxos(userAddress);
  const networkFeeMint = 520;
  const filteredUserUtxos = userUtxos.filter(
    val => !val.token && val.satoshis >= mintPriceSats + networkFeeMint,
  );
  const bchBalanceUser = userUtxos.reduce((total, utxo) => utxo.token ? total : total + utxo.satoshis, 0n);
  const userInput = filteredUserUtxos[0];

this code could just as well select an array of userInputs to get to the required minting amount.

Next the fromP2PKH(userInput, userSig) in the transaction construction should be using this array of userInputs and then set the all signatures to be empty before adding each input to the listSourceOutputs .