mirror of https://github.com/BTCPrivate/copay.git
tx broadcasting working
This commit is contained in:
parent
73e7b0d0e0
commit
df23125f5e
|
@ -153,7 +153,7 @@
|
|||
<div class="large-6 columns p70l">
|
||||
<h3 class="panel-title">Copayers ({{$root.wallet.network.connectedPeers.length}}/{{$root.wallet.publicKeyRing.requiredCopayers}})</h3>
|
||||
<ul class="no-bullet">
|
||||
<li class="panel" ng-repeat="copayer in $root.connectedPeers">
|
||||
<li class="panel" ng-repeat="copayer in $root.wallet.network.connectedPeers">
|
||||
<span ng-if="copayer == $root.peerId"> You ({{$root.peerId}})<i class="fi-check size-24"></i></span>
|
||||
<span ng-if="copayer != $root.peerId">{{copayer}}</span>
|
||||
<span>
|
||||
|
|
|
@ -15,7 +15,9 @@ angular.module('copay.home').controller('HomeController',
|
|||
}
|
||||
|
||||
$scope.newAddr = function() {
|
||||
console.log('[home.js.17:newAddr:]'); //TODO
|
||||
var a = $rootScope.wallet.generateAddress();
|
||||
console.log('[home.js.19]',a); //TODO
|
||||
$scope.addrs.push({ addrStr: a.toString() });
|
||||
};
|
||||
|
||||
|
|
|
@ -14,11 +14,17 @@ angular.module('copay.signin').controller('SigninController',
|
|||
};
|
||||
|
||||
var _setupUxHandlers = function(w) {
|
||||
w.on('created', function(){
|
||||
w.on('created', function() {
|
||||
$location.path('peer');
|
||||
$rootScope.wallet = w;
|
||||
$rootScope.$digest();
|
||||
});
|
||||
w.on('refresh', function() {
|
||||
|
||||
console.log('[signin.js.23] RECEIVED REFRESH'); //TODO
|
||||
$rootScope.$digest();
|
||||
});
|
||||
|
||||
w.on('openError', function(){
|
||||
$scope.loading = false;
|
||||
$rootScope.flashMessage = {type:'error', message: 'Wallet not found'};
|
||||
|
|
|
@ -25,13 +25,15 @@ function Wallet(opts) {
|
|||
console.log('creating '+opts.requiredCopayers+' of '+opts.totalCopayers+' wallet');
|
||||
|
||||
this.id = opts.id || Wallet.getRandomId();
|
||||
this.verbose = opts.verbose;
|
||||
this.publicKeyRing.walletId = this.id;
|
||||
this.txProposals.walletId = this.id;
|
||||
|
||||
}
|
||||
|
||||
Wallet.parent=EventEmitter;
|
||||
Wallet.prototype.log = function(){
|
||||
if (!this.verbose) return;
|
||||
// if (!this.verbose) return;
|
||||
console.log(arguments);
|
||||
};
|
||||
|
||||
|
@ -61,7 +63,6 @@ Wallet.prototype._handlePublicKeyRing = function(senderId, data, isInbound) {
|
|||
if (shouldSend) {
|
||||
this.sendPublicKeyRing(recipients);
|
||||
}
|
||||
|
||||
this.store();
|
||||
};
|
||||
|
||||
|
@ -98,6 +99,7 @@ Wallet.prototype._handleData = function(senderId, data, isInbound) {
|
|||
if (this.id !== data.walletId)
|
||||
throw new Error('wrong message received: Bad wallet ID');
|
||||
|
||||
console.log('[Wallet.js.98]' , data.type); //TODO
|
||||
|
||||
switch(data.type) {
|
||||
case 'publicKeyRing':
|
||||
|
@ -113,11 +115,7 @@ Wallet.prototype._handleData = function(senderId, data, isInbound) {
|
|||
};
|
||||
|
||||
Wallet.prototype._handleNetworkChange = function(newPeer) {
|
||||
|
||||
console.log('[Wallet.js.112:newPeer:]',newPeer); //TODO
|
||||
if (!newPeer) return;
|
||||
|
||||
console.log('[Wallet.js.112:newPeer:]',newPeer); //TODO
|
||||
this.log('#### Setting new PEER:', newPeer);
|
||||
this.sendWalletId(newPeer);
|
||||
this.sendPublicKeyRing(newPeer);
|
||||
|
@ -137,6 +135,7 @@ Wallet.prototype.netStart = function() {
|
|||
};
|
||||
|
||||
Wallet.prototype.store = function() {
|
||||
console.log('[Wallet.js.135:store:]'); //TODO
|
||||
this.storage.set(this.id,'opts', {
|
||||
id: this.id,
|
||||
spendUnconfirmed: this.spendUnconfirmed,
|
||||
|
@ -146,6 +145,9 @@ Wallet.prototype.store = function() {
|
|||
this.storage.set(this.id,'publicKeyRing', this.publicKeyRing.toObj());
|
||||
this.storage.set(this.id,'txProposals', this.txProposals.toObj());
|
||||
this.storage.set(this.id,'privateKey', this.privateKey.toObj());
|
||||
|
||||
console.log('[Wallet.js.146] EMIT REFRESH'); //TODO
|
||||
this.emit('refresh');
|
||||
};
|
||||
|
||||
|
||||
|
@ -227,8 +229,22 @@ Wallet.prototype.sign = function(ntxid) {
|
|||
|
||||
if (ret.signaturesAdded) {
|
||||
txp.signedBy[this.privateKey.id] = Date.now();
|
||||
w.store();
|
||||
console.log('[Wallet.js.230:ret:]',ret); //TODO
|
||||
if (ret.isFullySigned) {
|
||||
console.log('[Wallet.js.231] BROADCASTING TX!!!'); //TODO
|
||||
var tx = txp.builder.build();
|
||||
var txHex = tx.serialize().toString('hex');
|
||||
this.blockchain.sendRawTransaction(txHex, function(txid) {
|
||||
console.log('[Wallet.js.235:txid:]',txid); //TODO
|
||||
if (txid) {
|
||||
this.store();
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
this.sendTxProposals();
|
||||
this.store();
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
|
|
@ -114,7 +114,10 @@ WalletFactory.prototype.create = function(opts) {
|
|||
};
|
||||
|
||||
WalletFactory.prototype.open = function(walletId) {
|
||||
var w = this.read(walletId) || this.create({id: walletId});
|
||||
var w = this.read(walletId) || this.create({
|
||||
id: walletId,
|
||||
verbose: this.verbose,
|
||||
});
|
||||
return w;
|
||||
};
|
||||
|
||||
|
|
|
@ -67,7 +67,6 @@ Network.prototype._showConnectedPeers = function() {
|
|||
};
|
||||
|
||||
Network.prototype._onClose = function(peerId) {
|
||||
console.log('[Network.js.70] _onClose'); //TODO
|
||||
this.connectedPeers = Network._arrayRemove(peerId, this.connectedPeers);
|
||||
this._notify();
|
||||
};
|
||||
|
@ -160,6 +159,7 @@ Network.prototype._setupConnectionHandlers = function(dataConn, isInbound) {
|
|||
|
||||
dataConn.on('close', function() {
|
||||
if (self.closing) return;
|
||||
self.closing=1;
|
||||
console.log('### CLOSE RECV FROM:', dataConn.peer);
|
||||
self._onClose(dataConn.peer);
|
||||
this.emit('close');
|
||||
|
@ -168,8 +168,6 @@ Network.prototype._setupConnectionHandlers = function(dataConn, isInbound) {
|
|||
|
||||
Network.prototype._notify = function(newPeer) {
|
||||
this._showConnectedPeers();
|
||||
|
||||
console.log('[WebRTC.js.172]', newPeer); //TODO
|
||||
this.emit('networkChange', newPeer);
|
||||
};
|
||||
|
||||
|
@ -210,6 +208,8 @@ Network.prototype._setupPeerHandlers = function(openCallback) {
|
|||
|
||||
Network.prototype.start = function(openCallback) {
|
||||
// Start PeerJS Peer
|
||||
if (this.peer) return openCallback(); // This is for connectTo-> peer is started before
|
||||
|
||||
this.peer = new Peer(this.peerId, {
|
||||
key: this.apiKey, // TODO: we need our own PeerServer KEY (http://peerjs.com/peerserver)
|
||||
debug: this.debug,
|
||||
|
|
Loading…
Reference in New Issue