How to use the algosdk.Multisig.MultiSigTransaction function in algosdk

To help you get started, we’ve selected a few algosdk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github BitGo / BitGoJS / modules / core / src / v2 / coins / algo.ts View on Github external
const txHex = params.txHex || (params.halfSigned && params.halfSigned.txHex);

      if (!txHex) {
        throw new Error('missing required param txHex or halfSigned.txHex');
      }
      let tx;
      try {
        const txToHex = Buffer.from(txHex, 'base64');
        const decodedTx = Encoding.decode(txToHex);

        // if we are a signed msig tx, the structure actually has the { msig, txn } as the root object
        // if we are not signed, the decoded tx is the txn - refer to partialSignTxn and MultiSig constructor
        //   in algosdk for more information
        const txnForDecoding = decodedTx.txn || decodedTx;

        tx = Multisig.MultiSigTransaction.from_obj_for_encoding(txnForDecoding);
      } catch (ex) {
        throw new Error('txHex needs to be a valid tx encoded as base64 string');
      }

      const id = tx.txID();
      const fee = { fee: tx.fee };

      const outputAmount = tx.amount || 0;
      const outputs: { amount: number; address: string }[] = [];
      if (tx.to) {
        outputs.push({
          amount: outputAmount,
          address: Address.encode(new Uint8Array(tx.to.publicKey)),
        });
      }