Join our webinar on Wednesday, June 26, at 1pm EDTHow Chia Mitigates Risk in the Crypto Industry.Register
Socket
Socket
Sign inDemoInstall

bitcore-wallet-utils

Package Overview
Dependencies
73
Maintainers
3
Versions
31
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.13 to 0.0.14

8

lib/walletutils.js

@@ -152,4 +152,11 @@ 'use strict';

WalletUtils.buildTx = function(txp) {
Bitcore.Transaction.FEE_SECURITY_MARGIN = 1;
var t = new Bitcore.Transaction();
if (txp.feePerKb) {
$.checkArgument(txp.feePerKb <= 10000);
t.feePerKb(txp.feePerKb);
}
_.each(txp.inputs, function(i) {

@@ -200,3 +207,2 @@ t.from(i, i.publicKeys, txp.requiredSignatures);

var signatures = _.map(privs, function(priv, i) {

@@ -203,0 +209,0 @@ return t.getSignatures(priv);

4

package.json

@@ -5,3 +5,3 @@ {

"author": "BitPay Inc",
"version": "0.0.13",
"version": "0.0.14",
"main": "index.js",

@@ -23,3 +23,3 @@ "keywords": [

"dependencies": {
"bitcore": "^0.11.4",
"bitcore": "git://github.com/bitpay/bitcore.git#a4ac3f50d300b3f89fad02f9e38fc536ac90abdc",
"coveralls": "^2.11.2",

@@ -26,0 +26,0 @@ "lodash": "^3.3.1",

@@ -203,3 +203,70 @@ 'use strict';

describe('#buildTx', function() {
it('should build a tx correctly', function() {
var hdPrivateKey = new Bitcore.HDPrivateKey('tprv8ZgxMBicQKsPdPLE72pfSo7CvzTsWddGHdwSuMNrcerr8yQZKdaPXiRtP9Ew8ueSe9M7jS6RJsp4DiAVS2xmyxcCC9kZV6X1FMsX7EQX2R5');
var derivedPrivateKey = hdPrivateKey.derive(WalletUtils.PATHS.BASE_ADDRESS_DERIVATION);
var toAddress = 'msj42CCGruhRsFrGATiUuh25dtxYtnpbTx';
var changeAddress = 'msj42CCGruhRsFrGATiUuh25dtxYtnpbTx';
var publicKeyRing = [{
xPubKey: new Bitcore.HDPublicKey(derivedPrivateKey)
}];
var utxos = helpers.generateUtxos(publicKeyRing, 'm/1/0', 1, [1000, 2000]);
var txp = {
inputs: utxos,
toAddress: toAddress,
amount: 1200,
changeAddress: {
address: changeAddress
},
requiredSignatures: 1,
outputOrder: [0, 1]
};
var t = WalletUtils.buildTx(txp);
var bitcoreError = t.getSerializationError({
disableIsFullySigned: true,
});
should.not.exist(bitcoreError);
t.getFee().should.equal(10000);
});
it('should build a tx with custom fee per kb', function() {
var hdPrivateKey = new Bitcore.HDPrivateKey('tprv8ZgxMBicQKsPdPLE72pfSo7CvzTsWddGHdwSuMNrcerr8yQZKdaPXiRtP9Ew8ueSe9M7jS6RJsp4DiAVS2xmyxcCC9kZV6X1FMsX7EQX2R5');
var derivedPrivateKey = hdPrivateKey.derive(WalletUtils.PATHS.BASE_ADDRESS_DERIVATION);
var toAddress = 'msj42CCGruhRsFrGATiUuh25dtxYtnpbTx';
var changeAddress = 'msj42CCGruhRsFrGATiUuh25dtxYtnpbTx';
var publicKeyRing = [{
xPubKey: new Bitcore.HDPublicKey(derivedPrivateKey)
}];
var utxos = helpers.generateUtxos(publicKeyRing, 'm/1/0', 1, [1000, 2000]);
var txp = {
inputs: utxos,
toAddress: toAddress,
amount: 1200,
changeAddress: {
address: changeAddress
},
feePerKb: 15000,
requiredSignatures: 1,
outputOrder: [0, 1]
};
(function() {
WalletUtils.buildTx(txp);
}).should.throw('Illegal Argument');
txp.feePerKb = 5000;
var t = WalletUtils.buildTx(txp);
var bitcoreError = t.getSerializationError({
disableIsFullySigned: true,
});
should.not.exist(bitcoreError);
t.getFee().should.equal(5000);
});
});
describe('#signTxp', function() {

@@ -206,0 +273,0 @@ it('should sign correctly', function() {

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc