Skip to content

Commit ff963f9

Browse files
Optimize deposit sweep proposal generator
Fetching deposit script type is not needed for sweep proposal generation. Doing so means making an additional Electrum call for each deposit. This makes proposal generation longer and more prone to failure. At the same time, the script type is used only for Maintainer CLI which is not so important since we have tbtcscan and there is no way to manually trigger sweeps due to the introduction of RFC 12. That said, we are removing script type fetch from the process. (cherry picked from commit 079bb82)
1 parent f958ba0 commit ff963f9

File tree

2 files changed

+2
-19
lines changed

2 files changed

+2
-19
lines changed

cmd/maintainercli.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,12 @@ var listDepositsCommand = cobra.Command{
132132

133133
func printDepositsTable(deposits []*tbtcpg.Deposit) error {
134134
w := tabwriter.NewWriter(os.Stdout, 2, 4, 1, ' ', tabwriter.AlignRight)
135-
fmt.Fprintf(w, "index\twallet\ttype\tvalue (BTC)\tdeposit key\trevealed deposit data\tconfirmations\tswept\t\n")
135+
fmt.Fprintf(w, "index\twallet\tvalue (BTC)\tdeposit key\trevealed deposit data\tconfirmations\tswept\t\n")
136136

137137
for i, deposit := range deposits {
138-
fmt.Fprintf(w, "%d\t%s\t%s\t%.5f\t%s\t%s\t%d\t%t\t\n",
138+
fmt.Fprintf(w, "%d\t%s\t%.5f\t%s\t%s\t%d\t%t\t\n",
139139
i,
140140
hexutils.Encode(deposit.WalletPublicKeyHash[:]),
141-
deposit.ScriptType,
142141
deposit.AmountBtc,
143142
deposit.DepositKey,
144143
fmt.Sprintf(

pkg/tbtcpg/deposit_sweep.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ type Deposit struct {
104104
DepositReference
105105

106106
WalletPublicKeyHash [20]byte
107-
ScriptType bitcoin.ScriptType
108107
DepositKey string
109108
IsSwept bool
110109
AmountBtc float64
@@ -241,20 +240,6 @@ func findDeposits(
241240
continue
242241
}
243242

244-
var scriptType bitcoin.ScriptType
245-
depositTransaction, err := btcChain.GetTransaction(
246-
event.FundingTxHash,
247-
)
248-
if err != nil {
249-
fnLogger.Errorf(
250-
"failed to get deposit transaction data: [%v]",
251-
err,
252-
)
253-
} else {
254-
publicKeyScript := depositTransaction.Outputs[event.FundingOutputIndex].PublicKeyScript
255-
scriptType = bitcoin.GetScriptType(publicKeyScript)
256-
}
257-
258243
result = append(
259244
result,
260245
&Deposit{
@@ -264,7 +249,6 @@ func findDeposits(
264249
RevealBlock: event.BlockNumber,
265250
},
266251
WalletPublicKeyHash: event.WalletPublicKeyHash,
267-
ScriptType: scriptType,
268252
DepositKey: hexutils.Encode(depositKey.Bytes()),
269253
IsSwept: isSwept,
270254
AmountBtc: convertSatToBtc(float64(depositRequest.Amount)),

0 commit comments

Comments
 (0)