|
|
@ -4,6 +4,7 @@ import ( |
|
|
|
"encoding/json" |
|
|
|
"encoding/json" |
|
|
|
"errors" |
|
|
|
"errors" |
|
|
|
"fmt" |
|
|
|
"fmt" |
|
|
|
|
|
|
|
"strings" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
// walletAPIOut sends JSON requests to the wallet API and returns its response.
|
|
|
|
// walletAPIOut sends JSON requests to the wallet API and returns its response.
|
|
|
@ -65,3 +66,29 @@ func (k *Keybase) CancelRequest(requestID string) error { |
|
|
|
_, err := k.Exec("wallet", "cancel-request", requestID) |
|
|
|
_, err := k.Exec("wallet", "cancel-request", requestID) |
|
|
|
return err |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Send sends the specified amount of the specified currency to a user
|
|
|
|
|
|
|
|
func (w Wallet) Send(recipient string, amount string, currency string, message ...string) (WalletAPI, error) { |
|
|
|
|
|
|
|
m := WalletAPI{ |
|
|
|
|
|
|
|
Params: &wParams{}, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
m.Method = "send" |
|
|
|
|
|
|
|
m.Params.Options.Recipient = recipient |
|
|
|
|
|
|
|
m.Params.Options.Amount = amount |
|
|
|
|
|
|
|
m.Params.Options.Currency = currency |
|
|
|
|
|
|
|
if len(message) > 0 { |
|
|
|
|
|
|
|
m.Params.Options.Message = strings.Join(message, " ") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
r, err := walletAPIOut(w.keybase, m) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
return WalletAPI{}, err |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return r, err |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// SendXLM sends the specified amount of XLM to a user
|
|
|
|
|
|
|
|
func (w Wallet) SendXLM(recipient string, amount string, message ...string) (WalletAPI, error) { |
|
|
|
|
|
|
|
result, err := w.Send(recipient, amount, "XLM", message...) |
|
|
|
|
|
|
|
return result, err |
|
|
|
|
|
|
|
} |
|
|
|