Documentation ¶
Index ¶
- Constants
- Variables
- func AddUint64(ns ...uint64) (sum uint64, overflow bool, err error)
- func CreateBuckets(update func(fn func(*bolt.Tx) error) error, buckets ...[]byte) error
- func DecodeResponse(rsp *http.Response, successStatus int, data any, allowEmptyResponse bool) error
- func EncodeHex(value []byte) string
- func EnsureSubBucket(tx *bolt.Tx, parentBucket []byte, bucket []byte, allowAbsent bool) (*bolt.Bucket, error)
- func ExtractOffsetMarker(rsp *http.Response) (string, error)
- func GetURL(url url.URL, pathElements ...string) *url.URL
- func ParseHex[T types.SystemID | types.UnitID | TxHash | []byte](value string, required bool) (T, error)
- func ParseMaxResponseItems(s string, maxValue int) (int, error)
- func SetLinkHeader(u *url.URL, w http.ResponseWriter, next string)
- func SetPaginationParams(u *url.URL, offset string, limit int)
- func SetQueryParam(u *url.URL, key, val string)
- func WriteBillsFile(path string, res []*BillProof) error
- type Bill
- type BillProof
- type Bills
- type Builder
- type EmptyResponse
- type ErrorResponse
- type InfoResponse
- type Predicate
- type Proof
- type PubKey
- type PubKeyHash
- type ResponseWriter
- func (rw *ResponseWriter) ErrorResponse(w http.ResponseWriter, code int, err error)
- func (rw *ResponseWriter) InvalidParamResponse(w http.ResponseWriter, name string, err error)
- func (rw *ResponseWriter) WriteCborResponse(w http.ResponseWriter, data any)
- func (rw *ResponseWriter) WriteErrorResponse(w http.ResponseWriter, err error)
- func (rw *ResponseWriter) WriteResponse(w http.ResponseWriter, data any)
- type SendOpts
- type Transactions
- type TxHash
- type TxHistoryRecord
- type TxHistoryRecordKind
- type TxHistoryRecordState
- type TxProof
- type Wallet
Constants ¶
const ( ContentType = "Content-Type" ApplicationJson = "application/json" ApplicationCbor = "application/cbor" UserAgent = "User-Agent" QueryParamOffsetKey = "offsetKey" QueryParamLimit = "limit" HeaderLink = "Link" HeaderLinkValueFormat = `<%s>; rel="next"` )
Variables ¶
var ( ErrTxProofNil = errors.New("tx proof is nil") ErrInvalidValue = errors.New("invalid value") ErrMissingDCTargetUnitID = errors.New("dc target unit id is missing") ErrInvalidTxHash = errors.New("bill txHash is not equal to actual transaction hash") ErrInvalidTxType = errors.New("invalid tx type") )
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") )
var ErrRecordNotFound = errors.New("not found")
var SwaggerFiles embed.FS
Functions ¶
func AddUint64 ¶ added in v0.2.0
AddUint64 adds a list of uint64s together, returning an error and a boolean indicator if the sum overflows uint64.
func CreateBuckets ¶ added in v0.2.0
func DecodeResponse ¶ added in v0.2.1
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 EnsureSubBucket ¶ added in v0.2.0
func ExtractOffsetMarker ¶ added in v0.2.0
func ParseMaxResponseItems ¶ added in v0.2.0
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 ¶ added in v0.2.0
func SetLinkHeader(u *url.URL, w http.ResponseWriter, next string)
func SetPaginationParams ¶ added in v0.2.0
func SetQueryParam ¶ added in v0.2.0
func WriteBillsFile ¶ added in v0.2.0
Types ¶
type Bill ¶ added in v0.2.0
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"` // fcb specific fields // LastAddFCTxHash last add fee credit tx hash LastAddFCTxHash []byte `json:"lastAddFcTxHash,omitempty"` }
TODO used to be protobuf defined Bill struct used as import/export/download/upload unified schema across applications possibly can be removed as import/export/download/upoad feature was dropped
func (*Bill) GetLastAddFCTxHash ¶ added in v0.2.0
type Bills ¶ added in v0.2.0
type Bills struct {
Bills []*Bill `json:"bills,omitempty"`
}
func ReadBillsFile ¶ added in v0.2.0
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
func (*Builder) SetABClientConf ¶
func (b *Builder) SetABClientConf(abcConf client.AlphabillClientConfig) *Builder
type EmptyResponse ¶ added in v0.2.0
type EmptyResponse struct{}
type ErrorResponse ¶ added in v0.2.0
type ErrorResponse struct {
Message string `json:"message"`
}
type InfoResponse ¶ added in v0.2.1
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 Proof ¶ added in v0.1.4
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 ¶ added in v0.2.0
func (*Proof) ToGenericProof ¶ added in v0.2.0
type PubKey ¶ added in v0.1.4
type PubKey []byte
func DecodePubKeyHex ¶ added in v0.2.0
func (PubKey) Hash ¶ added in v0.2.0
func (pk PubKey) Hash() PubKeyHash
type PubKeyHash ¶ added in v0.2.0
type PubKeyHash []byte
type ResponseWriter ¶ added in v0.2.0
type ResponseWriter struct {
LogErr func(a ...any)
}
func (*ResponseWriter) ErrorResponse ¶ added in v0.2.0
func (rw *ResponseWriter) ErrorResponse(w http.ResponseWriter, code int, err error)
func (*ResponseWriter) InvalidParamResponse ¶ added in v0.2.0
func (rw *ResponseWriter) InvalidParamResponse(w http.ResponseWriter, name string, err error)
func (*ResponseWriter) WriteCborResponse ¶ added in v0.2.0
func (rw *ResponseWriter) WriteCborResponse(w http.ResponseWriter, data any)
func (*ResponseWriter) WriteErrorResponse ¶ added in v0.2.0
func (rw *ResponseWriter) WriteErrorResponse(w http.ResponseWriter, err error)
func (*ResponseWriter) WriteResponse ¶ added in v0.2.0
func (rw *ResponseWriter) WriteResponse(w http.ResponseWriter, data any)
type SendOpts ¶ added in v0.1.1
type SendOpts struct { // RetryOnFullTxBuffer retries to send transaction when tx buffer is full RetryOnFullTxBuffer bool }
type Transactions ¶ added in v0.2.0
type Transactions struct { Transactions []*types.TransactionOrder // contains filtered or unexported fields }
type TxHistoryRecord ¶ added in v0.2.0
type TxHistoryRecord struct { UnitID types.UnitID TxHash TxHash CounterParty []byte Timeout uint64 State TxHistoryRecordState Kind TxHistoryRecordKind // contains filtered or unexported fields }
type TxHistoryRecordKind ¶ added in v0.2.0
type TxHistoryRecordKind byte
const ( OUTGOING TxHistoryRecordKind = iota INCOMING )
type TxHistoryRecordState ¶ added in v0.2.0
type TxHistoryRecordState byte
const ( UNCONFIRMED TxHistoryRecordState = iota CONFIRMED FAILED )
type TxProof ¶ added in v0.2.0
TxProof type alias for block.TxProof, can be removed once block package is moved out of internal
type Wallet ¶
Shutdown needs to be called to release resources used by wallet.
func (*Wallet) GetRoundNumber ¶ added in v0.2.0
GetRoundNumber queries the node for latest round number
func (*Wallet) SendTransaction ¶
func (w *Wallet) SendTransaction(ctx context.Context, tx *types.TransactionOrder, opts *SendOpts) error
SendTransaction broadcasts transaction to configured node. Returns nil if transaction was successfully accepted by node, otherwise returns error.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package log implements a logger interface that is used for logging inside Alphabill Wallet SDK.
|
Package log implements a logger interface that is used for logging inside Alphabill Wallet SDK. |