wallet

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContentType     = "Content-Type"
	ApplicationJson = "application/json"
	ApplicationCbor = "application/cbor"
	UserAgent       = "User-Agent"

	QueryParamOffsetKey   = "offsetKey"
	QueryParamLimit       = "limit"
	HeaderLink            = "Link"
	HeaderLinkValueFormat = `<%s>; rel="next"`
)
View Source
const (
	LockReasonAddFees = 1 + iota
	LockReasonReclaimFees
	LockReasonCollectDust
	LockReasonManual
)

Variables

View Source
var (
	// ErrInvalidRequest is returned when backend responded with 4nn status code, use errors.Is to check for it.
	ErrInvalidRequest = errors.New("invalid request")

	// ErrNotFound is returned when backend responded with 404 status code, use errors.Is to check for it.
	ErrNotFound = errors.New("not found")
)
View Source
var ErrRecordNotFound = errors.New("not found")
View Source
var SwaggerFiles embed.FS

Functions

func CreateBuckets

func CreateBuckets(update func(fn func(*bolt.Tx) error) error, buckets ...[]byte) error

func DecodeResponse

func DecodeResponse(rsp *http.Response, successStatus int, data any, allowEmptyResponse bool) error

DecodeResponse when "rsp" StatusCode is equal to "successStatus" response body is decoded into "data". In case of some other response status body is expected to contain error response json struct.

func EncodeHex

func EncodeHex(value []byte) string

func EnsureSubBucket

func EnsureSubBucket(tx *bolt.Tx, parentBucket []byte, bucket []byte, allowAbsent bool) (*bolt.Bucket, error)

func ExtractOffsetMarker

func ExtractOffsetMarker(rsp *http.Response) (string, error)

func GetURL

func GetURL(url url.URL, pathElements ...string) *url.URL

func ParseHex

func ParseHex[T types.UnitID | TxHash | []byte](value string, required bool) (T, error)

func ParseMaxResponseItems

func ParseMaxResponseItems(s string, maxValue int) (int, error)

parseMaxResponseItems parses input "s" as integer. When empty string or int over "maxValue" is sent in "maxValue" is returned. In case of invalid int or value smaller than 1 error is returned.

func SetLinkHeader

func SetLinkHeader(u *url.URL, w http.ResponseWriter, next string)

func SetPaginationParams

func SetPaginationParams(u *url.URL, offset string, limit int)

func SetQueryParam

func SetQueryParam(u *url.URL, key, val string)

Types

type Bill

type Bill struct {
	Id                   []byte     `json:"id,omitempty"`
	Value                uint64     `json:"value,omitempty,string"`
	TxHash               []byte     `json:"txHash,omitempty"`
	DCTargetUnitID       []byte     `json:"targetUnitId,omitempty"`
	DCTargetUnitBacklink []byte     `json:"targetUnitBacklink,omitempty"`
	Locked               LockReason `json:"locked,omitempty,string"`
}

func (*Bill) GetID

func (x *Bill) GetID() []byte

func (*Bill) GetTxHash

func (x *Bill) GetTxHash() []byte

func (*Bill) GetValue

func (x *Bill) GetValue() uint64

func (*Bill) IsLocked

func (x *Bill) IsLocked() bool

type Bills

type Bills struct {
	Bills []*Bill `json:"bills,omitempty"`
}

type EmptyResponse

type EmptyResponse struct{}

type ErrorResponse

type ErrorResponse struct {
	Message string `json:"message"`
}

type InfoResponse

type InfoResponse struct {
	SystemID string `json:"system_id"` // hex encoded system identifier (without 0x prefix)
	Name     string `json:"name"`      // one of [money backend | tokens backend]
}

InfoResponse should be compatible with Node /info request

type LockReason

type LockReason uint64

func (LockReason) String

func (r LockReason) String() string

type Predicate

type Predicate []byte

type Proof

type Proof struct {
	TxRecord *types.TransactionRecord `json:"txRecord"`
	TxProof  *types.TxProof           `json:"txProof"`
	// contains filtered or unexported fields
}

Proof wrapper struct around TxRecord and TxProof

func NewTxProof

func NewTxProof(txIdx int, b *types.Block, hashAlgorithm crypto.Hash) (*Proof, error)

func (*Proof) GetActualFee

func (p *Proof) GetActualFee() uint64

type PubKey

type PubKey []byte

func DecodePubKeyHex

func DecodePubKeyHex(pubKey string) (PubKey, error)

func ParsePubKey

func ParsePubKey(pubkey string, required bool) (PubKey, error)

func (PubKey) Hash

func (pk PubKey) Hash() PubKeyHash

type PubKeyHash

type PubKeyHash []byte

type ResponseWriter

type ResponseWriter struct {
	LogErr func(err error)
}

func (*ResponseWriter) ErrorResponse

func (rw *ResponseWriter) ErrorResponse(w http.ResponseWriter, code int, err error)

func (*ResponseWriter) InvalidParamResponse

func (rw *ResponseWriter) InvalidParamResponse(w http.ResponseWriter, name string, err error)

func (*ResponseWriter) WriteCborResponse

func (rw *ResponseWriter) WriteCborResponse(w http.ResponseWriter, data any)

func (*ResponseWriter) WriteErrorResponse

func (rw *ResponseWriter) WriteErrorResponse(w http.ResponseWriter, err error)

func (*ResponseWriter) WriteResponse

func (rw *ResponseWriter) WriteResponse(w http.ResponseWriter, data any)

type RoundNumber

type RoundNumber struct {
	RoundNumber            uint64 `json:"roundNumber,string"`            // last known round number
	LastIndexedRoundNumber uint64 `json:"lastIndexedRoundNumber,string"` // last indexed round number
}

type Transactions

type Transactions struct {
	Transactions []*types.TransactionOrder
	// contains filtered or unexported fields
}

type TxHash

type TxHash []byte

type TxHistoryRecord

type TxHistoryRecord struct {
	UnitID       types.UnitID
	TxHash       TxHash
	CounterParty []byte
	Timeout      uint64
	State        TxHistoryRecordState
	Kind         TxHistoryRecordKind
	// contains filtered or unexported fields
}

type TxHistoryRecordKind

type TxHistoryRecordKind byte
const (
	OUTGOING TxHistoryRecordKind = iota
	INCOMING
)

type TxHistoryRecordState

type TxHistoryRecordState byte
const (
	UNCONFIRMED TxHistoryRecordState = iota
	CONFIRMED
	FAILED
)

type TxProof

type TxProof = types.TxProof

TxProof type alias for block.TxProof, can be removed once block package is moved out of internal

Jump to

Keyboard shortcuts

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