CashScript / cashscript

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

make transactionBuilder.inputs public to generate SourceOutputs #198

Open mr-zwets opened 1 month ago

mr-zwets commented 1 month ago

For walletConnect signing with SIGHASH_UTXOS, users need access to the transactions' sourceOutputs.

It is easy to generate sourceOutputs with the transactionBuilder.inputs

but transactionBuilder.inputs is currently a private property.

    // Generate source outputs from inputs (for signing with SIGHASH_UTXOS)
    const sourceOutputs = this.inputs.map((input) => {
      const sourceOutput = {
        amount: input.satoshis,
        to: input.unlocker.generateLockingBytecode(),
        token: input.token,
      };

      return cashScriptOutputToLibauthOutput(sourceOutput);
    });

releated to issue https://github.com/CashScript/cashscript/issues/191 "Create a way for the advanced transaction builder to communicate with WalletConnect for signing"

mr-zwets commented 1 month ago

somewhat related, the ninjas.cash mint used the following code when constructing the listSourceOutputs for walletconnect

contract: {
        abiFunction: transaction.abiFunction,
        redeemScript: contract.redeemScript,
        artifact: contract.artifact,
      }

https://github.com/cashninjas/ninjas.cash/blob/ee64614776d95389dcb1389e9760be574aea8c0a/js/mint.js#L260

however as Salemkode pointed out transaction.abiFunction is private in TS