Skip to content

Commit

Permalink
Updated new struct names from go-paymail
Browse files Browse the repository at this point in the history
  • Loading branch information
mrz1836 committed Jan 5, 2022
1 parent 878a04c commit e08e97a
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 14 deletions.
2 changes: 1 addition & 1 deletion cmd/capabilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Read more at: `+chalk.Cyan.Color("http://bsvalias.org/02-02-capability-discovery
}

// Get the capabilities
var capabilities *paymail.Capabilities
var capabilities *paymail.CapabilitiesResponse
capabilities, err = getCapabilities(domain, false)
if err != nil {
if strings.Contains(err.Error(), "context deadline exceeded") {
Expand Down
17 changes: 10 additions & 7 deletions cmd/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func newPaymailClient(tracing bool, nameServer string) (*paymail.Client, error)
}

// getPki will get a pki response (logging and basic error handling)
func getPki(pkiURL, alias, domain string, allowCache bool) (pki *paymail.PKI, err error) {
func getPki(pkiURL, alias, domain string, allowCache bool) (pki *paymail.PKIResponse, err error) {

// Start the request
displayHeader(chalker.DEFAULT, fmt.Sprintf("Retrieving public key information for %s...", chalk.Cyan.Color(alias+"@"+domain)))
Expand Down Expand Up @@ -165,7 +165,7 @@ func getSrvRecord(domain string, validate bool, allowCache bool) (srv *net.SRV,
}

// getCapabilities will check SRV first, then attempt default domain:port check (logging and basic error handling)
func getCapabilities(domain string, allowCache bool) (capabilities *paymail.Capabilities, err error) {
func getCapabilities(domain string, allowCache bool) (capabilities *paymail.CapabilitiesResponse, err error) {

capabilityDomain := ""
capabilityPort := paymail.DefaultPort
Expand Down Expand Up @@ -241,7 +241,8 @@ func getCapabilities(domain string, allowCache bool) (capabilities *paymail.Capa
}

// resolveAddress will resolve an address (logging and basic error handling)
func resolveAddress(resolveURL, alias, domain, senderHandle, signature, purpose string, amount uint64) (response *paymail.Resolution, err error) {
func resolveAddress(resolveURL, alias, domain, senderHandle,
signature, purpose string, amount uint64) (response *paymail.ResolutionResponse, err error) {

// Start the request
displayHeader(chalker.DEFAULT, fmt.Sprintf("Resolving address for %s...", chalk.Cyan.Color(alias+"@"+domain)))
Expand Down Expand Up @@ -281,7 +282,8 @@ func resolveAddress(resolveURL, alias, domain, senderHandle, signature, purpose
}

// getP2PPaymentDestination will start a new p2p transaction request (logging and basic error handling)
func getP2PPaymentDestination(destinationURL, alias, domain string, satoshis uint64) (response *paymail.PaymentDestination, err error) {
func getP2PPaymentDestination(destinationURL, alias,
domain string, satoshis uint64) (response *paymail.PaymentDestinationResponse, err error) {

// Start the request
displayHeader(chalker.DEFAULT, fmt.Sprintf("Starting new P2P payment request for %s...", chalk.Cyan.Color(alias+"@"+domain)))
Expand Down Expand Up @@ -314,7 +316,8 @@ func getP2PPaymentDestination(destinationURL, alias, domain string, satoshis uin
}

// getPublicProfile will get a public profile (logging and basic error handling)
func getPublicProfile(profileURL, alias, domain string, allowCache bool) (profile *paymail.PublicProfile, err error) {
func getPublicProfile(profileURL, alias,
domain string, allowCache bool) (profile *paymail.PublicProfileResponse, err error) {

// Start the request
displayHeader(chalker.DEFAULT, fmt.Sprintf("Retrieving public profile for %s...", chalk.Cyan.Color(alias+"@"+domain)))
Expand Down Expand Up @@ -646,7 +649,7 @@ func getBaemail(alias, domain string, allowCache bool) (response *baemail.Respon
}

// verifyPubKey will verify a given pubkey against a paymail address (logging and basic error handling)
func verifyPubKey(verifyURL, alias, domain, pubKey string) (response *paymail.Verification, err error) {
func verifyPubKey(verifyURL, alias, domain, pubKey string) (response *paymail.VerificationResponse, err error) {

// Start the request
displayHeader(chalker.DEFAULT, fmt.Sprintf("Verifing pubkey for %s...", chalk.Cyan.Color(alias+"@"+domain)))
Expand Down Expand Up @@ -723,7 +726,7 @@ func displayHeader(level, text string) {
}

// GetPublicInfo will get all the public info for a given paymail
func (p *PaymailDetails) GetPublicInfo(capabilities *paymail.Capabilities) (err error) {
func (p *PaymailDetails) GetPublicInfo(capabilities *paymail.CapabilitiesResponse) (err error) {

// Requirements
if len(p.Handle) == 0 {
Expand Down
4 changes: 2 additions & 2 deletions cmd/p2p.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,15 @@ Read more at: `+chalk.Cyan.Color("https://docs.moneybutton.com/docs/paymail-07-p
parts := strings.Split(paymailAddress, "@")

// Fire the P2P request
var p2pResponse *paymail.PaymentDestination
var p2pResponse *paymail.PaymentDestinationResponse
if p2pResponse, err = getP2PPaymentDestination(destinationURL, parts[0], domain, satoshis); err != nil {
chalker.Log(chalker.ERROR, fmt.Sprintf("P2P payment destination request failed: %s", err.Error()))
return
}

// Attempt to get a public profile if the capability is found
profileURL := capabilities.GetString(paymail.BRFCPublicProfile, "")
var profile *paymail.PublicProfile
var profile *paymail.PublicProfileResponse
if len(profileURL) > 0 && !skipPublicProfile {
if profile, err = getPublicProfile(profileURL, parts[0], domain, true); err != nil {
chalker.Log(chalker.ERROR, fmt.Sprintf("Get public profile failed: %s", err.Error()))
Expand Down
2 changes: 1 addition & 1 deletion cmd/resolve.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ Read more at: `+chalk.Cyan.Color("http://bsvalias.org/04-01-basic-address-resolu
}

// Get the PKI for the given address
var senderPki *paymail.PKI
var senderPki *paymail.PKIResponse
if senderPki, err = getPki(senderPkiURL, senderAlias, senderDomain, true); err != nil {
chalker.Log(chalker.ERROR, fmt.Sprintf("Find PKI Failed: %s", err.Error()))
return
Expand Down
4 changes: 2 additions & 2 deletions cmd/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ Read more at: `+chalk.Cyan.Color("http://bsvalias.org/index.html")),
}

// Get the capabilities
var capabilities *paymail.Capabilities
var capabilities *paymail.CapabilitiesResponse
if capabilities, err = getCapabilities(domain, false); err != nil {
if strings.Contains(err.Error(), "context deadline exceeded") {
chalker.Log(chalker.WARN, fmt.Sprintf("No capabilities found for: %s", domain))
Expand All @@ -160,7 +160,7 @@ Read more at: `+chalk.Cyan.Color("http://bsvalias.org/index.html")),
if len(paymailAddress) > 0 && len(pkiURL) > 0 {

// Get the PKI for the given address
var pki *paymail.PKI
var pki *paymail.PKIResponse
if pki, err = getPki(pkiURL, alias, domain, false); err != nil {
chalker.Log(chalker.ERROR, fmt.Sprintf("Error: %s", err.Error()))
return
Expand Down
2 changes: 1 addition & 1 deletion cmd/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ Read more at: `+chalk.Cyan.Color("http://bsvalias.org/05-verify-public-key-owner
}

// Fire the verify request
var verify *paymail.Verification
var verify *paymail.VerificationResponse
if verify, err = verifyPubKey(verifyURL, alias, domain, pubKey); err != nil {
chalker.Log(chalker.ERROR, fmt.Sprintf("verify pubkey request failed: %s", err.Error()))
return
Expand Down

0 comments on commit e08e97a

Please sign in to comment.