Skip to content

Commit

Permalink
fix: filter descriptor
Browse files Browse the repository at this point in the history
  • Loading branch information
jvsena42 committed Oct 28, 2024
1 parent fe949f7 commit c8edcdd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class FlorestaDaemonImpl(
dataDir = datadir,
electrumAddress = ELECTRUM_ADDRESS,
network = FlorestaNetwork.SIGNET,
walletDescriptor = descriptorList.toString().filterInternalBrackets()
walletDescriptor = descriptorList?.firstOrNull()
)
daemon = Florestad.fromConfig(config)
daemon.start().also {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import com.github.jvsena42.floresta.data.FlorestaRpc
import com.github.jvsena42.floresta.domain.model.florestaRPC.GetBlockchainInfoResponse
import com.github.jvsena42.floresta.domain.model.florestaRPC.GetPeerInfoResponse
import com.github.jvsena42.floresta.domain.model.florestaRPC.RpcMethods
import com.github.jvsena42.floresta.presentation.util.filterInternalBrackets
import com.google.gson.Gson
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.Flow
Expand Down Expand Up @@ -37,14 +36,14 @@ class FlorestaRpcImpl(
}

override suspend fun loadDescriptor(descriptor: String): Flow<Result<JSONObject>> = flow {
Log.d(TAG, "loadDescriptor: $descriptor \n ${descriptor.filterInternalBrackets()}")
Log.d(TAG, "loadDescriptor: $descriptor")
val arguments = JSONArray()
arguments.put(descriptor)

getBlockchainInfo().first().onSuccess { result ->
if (result.result.ibd) {
delay(10.seconds)
loadDescriptor(descriptor.filterInternalBrackets())
loadDescriptor(descriptor)
} else {
emit(
sendJsonRpcRequest(
Expand All @@ -56,7 +55,7 @@ class FlorestaRpcImpl(
}
}.onFailure {
delay(30.seconds)
loadDescriptor(descriptor.filterInternalBrackets())
loadDescriptor(descriptor)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,4 @@ fun ULong?.formatInBtc(): String {
// this.toFloat().div(100_000_000)
// }
// return DecimalFormat("0.00000000").format(balanceInSats)
//}

fun String?.filterInternalBrackets() : String{
if (this.isNullOrEmpty()) return ""

return this.replace(Regex("""\[([^\[\]]*)\]"""), "$1")
}
//}

0 comments on commit c8edcdd

Please sign in to comment.