Handle "transaction already exists" error
This commit is contained in:
parent
e3d7ab6e75
commit
4d47bc6df8
@ -94,8 +94,6 @@ func blockConnected() {
|
|||||||
for _, ticket := range pending {
|
for _, ticket := range pending {
|
||||||
feeTxHash, err := dcrdClient.SendRawTransaction(ticket.FeeTxHex)
|
feeTxHash, err := dcrdClient.SendRawTransaction(ticket.FeeTxHex)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// TODO: SendRawTransaction can return a "transcation already
|
|
||||||
// exists" error, which isnt necessarily a problem here.
|
|
||||||
log.Errorf("SendRawTransaction error: %v", err)
|
log.Errorf("SendRawTransaction error: %v", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|||||||
18
rpc/dcrd.go
18
rpc/dcrd.go
@ -5,6 +5,7 @@ import (
|
|||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/decred/dcrd/blockchain/stake/v3"
|
"github.com/decred/dcrd/blockchain/stake/v3"
|
||||||
@ -100,8 +101,25 @@ func (c *DcrdRPC) SendRawTransaction(txHex string) (string, error) {
|
|||||||
var txHash string
|
var txHash string
|
||||||
err := c.Call(c.ctx, "sendrawtransaction", &txHash, txHex, allowHighFees)
|
err := c.Call(c.ctx, "sendrawtransaction", &txHash, txHex, allowHighFees)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
// 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
|
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
|
return txHash, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -215,8 +215,6 @@ findAddress:
|
|||||||
if ticket.Confirmed {
|
if ticket.Confirmed {
|
||||||
feeTxHash, err := dcrdClient.SendRawTransaction(payFeeRequest.FeeTx)
|
feeTxHash, err := dcrdClient.SendRawTransaction(payFeeRequest.FeeTx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// TODO: SendRawTransaction can return a "transcation already
|
|
||||||
// exists" error, which isnt necessarily a problem here.
|
|
||||||
log.Errorf("SendRawTransaction failed: %v", err)
|
log.Errorf("SendRawTransaction failed: %v", err)
|
||||||
sendErrorResponse("dcrwallet RPC error", http.StatusInternalServerError, c)
|
sendErrorResponse("dcrwallet RPC error", http.StatusInternalServerError, c)
|
||||||
return
|
return
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user