Skip to content

Commit 968ac3e

Browse files
authored
Wallet maintainer: Resolve deposit script type at the very end (#3719)
The script type resolution requires access to transaction data stored on the Bitcoin blockchain. If the given transaction hasn't actually happened but was revealed as deposit to the `Bridge`, the maintainer will not be able to resolve the deposit script type. So far, an error was returned in that case and the maintainer stopped the entire deposit sweep task. This cannot happen as the maintainer can be blocked on deposit sweeps for a long time. Instead, the maintainer should log an error and leave the deposit type unresolved.
2 parents f559b3e + 65a0f26 commit 968ac3e

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

pkg/maintainer/wallet/deposit_sweep.go

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -117,19 +117,6 @@ func FindDeposits(
117117

118118
logger.Debugf("getting details of deposit %d/%d", i+1, len(depositRevealedEvents))
119119

120-
depositTransaction, err := btcChain.GetTransaction(
121-
event.FundingTxHash,
122-
)
123-
if err != nil {
124-
return result, fmt.Errorf(
125-
"failed to get deposit transaction: [%w]",
126-
err,
127-
)
128-
}
129-
130-
publicKeyScript := depositTransaction.Outputs[event.FundingOutputIndex].PublicKeyScript
131-
scriptType := bitcoin.GetScriptType(publicKeyScript)
132-
133120
depositKey := chain.BuildDepositKey(event.FundingTxHash, event.FundingOutputIndex)
134121

135122
depositRequest, found, err := chain.GetDepositRequest(
@@ -172,6 +159,20 @@ func FindDeposits(
172159
continue
173160
}
174161

162+
var scriptType bitcoin.ScriptType
163+
depositTransaction, err := btcChain.GetTransaction(
164+
event.FundingTxHash,
165+
)
166+
if err != nil {
167+
logger.Errorf(
168+
"failed to get deposit transaction data: [%v]",
169+
err,
170+
)
171+
} else {
172+
publicKeyScript := depositTransaction.Outputs[event.FundingOutputIndex].PublicKeyScript
173+
scriptType = bitcoin.GetScriptType(publicKeyScript)
174+
}
175+
175176
result = append(
176177
result,
177178
&Deposit{
@@ -229,7 +230,7 @@ func FindDepositsToSweep(
229230
return nil,
230231
fmt.Errorf(
231232
"failed to get deposits for [%s] wallet: [%w]",
232-
walletToSweep,
233+
hexutils.Encode(walletToSweep[:]),
233234
err,
234235
)
235236
}

0 commit comments

Comments
 (0)