rest

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2017 License: Apache-2.0 Imports: 11 Imported by: 0

README

basecoin-server

Proxy server

This package exposes access to key management i.e

  • creating
  • listing
  • updating
  • deleting

The HTTP handlers can be embedded in a larger server that does things like signing transactions and posting them to a Tendermint chain (which requires domain-knowledge of the transaction types and is out of scope of this generic app).

Key Management

We expose a couple of methods for safely managing your keychain. If you are embedding this in a larger server, you will typically want to mount all these paths /keys.

HTTP Method Route Description
POST / Requires a name and passphrase to create a brand new key
GET / Retrieves the list of all available key names, along with their public key and address
GET /{name} Updates the passphrase for the given key. It requires you to correctly provide the current passphrase, as well as a new one.
DELETE /{name} Permanently delete this private key. It requires you to correctly provide the current passphrase.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultKeysManager

func DefaultKeysManager() keys.Manager

func PostTx

func PostTx(tx sdk.Tx) (*ctypes.ResultBroadcastTxCommit, error)

PostTx is same as a tx

func RegisterPostTx

func RegisterPostTx(r *mux.Router) error

RegisterPostTx is a mux.Router handler that exposes POST method access to post a transaction to the blockchain.

func RegisterSignTx

func RegisterSignTx(r *mux.Router) error

RegisterSignTx is a mux.Router handler that exposes POST method access to sign a transaction.

func SignTx

func SignTx(name, pass string, tx sdk.Tx) error

SignTx will modify the tx in-place, adding a signature if possible

Types

type CreateKeyRequest

type CreateKeyRequest struct {
	Name       string `json:"name,omitempty" validate:"required,min=3,printascii"`
	Passphrase string `json:"password,omitempty" validate:"required,min=10"`

	// Algo is the requested algorithm to create the key
	Algo string `json:"algo,omitempty"`
}

type CreateKeyResponse

type CreateKeyResponse struct {
	Key  keys.Info `json:"key,omitempty"`
	Seed string    `json:"seed_phrase,omitempty"`
}

type DeleteKeyRequest

type DeleteKeyRequest struct {
	Name       string `json:"name,omitempty" validate:"required,min=3,printascii"`
	Passphrase string `json:"password,omitempty" validate:"required,min=10"`
}

type Keys

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

func New

func New(manager keys.Manager, algo string) *Keys

func NewDefaultKeysManager

func NewDefaultKeysManager(algo string) *Keys

func (*Keys) DeleteKey

func (k *Keys) DeleteKey(w http.ResponseWriter, r *http.Request)

func (*Keys) GenerateKey

func (k *Keys) GenerateKey(w http.ResponseWriter, r *http.Request)

func (*Keys) GetKey

func (k *Keys) GetKey(w http.ResponseWriter, r *http.Request)

func (*Keys) ListKeys

func (k *Keys) ListKeys(w http.ResponseWriter, r *http.Request)

func (*Keys) RegisterAllCRUD

func (k *Keys) RegisterAllCRUD(r *mux.Router) error

RegisterAllCRUD is a convenience method to register all CRUD for keys to allow access by methods and routes: POST: /keys GET: /keys GET: /keys/{name} POST, PUT: /keys/{name} DELETE: /keys/{name}

func (*Keys) UpdateKey

func (k *Keys) UpdateKey(w http.ResponseWriter, r *http.Request)

type SendInput

type SendInput struct {
	Fees     *coin.Coin `json:"fees"`
	Multi    bool       `json:"multi,omitempty"`
	Sequence uint32     `json:"sequence"`

	To     *sdk.Actor `json:"to"`
	From   *sdk.Actor `json:"from"`
	Amount coin.Coins `json:"amount"`
}

SendInput is the request to send an amount from one actor to another. Note: Not using the `validator:""` tags here because SendInput has many fields so it would be nice to figure out all the invalid inputs and report them back to the caller, in one shot.

type SignRequest

type SignRequest struct {
	Name     string `json:"name,omitempty" validate:"required,min=3,printascii"`
	Password string `json:"password,omitempty" validate:"required,min=10"`

	Tx sdk.Tx `json:"tx" validate:"required"`
}

type UpdateKeyRequest

type UpdateKeyRequest struct {
	Name    string `json:"name,omitempty" validate:"required,min=3,printascii"`
	OldPass string `json:"password,omitempty" validate:"required,min=10"`
	NewPass string `json:"new_passphrase,omitempty" validate:"required,min=10"`
}

Jump to

Keyboard shortcuts

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