Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
} else if (wallet === 'bitcoin_ledger_nagive_segwit') {
addressType = 'bech32'
}
const ledger = new BitcoinLedgerProvider({network: BitcoinNetworks[btcConfig.network]}, addressType)
if (window.useWebBle || localStorage.useWebBle) {
ledger.useWebBle()
}
btcClient.addProvider(getBitcoinDataProvider(btcConfig))
btcClient.addProvider(ledger)
btcClient.addProvider(new BitcoinSwapProvider({network: BitcoinNetworks[btcConfig.network]}, btcConfig.swapMode))
} else if (wallet === 'bitcoin_node') {
if (btcConfig.rpc.addressType === 'p2sh-segwit') {
throw new Error('Wrapped segwit addresses (p2sh-segwit) are currently unsupported.')
}
btcClient.addProvider(new BitcoinRpcProvider(btcConfig.rpc.url, btcConfig.rpc.username, btcConfig.rpc.password, btcConfig.feeNumberOfBlocks))
btcClient.addProvider(new BitcoinNodeWalletProvider(BitcoinNetworks[btcConfig.network], btcConfig.rpc.url, btcConfig.rpc.username, btcConfig.rpc.password, btcConfig.rpc.addressType))
btcClient.addProvider(new BitcoinSwapProvider({network: BitcoinNetworks[btcConfig.network]}, btcConfig.swapMode))
} else {
// Verify functions required when wallet not connected
btcClient.addProvider(getBitcoinDataProvider(btcConfig))
btcClient.addProvider(new BitcoinSwapProvider({network: BitcoinNetworks[btcConfig.network]}, btcConfig.swapMode))
}
return btcClient
}
function getBitcoinDataProvider (btcConfig) {
if (btcConfig.rpc) {
return new BitcoinRpcProvider(btcConfig.rpc.url, btcConfig.rpc.username, btcConfig.rpc.password, btcConfig.feeNumberOfBlocks)
} else if (btcConfig.api) {
return new BitcoinEsploraApiProvider(btcConfig.api.url, btcConfig.feeNumberOfBlocks)
}
}