Skip to content

Commit

Permalink
backend: do not log error containing serialized tx
Browse files Browse the repository at this point in the history
The error message coming from electrum contains the serialized
transaction and we do not want it in the logs, for privacy
reasons, so we strip it.
  • Loading branch information
bznein committed Jan 16, 2025
1 parent 3a24ebc commit 78a033f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion backend/coins/btc/electrum/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ import (
"bytes"
"context"
"encoding/hex"
"errors"
"fmt"
"strings"

"github.com/BitBoxSwiss/bitbox-wallet-app/backend/coins/btc/blockchain"
"github.com/BitBoxSwiss/bitbox-wallet-app/util/errp"
Expand Down Expand Up @@ -120,7 +123,8 @@ func (c *client) TransactionBroadcast(transaction *wire.MsgTx) error {
rawTxHex := hex.EncodeToString(rawTx.Bytes())
txID, err := c.client.TransactionBroadcast(context.Background(), rawTxHex)
if err != nil {
return err
// Return a new error, stripping the rawTxHex from it, if it is there.
return errors.New(strings.ReplaceAll(err.Error(), fmt.Sprintf("[%s]", rawTxHex), ""))
}
if txID != transaction.TxHash().String() {
return errp.New("Response is unexpected (transaction hash mismatch)")
Expand Down

0 comments on commit 78a033f

Please sign in to comment.