Skip to content

Commit

Permalink
[Backport] Optimize deposit sweep proposal generator (#3808)
Browse files Browse the repository at this point in the history
This pull request backports
#3805 to the
`releases/mainnet/v2.0.1` branch.
  • Loading branch information
lukasz-zimnoch authored Apr 11, 2024
2 parents f958ba0 + ff963f9 commit 62d13e9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 19 deletions.
5 changes: 2 additions & 3 deletions cmd/maintainercli.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,12 @@ var listDepositsCommand = cobra.Command{

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

for i, deposit := range deposits {
fmt.Fprintf(w, "%d\t%s\t%s\t%.5f\t%s\t%s\t%d\t%t\t\n",
fmt.Fprintf(w, "%d\t%s\t%.5f\t%s\t%s\t%d\t%t\t\n",
i,
hexutils.Encode(deposit.WalletPublicKeyHash[:]),
deposit.ScriptType,
deposit.AmountBtc,
deposit.DepositKey,
fmt.Sprintf(
Expand Down
16 changes: 0 additions & 16 deletions pkg/tbtcpg/deposit_sweep.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ type Deposit struct {
DepositReference

WalletPublicKeyHash [20]byte
ScriptType bitcoin.ScriptType
DepositKey string
IsSwept bool
AmountBtc float64
Expand Down Expand Up @@ -241,20 +240,6 @@ func findDeposits(
continue
}

var scriptType bitcoin.ScriptType
depositTransaction, err := btcChain.GetTransaction(
event.FundingTxHash,
)
if err != nil {
fnLogger.Errorf(
"failed to get deposit transaction data: [%v]",
err,
)
} else {
publicKeyScript := depositTransaction.Outputs[event.FundingOutputIndex].PublicKeyScript
scriptType = bitcoin.GetScriptType(publicKeyScript)
}

result = append(
result,
&Deposit{
Expand All @@ -264,7 +249,6 @@ func findDeposits(
RevealBlock: event.BlockNumber,
},
WalletPublicKeyHash: event.WalletPublicKeyHash,
ScriptType: scriptType,
DepositKey: hexutils.Encode(depositKey.Bytes()),
IsSwept: isSwept,
AmountBtc: convertSatToBtc(float64(depositRequest.Amount)),
Expand Down

0 comments on commit 62d13e9

Please sign in to comment.