From 72c4ea00652d7cd31dc8a5cd8000b18d0bb8596f Mon Sep 17 00:00:00 2001 From: Felipe Knorr Kuhn <100320+knorrium@users.noreply.github.com> Date: Wed, 6 Jul 2022 12:34:54 -0700 Subject: [PATCH] Fix crypto library usage for the Electrum API --- backend/src/api/bitcoin/electrum-api.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/backend/src/api/bitcoin/electrum-api.ts b/backend/src/api/bitcoin/electrum-api.ts index 54d75d67b..73fc3f28f 100644 --- a/backend/src/api/bitcoin/electrum-api.ts +++ b/backend/src/api/bitcoin/electrum-api.ts @@ -5,8 +5,7 @@ import { IEsploraApi } from './esplora-api.interface'; import { IElectrumApi } from './electrum-api.interface'; import BitcoinApi from './bitcoin-api'; import logger from '../../logger'; -import * as sha256 from 'crypto-js/sha256'; -import * as hexEnc from 'crypto-js/enc-hex'; +import crypto from "crypto-js"; import loadingIndicators from '../loading-indicators'; import memoryCache from '../memory-cache'; @@ -144,8 +143,8 @@ class BitcoindElectrsApi extends BitcoinApi implements AbstractBitcoinApi { } private encodeScriptHash(scriptPubKey: string): string { - const addrScripthash = hexEnc.stringify(sha256(hexEnc.parse(scriptPubKey))); - return addrScripthash.match(/.{2}/g).reverse().join(''); + const addrScripthash = crypto.enc.Hex.stringify(crypto.SHA256(crypto.enc.Hex.parse(scriptPubKey))); + return addrScripthash!.match(/.{2}/g)!.reverse().join(''); } }