Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

Commit

Permalink
Do not error on receiving paymail transaction if already exists
Browse files Browse the repository at this point in the history
  • Loading branch information
icellan committed Nov 30, 2022
1 parent 06572a1 commit fa0af7d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions paymail_service_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"database/sql"
"encoding/hex"
"errors"
"fmt"
"time"

Expand All @@ -12,6 +13,7 @@ import (
"github.com/libsv/go-bk/bec"
"github.com/libsv/go-bk/bip32"
"github.com/libsv/go-bt/v2/bscript"
"github.com/mrz1836/go-datastore"
customTypes "github.com/mrz1836/go-datastore/custom_types"
"github.com/tonicpow/go-paymail"
"github.com/tonicpow/go-paymail/server"
Expand Down Expand Up @@ -144,13 +146,12 @@ func (p *PaymailDefaultServiceProvider) RecordTransaction(ctx context.Context,
metadata[p2pMetadataField] = p2pTx.MetaData
metadata[ReferenceIDField] = p2pTx.Reference

// todo: check if tx already exists, then gracefully respond?

// Record the transaction
transaction, err := p.client.RecordTransaction(
ctx, "", p2pTx.Hex, "", []ModelOps{WithMetadatas(metadata)}...,
)
if err != nil {
// do not return an error if we already have the transaction
if err != nil && !errors.Is(err, datastore.ErrDuplicateKey) {
return nil, err
}

Expand Down

0 comments on commit fa0af7d

Please sign in to comment.