Move appropriate methods to wallet interface
This commit is contained in:
6
types.go
6
types.go
@ -566,8 +566,12 @@ type Wallet struct {
|
||||
}
|
||||
|
||||
type wallet interface {
|
||||
CancelRequest(requestID string) error
|
||||
RequestPayment(user string, amount float64, memo ...string)
|
||||
Send(recipient string, amount string, currency string, message ...string) (WalletAPI, error)
|
||||
SendXLM(recipient string, amount string, message ...string) (WalletAPI, error)
|
||||
StellarAddress(user string) (string, error)
|
||||
TxDetail(txid string) (WalletAPI, error)
|
||||
}
|
||||
|
||||
type keybase interface {
|
||||
@ -580,8 +584,6 @@ type keybase interface {
|
||||
loggedIn() bool
|
||||
username() string
|
||||
version() string
|
||||
RequestPayment(user string, amount float64, memo ...string)
|
||||
CancelRequest(requestID string) error
|
||||
}
|
||||
|
||||
type status struct {
|
||||
|
||||
14
wallet.go
14
wallet.go
@ -25,26 +25,26 @@ func walletAPIOut(k *Keybase, w WalletAPI) (WalletAPI, error) {
|
||||
}
|
||||
|
||||
// TxDetail returns details of a stellar transaction
|
||||
func (k *Keybase) TxDetail(txid string) (WalletAPI, error) {
|
||||
func (w Wallet) TxDetail(txid string) (WalletAPI, error) {
|
||||
m := WalletAPI{
|
||||
Params: &wParams{},
|
||||
}
|
||||
m.Method = "details"
|
||||
m.Params.Options.Txid = txid
|
||||
|
||||
r, err := walletAPIOut(k, m)
|
||||
r, err := walletAPIOut(w.keybase, m)
|
||||
return r, err
|
||||
}
|
||||
|
||||
// StellarAddress returns the primary stellar address of a given user
|
||||
func (k *Keybase) StellarAddress(user string) (string, error) {
|
||||
func (w Wallet) StellarAddress(user string) (string, error) {
|
||||
m := WalletAPI{
|
||||
Params: &wParams{},
|
||||
}
|
||||
m.Method = "lookup"
|
||||
m.Params.Options.Name = user
|
||||
|
||||
r, err := walletAPIOut(k, m)
|
||||
r, err := walletAPIOut(w.keybase, m)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@ -52,7 +52,8 @@ func (k *Keybase) StellarAddress(user string) (string, error) {
|
||||
}
|
||||
|
||||
// RequestPayment sends a request for payment to a user
|
||||
func (k *Keybase) RequestPayment(user string, amount float64, memo ...string) error {
|
||||
func (w Wallet) RequestPayment(user string, amount float64, memo ...string) error {
|
||||
k := w.keybase
|
||||
if len(memo) > 0 {
|
||||
_, err := k.Exec("wallet", "request", user, fmt.Sprintf("%f", amount), "-m", memo[0])
|
||||
return err
|
||||
@ -62,7 +63,8 @@ func (k *Keybase) RequestPayment(user string, amount float64, memo ...string) er
|
||||
}
|
||||
|
||||
// CancelRequest cancels a request for payment previously sent to a user
|
||||
func (k *Keybase) CancelRequest(requestID string) error {
|
||||
func (w Wallet) CancelRequest(requestID string) error {
|
||||
k := w.keybase
|
||||
_, err := k.Exec("wallet", "cancel-request", requestID)
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user