mirror of https://github.com/BTCPrivate/copay.git
fix conflics
This commit is contained in:
parent
b2f377da18
commit
1e8895f4b8
|
@ -19,8 +19,8 @@ html, body {height: 100%;}
|
||||||
|
|
||||||
#footer {
|
#footer {
|
||||||
position: relative;
|
position: relative;
|
||||||
margin-top: -91px; /* negative value of footer height */
|
margin-top: -96px; /* negative value of footer height */
|
||||||
height: 91px;
|
height: 96px;
|
||||||
clear:both;
|
clear:both;
|
||||||
padding: 5px 2rem;
|
padding: 5px 2rem;
|
||||||
}
|
}
|
||||||
|
|
30
index.html
30
index.html
|
@ -110,19 +110,20 @@
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="large-2 columns" style="float:right;"
|
<div class="large-2 columns" style="float:right;"
|
||||||
ng-repeat="copayer in $root.wallet.getRegisteredPeerIds()">
|
ng-repeat="c in $root.wallet.getRegisteredPeerIds()">
|
||||||
<video
|
<video
|
||||||
ng-class="($root.wallet.getOnlinePeerIDs().indexOf(copayer) != -1) ? 'online' : 'offline'"
|
ng-class="($root.wallet.getOnlinePeerIDs().indexOf(c.peerId) != -1) ? 'online' : 'offline'"
|
||||||
class="video-small"
|
class="video-small"
|
||||||
autoplay ng-show="$root.videoSrc[copayer]"
|
autoplay ng-show="$root.videoSrc[c.peerId]"
|
||||||
ng-src="{{$root.getVideoURL(copayer)}}"
|
ng-src="{{$root.getVideoURL(c.peerId)}}"
|
||||||
id="{{copayer + '-video'}}" muted="true"
|
id="{{c.peerId + '-video'}}" muted="true"
|
||||||
title="{{copayer + (copayer == $root.wallet.network.peerId?' (You)':'')}}" ></video>
|
title="{{c.peerId + (c.peerId == $root.wallet.network.peerId?' (You)':'')}}" ></video>
|
||||||
<img ng-show="!$root.videoSrc[copayer]"
|
<img ng-show="!$root.videoSrc[c.peerId]"
|
||||||
ng-class="($root.wallet.getOnlinePeerIDs().indexOf(copayer) != -1) ? 'online' : 'offline'"
|
ng-class="($root.wallet.getOnlinePeerIDs().indexOf(c.peerId) != -1) ? 'online' : 'offline'"
|
||||||
class="video-small"
|
class="video-small"
|
||||||
src="./img/satoshi.gif"
|
src="./img/satoshi.gif"
|
||||||
title="{{copayer + (copayer == $root.wallet.network.peerId?' (You)':'')}}" />
|
title="{{c.peerId + (c.peerId == $root.wallet.network.peerId?' (You)':'')}}" />
|
||||||
|
<div ng-if="c.nick" class="small-8 text-center" style="position:absolute; width:115%; bottom:-10px">{{c.nick}}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!--
|
<!--
|
||||||
|
@ -146,8 +147,10 @@
|
||||||
<h3>Join a Wallet in Creation</h3>
|
<h3>Join a Wallet in Creation</h3>
|
||||||
<input type="text" class="form-control" placeholder="Paste wallet secret here"
|
<input type="text" class="form-control" placeholder="Paste wallet secret here"
|
||||||
ng-model="connectionId" required autofocus>
|
ng-model="connectionId" required autofocus>
|
||||||
|
<input type="text" class="form-control" placeholder="Your name (optional)"
|
||||||
|
ng-model="nickname">
|
||||||
<button class="button primary expand radius"
|
<button class="button primary expand radius"
|
||||||
ng-click="join(connectionId)" ng-disabled="loading" loading="Joining">Join</button>
|
ng-click="join(connectionId,nickname)" ng-disabled="loading" loading="Joining">Join</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="large-6 columns">
|
<div class="large-6 columns">
|
||||||
|
@ -224,17 +227,22 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="small-12 medium-6 medium-centered large-6 large-centered columns m30v">
|
<div class="small-12 medium-6 medium-centered large-6 large-centered columns m30v">
|
||||||
<h6>Wallet name (optional)</h6>
|
<h6>Wallet name (optional)</h6>
|
||||||
<input type="text" class="form-control" ng-model="walletName" placeholder="Enter wallet name">
|
<input type="text" class="form-control" ng-model="walletName" placeholder="Enter wallet name">
|
||||||
</div>
|
</div>
|
||||||
|
<div class="large-6 large-centered columns m30v">
|
||||||
|
<h6>Your nickname (optional)</h6>
|
||||||
|
<input ng-model="myNickname" placeholder="" class="size-24" style="width:100%">
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="large-12 columns line-dashed">
|
<div class="large-12 columns line-dashed">
|
||||||
<button class="button primary radius right" type="button"
|
<button class="button primary radius right" type="button"
|
||||||
ng-click="create(totalCopayers, requiredCopayers, walletName)">
|
ng-click="create(totalCopayers, requiredCopayers, walletName, myNickname)">
|
||||||
Create {{requiredCopayers}}-of-{{totalCopayers}} wallet
|
Create {{requiredCopayers}}-of-{{totalCopayers}} wallet
|
||||||
</button>
|
</button>
|
||||||
<a class="button secondary radius" href="#signin">Go back</a>
|
<a class="button secondary radius" href="#signin">Go back</a>
|
||||||
|
|
|
@ -31,13 +31,15 @@ angular.module('copay.setup').controller('SetupController',
|
||||||
updateRCSelect(tc);
|
updateRCSelect(tc);
|
||||||
});
|
});
|
||||||
|
|
||||||
$scope.create = function(totalCopayers, requiredCopayers, walletName) {
|
$scope.create = function(totalCopayers, requiredCopayers, walletName, myNickname) {
|
||||||
$scope.loading = true;
|
$scope.loading = true;
|
||||||
var opts = {
|
var opts = {
|
||||||
requiredCopayers: requiredCopayers,
|
requiredCopayers: requiredCopayers,
|
||||||
totalCopayers: totalCopayers,
|
totalCopayers: totalCopayers,
|
||||||
name: walletName,
|
name: walletName,
|
||||||
|
nickname: myNickname,
|
||||||
};
|
};
|
||||||
|
console.log('[setup.js.31:opts:]',opts); //TODO
|
||||||
var w = walletFactory.create(opts);
|
var w = walletFactory.create(opts);
|
||||||
controllerUtils.startNetwork(w);
|
controllerUtils.startNetwork(w);
|
||||||
};
|
};
|
||||||
|
|
|
@ -18,15 +18,14 @@ angular.module('copay.signin').controller('SigninController',
|
||||||
controllerUtils.startNetwork(w);
|
controllerUtils.startNetwork(w);
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.join = function(secret) {
|
$scope.join = function(secret, nickname ) {
|
||||||
$scope.loading = true;
|
$scope.loading = true;
|
||||||
|
|
||||||
walletFactory.network.on('badSecret', function() {
|
walletFactory.network.on('badSecret', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
walletFactory.joinCreateSession(secret, function(err,w) {
|
walletFactory.joinCreateSession(secret, nickname, function(err,w) {
|
||||||
$scope.loading = false;
|
$scope.loading = false;
|
||||||
console.log('[signin.js.27:err:]',err,w); //TODO
|
|
||||||
|
|
||||||
if (err || !w) {
|
if (err || !w) {
|
||||||
if (err === 'joinError')
|
if (err === 'joinError')
|
||||||
|
|
|
@ -22,7 +22,7 @@ angular.module('copay.transactions').controller('TransactionsController',
|
||||||
|
|
||||||
tx.outs.forEach(function(o) {
|
tx.outs.forEach(function(o) {
|
||||||
var addr = bitcore.Address.fromScriptPubKey(o.getScript(), config.networkName)[0].toString();
|
var addr = bitcore.Address.fromScriptPubKey(o.getScript(), config.networkName)[0].toString();
|
||||||
if (!w.addressIsOwn(addr)) {
|
if (!w.addressIsOwn(addr, true)) {
|
||||||
outs.push({
|
outs.push({
|
||||||
address: addr,
|
address: addr,
|
||||||
value: bitcore.util.valueToBigInt(o.getValue())/bitcore.util.COIN,
|
value: bitcore.util.valueToBigInt(o.getValue())/bitcore.util.COIN,
|
||||||
|
|
|
@ -32,6 +32,8 @@ function PublicKeyRing(opts) {
|
||||||
this.addressIndex= opts.addressIndex || 0;
|
this.addressIndex= opts.addressIndex || 0;
|
||||||
|
|
||||||
this.publicKeysCache = opts.publicKeysCache || {};
|
this.publicKeysCache = opts.publicKeysCache || {};
|
||||||
|
this.nicknameFor = opts.nicknameFor || {};
|
||||||
|
this.copayerIds = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -54,10 +56,13 @@ PublicKeyRing.fromObj = function (data) {
|
||||||
if (data instanceof PublicKeyRing) {
|
if (data instanceof PublicKeyRing) {
|
||||||
throw new Error('bad data format: Did you use .toObj()?');
|
throw new Error('bad data format: Did you use .toObj()?');
|
||||||
}
|
}
|
||||||
data.copayersBIP32 = data.copayersExtPubKeys.map(function(pk) {
|
var ret = new PublicKeyRing(data);
|
||||||
return new BIP32(pk);
|
|
||||||
});
|
for (var k in data.copayersExtPubKeys) {
|
||||||
return new PublicKeyRing(data);
|
ret.addCopayer(data.copayersExtPubKeys[k]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
};
|
};
|
||||||
|
|
||||||
PublicKeyRing.prototype.toObj = function() {
|
PublicKeyRing.prototype.toObj = function() {
|
||||||
|
@ -72,23 +77,12 @@ PublicKeyRing.prototype.toObj = function() {
|
||||||
copayersExtPubKeys: this.copayersBIP32.map( function (b) {
|
copayersExtPubKeys: this.copayersBIP32.map( function (b) {
|
||||||
return b.extendedPublicKeyString();
|
return b.extendedPublicKeyString();
|
||||||
}),
|
}),
|
||||||
|
nicknameFor: this.nicknameFor,
|
||||||
publicKeysCache: this.publicKeysCache
|
publicKeysCache: this.publicKeysCache
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
PublicKeyRing.prototype.serialize = function () {
|
|
||||||
return JSON.stringify(this.toObj());
|
|
||||||
};
|
|
||||||
|
|
||||||
PublicKeyRing.prototype.getCopayerId = function(i) {
|
PublicKeyRing.prototype.getCopayerId = function(i) {
|
||||||
this.copayerIds = this.copayerIds || [];
|
|
||||||
|
|
||||||
if (!this.copayerIds[i]) {
|
|
||||||
var path = PublicKeyRing.ID_BRANCH;
|
|
||||||
var bip32 = this.copayersBIP32[i].derive(path);
|
|
||||||
this.copayerIds[i]= bip32.eckey.public.toString('hex');
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.copayerIds[i];
|
return this.copayerIds[i];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -101,12 +95,7 @@ PublicKeyRing.prototype.isComplete = function () {
|
||||||
};
|
};
|
||||||
|
|
||||||
PublicKeyRing.prototype.getAllCopayerIds = function() {
|
PublicKeyRing.prototype.getAllCopayerIds = function() {
|
||||||
var ret = [];
|
return this.copayerIds;
|
||||||
var l = this.registeredCopayers();
|
|
||||||
for(var i=0; i<l; i++) {
|
|
||||||
ret.push(this.getCopayerId(i));
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
PublicKeyRing.prototype.myCopayerId = function(i) {
|
PublicKeyRing.prototype.myCopayerId = function(i) {
|
||||||
|
@ -119,14 +108,30 @@ PublicKeyRing.prototype._checkKeys = function() {
|
||||||
throw new Error('dont have required keys yet');
|
throw new Error('dont have required keys yet');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
PublicKeyRing.prototype._newExtendedPublicKey = function () {
|
PublicKeyRing.prototype._newExtendedPublicKey = function () {
|
||||||
return new BIP32(this.network.name)
|
return new BIP32(this.network.name)
|
||||||
.extendedPublicKeyString();
|
.extendedPublicKeyString();
|
||||||
};
|
};
|
||||||
|
|
||||||
PublicKeyRing.prototype.addCopayer = function (newEpk) {
|
PublicKeyRing.prototype._updateBip = function (index) {
|
||||||
|
var path = PublicKeyRing.ID_BRANCH;
|
||||||
|
var bip32 = this.copayersBIP32[index].derive(path);
|
||||||
|
this.copayerIds[index]= bip32.eckey.public.toString('hex');
|
||||||
|
};
|
||||||
|
|
||||||
|
PublicKeyRing.prototype._setNicknameForIndex = function (index, nickname) {
|
||||||
|
this.nicknameFor[this.copayerIds[index]] = nickname;
|
||||||
|
};
|
||||||
|
|
||||||
|
PublicKeyRing.prototype.nicknameForIndex = function (index) {
|
||||||
|
return this.nicknameFor[this.copayerIds[index]];
|
||||||
|
};
|
||||||
|
|
||||||
|
PublicKeyRing.prototype.nicknameForCopayer = function (copayerId) {
|
||||||
|
return this.nicknameFor[copayerId];
|
||||||
|
};
|
||||||
|
|
||||||
|
PublicKeyRing.prototype.addCopayer = function (newEpk, nickname) {
|
||||||
if (this.isComplete())
|
if (this.isComplete())
|
||||||
throw new Error('already have all required key:' + this.totalCopayers);
|
throw new Error('already have all required key:' + this.totalCopayers);
|
||||||
|
|
||||||
|
@ -139,7 +144,13 @@ PublicKeyRing.prototype.addCopayer = function (newEpk) {
|
||||||
throw new Error('already have that key');
|
throw new Error('already have that key');
|
||||||
});
|
});
|
||||||
|
|
||||||
this.copayersBIP32.push(new BIP32(newEpk));
|
var i=this.copayersBIP32.length;
|
||||||
|
var bip = new BIP32(newEpk);
|
||||||
|
this.copayersBIP32.push(bip);
|
||||||
|
this._updateBip(i);
|
||||||
|
if (nickname) {
|
||||||
|
this._setNicknameForIndex(i,nickname);
|
||||||
|
}
|
||||||
return newEpk;
|
return newEpk;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -156,9 +167,9 @@ PublicKeyRing.prototype.getPubKeys = function (index, isChange) {
|
||||||
pubKeys[i] = bip32.eckey.public;
|
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')});
|
else {
|
||||||
//console.log('public keys cache HIT');
|
pubKeys = pubKeys.map(function(s){return new Buffer(s,'hex');});
|
||||||
}
|
}
|
||||||
|
|
||||||
return pubKeys;
|
return pubKeys;
|
||||||
|
@ -193,7 +204,6 @@ PublicKeyRing.prototype.getScriptPubKeyHex = function (index, isChange) {
|
||||||
return Script.createP2SH(addr.payload()).getBuffer().toString('hex');
|
return Script.createP2SH(addr.payload()).getBuffer().toString('hex');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//generate a new address, update index.
|
//generate a new address, update index.
|
||||||
PublicKeyRing.prototype.generateAddress = function(isChange) {
|
PublicKeyRing.prototype.generateAddress = function(isChange) {
|
||||||
|
|
||||||
|
@ -206,7 +216,6 @@ PublicKeyRing.prototype.generateAddress = function(isChange) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
PublicKeyRing.prototype.getAddresses = function(excludeChange) {
|
PublicKeyRing.prototype.getAddresses = function(excludeChange) {
|
||||||
|
@ -254,8 +263,6 @@ PublicKeyRing.prototype.getRedeemScriptMap = function () {
|
||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PublicKeyRing.prototype._checkInPRK = function(inPKR, ignoreId) {
|
PublicKeyRing.prototype._checkInPRK = function(inPKR, ignoreId) {
|
||||||
|
|
||||||
if (!ignoreId && this.walletId !== inPKR.walletId) {
|
if (!ignoreId && this.walletId !== inPKR.walletId) {
|
||||||
|
@ -313,7 +320,11 @@ PublicKeyRing.prototype._mergePubkeys = function(inPKR) {
|
||||||
if (self.isComplete()) {
|
if (self.isComplete()) {
|
||||||
throw new Error('trying to add more pubkeys, when PKR isComplete at merge');
|
throw new Error('trying to add more pubkeys, when PKR isComplete at merge');
|
||||||
}
|
}
|
||||||
|
var l2 = self.copayersBIP32.length;
|
||||||
self.copayersBIP32.push(new BIP32(epk));
|
self.copayersBIP32.push(new BIP32(epk));
|
||||||
|
self._updateBip(l2);
|
||||||
|
if (inPKR.nicknameFor[self.getCopayerId(l2)])
|
||||||
|
self._setNicknameForIndex(l2,inPKR.nicknameFor[self.getCopayerId(l2)]);
|
||||||
hasChanged=true;
|
hasChanged=true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -33,8 +33,8 @@ function Wallet(opts) {
|
||||||
this.verbose = opts.verbose;
|
this.verbose = opts.verbose;
|
||||||
this.publicKeyRing.walletId = this.id;
|
this.publicKeyRing.walletId = this.id;
|
||||||
this.txProposals.walletId = this.id;
|
this.txProposals.walletId = this.id;
|
||||||
|
|
||||||
this.network.maxPeers = this.totalCopayers;
|
this.network.maxPeers = this.totalCopayers;
|
||||||
|
this.registeredPeerIds = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
Wallet.parent = EventEmitter;
|
Wallet.parent = EventEmitter;
|
||||||
|
@ -196,7 +196,6 @@ Wallet.prototype.netStart = function() {
|
||||||
|
|
||||||
net.start(startOpts, function() {
|
net.start(startOpts, function() {
|
||||||
self.emit('created', net.getPeer());
|
self.emit('created', net.getPeer());
|
||||||
var registered = self.getRegisteredPeerIds();
|
|
||||||
for (var i = 0; i < self.publicKeyRing.registeredCopayers(); i++) {
|
for (var i = 0; i < self.publicKeyRing.registeredCopayers(); i++) {
|
||||||
var otherId = self.getCopayerId(i);
|
var otherId = self.getCopayerId(i);
|
||||||
if (otherId !== myId) {
|
if (otherId !== myId) {
|
||||||
|
@ -216,13 +215,19 @@ Wallet.prototype.getOnlinePeerIDs = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
Wallet.prototype.getRegisteredPeerIds = function() {
|
Wallet.prototype.getRegisteredPeerIds = function() {
|
||||||
var ret = [];
|
var l = this.publicKeyRing.registeredCopayers();
|
||||||
for (var i = 0; i < this.publicKeyRing.registeredCopayers(); i++) {
|
if (this.registeredPeerIds.length !== l) {
|
||||||
var cid = this.getCopayerId(i)
|
this.registeredPeerIds = [];
|
||||||
|
for (var i = 0; i < l; i++) {
|
||||||
|
var cid = this.getCopayerId(i);
|
||||||
var pid = this.network.peerFromCopayer(cid);
|
var pid = this.network.peerFromCopayer(cid);
|
||||||
ret.push(pid);
|
this.registeredPeerIds.push({
|
||||||
|
peerId: pid,
|
||||||
|
nick: this.publicKeyRing.nicknameForCopayer(cid)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return ret;
|
}
|
||||||
|
return this.registeredPeerIds;
|
||||||
};
|
};
|
||||||
|
|
||||||
Wallet.prototype.store = function(isSync) {
|
Wallet.prototype.store = function(isSync) {
|
||||||
|
@ -416,8 +421,8 @@ Wallet.prototype.getAddressesInfo = function(excludeChange) {
|
||||||
return this.publicKeyRing.getAddressesInfo(excludeChange);
|
return this.publicKeyRing.getAddressesInfo(excludeChange);
|
||||||
};
|
};
|
||||||
|
|
||||||
Wallet.prototype.addressIsOwn = function(addrStr) {
|
Wallet.prototype.addressIsOwn = function(addrStr, excludeChange) {
|
||||||
var addrList = this.getAddressesStr();
|
var addrList = this.getAddressesStr(excludeChange);
|
||||||
var l = addrList.length;
|
var l = addrList.length;
|
||||||
var ret = false;
|
var ret = false;
|
||||||
|
|
||||||
|
|
|
@ -104,7 +104,7 @@ WalletFactory.prototype.create = function(opts) {
|
||||||
requiredCopayers: requiredCopayers,
|
requiredCopayers: requiredCopayers,
|
||||||
totalCopayers: totalCopayers,
|
totalCopayers: totalCopayers,
|
||||||
});
|
});
|
||||||
opts.publicKeyRing.addCopayer(opts.privateKey.getExtendedPublicKeyString());
|
opts.publicKeyRing.addCopayer(opts.privateKey.getExtendedPublicKeyString(), opts.nickname);
|
||||||
this.log('\t### PublicKeyRing Initialized');
|
this.log('\t### PublicKeyRing Initialized');
|
||||||
|
|
||||||
opts.txProposals = opts.txProposals || new TxProposals({
|
opts.txProposals = opts.txProposals || new TxProposals({
|
||||||
|
@ -149,7 +149,7 @@ WalletFactory.prototype.remove = function(walletId) {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
WalletFactory.prototype.joinCreateSession = function(secret, cb) {
|
WalletFactory.prototype.joinCreateSession = function(secret, nickname, cb) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
var s;
|
var s;
|
||||||
|
@ -175,6 +175,7 @@ WalletFactory.prototype.joinCreateSession = function(secret, cb) {
|
||||||
self.network.on('data', function(sender, data) {
|
self.network.on('data', function(sender, data) {
|
||||||
if (data.type ==='walletId') {
|
if (data.type ==='walletId') {
|
||||||
data.opts.privateKey = privateKey;
|
data.opts.privateKey = privateKey;
|
||||||
|
data.opts.nickname = nickname;
|
||||||
var w = self.open(data.walletId, data.opts);
|
var w = self.open(data.walletId, data.opts);
|
||||||
w.firstCopayerId = s.pubKey;
|
w.firstCopayerId = s.pubKey;
|
||||||
return cb(null, w);
|
return cb(null, w);
|
||||||
|
|
|
@ -280,6 +280,60 @@ describe('PublicKeyRing model', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
it('#merge with nickname', function () {
|
||||||
|
var w = new PublicKeyRing(config);
|
||||||
|
should.exist(w);
|
||||||
|
for(var i=0; i<3; i++) {
|
||||||
|
w.addCopayer();
|
||||||
|
};
|
||||||
|
w._setNicknameForIndex(0,'pepe0');
|
||||||
|
w._setNicknameForIndex(1,'pepe1');
|
||||||
|
|
||||||
|
w.nicknameForIndex(0).should.equal('pepe0');
|
||||||
|
w.nicknameForIndex(1).should.equal('pepe1');
|
||||||
|
should.not.exist(w.nicknameForIndex(2));
|
||||||
|
|
||||||
|
|
||||||
|
for(var i=0; i<2; i++) {
|
||||||
|
w.isComplete().should.equal(false);
|
||||||
|
var w2 = new PublicKeyRing({
|
||||||
|
networkName: 'livenet',
|
||||||
|
id: w.id,
|
||||||
|
});
|
||||||
|
w2.addCopayer();
|
||||||
|
w2._setNicknameForIndex(0,'juan' + i);
|
||||||
|
w.merge(w2).should.equal(true);
|
||||||
|
}
|
||||||
|
w.isComplete().should.equal(true);
|
||||||
|
|
||||||
|
w.nicknameForIndex(0).should.equal('pepe0');
|
||||||
|
w.nicknameForIndex(1).should.equal('pepe1');
|
||||||
|
should.not.exist(w.nicknameForIndex(2));
|
||||||
|
w.nicknameForIndex(3).should.equal('juan0');
|
||||||
|
w.nicknameForIndex(4).should.equal('juan1');
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
it('#toObj #fromObj with nickname', function () {
|
||||||
|
var w = new PublicKeyRing(config);
|
||||||
|
should.exist(w);
|
||||||
|
for(var i=0; i<3; i++) {
|
||||||
|
w.addCopayer(null, 'tito'+i);
|
||||||
|
};
|
||||||
|
w.nicknameForIndex(0).should.equal('tito0');
|
||||||
|
w.nicknameForIndex(1).should.equal('tito1');
|
||||||
|
w.nicknameForIndex(2).should.equal('tito2');
|
||||||
|
should.not.exist(w.nicknameForIndex(3));
|
||||||
|
|
||||||
|
var o = JSON.parse(JSON.stringify(w.toObj()));
|
||||||
|
var w2 = PublicKeyRing.fromObj( o );
|
||||||
|
w2.nicknameForIndex(0).should.equal('tito0');
|
||||||
|
w2.nicknameForIndex(1).should.equal('tito1');
|
||||||
|
w2.nicknameForIndex(2).should.equal('tito2');
|
||||||
|
should.not.exist(w2.nicknameForIndex(3));
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
it('#getRedeemScriptMap check tests', function () {
|
it('#getRedeemScriptMap check tests', function () {
|
||||||
var k = createW();
|
var k = createW();
|
||||||
var w = k.w;
|
var w = k.w;
|
||||||
|
|
|
@ -59,7 +59,7 @@ describe('WalletFactory model', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('#fromObj #toObj round trip', function() {
|
it('#fromObj #toObj round trip', function() {
|
||||||
var o = '{"opts":{"id":"dbfe10c3fae71cea","spendUnconfirmed":1,"requiredCopayers":3,"totalCopayers":5,"netKey":"LppzFYqlgT0="},"publicKeyRing":{"walletId":"dbfe10c3fae71cea","networkName":"testnet","requiredCopayers":3,"totalCopayers":5,"changeAddressIndex":3,"addressIndex":3,"copayersExtPubKeys":["tpubD6NzVbkrYhZ4YGK8ZhZ8WVeBXNAAoTYjjpw9twCPiNGrGQYFktP3iVQkKmZNiFnUcAFMJRxJVJF6Nq9MDv2kiRceExJaHFbxUCGUiRhmy97","tpubD6NzVbkrYhZ4YKGDJkzWdQsQV3AcFemaQKiwNhV4RL8FHnBFvinidGdQtP8RKj3h34E65RkdtxjrggZYqsEwJ8RhhN2zz9VrjLnrnwbXYNc","tpubD6NzVbkrYhZ4YkDiewjb32Pp3Sz9WK2jpp37KnL7RCrHAyPpnLfgdfRnTdpn6DTWmPS7niywfgWiT42aJb1J6CjWVNmkgsMCxuw7j9DaGKB","tpubD6NzVbkrYhZ4XEtUAz4UUTWbprewbLTaMhR8NUvSJUEAh4Sidxr6rRPFdqqVRR73btKf13wUjds2i8vVCNo8sbKrAnyoTr3o5Y6QSbboQjk","tpubD6NzVbkrYhZ4Yj9AAt6xUVuGPVd8jXCrEE6V2wp7U3PFh8jYYvVad31b4VUXEYXzSnkco4fktu8r4icBsB2t3pCR3WnhVLedY2hxGcPFLKD"],"publicKeysCache":{"m/0/1/0":["0314368b8efa07e8c7dad30498d0a7e3aa575db1fef833347c6d381c1a33a17b17","02cfd95f89ab46bd3bd86954dd9f83dbab0cd2e4466dee587e8e4d8d733fc0d748","02568969eb6212fe946450be6c5b3353fc754a40b2cdc4aed501a8976fec371da8","0360f870a088ae0ef1c37035a9b6a462ca8dcdd5da275f4e2dcd19f44b81d3e7e4","0300ad8f1bded838b02e127bb25961fbcee718db2df81f680f889692acdcbdd73d"],"m/0/1/1":["024f97a9adb2fa9306c4e3d9244f5e5355c7e2c6b3dd4122ba804e17dc9729df5d","0214834a5adcbc4ad0f3bbbc1c280b8ac480387fcc9a1fd988c1526ed496d923c4","024e72338bd5e976375d076bd71a9649e9141b4cbfc9e16cb7109b354b3e913a05","0322045ea35c3118aa7ab9f2c9f182b0120956b0aa65cc72b9d093f145327a4b17","030dc2450c72df366c1960739c577a2efd4451070bd78effcb6f71d1bcd7dfc7a8"],"m/0/1/2":["0247de59deb66783b8f9b0c326234a9569d00866c2a73f599e77a4d0cab5cbce8f","0376e49f0ac3647404034aae0dc8dd927c34a634ef24ea36f56a272f75fce9539b","032fbaa2593bd1eea4a46e7ac15f15802cdd1eb65a7d5bc4364ddd9d52f0838234","03a81f2a7e1f7191aa0b0c6e0a4ccefc71edd3564e86014972fe338045f68d5a5a","02eb8a012ea9a709392502cacda6ef5115d6d2319ab470d546d9068ab941621a99"],"m/0/0/0":["036dcbd378b4352120d6b720b6294dd2d0dd02801fcf010bb69dadbec1f3999279","022089eedb85dc45d1efa418e1ea226588deedebc1d85acca15ff72783e33636c0","0388aa5fd432b74c56427396f350d236c3ca8f7b2f62da513ce4c2e6ff04a67e9c","02fc4caa7449db7483d2e1fccdacac6fa2f736278c758af9966402589b5632f13e","02e4a15b885d8b2d586f82fa85d16179644e60a154674bde0ec3004810b1bdab99"],"m/0/0/1":["039afa26b2f341c76c7b3c3d0672438f35ac6ebb67b1ddfefac9cd79b7b24418c1","021acaaf500d431ebc396f50630767b01c91ce98ae48e968775ceaad932b7e3b8e","022a947259c4a9f76d5e95c0849df31d01233df41d0d75d631b89317a48d8cddce","03d38d9f94217da780303d9a8987c86d737ef39683febc0cd6632cddbfa62186fd","0394d2581b307fe2af19721888d922aab58ab198ef88cedf9506177e30d807811e"],"m/0/0/2":["037825ffce15d34f9bd6c02bcda7701826706471a4d6ab5004eb965f98811c2098","023768dd6d3c71b7df5733ccda5b2d8b454d5b4c4179d91a6fda74db8b869a2406","021a79e91f003f308764d43039e9b5d56bc8f33ca2f4d30ec6cc5a37c0d09dc273","02437f1e388b273936319f79a5d22958ef5ebff9c8cd7b6f6f72518445b1e30867","0373b0881cb4fd02baa62589023fdfe9739c6148cf104d907549f2528eb80146f5"]}},"txProposals":{"txps":[],"walletId":"dbfe10c3fae71cea","networkName":"testnet"},"privateKey":{"extendedPrivateKeyString":"tprv8ZgxMBicQKsPeoHLg3tY75z4xLeEe8MqAXLNcRA6J6UTRvHV8VZTXznt9eoTmSk1fwSrwZtMhY3XkNsceJ14h6sCXHSWinRqMSSbY8tfhHi","networkName":"testnet","privateKeyCache":{}}}';
|
var o = '{"opts":{"id":"dbfe10c3fae71cea","spendUnconfirmed":1,"requiredCopayers":3,"totalCopayers":5,"netKey":"LppzFYqlgT0="},"publicKeyRing":{"walletId":"dbfe10c3fae71cea","networkName":"testnet","requiredCopayers":3,"totalCopayers":5,"changeAddressIndex":3,"addressIndex":3,"copayersExtPubKeys":["tpubD6NzVbkrYhZ4YGK8ZhZ8WVeBXNAAoTYjjpw9twCPiNGrGQYFktP3iVQkKmZNiFnUcAFMJRxJVJF6Nq9MDv2kiRceExJaHFbxUCGUiRhmy97","tpubD6NzVbkrYhZ4YKGDJkzWdQsQV3AcFemaQKiwNhV4RL8FHnBFvinidGdQtP8RKj3h34E65RkdtxjrggZYqsEwJ8RhhN2zz9VrjLnrnwbXYNc","tpubD6NzVbkrYhZ4YkDiewjb32Pp3Sz9WK2jpp37KnL7RCrHAyPpnLfgdfRnTdpn6DTWmPS7niywfgWiT42aJb1J6CjWVNmkgsMCxuw7j9DaGKB","tpubD6NzVbkrYhZ4XEtUAz4UUTWbprewbLTaMhR8NUvSJUEAh4Sidxr6rRPFdqqVRR73btKf13wUjds2i8vVCNo8sbKrAnyoTr3o5Y6QSbboQjk","tpubD6NzVbkrYhZ4Yj9AAt6xUVuGPVd8jXCrEE6V2wp7U3PFh8jYYvVad31b4VUXEYXzSnkco4fktu8r4icBsB2t3pCR3WnhVLedY2hxGcPFLKD"],"nicknameFor":{},"publicKeysCache":{"m/0/1/0":["0314368b8efa07e8c7dad30498d0a7e3aa575db1fef833347c6d381c1a33a17b17","02cfd95f89ab46bd3bd86954dd9f83dbab0cd2e4466dee587e8e4d8d733fc0d748","02568969eb6212fe946450be6c5b3353fc754a40b2cdc4aed501a8976fec371da8","0360f870a088ae0ef1c37035a9b6a462ca8dcdd5da275f4e2dcd19f44b81d3e7e4","0300ad8f1bded838b02e127bb25961fbcee718db2df81f680f889692acdcbdd73d"],"m/0/1/1":["024f97a9adb2fa9306c4e3d9244f5e5355c7e2c6b3dd4122ba804e17dc9729df5d","0214834a5adcbc4ad0f3bbbc1c280b8ac480387fcc9a1fd988c1526ed496d923c4","024e72338bd5e976375d076bd71a9649e9141b4cbfc9e16cb7109b354b3e913a05","0322045ea35c3118aa7ab9f2c9f182b0120956b0aa65cc72b9d093f145327a4b17","030dc2450c72df366c1960739c577a2efd4451070bd78effcb6f71d1bcd7dfc7a8"],"m/0/1/2":["0247de59deb66783b8f9b0c326234a9569d00866c2a73f599e77a4d0cab5cbce8f","0376e49f0ac3647404034aae0dc8dd927c34a634ef24ea36f56a272f75fce9539b","032fbaa2593bd1eea4a46e7ac15f15802cdd1eb65a7d5bc4364ddd9d52f0838234","03a81f2a7e1f7191aa0b0c6e0a4ccefc71edd3564e86014972fe338045f68d5a5a","02eb8a012ea9a709392502cacda6ef5115d6d2319ab470d546d9068ab941621a99"],"m/0/0/0":["036dcbd378b4352120d6b720b6294dd2d0dd02801fcf010bb69dadbec1f3999279","022089eedb85dc45d1efa418e1ea226588deedebc1d85acca15ff72783e33636c0","0388aa5fd432b74c56427396f350d236c3ca8f7b2f62da513ce4c2e6ff04a67e9c","02fc4caa7449db7483d2e1fccdacac6fa2f736278c758af9966402589b5632f13e","02e4a15b885d8b2d586f82fa85d16179644e60a154674bde0ec3004810b1bdab99"],"m/0/0/1":["039afa26b2f341c76c7b3c3d0672438f35ac6ebb67b1ddfefac9cd79b7b24418c1","021acaaf500d431ebc396f50630767b01c91ce98ae48e968775ceaad932b7e3b8e","022a947259c4a9f76d5e95c0849df31d01233df41d0d75d631b89317a48d8cddce","03d38d9f94217da780303d9a8987c86d737ef39683febc0cd6632cddbfa62186fd","0394d2581b307fe2af19721888d922aab58ab198ef88cedf9506177e30d807811e"],"m/0/0/2":["037825ffce15d34f9bd6c02bcda7701826706471a4d6ab5004eb965f98811c2098","023768dd6d3c71b7df5733ccda5b2d8b454d5b4c4179d91a6fda74db8b869a2406","021a79e91f003f308764d43039e9b5d56bc8f33ca2f4d30ec6cc5a37c0d09dc273","02437f1e388b273936319f79a5d22958ef5ebff9c8cd7b6f6f72518445b1e30867","0373b0881cb4fd02baa62589023fdfe9739c6148cf104d907549f2528eb80146f5"]}},"txProposals":{"txps":[],"walletId":"dbfe10c3fae71cea","networkName":"testnet"},"privateKey":{"extendedPrivateKeyString":"tprv8ZgxMBicQKsPeoHLg3tY75z4xLeEe8MqAXLNcRA6J6UTRvHV8VZTXznt9eoTmSk1fwSrwZtMhY3XkNsceJ14h6sCXHSWinRqMSSbY8tfhHi","networkName":"testnet","privateKeyCache":{}}}';
|
||||||
|
|
||||||
var wf = new WalletFactory(config);
|
var wf = new WalletFactory(config);
|
||||||
var w = wf.fromObj(JSON.parse(o));
|
var w = wf.fromObj(JSON.parse(o));
|
||||||
|
|
Loading…
Reference in New Issue