cryptonym

package module
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2021 License: MIT Imports: 55 Imported by: 0

README

Cryptonym

This is a utility for testing the FIO Protocol

This is intended for advanced users, such as developers and block-producers. Using cryptonym as a general wallet is not advised. It is provided with no warranty, it is assumed that the user understands what they are doing and assumes all liability.

History

This is a tool built during the development of the FIO chain by Dapix. Originally it was developed for security testing of contracts. Most of the attack capabilities have been removed and the FIO Foundation has graciously allowed me to release the project for the FIO community.

Features

  • connects to a server, and pulls a list of all accounts with an ABI
  • provides a list of these on the left side of the window
  • selecting an action will retrieve the abi for the account
  • presents an editor
  • in many cases has sensible default values
  • submission as a msig-proposal
  • a viewer pops up to see both the request and response.

Other useful abilities:

  • retrieves a list of available api endpoints, and presents a form for sending requests directly
  • a key generator, with vanity key generation
  • some limited msig functionality, for now only a form for update-auth to create and ability to propose. viewing, rejecting, approving and cancel abilities are planned
  • account lookup, by pub key, fio address, fio domain, private key, or account
  • table browser for viewing data
  • abi viewer
  • bp voting tool
  • ability to view pending FIO requests, reject, respond, or request funds. (Handling sent requests is not yet available.)

Advanced-mode offers additional functionality when sending actions.

Using the advanced features will not normally be useful for sending transactions and is disabled by default.

  • The editor has additional options
    • changing abi field types
    • using various fuzzers to generate data
    • performs as little error checking as possible (within limitations of being able to serialize)
    • includes many features to modify the request
  • requests can be sent in batches/loops. WARNING: this can quickly deplete funds.
Action Editor

editor

API

API requests

FIO Requests

respond to request

Voting

vote for producers

Note on building ...

  • Requires Go v1.14 or higher.
  • This is built with the Fyne windowing toolkit, which requires several libraries to be installed:

To build and install, clone this repo, and run ...

cryptonym$ go install ./...

And the binary cryptonym-wallet will be placed inside $GOPATH/bin (most likely ~/go/bin)

Documentation

Index

Constants

View Source
const (
	AppTitle = "Cryptonym"
)

Variables

View Source
var (
	WinSettings = getSavedWindowSettings()
	W           = WinSettings.W
	H           = WinSettings.H

	ActionW           = 220 // width of action buttons on left side
	WidthReduce       = 26  // trim down size of right window this much to account for padding
	App               = app.NewWithID("explorer")
	Win               = App.NewWindow(AppTitle)
	BalanceChan       = make(chan bool)
	BalanceLabel      = widget.NewLabel("")
	DefaultFioAddress = ""
	TableIndex        = NewTableIndex()

	EndPoints = SupportedApis{Apis: []string{"/v1/chain/push_transaction"}}

	RepaintChan             = make(chan bool)
	PasswordVisible         bool
	SettingsLoaded          = make(chan *FioSettings)
	Settings                = DefaultSettings()
	TxResultBalanceChan     = make(chan string)
	TxResultBalanceChanOpen = false

	Connected bool
	Uri       = ""
	Api       = &fio.API{}
	Opts      = &fio.TxOptions{}
	Account   = func() *fio.Account {
		a, _ := fio.NewAccountFromWif("5JBbUG5SDpLWxvBKihMeXLENinUzdNKNeozLas23Mj6ZNhz3hLS")
		return a
	}()
)
View Source
var (
	MsigRefreshRequests = make(chan bool)
	MsigLastTab         = 0
	MsigLoaded          bool
)
View Source
var (
	FormState = NewAbi(0)
)
View Source
var MainnetApi = []string{

	"https://fio.eosdac.io",
	"https://fio.eosphere.io",
	"https://fio.eosrio.io",
	"https://fio.eosusa.news",
	"https://api.fio.alohaeos.com",
	"https://fio.genereos.io",
	"https://fio.greymass.com",
	"https://api.fio.eosdetroit.io",
	"https://fio.zenblocks.io",
	"https://api.fio.currencyhub.io",
	"https://fio.cryptolions.io",
	"https://fio.eosdublin.io",
	"https://api.fio.greeneosio.com",
	"https://api.fiosweden.org",
	"https://fio.eu.eosamsterdam.net",
	"https://fioapi.ledgerwise.io",
	"https://fio.acherontrading.com",
}
View Source
var PrivilegedActions = map[string]bool{
	"eosio::addaction":           true,
	"eosio::addlocked":           true,
	"eosio::burnaction":          true,
	"eosio::canceldelay":         true,
	"eosio::crautoproxy":         true,
	"eosio::incram":              true,
	"eosio::inhibitunlck":        true,
	"eosio::init":                true,
	"eosio::setpriv":             true,
	"eosio::newaccount":          true,
	"eosio::onblock":             true,
	"eosio::onerror":             true,
	"eosio::resetclaim":          true,
	"eosio::remaction":           true,
	"eosio::rmvproducer":         true,
	"eosio::setabi":              true,
	"eosio::setautoproxy":        true,
	"eosio::setcode":             true,
	"eosio::setparams":           true,
	"eosio::unlocktokens":        true,
	"eosio::updatepower":         true,
	"eosio::updlbpclaim":         true,
	"eosio::updlocked":           true,
	"eosio::updtrevision":        true,
	"eosio.wrap::execute":        true,
	"fio.address::bind2eosio":    true,
	"fio.address::decrcounter":   true,
	"fio.token::create":          true,
	"fio.token::issue":           true,
	"fio.token::mintfio":         true,
	"fio.token::retire":          true,
	"fio.token::transfer":        true,
	"fio.tpid::rewardspaid":      true,
	"fio.tpid::updatebounty":     true,
	"fio.tpid::updatetpid":       true,
	"fio.treasury::startclock":   true,
	"fio.treasury::bppoolupdate": true,
	"fio.treasury::bprewdupdate": true,
	"fio.treasury::fdtnrwdupdat": true,
}
View Source
var ProducerActions = map[string]bool{
	"fio.treasury::bpclaim":    true,
	"fio.address::burnexpired": true,
	"fio.fee::bundlevote":      true,
	"fio.fee::bytemandfee":     true,
	"fio.fee::createfee":       true,
	"fio.fee::mandatoryfee":    true,
	"fio.fee::setfeemult":      true,
	"fio.fee::setfeevote":      true,
	"fio.fee::updatefees":      true,
	"eosio::regproducer":       true,
	"eosio::unregprod":         true,
}
View Source
var RefreshQr = make(chan bool)
View Source
var RefreshRequestsChan = make(chan bool)
View Source
var RefreshVotesChan = make(chan bool)
View Source
var (
	Results = make([]TxResult, 0)
)

Functions

func CustomTheme

func CustomTheme() fyne.Theme

func DarkerTheme

func DarkerTheme() *prettyfyne.PrettyTheme

func DefaultJsonFor

func DefaultJsonFor(endpoint string) string

func EncryptSettings

func EncryptSettings(set *FioSettings, salt []byte, password string) (encrypted []byte, err error)

func ExGreyTheme

func ExGreyTheme() prettyfyne.PrettyTheme

func ExLightTheme

func ExLightTheme() prettyfyne.PrettyTheme

func FioDomainNameHash

func FioDomainNameHash(s string) string

func FioLogoCanvas

func FioLogoCanvas() fyne.CanvasObject

func FlipEndian

func FlipEndian(orig []byte) []byte

func GetAbiForm

func GetAbiForm(action string, account *fio.Account, api *fio.API, opts *fio.TxOptions) (fyne.CanvasObject, error)

GetAbiForm returns the fyne form for editing the request, it also handles state tracking via the FormState which is later used to build the transaction.

func GetAbiViewer

func GetAbiViewer(w int, h int, api *fio.API) (tab *widget.Box, ok bool)

func GetChains

func GetChains() []string

func GetCurrentVotes

func GetCurrentVotes(actor string, api *fio.API) (votes string)

func GetLocation

func GetLocation(i int) string

func GetPending

func GetPending(refreshChan chan bool, account *fio.Account, api *fio.API) (form fyne.CanvasObject, err error)

func GetTableBrowser

func GetTableBrowser(w int, h int, api *fio.API) (tab *widget.Box, ok bool)

func GetTokens

func GetTokens(s string) []string

func InitServerInfo

func InitServerInfo(info chan ServerInfo, reconnected chan bool) fyne.CanvasObject

func KeyGenTab

func KeyGenTab() *widget.Box

func MkDir

func MkDir() (ok bool, err error)

func MsigRequestsContent

func MsigRequestsContent(api *fio.API, opts *fio.TxOptions, account *fio.Account) *widget.TabItem

func NewAccountSearchTab

func NewAccountSearchTab(box chan fyne.Container, account *fio.Account)

func NewApiRequestTab

func NewApiRequestTab(container chan fyne.Container)

func NewRequest

func NewRequest(account *fio.Account, api *fio.API) fyne.CanvasObject

func PctHeight

func PctHeight() int

func PromptForPassword

func PromptForPassword()

func ProposalRows

func ProposalRows(offset int, limit int, api *fio.API, opts *fio.TxOptions, account *fio.Account) *widget.Box

func QueryTable

func QueryTable(offset uint32, max uint32, contract string, table string, api *fio.API) (out *string, query string, more bool)

func QueryTableAdvanced

func QueryTableAdvanced(max uint32, scope string, contract string, table string, index string, keyType string, lower string, upper string, transform string, reverse bool, api *fio.API) (out *string, query string, more bool)

func RWidth

func RWidth() int

func RequestContent

func RequestContent(reqContent chan fyne.CanvasObject, refresh chan bool)

func ResetTxResult

func ResetTxResult()

func RespondRequest

func RespondRequest(req *fio.FundsReqTableResp, decrypted *fio.ObtRequestContent, closed chan interface{}, account *fio.Account, api *fio.API) fyne.CanvasObject

func SaveEncryptedSettings

func SaveEncryptedSettings(password string, settings *FioSettings) (ok bool, err error)

func SettingsWindow

func SettingsWindow()

func ShowFullRequest

func ShowFullRequest(b []byte, win fyne.Window)

func ShowFullResponse

func ShowFullResponse(b []byte, win fyne.Window)

func TxResultsWindow

func TxResultsWindow(win *txResultOpts, api *fio.API, opts *fio.TxOptions, account *fio.Account)

func UpdateAuthContent

func UpdateAuthContent(container chan fyne.Container, api *fio.API, opts *fio.TxOptions, account *fio.Account)

func ViewRequest

func ViewRequest(id uint64, closed chan interface{}, refresh chan bool, account *fio.Account, api *fio.API) fyne.CanvasObject

func VoteContent

func VoteContent(content chan fyne.CanvasObject, refresh chan bool)

Types

type Abi

type Abi struct {
	Rows     []AbiFormItem
	Action   string
	Contract string
	// contains filtered or unexported fields
}

func NewAbi

func NewAbi(length int) *Abi

func (*Abi) AddNewRowButton

func (abi *Abi) AddNewRowButton(name *widget.Entry, account *fio.Account, form *widget.Form) *widget.Button

func (*Abi) AppendRow

func (abi *Abi) AppendRow(myName string, account *fio.Account, form *widget.Form)

func (*Abi) DeriveJsonAbi

func (abi *Abi) DeriveJsonAbi() (abiJson []byte)

func (*Abi) GeneratePayloads

func (abi *Abi) GeneratePayloads(key *fio.Account) error

TODO: rethink this, instead of calling this every request, maybe pass pointers to functions?

func (*Abi) PackAndSign

func (abi *Abi) PackAndSign(api *fio.API, opts *fio.TxOptions, account *fio.Account, msig bool) (json.RawMessage, *eos.PackedTransaction, error)

func (*Abi) Update

func (abi *Abi) Update(index *int, abiForm AbiFormItem)

func (*Abi) UpdateInput

func (abi *Abi) UpdateInput(name string, t *widget.Entry)

func (*Abi) UpdateLen

func (abi *Abi) UpdateLen(name string, t *widget.Select)

func (*Abi) UpdateSendAs

func (abi *Abi) UpdateSendAs(name string, t *widget.Select)

func (*Abi) UpdateType

func (abi *Abi) UpdateType(name string, t *widget.Select)

func (*Abi) UpdateValue

func (abi *Abi) UpdateValue(index *int, value interface{}, isSlice bool, noJsonEscape bool)

func (*Abi) UpdateValueWithConvert

func (abi *Abi) UpdateValueWithConvert(index *int, value interface{}, isSlice bool, abiType string, noJsonEscape bool)

func (*Abi) UpdateVariation

func (abi *Abi) UpdateVariation(name string, t *widget.Select)

type AbiFormItem

type AbiFormItem struct {
	Contract   string
	Action     string
	Order      int
	Name       *string
	Type       *widget.Select
	SendAs     *widget.Select
	Variation  *widget.Select
	Len        *widget.Select
	Input      *widget.Entry
	Value      *interface{}
	IsSlice    bool
	SliceValue []*interface{}
	// contains filtered or unexported fields
}

type AccountInformation

type AccountInformation struct {
	*sync.Mutex

	Actor      string   `json:"actor"`
	PubKey     string   `json:"pub_key"`
	PrivKey    string   `json:"priv_key"`
	Balance    int64    `json:"balance"`
	BundleCred int      `json:"bundle_cred"`
	MsigOwners []string `json:"msig_owners"`
	MsigThresh uint32   `json:"msig_thresh"`
	RamUsed    int64    `json:"ram_used"`

	FioNames []FioAddressStruct `json:"fio_names"`

	FioDomains []FioDomainStruct `json:"fio_domains"`
	PublicKeys []AddressesList   `json:"public_keys"`

	Producer *ProducerInfo `json:"producer"`
	// contains filtered or unexported fields
}

func AccountSearch

func AccountSearch(searchFor string, value string) (as *AccountInformation, err error)

type AddressesList

type AddressesList struct {
	TokenCode     string `json:"token_code"`
	ChainCode     string `json:"chain_code"`
	PublicAddress string `json:"public_address"`
}

type ClickEntry

type ClickEntry struct {
	widget.Entry
	Button *widget.Button
}

func NewClickEntry

func NewClickEntry(b *widget.Button) *ClickEntry

func (*ClickEntry) KeyDown

func (e *ClickEntry) KeyDown(key *fyne.KeyEvent)

type EnterEntry

type EnterEntry struct {
	widget.Entry
	Action func()
}

func NewEnterEntry

func NewEnterEntry(f func()) *EnterEntry

func (*EnterEntry) KeyDown

func (e *EnterEntry) KeyDown(key *fyne.KeyEvent)

type EnterSelectEntry

type EnterSelectEntry struct {
	widget.SelectEntry
	Action func()
}

func NewEnterSelectEntry

func NewEnterSelectEntry(entries []string, f func()) *EnterSelectEntry

func (*EnterSelectEntry) KeyDown

func (e *EnterSelectEntry) KeyDown(key *fyne.KeyEvent)

type FioActions

type FioActions struct {
	sync.RWMutex
	Index   []string
	Actions map[string][]string
}

func GetAccountSummary

func GetAccountSummary(api *fio.API) (*FioActions, error)

type FioAddressStruct

type FioAddressStruct struct {
	Id           int             `json:"id"`
	Name         string          `json:"name"`
	NameHash     string          `json:"namehash"`
	Domain       string          `json:"domain"`
	DomainHash   string          `json:"domainhash"`
	Expiration   int64           `json:"expiration"`
	OwnerAccount string          `json:"owner_account"`
	Addresses    []AddressesList `json:"addresses"`
	BundleCount  uint64          `json:"bundleeligiblecountdown"`
}

type FioCustomTheme

type FioCustomTheme struct {
}

FioCustomTheme is a simple demonstration of a bespoke theme loaded by a Fyne app.

func (FioCustomTheme) BackgroundColor

func (FioCustomTheme) BackgroundColor() color.Color

func (FioCustomTheme) ButtonColor

func (FioCustomTheme) ButtonColor() color.Color

func (FioCustomTheme) DisabledButtonColor

func (FioCustomTheme) DisabledButtonColor() color.Color

func (FioCustomTheme) DisabledIconColor

func (FioCustomTheme) DisabledIconColor() color.Color

func (FioCustomTheme) DisabledTextColor

func (FioCustomTheme) DisabledTextColor() color.Color

func (FioCustomTheme) FocusColor

func (FioCustomTheme) FocusColor() color.Color

func (FioCustomTheme) HoverColor

func (FioCustomTheme) HoverColor() color.Color

func (FioCustomTheme) HyperlinkColor

func (FioCustomTheme) HyperlinkColor() color.Color

func (FioCustomTheme) IconColor

func (FioCustomTheme) IconColor() color.Color

func (FioCustomTheme) IconInlineSize

func (FioCustomTheme) IconInlineSize() int

func (FioCustomTheme) Padding

func (FioCustomTheme) Padding() int

func (FioCustomTheme) PlaceHolderColor

func (FioCustomTheme) PlaceHolderColor() color.Color

func (FioCustomTheme) PrimaryColor

func (FioCustomTheme) PrimaryColor() color.Color

func (FioCustomTheme) ScrollBarColor

func (FioCustomTheme) ScrollBarColor() color.Color

func (FioCustomTheme) ScrollBarSize

func (FioCustomTheme) ScrollBarSize() int

func (FioCustomTheme) ScrollBarSmallSize

func (FioCustomTheme) ScrollBarSmallSize() int

func (FioCustomTheme) ShadowColor

func (FioCustomTheme) ShadowColor() color.Color

func (FioCustomTheme) TextBoldFont

func (FioCustomTheme) TextBoldFont() fyne.Resource

func (FioCustomTheme) TextBoldItalicFont

func (FioCustomTheme) TextBoldItalicFont() fyne.Resource

func (FioCustomTheme) TextColor

func (FioCustomTheme) TextColor() color.Color

func (FioCustomTheme) TextFont

func (FioCustomTheme) TextFont() fyne.Resource

func (FioCustomTheme) TextItalicFont

func (FioCustomTheme) TextItalicFont() fyne.Resource

func (FioCustomTheme) TextMonospaceFont

func (FioCustomTheme) TextMonospaceFont() fyne.Resource

func (FioCustomTheme) TextSize

func (FioCustomTheme) TextSize() int

type FioDomainStruct

type FioDomainStruct struct {
	Name       string          `json:"name"`
	IsPublic   uint8           `json:"is_public"`
	Expiration int64           `json:"expiration"`
	Account    eos.AccountName `json:"account"`
}

type FioSettings

type FioSettings struct {
	Server string `json:"server"`
	Proxy  string `json:"proxy"`

	DefaultKey     string `json:"default_key"`
	DefaultKeyDesc string `json:"default_key_desc"`
	FavKey2        string `json:"fav_key_2"`
	FavKey2Desc    string `json:"fav_key_2_desc"`
	FavKey3        string `json:"fav_key_3"`
	FavKey3Desc    string `json:"fav_key_3_desc"`
	FavKey4        string `json:"fav_key_4"`
	FavKey4Desc    string `json:"fav_key_4_desc"`

	MsigAccount string `json:"msig_account"`
	Tpid        string `json:"tpid"`

	AdvancedFeatures bool `json:"advanced_features"`

	// future:
	KeosdAddress  string `json:"keosd_address"`
	KeosdPassword string `json:"keosd_password"`
}

func DecryptSettings

func DecryptSettings(encrypted []byte, password string) (settings *FioSettings, err error)

func DefaultSettings

func DefaultSettings() *FioSettings

func LoadEncryptedSettings

func LoadEncryptedSettings(password string) (ok bool, fileLength int, settings *FioSettings, err error)

will never return a nil settings

type ProducerInfo

type ProducerInfo struct {
	Owner             string    `json:"owner"`
	FioAddress        string    `json:"fio_address"`
	TotalVotes        float64   `json:"total_votes"`
	ProducerPublicKey string    `json:"producer_public_key"`
	IsActive          bool      `json:"is_active"`
	Url               string    `json:"url"`
	UnpaidBlocks      int       `json:"unpaid_blocks"`
	LastClaimTime     time.Time `json:"last_claim_time"`
	Location          int       `json:"location"`
}

type ServerInfo

type ServerInfo struct {
	Info *eos.InfoResp
	Uri  string
}

type SupportedApis

type SupportedApis struct {
	Apis []string `json:"apis"`
}

func (*SupportedApis) Update

func (apiList *SupportedApis) Update(url string, filter bool) error

type TableBrowserIndex

type TableBrowserIndex struct {
	// contains filtered or unexported fields
}

func NewTableIndex

func NewTableIndex() *TableBrowserIndex

func (*TableBrowserIndex) Add

func (tb *TableBrowserIndex) Add(contract string, tables []string) (ok bool)

func (*TableBrowserIndex) Get

func (tb *TableBrowserIndex) Get(contract string) (tables []string)

func (*TableBrowserIndex) IsCreated

func (tb *TableBrowserIndex) IsCreated() bool

func (*TableBrowserIndex) List

func (tb *TableBrowserIndex) List() []string

func (*TableBrowserIndex) SetCreated

func (tb *TableBrowserIndex) SetCreated(b bool)

type TxResult

type TxResult struct {
	FullResp []byte
	FullReq  []byte
	Resp     []byte
	Req      []byte
	Success  bool
	Index    int
	Summary  string
}

type TxSummary

type TxSummary struct {
	TransactionId string `json:"transaction_id" yaml:"Transaction Id"`
	Processed     struct {
		BlockNum  uint32 `json:"block_num" yaml:"Block Number"`
		BlockTime string `json:"block_time" yaml:"Block Time"`
		Receipt   struct {
			Status string `json:"status" yaml:"Status"`
		} `json:"receipt" yaml:"Receipt,omitempty"`
	} `json:"processed" yaml:"Processed,omitempty"`
	ErrorCode  interface{} `json:"error_code" yaml:"Error,omitempty"`                             // is this a string, int, varies on context?
	TotalBytes int         `json:"total_bytes,omitempty" yaml:"TX Size of All Actions,omitempty"` // this is field we calculate later
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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