Skip to content
This repository has been archived by the owner on Sep 12, 2019. It is now read-only.

Commit

Permalink
Merge pull request #113 from stellar/xlm-compliance
Browse files Browse the repository at this point in the history
add compliance support for xlm
  • Loading branch information
bartekn authored Apr 25, 2018
2 parents e6f65f3 + f10b089 commit b4294ac
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,19 @@ func (rh *RequestHandler) HandlerSend(c web.C, w http.ResponseWriter, r *http.Re

mutators := []interface{}{
b.Destination{destinationObject.AccountID},
b.CreditAmount{
}

if request.AssetCode == "" {
mutators = append(mutators, b.NativeAmount{
request.Amount,
})

} else {
mutators = append(mutators, b.CreditAmount{
request.AssetCode,
request.AssetIssuer,
request.Amount,
},
})
}

if payWithMutator != nil {
Expand Down
14 changes: 7 additions & 7 deletions src/github.com/stellar/gateway/protocols/compliance/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"strings"

"github.com/stellar/gateway/protocols"
"github.com/stellar/go/keypair"
proto "github.com/stellar/go/protocols/compliance"
)

Expand All @@ -24,9 +23,9 @@ type SendRequest struct {
// Amount destination should receive
Amount string `name:"amount" required:""`
// Code of the asset destination should receive
AssetCode string `name:"asset_code" required:""`
AssetCode string `name:"asset_code"`
// Issuer of the asset destination should receive
AssetIssuer string `name:"asset_issuer" required:""`
AssetIssuer string `name:"asset_issuer"`
// Only for path_payment
SendMax string `name:"send_max"`
// Only for path_payment
Expand Down Expand Up @@ -74,11 +73,12 @@ func (request *SendRequest) Validate() error {
return protocols.NewInvalidParameterError("destination", request.Destination, "Not a valid stellar address.")
}

_, err = keypair.Parse(request.AssetIssuer)
if !protocols.IsValidAccountID(request.AssetIssuer) {
return protocols.NewInvalidParameterError("asset_issuer", request.AssetIssuer, "Asset issuer must be a public key (starting with `G`).")
}
if request.AssetCode != "" {

if !protocols.IsValidAccountID(request.AssetIssuer) {
return protocols.NewInvalidParameterError("asset_issuer", request.AssetIssuer, "Asset issuer must be a public key (starting with `G`).")
}
}
return nil
}

Expand Down

0 comments on commit b4294ac

Please sign in to comment.