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

Added GetPaymailAddress action #58

Merged
merged 1 commit into from
Apr 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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