Skip to content

Commit

Permalink
AND-9642 NowNodes and GetBlock api fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nemelianov-tangem authored and kozarezvlad committed Jan 13, 2025
1 parent 43d20a4 commit 7ef4f0e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ internal class FlareProvidersBuilder(
when (it) {
is ProviderType.Public -> createPublickProvider(url = it.url)
ProviderType.NowNodes -> config.nowNodeCredentials?.apiKey.letNotBlank { nowNodesApiKey ->
EthereumJsonRpcProvider(baseUrl = "https://flr.nownodes.io/$nowNodesApiKey/ext/bc/C/rpc")
EthereumJsonRpcProvider(
baseUrl = "https://flr.nownodes.io/$nowNodesApiKey/",
postfixUrl = POSTFIX_WITH_BC,
)
}
else -> null
}
Expand All @@ -38,6 +41,7 @@ internal class FlareProvidersBuilder(
}

private companion object {
val POSTFIX_URLS = listOf("ext/C/rpc", "ext/bc/C/rpc")
const val POSTFIX_WITH_BC = "ext/bc/C/rpc"
val POSTFIX_URLS = listOf("ext/C/rpc", POSTFIX_WITH_BC)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.tangem.blockchain.blockchains.bitcoin.BitcoinUnspentOutput
import com.tangem.blockchain.blockchains.bitcoin.network.BitcoinAddressInfo
import com.tangem.blockchain.blockchains.bitcoin.network.BitcoinFee
import com.tangem.blockchain.blockchains.bitcoin.network.BitcoinNetworkProvider
import com.tangem.blockchain.blockchains.bitcoincash.BitcoinCashAddressService
import com.tangem.blockchain.blockchains.clore.CloreMainNetParams
import com.tangem.blockchain.blockchains.dash.DashMainNetParams
import com.tangem.blockchain.blockchains.ducatus.DucatusMainNetParams
Expand All @@ -23,6 +24,7 @@ import com.tangem.common.extensions.hexToBytes
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import org.bitcoinj.core.Address
import org.bitcoinj.core.LegacyAddress
import org.bitcoinj.params.MainNetParams
import org.bitcoinj.params.TestNet3Params
import org.bitcoinj.script.ScriptBuilder
Expand Down Expand Up @@ -120,7 +122,13 @@ class BlockBookNetworkProvider(
getUtxoResponseItems: List<GetUtxoResponseItem>,
address: String,
): List<BitcoinUnspentOutput> {
val addressBitcoinJ = Address.fromString(networkParameters, address)
val addressBitcoinJ = when (blockchain) {
Blockchain.BitcoinCash, Blockchain.BitcoinCashTestnet -> {
val addressService = BitcoinCashAddressService(blockchain)
LegacyAddress.fromPubKeyHash(networkParameters, addressService.getPublicKeyHash(address))
}
else -> Address.fromString(networkParameters, address)
}
val outputScript = ScriptBuilder.createOutputScript(addressBitcoinJ).program

return getUtxoResponseItems.mapNotNull {
Expand Down

0 comments on commit 7ef4f0e

Please sign in to comment.