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

Commit

Permalink
Make sure the xpub exists for the paymail
Browse files Browse the repository at this point in the history
  • Loading branch information
mrz1836 committed May 17, 2022
1 parent 136d2b6 commit 8d4de5b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions action_paymails.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ func (c *Client) NewPaymailAddress(ctx context.Context, xPubKey, address, public
// Check for existing NewRelic transaction
ctx = c.GetOrStartTxn(ctx, "new_paymail_address")

// Get the xPub (make sure it exists)
_, err := c.GetXpub(ctx, xPubKey)
if err != nil {
return nil, err
}

// Start the new paymail address model
paymailAddress := newPaymail(
address,
Expand All @@ -109,10 +115,9 @@ func (c *Client) NewPaymailAddress(ctx context.Context, xPubKey, address, public
paymailAddress.PublicName = publicName

// Save the model
if err := paymailAddress.Save(ctx); err != nil {
if err = paymailAddress.Save(ctx); err != nil {
return nil, err
}

return paymailAddress, nil
}

Expand Down

0 comments on commit 8d4de5b

Please sign in to comment.