Handle "transaction already exists" error
This commit is contained in:
parent
e3d7ab6e75
commit
4d47bc6df8
@ -94,8 +94,6 @@ func blockConnected() {
|
||||
for _, ticket := range pending {
|
||||
feeTxHash, err := dcrdClient.SendRawTransaction(ticket.FeeTxHex)
|
||||
if err != nil {
|
||||
// TODO: SendRawTransaction can return a "transcation already
|
||||
// exists" error, which isnt necessarily a problem here.
|
||||
log.Errorf("SendRawTransaction error: %v", err)
|
||||
continue
|
||||
}
|
||||
|
||||
20
rpc/dcrd.go
20
rpc/dcrd.go
@ -5,6 +5,7 @@ import (
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/decred/dcrd/blockchain/stake/v3"
|
||||
@ -100,7 +101,24 @@ func (c *DcrdRPC) SendRawTransaction(txHex string) (string, error) {
|
||||
var txHash string
|
||||
err := c.Call(c.ctx, "sendrawtransaction", &txHash, txHex, allowHighFees)
|
||||
if err != nil {
|
||||
return "", err
|
||||
// It's not a problem if the transaction has already been broadcast,
|
||||
// just need to calculate and return its hash.
|
||||
if !strings.Contains(err.Error(), "transaction already exists") {
|
||||
return "", err
|
||||
}
|
||||
|
||||
msgHex, err := hex.DecodeString(txHex)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("DecodeString error: %v", err)
|
||||
|
||||
}
|
||||
msgTx := wire.NewMsgTx()
|
||||
if err = msgTx.FromBytes(msgHex); err != nil {
|
||||
return "", fmt.Errorf("FromBytes error: %v", err)
|
||||
|
||||
}
|
||||
|
||||
txHash = msgTx.TxHash().String()
|
||||
}
|
||||
return txHash, nil
|
||||
}
|
||||
|
||||
@ -215,8 +215,6 @@ findAddress:
|
||||
if ticket.Confirmed {
|
||||
feeTxHash, err := dcrdClient.SendRawTransaction(payFeeRequest.FeeTx)
|
||||
if err != nil {
|
||||
// TODO: SendRawTransaction can return a "transcation already
|
||||
// exists" error, which isnt necessarily a problem here.
|
||||
log.Errorf("SendRawTransaction failed: %v", err)
|
||||
sendErrorResponse("dcrwallet RPC error", http.StatusInternalServerError, c)
|
||||
return
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user