rest

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2017 License: Apache-2.0 Imports: 8 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

This section is empty.

Types

type RequestCreate added in v0.8.0

type RequestCreate 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 RequestDelete added in v0.8.0

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

type RequestRecover added in v0.8.0

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

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

type RequestSign added in v0.8.0

type RequestSign 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 RequestUpdate added in v0.8.0

type RequestUpdate 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"`
}

type ResponseCreate added in v0.8.0

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

type ResponseRecover added in v0.8.0

type ResponseRecover struct {
	Key keys.Info `json:"key,omitempty"`
}

type ServiceKeys added in v0.8.0

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

ServiceKeys exposes a REST API service for managing keys and signing transactions

func NewServiceKeys added in v0.8.0

func NewServiceKeys(manager keys.Manager) *ServiceKeys

New returns a new instance of the keys service

func (*ServiceKeys) Create added in v0.8.0

func (s *ServiceKeys) Create(w http.ResponseWriter, r *http.Request)

func (*ServiceKeys) Delete added in v0.8.0

func (s *ServiceKeys) Delete(w http.ResponseWriter, r *http.Request)

func (*ServiceKeys) Get added in v0.8.0

func (s *ServiceKeys) Get(w http.ResponseWriter, r *http.Request)

func (*ServiceKeys) List added in v0.8.0

func (s *ServiceKeys) List(w http.ResponseWriter, r *http.Request)

func (*ServiceKeys) Recover added in v0.8.0

func (s *ServiceKeys) Recover(w http.ResponseWriter, r *http.Request)

func (*ServiceKeys) RegisterCRUD added in v0.8.0

func (s *ServiceKeys) RegisterCRUD(r *mux.Router) error

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

func (*ServiceKeys) RegisterSignTx added in v0.8.0

func (s *ServiceKeys) RegisterSignTx(r *mux.Router) error

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

func (*ServiceKeys) SignTx added in v0.8.0

func (s *ServiceKeys) SignTx(w http.ResponseWriter, r *http.Request)

func (*ServiceKeys) Update added in v0.8.0

func (s *ServiceKeys) Update(w http.ResponseWriter, r *http.Request)

type ServiceTxs added in v0.8.0

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

ServiceTxs exposes a REST API service for sendings txs. It wraps a Tendermint RPC client.

func NewServiceTxs added in v0.8.0

func NewServiceTxs(c rpcclient.Client) *ServiceTxs

func (*ServiceTxs) PostTx added in v0.8.0

func (s *ServiceTxs) PostTx(w http.ResponseWriter, r *http.Request)

func (*ServiceTxs) RegisterPostTx added in v0.8.0

func (s *ServiceTxs) RegisterPostTx(r *mux.Router) error

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

Jump to

Keyboard shortcuts

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