Browse Source

Add TxDetail for stellar transactions

main
Sam 6 years ago
parent
commit
399e0b4e94
  1. 7
      chatIn.go
  2. 44
      wallet.go

7
chatIn.go

@ -121,13 +121,10 @@ func getNewMessages(k Keybase, c chan<- ChatIn, filterString string) {
// Runner() runs keybase chat api-listen, and passes incoming messages to the message handler func // Runner() runs keybase chat api-listen, and passes incoming messages to the message handler func
func (k Keybase) Runner(handler func(ChatIn), channelFilters ...Channel) { func (k Keybase) Runner(handler func(ChatIn), channelFilters ...Channel) {
c := make(chan ChatIn, 10) c := make(chan ChatIn, 50)
defer close(c) defer close(c)
go getNewMessages(k, c, createFilterString(channelFilters...)) go getNewMessages(k, c, createFilterString(channelFilters...))
for { for {
chat, ok := <-c go handler(<-c)
if ok {
go handler(chat)
}
} }
} }

44
wallet.go

@ -8,6 +8,13 @@ import (
// ---- Struct for sending to API // ---- Struct for sending to API
type walletOut struct { type walletOut struct {
Method string `json:"method"` Method string `json:"method"`
Params walletOutParams `json:"params"`
}
type walletOutOptions struct {
Txid string `json:"txid"`
}
type walletOutParams struct {
Options walletOutOptions `json:"options"`
} }
// ---- // ----
@ -25,6 +32,15 @@ type asset struct {
Desc string `json:"desc"` Desc string `json:"desc"`
InfoURL string `json:"infoUrl"` InfoURL string `json:"infoUrl"`
} }
type sourceAsset struct {
Type string `json:"type"`
Code string `json:"code"`
Issuer string `json:"issuer"`
VerifiedDomain string `json:"verifiedDomain"`
IssuerName string `json:"issuerName"`
Desc string `json:"desc"`
InfoURL string `json:"infoUrl"`
}
type balance struct { type balance struct {
Asset asset `json:"asset"` Asset asset `json:"asset"`
Amount string `json:"amount"` Amount string `json:"amount"`
@ -41,6 +57,24 @@ type WalletResult struct {
Balance []balance `json:"balance"` Balance []balance `json:"balance"`
ExchangeRate exchangeRate `json:"exchangeRate"` ExchangeRate exchangeRate `json:"exchangeRate"`
AccountMode int `json:"accountMode"` AccountMode int `json:"accountMode"`
TxID string `json:"txID"`
Time int64 `json:"time"`
Status string `json:"status"`
StatusDetail string `json:"statusDetail"`
Amount string `json:"amount"`
Asset asset `json:"asset"`
DisplayAmount string `json:"displayAmount"`
DisplayCurrency string `json:"displayCurrency"`
SourceAmountMax string `json:"sourceAmountMax"`
SourceAmountActual string `json:"sourceAmountActual"`
SourceAsset sourceAsset `json:"sourceAsset"`
FromStellar string `json:"fromStellar"`
ToStellar string `json:"toStellar"`
FromUsername string `json:"fromUsername"`
ToUsername string `json:"toUsername"`
Note string `json:"note"`
NoteErr string `json:"noteErr"`
Unread bool `json:"unread"`
} }
// ---- // ----
@ -69,3 +103,13 @@ func (k Keybase) Balances() ([]WalletResult, error) {
r, err := walletAPIOut(k.Path, m) r, err := walletAPIOut(k.Path, m)
return r.Result, err return r.Result, err
} }
// TxDetail() returns details of a stellar transaction
func (k Keybase) TxDetail(txid string) (WalletResult, error) {
m := walletOut{}
m.Method = "details"
m.Params.Options.Txid = txid
r, err := walletAPIOut(k.Path, m)
return r.Result[0], err
}

Loading…
Cancel
Save