mirror of https://github.com/BTCPrivate/copay.git
small fixes
This commit is contained in:
parent
4092f0cb9d
commit
31b2d5abac
|
@ -71,9 +71,6 @@ PrivateKey.prototype.get = function(index,isChange) {
|
|||
|
||||
PrivateKey.prototype.getAll = function(addressIndex, changeAddressIndex) {
|
||||
var ret = [];
|
||||
console.log('[PrivateKey.js.75:addressIndex:]',addressIndex); //TODO
|
||||
console.log('[PrivateKey.js.79:changeAddressIndex:]',changeAddressIndex); //TODO
|
||||
|
||||
for(var i=0;i<addressIndex; i++) {
|
||||
ret.push(this.get(i,false));
|
||||
}
|
||||
|
|
|
@ -142,7 +142,7 @@ PublicKeyRing.prototype.getPubKeys = function (index, isChange) {
|
|||
var bip32 = this.copayersBIP32[i].derive(path);
|
||||
pubKeys[i] = bip32.eckey.public;
|
||||
}
|
||||
this.publicKeysCache[path] = pubKeys.map(function(pk){return pk.toString('hex')});
|
||||
this.publicKeysCache[path] = pubKeys.map(function(pk){return pk.toString('hex');});
|
||||
} else {
|
||||
pubKeys = pubKeys.map(function(s){return new Buffer(s,'hex')});
|
||||
}
|
||||
|
@ -158,22 +158,30 @@ PublicKeyRing.prototype._checkIndexRange = function (index, isChange) {
|
|||
}
|
||||
};
|
||||
|
||||
// TODO this could be cached
|
||||
PublicKeyRing.prototype.getRedeemScript = function (index, isChange) {
|
||||
this._checkIndexRange(index, isChange);
|
||||
|
||||
var pubKeys = this.getPubKeys(index, isChange);
|
||||
console.log('[PublicKeyRing.js.164:index:] getRedeemScript: ',index, isChange); //TODO
|
||||
var script = Script.createMultisig(this.requiredCopayers, pubKeys);
|
||||
return script;
|
||||
};
|
||||
|
||||
|
||||
// TODO this could be cached
|
||||
PublicKeyRing.prototype.getAddress = function (index, isChange) {
|
||||
this._checkIndexRange(index, isChange);
|
||||
var script = this.getRedeemScript(index,isChange);
|
||||
return Address.fromScript(script, this.network.name);
|
||||
};
|
||||
|
||||
// TODO this could be cached
|
||||
PublicKeyRing.prototype._addScriptMap = function (map, index, isChange) {
|
||||
this._checkIndexRange(index, isChange);
|
||||
var script = this.getRedeemScript(index,isChange);
|
||||
map[Address.fromScript(script, this.network.name).toString()] = script.getBuffer().toString('hex');
|
||||
};
|
||||
|
||||
// TODO this could be cached
|
||||
PublicKeyRing.prototype.getScriptPubKeyHex = function (index, isChange) {
|
||||
this._checkIndexRange(index, isChange);
|
||||
var addr = this.getAddress(index,isChange);
|
||||
|
@ -181,7 +189,6 @@ PublicKeyRing.prototype.getScriptPubKeyHex = function (index, isChange) {
|
|||
};
|
||||
|
||||
|
||||
|
||||
//generate a new address, update index.
|
||||
PublicKeyRing.prototype.generateAddress = function(isChange) {
|
||||
|
||||
|
@ -216,11 +223,10 @@ PublicKeyRing.prototype.getRedeemScriptMap = function () {
|
|||
var ret = {};
|
||||
|
||||
for (var i=0; i<this.changeAddressIndex; i++) {
|
||||
ret[this.getAddress(i,true)] = this.getRedeemScript(i,true).getBuffer().toString('hex');
|
||||
this._addScriptMap(ret,i,true);
|
||||
}
|
||||
|
||||
for (var i=0; i<this.addressIndex; i++) {
|
||||
ret[this.getAddress(i)] = this.getRedeemScript(i).getBuffer().toString('hex');
|
||||
this._addScriptMap(ret,i,false);
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
|
|
@ -269,7 +269,6 @@ Wallet.prototype.sendPublicKeyRing = function(recipients) {
|
|||
|
||||
Wallet.prototype.generateAddress = function(isChange) {
|
||||
var addr = this.publicKeyRing.generateAddress(isChange);
|
||||
console.log('[Wallet.js.281:addr:]',addr, this.publicKeyRing.toObj(), this.getAddresses()); //TODO
|
||||
this.sendPublicKeyRing();
|
||||
this.store(true);
|
||||
return addr;
|
||||
|
@ -318,7 +317,6 @@ Wallet.prototype.sign = function(ntxid) {
|
|||
|
||||
var pkr = self.publicKeyRing;
|
||||
var keys = self.privateKey.getAll(pkr.addressIndex, pkr.changeAddressIndex);
|
||||
console.log('[Wallet.js.329:keys:] LENGTH::',keys.length, pkr.addressIndex, pkr.changeAddressIndex); //TODO
|
||||
|
||||
var b = txp.builder;
|
||||
var before = b.signaturesAdded;
|
||||
|
@ -465,11 +463,11 @@ Wallet.prototype.createTx = function(toAddress, amountSatStr, opts, cb) {
|
|||
}
|
||||
|
||||
self.getSafeUnspent(function(unspentList) {
|
||||
// TODO check enough funds, etc.
|
||||
self.createTxSync(toAddress, amountSatStr, unspentList, opts);
|
||||
if (self.createTxSync(toAddress, amountSatStr, unspentList, opts)) {
|
||||
self.sendPublicKeyRing(); // Change Address
|
||||
self.sendTxProposals();
|
||||
self.store();
|
||||
}
|
||||
return cb();
|
||||
});
|
||||
};
|
||||
|
@ -497,11 +495,8 @@ Wallet.prototype.createTxSync = function(toAddress, amountSatStr, utxos, opts) {
|
|||
|
||||
var signRet;
|
||||
if (priv) {
|
||||
var keys = priv.getAll(pkr.addressIndex, pkr.changeAddressIndex);
|
||||
console.log('[Wallet.js.329:keys:] LENGTH::',keys.length, pkr.addressIndex, pkr.changeAddressIndex); //TODO
|
||||
b.sign( keys );
|
||||
b.sign( priv.getAll(pkr.addressIndex, pkr.changeAddressIndex) );
|
||||
}
|
||||
console.log('[Wallet.js.494]', b, b.build().serialize().toString('hex')); //TODO
|
||||
var me = {};
|
||||
var myId = this.getMyPeerId();
|
||||
var now = Date.now();
|
||||
|
|
|
@ -261,7 +261,6 @@ console.log('[WebRTC.js.255] WARN: NO CONNECTION TO:', peerId); //TODO
|
|||
|
||||
Network.prototype.send = function(peerIds, data, cb) {
|
||||
var self=this;
|
||||
console.log('[WebRTC.js.242] SENDING ', data.type); //TODO
|
||||
if (!peerIds) {
|
||||
peerIds = this.connectedPeers;
|
||||
data.isBroadcast = 1;
|
||||
|
|
|
@ -107,15 +107,14 @@ describe('TxProposals model', function() {
|
|||
verifyP2SH: true,
|
||||
dontVerifyStrictEnc: true
|
||||
}, function(err, results){
|
||||
console.log('[test.TxProposals.js.106:err:]',err, results); //TODO
|
||||
// should.not.exist(err);
|
||||
// results.should.equal(true);
|
||||
should.not.exist(err);
|
||||
results.should.equal(true);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
it.skip('should create an instance', function () {
|
||||
it('should create an instance', function () {
|
||||
var w = new TxProposals({
|
||||
networkName: config.networkName
|
||||
});
|
||||
|
@ -157,7 +156,7 @@ describe('TxProposals model', function() {
|
|||
};
|
||||
|
||||
|
||||
it.skip('#getUsedUnspend', function () {
|
||||
it('#getUsedUnspend', function () {
|
||||
var priv = new PrivateKey(config);
|
||||
var w = new TxProposals({
|
||||
networkName: config.networkName,
|
||||
|
@ -181,7 +180,7 @@ describe('TxProposals model', function() {
|
|||
w.getUsedUnspent()[0].should.equal(unspentTest[0].txid);
|
||||
});
|
||||
|
||||
it.skip('#merge with self', function () {
|
||||
it('#merge with self', function () {
|
||||
var priv = new PrivateKey(config);
|
||||
var w = new TxProposals({
|
||||
networkName: config.networkName,
|
||||
|
@ -222,7 +221,7 @@ describe('TxProposals model', function() {
|
|||
|
||||
|
||||
|
||||
it.skip('#merge, merge signatures case 1', function () {
|
||||
it('#merge, merge signatures case 1', function () {
|
||||
var priv2 = new PrivateKey(config);
|
||||
var priv = new PrivateKey(config);
|
||||
var ts = Date.now();
|
||||
|
@ -297,7 +296,7 @@ var _dumpChunks = function (scriptSig, label) {
|
|||
};
|
||||
|
||||
|
||||
it.skip('#merge, merge signatures case 2', function () {
|
||||
it('#merge, merge signatures case 2', function () {
|
||||
|
||||
var priv = new PrivateKey(config);
|
||||
var priv2 = new PrivateKey(config);
|
||||
|
@ -399,7 +398,7 @@ var _dumpChunks = function (scriptSig, label) {
|
|||
});
|
||||
|
||||
|
||||
it.skip('#merge, merge signatures case 3', function () {
|
||||
it('#merge, merge signatures case 3', function () {
|
||||
|
||||
var priv = new PrivateKey(config);
|
||||
var priv2 = new PrivateKey(config);
|
||||
|
@ -496,7 +495,7 @@ var _dumpChunks = function (scriptSig, label) {
|
|||
|
||||
|
||||
|
||||
it.skip('#toObj #fromObj roundtrip', function () {
|
||||
it('#toObj #fromObj roundtrip', function () {
|
||||
|
||||
var priv = new PrivateKey(config);
|
||||
var pkr = createPKR([priv]);
|
||||
|
|
Loading…
Reference in New Issue