bitcore-wallet-utils
Advanced tools
Comparing version 0.0.13 to 0.0.14
@@ -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); |
@@ -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() { |
Git dependency
Supply chain riskContains a dependency which resolves to a remote git URL. Dependencies fetched from git URLs are not immutable can be used to inject untrusted code or reduce the likelihood of a reproducible install.
Found 1 instance in 1 package
22930
513
1
- Removedbitcore@0.11.7(transitive)
Updatedbitcore@git://github.com/bitpay/bitcore.git#a4ac3f50d300b3f89fad02f9e38fc536ac90abdc