Socket
Socket
Sign inDemoInstall

bitcore-lib-cash

Package Overview
Dependencies
Maintainers
3
Versions
101
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bitcore-lib-cash - npm Package Compare versions

Comparing version 8.25.21 to 8.25.22

69

lib/transaction/transaction.js

@@ -566,2 +566,61 @@ 'use strict';

/**
* associateInputs - Update inputs with utxos, allowing you to specify value, and pubkey.
* Populating these inputs allows for them to be signed with .sign(privKeys)
*
* @param {Array<Object>} utxos
* @param {Array<string | PublicKey>} pubkeys
* @param {number} threshold
* @param {Object} opts
* @returns {Array<number>}
*/
Transaction.prototype.associateInputs = function(utxos, pubkeys, threshold, opts) {
let indexes = [];
for(let utxo of utxos) {
const index = this.inputs.findIndex(i => i.prevTxId.toString('hex') === utxo.txId && i.outputIndex === utxo.outputIndex);
indexes.push(index);
if(index >= 0) {
this.inputs[index] = this._getInputFrom(utxo, pubkeys, threshold, opts);
}
}
return indexes;
};
Transaction.prototype._selectInputType = function(utxo, pubkeys, threshold) {
var clazz;
utxo = new UnspentOutput(utxo);
if(pubkeys && threshold) {
if (utxo.script.isMultisigOut()) {
clazz = MultiSigInput;
} else if (utxo.script.isScriptHashOut() || utxo.script.isWitnessScriptHashOut()) {
clazz = MultiSigScriptHashInput;
}
} else if (utxo.script.isPublicKeyHashOut() || utxo.script.isWitnessPublicKeyHashOut() || utxo.script.isScriptHashOut()) {
clazz = PublicKeyHashInput;
} else if (utxo.script.isPublicKeyOut()) {
clazz = PublicKeyInput;
} else {
clazz = Input;
}
return clazz;
};
Transaction.prototype._getInputFrom = function(utxo, pubkeys, threshold, opts) {
utxo = new UnspentOutput(utxo);
const InputClass = this._selectInputType(utxo, pubkeys, threshold);
const input = {
output: new Output({
script: utxo.script,
satoshis: utxo.satoshis
}),
prevTxId: utxo.txId,
outputIndex: utxo.outputIndex,
sequenceNumber: utxo.sequenceNumber,
script: Script.empty()
};
let args = pubkeys && threshold ? [pubkeys, threshold, false, opts] : []
return new InputClass(input, ...args);
}
Transaction.prototype._fromEscrowUtxo = function(utxo, pubkeys) {

@@ -1019,3 +1078,3 @@ const publicKeys = pubkeys.map(pubkey => new PublicKey(pubkey));

var copy = Array.prototype.concat.apply([], inputs);
let i = 0;
let i = 0;
copy.forEach((x) => { x.i = i++});

@@ -1031,3 +1090,3 @@ copy.sort(function(first, second) {

var copy = Array.prototype.concat.apply([], outputs);
let i = 0;
let i = 0;
copy.forEach((x) => { x.i = i++});

@@ -1130,3 +1189,3 @@ copy.sort(function(first, second) {

signingMethod = signingMethod || "ecdsa"
$.checkState(this.hasAllUtxoInfo(), 'Not all utxo information is available to sign the transaction.');

@@ -1153,3 +1212,3 @@ var self = this;

var results = [];
var hashData = Hash.sha256ripemd160(privKey.publicKey.toBuffer());

@@ -1394,3 +1453,3 @@ _.each(this.inputs, function forEachInput(input, index) {

$.checkArgument(
JSUtil.isNaturalNumber(version) && version <= CURRENT_VERSION,
JSUtil.isNaturalNumber(version) && version <= CURRENT_VERSION,
'Wrong version number');

@@ -1397,0 +1456,0 @@ this.version = version;

4

package.json
{
"name": "bitcore-lib-cash",
"version": "8.25.21",
"version": "8.25.22",
"description": "A pure and powerful JavaScript Bitcoin Cash library.",

@@ -55,3 +55,3 @@ "author": "BitPay <dev@bitpay.com>",

"license": "MIT",
"gitHead": "bfc9748d98ad3786fd22adf099227b0ce07c0771"
"gitHead": "56f151d1f2b9f8b21f71996b8d7900e34a2d356f"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc