browser: handle failed connections and witness accounts.
This commit is contained in:
parent
d96a579665
commit
70e3892f92
@ -161,17 +161,17 @@ function setMouseup(el, obj) {
|
|||||||
|
|
||||||
function formatWallet(wallet) {
|
function formatWallet(wallet) {
|
||||||
var html = '';
|
var html = '';
|
||||||
var key = wallet.master.toJSON().key;
|
var key = wallet.master.toJSON(true).key;
|
||||||
var i, tx, el;
|
var i, tx, el;
|
||||||
|
|
||||||
html += '<b>Wallet</b><br>';
|
html += '<b>Wallet</b><br>';
|
||||||
|
|
||||||
if (bcoin.network.primary.witness) {
|
if (wallet.account.witness) {
|
||||||
html += 'Current Address (p2wpkh): <b>'
|
html += 'Current Address (p2wpkh): <b>'
|
||||||
+ wallet.getAddress()
|
+ wallet.getAddress()
|
||||||
+ '</b><br>';
|
+ '</b><br>';
|
||||||
html += 'Current Address (p2wpkh behind p2sh): <b>'
|
html += 'Current Address (p2wpkh behind p2sh): <b>'
|
||||||
+ wallet.getProgramAddress()
|
+ wallet.getNestedAddress()
|
||||||
+ '</b><br>';
|
+ '</b><br>';
|
||||||
} else {
|
} else {
|
||||||
html += 'Current Address: <b>' + wallet.getAddress() + '</b><br>';
|
html += 'Current Address: <b>' + wallet.getAddress() + '</b><br>';
|
||||||
@ -189,8 +189,6 @@ function formatWallet(wallet) {
|
|||||||
+ utils.btc(balance.unconfirmed)
|
+ utils.btc(balance.unconfirmed)
|
||||||
+ '</b><br>';
|
+ '</b><br>';
|
||||||
|
|
||||||
html += 'Balance: <b>' + utils.btc(balance.total) + '</b><br>';
|
|
||||||
|
|
||||||
return wallet.getHistory();
|
return wallet.getHistory();
|
||||||
}).then(function(txs) {
|
}).then(function(txs) {
|
||||||
return wallet.toDetails(txs);
|
return wallet.toDetails(txs);
|
||||||
|
|||||||
@ -107,21 +107,30 @@ WSProxy.prototype._handleConnect = function _handleConnect(ws, port, host, nonce
|
|||||||
|
|
||||||
if (!/^[a-zA-Z0-9\.:\-]+$/.test(host)) {
|
if (!/^[a-zA-Z0-9\.:\-]+$/.test(host)) {
|
||||||
this.log('Client gave a bad host (%s).', state.host);
|
this.log('Client gave a bad host (%s).', state.host);
|
||||||
ws.emit('tcp close');
|
ws.emit('tcp error', {
|
||||||
|
message: 'EHOSTUNREACH',
|
||||||
|
code: 'EHOSTUNREACH'
|
||||||
|
});
|
||||||
ws.disconnect();
|
ws.disconnect();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IP.isPrivate(host)) {
|
if (IP.isPrivate(host)) {
|
||||||
this.log('Client is trying to connect to a private ip (%s).', state.host);
|
this.log('Client is trying to connect to a private ip (%s).', state.host);
|
||||||
ws.emit('tcp close');
|
ws.emit('tcp error', {
|
||||||
|
message: 'ENETUNREACH',
|
||||||
|
code: 'ENETUNREACH'
|
||||||
|
});
|
||||||
ws.disconnect();
|
ws.disconnect();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.ports.indexOf(port) === -1) {
|
if (this.ports.indexOf(port) === -1) {
|
||||||
this.log('Client is connecting to non-whitelist port (%s).', state.host);
|
this.log('Client is connecting to non-whitelist port (%s).', state.host);
|
||||||
ws.emit('tcp close');
|
ws.emit('tcp error', {
|
||||||
|
message: 'ENETUNREACH',
|
||||||
|
code: 'ENETUNREACH'
|
||||||
|
});
|
||||||
ws.disconnect();
|
ws.disconnect();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -132,7 +141,10 @@ WSProxy.prototype._handleConnect = function _handleConnect(ws, port, host, nonce
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.log(e.message);
|
this.log(e.message);
|
||||||
this.log('Closing %s (%s).', state.remoteHost, state.host);
|
this.log('Closing %s (%s).', state.remoteHost, state.host);
|
||||||
ws.emit('tcp close');
|
ws.emit('tcp error', {
|
||||||
|
message: 'ENETUNREACH',
|
||||||
|
code: 'ENETUNREACH'
|
||||||
|
});
|
||||||
ws.disconnect();
|
ws.disconnect();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user