Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | 6x 6x 6x 6x 13x 2x 2x 6x 11x 6x 13x 13x 13x 2x 12x | const { isValidAddress } = require('ethereumjs-util');
const { omit } = require('lodash');
const getColor = require('./getColor');
const { filterUnspent } = require('../../utils');
function othersHeartbeatUtxos(bridgeState) {
if (
bridgeState.config.heartbeat &&
bridgeState.config.heartbeat.color !== undefined &&
bridgeState.config.heartbeat.filter &&
bridgeState.account
) {
const {
currentState: { unspent },
account: { address },
config: {
heartbeat: { color },
},
} = bridgeState;
return Object.keys(unspent).filter(
k =>
unspent[k] &&
unspent[k].address.toLowerCase() !== address.toLowerCase() &&
Number(unspent[k].color) === Number(color)
);
}
return [];
}
module.exports = async (bridgeState, address, colorOrAddress) => {
const unspent = omit(bridgeState.currentState.unspent, [
...Object.keys(bridgeState.exitingUtxos),
...othersHeartbeatUtxos(bridgeState),
]);
let color = colorOrAddress;
if (isValidAddress(colorOrAddress)) {
color = await getColor(bridgeState, colorOrAddress);
}
return filterUnspent(unspent, address, color);
};
|