Socket
Socket
Sign inDemoInstall

bitcore

Package Overview
Dependencies
Maintainers
2
Versions
132
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bitcore - npm Package Compare versions

Comparing version 0.12.8 to 0.12.9

2

bower.json
{
"name": "bitcore",
"main": "./bitcore.min.js",
"version": "0.12.8",
"version": "0.12.9",
"homepage": "http://bitcore.io",

@@ -6,0 +6,0 @@ "authors": [

@@ -250,5 +250,6 @@ 'use strict';

var bn = new BN(json.bn, 'hex');
var network = Networks.get(json.network);
return {
bn: bn,
network: json.network,
network: network,
compressed: json.compressed

@@ -255,0 +256,0 @@ };

@@ -208,3 +208,3 @@ 'use strict';

return unspentError ||
return unspentError ||
this._hasDustOutputs(opts) ||

@@ -398,3 +398,3 @@ this._isMissingSignatures(opts);

$.checkState(this.outputs[this._changeIndex].script.toString() ===
this._changeScript.toString());
this._changeScript.toString());
}

@@ -639,2 +639,17 @@ // TODO: add other checks

/**
* Manually set the fee per KB for this transaction. Beware that this resets all the signatures
* for inputs (in further versions, SIGHASH_SINGLE or SIGHASH_NONE signatures will not
* be reset).
*
* @param {number} amount satoshis per KB to be sent
* @return {Transaction} this, for chaining
*/
Transaction.prototype.feePerKb = function(amount) {
$.checkArgument(_.isNumber(amount), 'amount must be a number');
this._feePerKb = amount;
this._updateChangeOutput();
return this;
};
/* Output management */

@@ -837,3 +852,3 @@

var available = this._getUnspentValue();
return Transaction._estimateFee(estimatedSize, available);
return Transaction._estimateFee(estimatedSize, available, this._feePerKb);
};

@@ -851,8 +866,8 @@

Transaction._estimateFee = function(size, amountAvailable) {
var fee = Math.ceil(size / Transaction.FEE_PER_KB);
Transaction._estimateFee = function(size, amountAvailable, feePerKb) {
var fee = Math.ceil(size / 1000) * (feePerKb || Transaction.FEE_PER_KB);
if (amountAvailable > fee) {
size += Transaction.CHANGE_OUTPUT_MAX_SIZE;
}
return Math.ceil(size / 1000) * Transaction.FEE_PER_KB;
return Math.ceil(size / 1000) * (feePerKb || Transaction.FEE_PER_KB);
};

@@ -859,0 +874,0 @@

{
"name": "bitcore",
"version": "0.12.8",
"version": "0.12.9",
"dependencies": {

@@ -5,0 +5,0 @@ "bn.js": {

{
"name": "bitcore",
"version": "0.12.8",
"version": "0.12.9",
"description": "A pure and powerful JavaScript Bitcoin library.",

@@ -5,0 +5,0 @@ "author": "BitPay <dev@bitpay.com>",

@@ -180,2 +180,13 @@ 'use strict';

it('input json should correctly initialize network field', function() {
['livenet', 'testnet', 'mainnet'].forEach(function (net) {
var pk = PrivateKey.fromJSON(JSON.stringify({
bn: '96c132224121b509b7d0a16245e957d9192609c5637c6228311287b1be21627a',
compressed: false,
network: net
}));
pk.network.should.be.deep.equal(Networks.get(net));
});
});
it('an object with private key info can be also used as argument for "fromJSON"', function() {

@@ -182,0 +193,0 @@ expect(PrivateKey._isJSON({bn: true, network: true})).to.equal(true);

@@ -260,2 +260,18 @@ 'use strict';

});
it('fee per kb can be set up manually', function() {
var inputs = _.map(_.range(10), function(i) {
var utxo = _.clone(simpleUtxoWith100000Satoshis);
utxo.outputIndex = i;
return utxo;
});
var transaction = new Transaction()
.from(inputs)
.to(toAddress, 950000)
.feePerKb(8000)
.change(changeAddress)
.sign(privateKey);
transaction._estimateSize().should.be.within(1000, 1999);
transaction.outputs.length.should.equal(2);
transaction.outputs[1].satoshis.should.equal(34000);
});
it('if satoshis are invalid', function() {

@@ -410,3 +426,5 @@ var transaction = new Transaction()

expect(function() {
return transaction.serialize({disableMoreOutputThanInput: true});
return transaction.serialize({
disableMoreOutputThanInput: true
});
}).to.throw(errors.Transaction.FeeError.TooLarge);

@@ -413,0 +431,0 @@ });

Sorry, the diff of this file is not supported yet

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