Skip to content

Commit

Permalink
minor log fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pm47 committed Feb 6, 2024
1 parent 6eba0f8 commit 7bd0e8a
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,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 @@ -190,7 +190,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 @@ -203,7 +203,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 7bd0e8a

Please sign in to comment.