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) {
|
||||
var html = '';
|
||||
var key = wallet.master.toJSON().key;
|
||||
var key = wallet.master.toJSON(true).key;
|
||||
var i, tx, el;
|
||||
|
||||
html += '<b>Wallet</b><br>';
|
||||
|
||||
if (bcoin.network.primary.witness) {
|
||||
if (wallet.account.witness) {
|
||||
html += 'Current Address (p2wpkh): <b>'
|
||||
+ wallet.getAddress()
|
||||
+ '</b><br>';
|
||||
html += 'Current Address (p2wpkh behind p2sh): <b>'
|
||||
+ wallet.getProgramAddress()
|
||||
+ wallet.getNestedAddress()
|
||||
+ '</b><br>';
|
||||
} else {
|
||||
html += 'Current Address: <b>' + wallet.getAddress() + '</b><br>';
|
||||
@ -189,8 +189,6 @@ function formatWallet(wallet) {
|
||||
+ utils.btc(balance.unconfirmed)
|
||||
+ '</b><br>';
|
||||
|
||||
html += 'Balance: <b>' + utils.btc(balance.total) + '</b><br>';
|
||||
|
||||
return wallet.getHistory();
|
||||
}).then(function(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)) {
|
||||
this.log('Client gave a bad host (%s).', state.host);
|
||||
ws.emit('tcp close');
|
||||
ws.emit('tcp error', {
|
||||
message: 'EHOSTUNREACH',
|
||||
code: 'EHOSTUNREACH'
|
||||
});
|
||||
ws.disconnect();
|
||||
return;
|
||||
}
|
||||
|
||||
if (IP.isPrivate(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();
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.ports.indexOf(port) === -1) {
|
||||
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();
|
||||
return;
|
||||
}
|
||||
@ -132,7 +141,10 @@ WSProxy.prototype._handleConnect = function _handleConnect(ws, port, host, nonce
|
||||
} catch (e) {
|
||||
this.log(e.message);
|
||||
this.log('Closing %s (%s).', state.remoteHost, state.host);
|
||||
ws.emit('tcp close');
|
||||
ws.emit('tcp error', {
|
||||
message: 'ENETUNREACH',
|
||||
code: 'ENETUNREACH'
|
||||
});
|
||||
ws.disconnect();
|
||||
return;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user