Skip to content

Commit

Permalink
minor log fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pm47 authored and sstone committed Feb 12, 2024
1 parent c5f3d10 commit 5210a1e
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ class ElectrumMiniWallet(
val addressMeta = bitcoinAddress?.let { addressMetas[it] }
return when {
bitcoinAddress == null || addressMeta == null -> {
// this should never happen
logger.error { "received subscription response for script hash ${msg.scriptHash} that does not match any address" }
// this will happen because multiple wallets may be sharing the same Electrum connection (e.g. swap-in and final wallet)
logger.debug { "received subscription response for script hash ${msg.scriptHash} that does not match any address" }
this
}
msg.status == null -> {
Expand Down Expand Up @@ -200,7 +200,7 @@ class ElectrumMiniWallet(
*/
suspend fun WalletState.subscribe(scriptHash: ByteVector32, bitcoinAddress: String): WalletState {
val response = client.startScriptHashSubscription(scriptHash)
logger.info { "subscribed to address=$bitcoinAddress scriptHash=$scriptHash" }
logger.debug { "subscribed to address=$bitcoinAddress scriptHash=$scriptHash" }
return processSubscriptionResponse(response)
}

Expand All @@ -213,7 +213,7 @@ class ElectrumMiniWallet(
suspend fun WalletState.addAddress(bitcoinAddress: String, meta: WalletState.Companion.AddressMeta): WalletState {
return computeScriptHash(bitcoinAddress)?.let { scriptHash ->
if (!scriptHashes.containsKey(scriptHash)) {
logger.info { "adding new address=${bitcoinAddress} index=${meta.indexOrNull ?: "n/a"}" }
logger.debug { "adding new address=${bitcoinAddress} index=${meta.indexOrNull ?: "n/a"}" }
scriptHashes = scriptHashes + (scriptHash to bitcoinAddress)
addressMetas = addressMetas + (bitcoinAddress to meta)
subscribe(scriptHash, bitcoinAddress)
Expand Down

0 comments on commit 5210a1e

Please sign in to comment.