cryptobill

package module
v0.0.0-...-5d17c74 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 25, 2019 License: MIT Imports: 15 Imported by: 0

README

cryptobill

Retrieves quotes and create transactions for multiple crypto bill services and cryptocurrencies.

Please note that this is under development, and although it works for me, you should use caution.

Currently supports price quoting for:

Only supports creating a transaction with Paid by Coins for BPAY.

Quote Example

This is a real result on 2018-10-26.

It shows the list in order of the apparent markup based on BitcoinAverage prices.

$ quote 1000 AUD --filter=BTC,ETH,BCH

  PBC| BTC| 0.11343| 1039.09807|  3.910%|
  B2B| BTC| 0.11352| 1039.90846|  3.991%|
  PBC| ETH| 3.64804| 1042.86772|  4.287%|
  B2B| ETH| 3.66797| 1048.56729|  4.857%|
  PBC| BCH| 1.66889| 1052.68224|  5.268%|
  B2B| BCH| 1.66889| 1052.68224|  5.268%|
 LROS| BTC| 0.11634| 1065.71874|  6.572%|
 LROS| ETH| 3.74721| 1071.21697|  7.122%|
 LROS| BCH| 1.75148| 1104.77434| 10.477%|

Pay BPAY Example

It will give you a destination address and an amount to pay into, e.g.:

$ cryptobill pay bpay 1000 aud btc pbc 1234 9999888877776666 --auth [email protected]

&cryptobill.TransactionAddResponse{
  ToAddress: "3TxgIzzzzzzzzzyyyyyyyyyyyyyyyxxxxx",
  TotalAmount: 0.1111,
}

How to use

This is a Go app. You need Go installed and in your path.

To run it, you can just use go run:

$ go run cmd/cryptobill/cryptobill.go --help

Usage: cryptobill.exe <command>

Flags:
  --help    Show context-sensitive help.

Commands:
  quote <amount> <fiat>

  pay bpay --auth=STRING <amount> <fiat> <crypto> <service> <code> <account>

  pay eft --auth=STRING <amount> <fiat> <crypto> <service> <bsb> <account-number> <account-name>

Run "cryptobill.exe <command> --help" for more information on a command.
exit status 1

Contributions

Feel free to send in pull requests.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Currencies = map[string]Currency{
	"AUD": Currency("AUD"),

	"BTC":       Currency("BTC"),
	"ETH":       Currency("ETH"),
	"BCH":       Currency("BCH"),
	"LTC":       Currency("LTC"),
	"XRP":       Currency("XRP"),
	"STEEM":     Currency("STEEM"),
	"PIVX":      Currency("PIVX"),
	"ZEC":       Currency("ZEC"),
	"ETC":       Currency("ETC"),
	"XMR":       Currency("XMR"),
	"DASH":      Currency("DASH"),
	"DOGE":      Currency("DOGE"),
	"BTX":       Currency("BTX"),
	"XEM":       Currency("XEM"),
	"SBD":       Currency("SBD"),
	"LIGHTNING": Currency("LIGHTNING"),
	"DCR":       Currency("DCR"),
	"OMG":       Currency("OMG"),
}

Functions

This section is empty.

Types

type Amount

type Amount float64

type BPAY

type BPAY struct {
	Code int `arg`
	// Populated dynamically
	Name    string
	Account string `arg`
}

type Bill

type Bill struct {
	Name string `arg`
	BPAY BPAY   `cmd`
	EFT  EFT    `cmd`
}

type Bills

type Bills map[string]*Bill

type Bit2Bill

type Bit2Bill struct{}

func (*Bit2Bill) Name

func (*Bit2Bill) Name() string

func (*Bit2Bill) PayBPAY

func (bb *Bit2Bill) PayBPAY(cb *CryptoBill, bpay *PayBPAY) (*PayResult, error)

func (*Bit2Bill) PayEFT

func (bb *Bit2Bill) PayEFT(cb *CryptoBill, eft *PayEFT) (*PayResult, error)

func (*Bit2Bill) Quote

func (bb *Bit2Bill) Quote(cb *CryptoBill, info *FiatInfo) ([]QuoteResult, error)

func (*Bit2Bill) ShortName

func (*Bit2Bill) ShortName() string

func (*Bit2Bill) Website

func (*Bit2Bill) Website() string

type Conversion

type Conversion struct {
	Fiat, Crypto Amount
}

type CryptoBill

type CryptoBill struct {
	HttpClient *http.Client
}

func NewCryptoBill

func NewCryptoBill() *CryptoBill

func (*CryptoBill) AddBill

func (cb *CryptoBill) AddBill(entry *Bill) error

func (*CryptoBill) GetBill

func (cb *CryptoBill) GetBill(name string) (*Bill, error)

func (*CryptoBill) ListBills

func (cb *CryptoBill) ListBills() error

func (*CryptoBill) LoadBills

func (cb *CryptoBill) LoadBills() (Bills, error)

func (*CryptoBill) PayBPAY

func (cb *CryptoBill) PayBPAY(bpay *PayBPAY) (*PayResult, error)

func (*CryptoBill) PayEFT

func (cb *CryptoBill) PayEFT(eft *PayEFT) (*PayResult, error)

func (*CryptoBill) Quote

func (cb *CryptoBill) Quote(info *FiatInfo) ([]QuoteResult, error)

func (*CryptoBill) SaveBills

func (cb *CryptoBill) SaveBills(entries Bills) error

type CurrenciesResponse

type CurrenciesResponse struct {
	Message string
	Items   struct {
		CurrencyDetails []CurrencyDetail
	}
}

type Currency

type Currency string

func NewCurrencyFromString

func NewCurrencyFromString(s string) (Currency, error)

type CurrencyDetail

type CurrencyDetail struct {
	// "BTC", etc.
	ShortForm string

	// "BitcoinCash", etc. Used for calling other endpoints.
	Type string

	// An added charge on top of the order book cost.
	TransactionCharge float64
	BrokeragePercent  float64
	GSTPercent        float64
}

type EFT

type EFT struct {
	BSB string `arg`
	// Populated dynamically
	BSBName       string
	AccountNumber string `arg`
	AccountName   string `arg`
	Remitter      string `help:"Shown on the receiving bank statement."`
}

type ExchangeRateResponse

type ExchangeRateResponse struct {
	PrimaryCurrency   string
	SecondaryCurrency string
	Price             float64
	ExchgID           int
	RTXVal            float64
}

type FiatInfo

type FiatInfo struct {
	Amount Amount   `arg help:"Fiat amount"`
	Fiat   Currency `arg help:"Fiat type, e.g. AUD"`
}

type LivingRoom

type LivingRoom struct{}

func (*LivingRoom) Name

func (lros *LivingRoom) Name() string

func (*LivingRoom) PayBPAY

func (lros *LivingRoom) PayBPAY(cb *CryptoBill, bpay *PayBPAY) (*PayResult, error)

func (*LivingRoom) PayEFT

func (lros *LivingRoom) PayEFT(cb *CryptoBill, eft *PayEFT) (*PayResult, error)

func (*LivingRoom) Quote

func (lros *LivingRoom) Quote(cb *CryptoBill, info *FiatInfo) ([]QuoteResult, error)

func (*LivingRoom) ShortName

func (lros *LivingRoom) ShortName() string

func (*LivingRoom) Website

func (lros *LivingRoom) Website() string

type OrderBookResponse

type OrderBookResponse struct {
	HighestBuy float64
}

type PaidByCoins

type PaidByCoins struct {
}

func (*PaidByCoins) Name

func (*PaidByCoins) Name() string

func (*PaidByCoins) PayBPAY

func (pbc *PaidByCoins) PayBPAY(cb *CryptoBill, bpay *PayBPAY) (*PayResult, error)

TODO: Refactor PayBPAY and PayEFT to reuse same code

func (*PaidByCoins) PayEFT

func (pbc *PaidByCoins) PayEFT(cb *CryptoBill, eft *PayEFT) (*PayResult, error)

TODO: Refactor PayBPAY and PayEFT to reuse same code

func (*PaidByCoins) Quote

func (pbc *PaidByCoins) Quote(cb *CryptoBill, info *FiatInfo) ([]QuoteResult, error)

func (*PaidByCoins) ShortName

func (*PaidByCoins) ShortName() string

func (*PaidByCoins) Website

func (*PaidByCoins) Website() string

type Pair

type Pair struct {
	Fiat, Crypto Currency
}

type PayBPAY

type PayBPAY struct {
	PayInfoService
	BPAY
}

type PayEFT

type PayEFT struct {
	PayInfoService
	EFT
}

type PayInfo

type PayInfo struct {
	FiatInfo
	Crypto Currency `arg help:"Cryptocurrency to spend"`
}

type PayInfoService

type PayInfoService struct {
	PayInfo
	Service string `arg help:"Service, e.g. PBC"`

	Auth string `required help:"For now only for your PBC email address."`
}

type PayResult

type PayResult struct {
	Address string
	Amount  Amount
}

type QuoteResponse

type QuoteResponse map[string]float64

type QuoteResult

type QuoteResult struct {
	Service    Service
	Pair       Pair
	Conversion Conversion
}

type Service

type Service interface {
	Name() string
	ShortName() string
	Website() string
	Quote(cb *CryptoBill, info *FiatInfo) ([]QuoteResult, error)
	PayBPAY(cb *CryptoBill, bpay *PayBPAY) (*PayResult, error)
	PayEFT(cb *CryptoBill, eft *PayEFT) (*PayResult, error)
}

func NewBit2Bill

func NewBit2Bill() Service

func NewLivingRoom

func NewLivingRoom() Service

func NewPaidByCoins

func NewPaidByCoins() Service

type TransactionAddRequest

type TransactionAddRequest struct {
	BillerCode int    `json:",omitempty"`
	BillerName string `json:",omitempty"`
	RefCode    string `json:",omitempty"`

	BSB         string `json:",omitempty"`
	BSBName     string `json:",omitempty"`
	AccountNo   string `json:",omitempty"`
	AccountName string `json:",omitempty"`
	Description string `json:",omitempty"`

	EnteredAmount            float64
	CurrencyType             string
	EnteredCurrency          string
	CurrencyExchRate         float64
	TotalAmount              string
	Email                    string
	HasEmail                 bool
	SessionID                string
	AlternateAddress         string
	TransactionServiceAmount int
	RTXVal                   float64
	QuoteExchgID             int
	CurrencyRatePerAUD       int
}

type TransactionAddResponse

type TransactionAddResponse struct {
	Message     string
	ToAddress   string
	TotalAmount float64
}

type VerifyEmailResponse

type VerifyEmailResponse struct {
	Message    string
	IsVerified bool
}

type VerifyPinRequest

type VerifyPinRequest struct {
	Email, Pin string
}

Directories

Path Synopsis
cmd
cryptobill command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL