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

Commit

Permalink
Merge pull request #58 from BuxOrg/siggi/paymail-action-get
Browse files Browse the repository at this point in the history
Added GetPaymailAddress action
  • Loading branch information
mergify[bot] authored Apr 11, 2022
2 parents 8ff9365 + 40fef77 commit 236c9f8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
17 changes: 17 additions & 0 deletions action_paymails.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,23 @@ import (
"github.com/BuxOrg/bux/utils"
)

// GetPaymailAddress will get a paymail address model
func (c *Client) GetPaymailAddress(ctx context.Context, address string, opts ...ModelOps) (*PaymailAddress, error) {

// Check for existing NewRelic transaction
ctx = c.GetOrStartTxn(ctx, "get_paymail_address")

// Get the paymail address
paymailAddress, err := getPaymail(ctx, address, append(opts, c.DefaultModelOptions()...)...)
if err != nil {
return nil, err
} else if paymailAddress == nil {
return nil, ErrMissingPaymail
}

return paymailAddress, nil
}

// NewPaymailAddress will create a new paymail address
func (c *Client) NewPaymailAddress(ctx context.Context, xPubKey, address, publicName, avatar string,
opts ...ModelOps) (*PaymailAddress, error) {
Expand Down
3 changes: 3 additions & 0 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ var ErrOutputValueUnSpendable = errors.New("output value un-spendable")
// ErrPaymailAddressIsInvalid is when the paymail address is NOT alias@domain.com
var ErrPaymailAddressIsInvalid = errors.New("paymail address is invalid")

// ErrPaymailAddressAlreadyRegistered is when the paymail address is already registered to another xpub
var ErrPaymailAddressAlreadyRegistered = errors.New("paymail address is already registered")

// ErrUtxoNotReserved is when the utxo is not reserved, but a transaction tries to spend it
var ErrUtxoNotReserved = errors.New("transaction utxo has not been reserved for spending")

Expand Down
1 change: 1 addition & 0 deletions interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ type XPubService interface {

// PaymailService is the paymail actions
type PaymailService interface {
GetPaymailAddress(ctx context.Context, address string, opts ...ModelOps) (*PaymailAddress, error)
NewPaymailAddress(ctx context.Context, key, address, publicName, avatar string, opts ...ModelOps) (*PaymailAddress, error)
DeletePaymailAddress(ctx context.Context, address string, opts ...ModelOps) error
UpdatePaymailAddress(ctx context.Context, address, publicName, avatar string,
Expand Down

0 comments on commit 236c9f8

Please sign in to comment.