feat: require Breez API key globally on mainnet (#520)

This commit is contained in:
yse
2024-10-08 16:17:34 +02:00
committed by GitHub
parent 046e7ab1c8
commit 42f4ca0129
34 changed files with 535 additions and 105 deletions

View File

@@ -224,6 +224,7 @@ fun asConfig(config: ReadableMap): Config? {
val network = config.getString("network")?.let { asLiquidNetwork(it) }!!
val paymentTimeoutSec = config.getDouble("paymentTimeoutSec").toULong()
val zeroConfMinFeeRateMsat = config.getInt("zeroConfMinFeeRateMsat").toUInt()
val breezApiKey = if (hasNonNullKey(config, "breezApiKey")) config.getString("breezApiKey") else null
val zeroConfMaxAmountSat =
if (hasNonNullKey(
config,
@@ -234,7 +235,6 @@ fun asConfig(config: ReadableMap): Config? {
} else {
null
}
val breezApiKey = if (hasNonNullKey(config, "breezApiKey")) config.getString("breezApiKey") else null
return Config(
liquidElectrumUrl,
bitcoinElectrumUrl,
@@ -243,8 +243,8 @@ fun asConfig(config: ReadableMap): Config? {
network,
paymentTimeoutSec,
zeroConfMinFeeRateMsat,
zeroConfMaxAmountSat,
breezApiKey,
zeroConfMaxAmountSat,
)
}
@@ -257,8 +257,8 @@ fun readableMapOf(config: Config): ReadableMap =
"network" to config.network.name.lowercase(),
"paymentTimeoutSec" to config.paymentTimeoutSec,
"zeroConfMinFeeRateMsat" to config.zeroConfMinFeeRateMsat,
"zeroConfMaxAmountSat" to config.zeroConfMaxAmountSat,
"breezApiKey" to config.breezApiKey,
"zeroConfMaxAmountSat" to config.zeroConfMaxAmountSat,
)
fun asConfigList(arr: ReadableArray): List<Config> {

View File

@@ -57,12 +57,14 @@ class BreezSDKLiquidModule(
@ReactMethod
fun defaultConfig(
network: String,
breezApiKey: String,
promise: Promise,
) {
executor.execute {
try {
val networkTmp = asLiquidNetwork(network)
val res = defaultConfig(networkTmp)
val breezApiKeyTmp = breezApiKey.takeUnless { it.isEmpty() }
val res = defaultConfig(networkTmp, breezApiKeyTmp)
val workingDir = File(reactApplicationContext.filesDir.toString() + "/breezSdkLiquid")
res.workingDir = workingDir.absolutePath