lib/transaction.js
function applyMultiSignatures(_txObj, i, signatures, redeemScript) {
  // Make a copy
  var txObj = JSON.parse(JSON.stringify(_txObj));

  var redeemScriptPushDataLength = zbufferutils.getPushDataLength(redeemScript);

  // Lmao no idea, just following the source code
  if (redeemScriptPushDataLength.length > 2) {
    if (redeemScriptPushDataLength.length === 6) {
      redeemScriptPushDataLength = redeemScriptPushDataLength.slice(2, 4);
    }
  }

  // http://www.soroushjp.com/2014/12/20/bitcoin-multisig-the-hard-way-understanding-raw-multisignature-bitcoin-transactions/
  txObj.ins[i].script = zopcodes.OP_0 + signatures.map(function (x) {
    return zbufferutils.getPushDataLength(x) + x;
  }).join('') + zopcodes.OP_PUSHDATA1 + redeemScriptPushDataLength + redeemScript;

  return txObj;
}
function applyMultiSignatures(_txObj, i, signatures, redeemScript) {
  // Make a copy
  var txObj = JSON.parse(JSON.stringify(_txObj));

  var redeemScriptPushDataLength = zbufferutils.getPushDataLength(redeemScript);

  // Lmao no idea, just following the source code
  if (redeemScriptPushDataLength.length > 2) {
    if (redeemScriptPushDataLength.length === 6) {
      redeemScriptPushDataLength = redeemScriptPushDataLength.slice(2, 4);
    }
  }

  // http://www.soroushjp.com/2014/12/20/bitcoin-multisig-the-hard-way-understanding-raw-multisignature-bitcoin-transactions/
  txObj.ins[i].script = zopcodes.OP_0 + signatures.map(function (x) {
    return zbufferutils.getPushDataLength(x) + x;
  }).join('') + zopcodes.OP_PUSHDATA1 + redeemScriptPushDataLength + redeemScript;

  return txObj;
}
/*
Applies the signatures to the transaction object
NOTE: You NEED to supply the signatures in order.
E.g. You made sigAddr1 with priv1, priv3, priv2
You can provide signatures of (priv1, priv2) (priv3, priv2) ...
But not (priv2, priv1)
@param {String} _txObj transaction object you wanna sign
@param {Int} index fof tx.in to sign
@param {[string]} signatures obtained from multiSign
@param {string} redeemScript (redeemScript of the multi-sig)
@param {string} hashcode (SIGHASH_ALL, SIGHASH_NONE, etc)
return {String} signature