mirror of https://github.com/BTCPrivate/copay.git
commit
cf4140ab2b
|
@ -7,10 +7,12 @@ angular.module('copay.transactions').controller('TransactionsController',
|
|||
$scope.oneAtATime = true;
|
||||
|
||||
var _updateTxs = function() {
|
||||
var inT = $rootScope.wallet.getTxProposals();
|
||||
var w =$rootScope.wallet;
|
||||
var inT = w.getTxProposals();
|
||||
var ts = [];
|
||||
|
||||
inT.forEach(function(i){
|
||||
var b =i.txp.builder;
|
||||
var b = i.txp.builder;
|
||||
var tx = b.build();
|
||||
var one = {
|
||||
valueOutSat: b.valueOutSat,
|
||||
|
@ -21,6 +23,7 @@ angular.module('copay.transactions').controller('TransactionsController',
|
|||
tx.outs.forEach(function(o) {
|
||||
var s = o.getScript();
|
||||
var aStr = bitcore.Address.fromScript(s, config.networkName).toString();
|
||||
if (!w.addressIsOwn(aStr))
|
||||
outs.push({address: aStr, value: bitcore.util.valueToBigInt(o.getValue())});
|
||||
});
|
||||
one.outs = outs;
|
||||
|
@ -42,7 +45,6 @@ angular.module('copay.transactions').controller('TransactionsController',
|
|||
$scope.sign = function (ntxid) {
|
||||
var w = $rootScope.wallet;
|
||||
var ret = w.sign(ntxid);
|
||||
console.log('[transactions.js.28:ret:]',ret); //TODO
|
||||
$rootScope.flashMessage = {type:'success', message: 'Transactions SEND! : ' + ret};
|
||||
_updateTxs();
|
||||
};
|
||||
|
|
|
@ -311,6 +311,22 @@ Wallet.prototype.getAddressesStr = function(onlyMain) {
|
|||
return ret;
|
||||
};
|
||||
|
||||
|
||||
Wallet.prototype.addressIsOwn = function(addrStr) {
|
||||
var addrList = this.getAddressesStr();
|
||||
var l = addrList.length;
|
||||
var ret = false;
|
||||
|
||||
for(var i=0; i<l; i++) {
|
||||
if (addrList[i] === addrStr) {
|
||||
ret = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
||||
|
||||
Wallet.prototype.getTotalBalance = function(cb) {
|
||||
this.getBalance(this.getAddressesStr(), function(balance) {
|
||||
return cb(balance);
|
||||
|
|
|
@ -44,12 +44,12 @@ WalletFactory.prototype._checkRead = function(walletId) {
|
|||
s.get(walletId, 'opts') &&
|
||||
s.get(walletId, 'privateKey')
|
||||
;
|
||||
return ret;
|
||||
return ret?true:false;
|
||||
};
|
||||
|
||||
WalletFactory.prototype.read = function(walletId) {
|
||||
if (! this._checkRead(walletId))
|
||||
throw Error('Check read failed');
|
||||
return false;
|
||||
|
||||
var s = this.storage;
|
||||
var opts = s.get(walletId, 'opts');
|
||||
|
@ -175,7 +175,7 @@ WalletFactory.prototype.connectTo = function(peerId, cb) {
|
|||
self.network.start(function() {
|
||||
self.network.connectTo(peerId)
|
||||
self.network.on('walletId', function(walletId) {
|
||||
console.log('[WalletFactory.js.187]'); //TODO
|
||||
self.log('Opening walletId:' + walletId);
|
||||
return cb(self.open(walletId));
|
||||
});
|
||||
});
|
||||
|
|
|
@ -133,7 +133,14 @@ describe('Wallet model', function() {
|
|||
Object.keys(t.txps[0].seenBy).length.should.equal(1);
|
||||
});
|
||||
|
||||
|
||||
it('#addressIsOwn', function () {
|
||||
var w = createW2();
|
||||
var l = w.getAddressesStr();
|
||||
for (var i=0; i<l.length; i++)
|
||||
w.addressIsOwn(l[i]).should.equal(true);
|
||||
w.addressIsOwn('mmHqhvTVbxgJTnePa7cfweSRjBCy9bQQXJ').should.equal(false);
|
||||
w.addressIsOwn('mgtUfP9sTJ6vPLoBxZLPEccGpcjNVryaCX').should.equal(false);
|
||||
});
|
||||
|
||||
it('#create. Signing with derivate keys', function () {
|
||||
|
||||
|
|
|
@ -39,6 +39,12 @@ describe('WalletFactory model', function() {
|
|||
var wf = new WalletFactory(config);
|
||||
should.exist(wf);
|
||||
});
|
||||
it('#_checkRead should return false', function() {
|
||||
var wf = new WalletFactory(config);
|
||||
wf._checkRead('dummy').should.equal(false);
|
||||
wf.read('dummy').should.equal(false);
|
||||
});
|
||||
|
||||
it('should be able to create wallets', function() {
|
||||
var wf = new WalletFactory(config);
|
||||
var w = wf.create();
|
||||
|
|
Loading…
Reference in New Issue