fix error with invalid chaintips

This commit is contained in:
Antoni Spaanderman 2022-01-22 15:13:10 +01:00
parent e8986e5fdc
commit 30632e9e11
No known key found for this signature in database
GPG Key ID: AE0B68E552E5DF8C

View File

@ -41,7 +41,12 @@ class BitcoinApi implements AbstractBitcoinApi {
$getBlockHeightTip(): Promise<number> {
return this.bitcoindClient.getChainTips()
.then((result: IBitcoinApi.ChainTips[]) => result[0].height);
.then((result: IBitcoinApi.ChainTips[]) => {
const activeTip = result.find(tip => tip.status === 'active');
if (activeTip) {
return activeTip.height;
}
});
}
$getTxIdsForBlock(hash: string): Promise<string[]> {