Browse Source

derive() -> deriveChild()

feat/estimateFee-limit
Ivan Socolsky 8 years ago
parent
commit
558c6fbc38
No known key found for this signature in database GPG Key ID: FAECE6A05FAA4F56
  1. 2
      lib/model/address.js
  2. 2
      lib/model/txproposal.js
  3. 4
      lib/server.js
  4. 14
      test/integration/helpers.js

2
lib/model/address.js

@ -47,7 +47,7 @@ Address._deriveAddress = function(scriptType, publicKeyRing, path, m, network) {
var publicKeys = _.map(publicKeyRing, function(item) {
var xpub = new Bitcore.HDPublicKey(item.xPubKey);
return xpub.derive(path).publicKey;
return xpub.deriveChild(path).publicKey;
});
var bitcoreAddress;

2
lib/model/txproposal.js

@ -333,7 +333,7 @@ TxProposal.prototype._addSignaturesToBitcoreTx = function(tx, signatures, xpub)
var input = self.inputs[i];
try {
var signature = Bitcore.crypto.Signature.fromString(signatureHex);
var pub = x.derive(self.inputPaths[i]).publicKey;
var pub = x.deriveChild(self.inputPaths[i]).publicKey;
var s = {
inputIndex: i,
signature: signature,

4
lib/server.js

@ -472,7 +472,7 @@ WalletService.prototype._verifySignature = function(text, signature, pubkey) {
* @param xPubKey
*/
WalletService.prototype._verifyRequestPubKey = function(requestPubKey, signature, xPubKey) {
var pub = (new Bitcore.HDPublicKey(xPubKey)).derive(Constants.PATHS.REQUEST_KEY_AUTH).publicKey;
var pub = (new Bitcore.HDPublicKey(xPubKey)).deriveChild(Constants.PATHS.REQUEST_KEY_AUTH).publicKey;
return Utils.verifyMessage(requestPubKey, signature, pub.toString());
};
@ -2017,7 +2017,7 @@ WalletService.prototype.createTx = function(opts, cb) {
});
};
WalletService.prototype._verifyRequestPubKey = function(requestPubKey, signature, xPubKey) {
var pub = (new Bitcore.HDPublicKey(xPubKey)).derive(Constants.PATHS.REQUEST_KEY_AUTH).publicKey;
var pub = (new Bitcore.HDPublicKey(xPubKey)).deriveChild(Constants.PATHS.REQUEST_KEY_AUTH).publicKey;
return Utils.verifyMessage(requestPubKey, signature, pub.toString());
};

14
test/integration/helpers.js

@ -88,7 +88,7 @@ helpers.signMessage = function(text, privKey) {
};
helpers.signRequestPubKey = function(requestPubKey, xPrivKey) {
var priv = new Bitcore.HDPrivateKey(xPrivKey).derive(Constants.PATHS.REQUEST_KEY_AUTH).privateKey;
var priv = new Bitcore.HDPrivateKey(xPrivKey).deriveChild(Constants.PATHS.REQUEST_KEY_AUTH).privateKey;
return helpers.signMessage(requestPubKey, priv);
};
@ -113,18 +113,18 @@ helpers._generateCopayersTestData = function(n) {
var xpriv = new Bitcore.HDPrivateKey();
var xpub = Bitcore.HDPublicKey(xpriv);
var xpriv_45H = xpriv.derive(45, true);
var xpriv_45H = xpriv.deriveChild(45, true);
var xpub_45H = Bitcore.HDPublicKey(xpriv_45H);
var id45 = Copayer._xPubToCopayerId(xpub_45H.toString());
var xpriv_44H_0H_0H = xpriv.derive(44, true).derive(0, true).derive(0, true);
var xpriv_44H_0H_0H = xpriv.deriveChild(44, true).deriveChild(0, true).deriveChild(0, true);
var xpub_44H_0H_0H = Bitcore.HDPublicKey(xpriv_44H_0H_0H);
var id44 = Copayer._xPubToCopayerId(xpub_44H_0H_0H.toString());
var xpriv_1H = xpriv.derive(1, true);
var xpriv_1H = xpriv.deriveChild(1, true);
var xpub_1H = Bitcore.HDPublicKey(xpriv_1H);
var priv = xpriv_1H.derive(0).privateKey;
var pub = xpub_1H.derive(0).publicKey;
var priv = xpriv_1H.deriveChild(0).privateKey;
var pub = xpub_1H.deriveChild(0).publicKey;
console.log('{id44: ', "'" + id44 + "',");
console.log('id45: ', "'" + id45 + "',");
@ -374,7 +374,7 @@ helpers.clientSign = function(txp, derivedXPrivKey) {
_.each(txp.inputs, function(i) {
if (!derived[i.path]) {
derived[i.path] = xpriv.derive(i.path).privateKey;
derived[i.path] = xpriv.deriveChild(i.path).privateKey;
privs.push(derived[i.path]);
}
});

Loading…
Cancel
Save