bitmark

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2020 License: ISC Imports: 15 Imported by: 4

Documentation

Overview

SPDX-License-Identifier: ISC Copyright (c) 2014-2020 Bitmark Inc. Use of this source code is governed by an ISC license that can be found in the LICENSE file.

SPDX-License-Identifier: ISC Copyright (c) 2014-2020 Bitmark Inc. Use of this source code is governed by an ISC license that can be found in the LICENSE file.

SPDX-License-Identifier: ISC Copyright (c) 2014-2020 Bitmark Inc. Use of this source code is governed by an ISC license that can be found in the LICENSE file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateShares

func CreateShares(params *ShareParams) (string, string, error)

func GrantShare

func GrantShare(params *ShareGrantingParams) (string, error)

func Issue

func Issue(params *IssuanceParams) ([]string, error)

func Offer

func Offer(params *OfferParams) error

func ReplyShareOffer

func ReplyShareOffer(params *GrantResponseParams) (string, error)

func Respond

func Respond(params *ResponseParams) (string, error)

func Transfer

func Transfer(params *TransferParams) (string, error)

Types

type Bitmark

type Bitmark struct {
	ID          string         `json:"id"`
	AssetID     string         `json:"asset_id"`
	LatestTxID  string         `json:"head_id"`
	Issuer      string         `json:"issuer"`
	Owner       string         `json:"owner"`
	Status      string         `json:"status"`
	Offer       *TransferOffer `json:"offer"`
	BlockNumber int            `json:"block_number"`
	Edition     int            `json:"edition"`
	Offset      int            `json:"offset"`
	CreatedAt   time.Time      `json:"created_at"`
	ConfirmedAt time.Time      `json:"confirmed_at"`
}

func Get

func Get(bitmarkID string) (*Bitmark, error)

func GetWithAsset

func GetWithAsset(bitmarkID string) (*Bitmark, *asset.Asset, error)

func List

func List(builder *QueryParamsBuilder) ([]*Bitmark, []*asset.Asset, error)

type CountersignedGrantRequest

type CountersignedGrantRequest struct {
	ShareID          string `json:"shareID" pack:"hex32"`
	Quantity         uint64 `json:"quantity" pack:"uint64"`
	Owner            string `json:"owner" pack:"account"`
	Recipient        string `json:"recipient" pack:"account"`
	BeforeBlock      uint64 `json:"beforeBlock" pack:"uint64"`
	Signature        string `json:"signature" pack:"hex64"`
	Countersignature string `json:"countersignature"`
}

Copy of bitmark share granting structure with counter signature

type CountersignedSwapRequest

type CountersignedSwapRequest struct {
	ShareIDOne       string `json:"shareIDOne" pack:"hex32"`   // share = issue id
	QuantityOne      uint64 `json:"quantityOne" pack:"uint64"` // shares to transfer > 0
	OwnerOne         string `json:"ownerOne" pack:"account"`   // base58
	ShareIDTwo       string `json:"shareIDTwo" pack:"hex32"`   // share = issue id
	QuantityTwo      uint64 `json:"quantityTwo" pack:"uint64"` // shares to transfer > 0
	OwnerTwo         string `json:"ownerTwo" pack:"account"`   // base58
	BeforeBlock      uint64 `json:"beforeBlock" pack:"uint64"` // expires when chain height > before block
	Signature        string `json:"signature" pack:"hex64"`
	Countersignature string `json:"countersignature"`
}

Copy of bitmark share swap structure with counter signature

type CountersignedTransferRequest

type CountersignedTransferRequest struct {
	Link             string   `json:"link" pack:"hex32"`
	Escrow           *payment `json:"-" pack:"payment"` // optional escrow payment address
	Owner            string   `json:"owner" pack:"account"`
	Signature        string   `json:"signature" pack:"hex64"`
	Countersignature string   `json:"countersignature"`
}

type GrantRequest

type GrantRequest struct {
	ShareID     string `json:"shareID" pack:"hex32"`
	Quantity    uint64 `json:"quantity" pack:"uint64"`
	Owner       string `json:"owner" pack:"account"`
	Recipient   string `json:"recipient" pack:"account"`
	BeforeBlock uint64 `json:"beforeBlock" pack:"uint64"`
	Signature   string `json:"signature"`
}

Copy of bitmark share granting structure

type GrantResponseParams

type GrantResponseParams struct {
	ID               string              `json:"id"`
	Action           OfferResponseAction `json:"action"`
	Countersignature string              `json:"countersignature"`
	// contains filtered or unexported fields
}

GrantResponseParams is the parameter for respond a share granting request

func NewGrantResponseParams

func NewGrantResponseParams(id string, grant *GrantRequest, action OfferResponseAction) *GrantResponseParams

NewGrantResponseParams returns GrantResponseParams

func (*GrantResponseParams) Sign

func (g *GrantResponseParams) Sign(receiver account.Account) error

Sign will generate the signature for a granting responding request

type IssuanceParams

type IssuanceParams struct {
	Issuances []*IssueRequest `json:"issues"`
}

func NewIssuanceParams

func NewIssuanceParams(assetID string, quantity int) (*IssuanceParams, error)

func (*IssuanceParams) Sign

func (p *IssuanceParams) Sign(issuer account.Account) error

Sign all issunaces in a batch

type IssueRequest

type IssueRequest struct {
	AssetID   string `json:"asset_id" pack:"hex64"`
	Owner     string `json:"owner" pack:"account"`
	Nonce     uint64 `json:"nonce" pack:"uint64"`
	Signature string `json:"signature"`
}

type OfferParams

type OfferParams struct {
	Offer struct {
		Transfer  *TransferRequest       `json:"record"`
		ExtraInfo map[string]interface{} `json:"extra_info"`
	} `json:"offer"`
}

func NewOfferParams

func NewOfferParams(receiver string, info map[string]interface{}) (*OfferParams, error)

func (*OfferParams) FromBitmark

func (o *OfferParams) FromBitmark(bitmarkID string) error

FromBitmark sets link asynchronously

func (*OfferParams) FromLatestTx

func (o *OfferParams) FromLatestTx(txID string)

FromLatestTx sets link synchronously

func (*OfferParams) Sign

func (o *OfferParams) Sign(sender account.Account) error

type OfferResponseAction

type OfferResponseAction string
const Accept OfferResponseAction = "accept"
const Cancel OfferResponseAction = "cancel"
const Reject OfferResponseAction = "reject"

type QuantityOptions

type QuantityOptions struct {
	Nonces   []uint64
	Quantity int
}

type QueryParamsBuilder

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

func NewQueryParamsBuilder

func NewQueryParamsBuilder() *QueryParamsBuilder

func (*QueryParamsBuilder) At

func (*QueryParamsBuilder) BitmarkIDs

func (ub *QueryParamsBuilder) BitmarkIDs(bitmarkIDs []string) *QueryParamsBuilder

func (*QueryParamsBuilder) Build

func (ub *QueryParamsBuilder) Build() (string, error)

func (*QueryParamsBuilder) IssuedBy

func (ub *QueryParamsBuilder) IssuedBy(issuer string) *QueryParamsBuilder

func (*QueryParamsBuilder) Limit

func (ub *QueryParamsBuilder) Limit(size int) *QueryParamsBuilder

func (*QueryParamsBuilder) LoadAsset

func (ub *QueryParamsBuilder) LoadAsset(load bool) *QueryParamsBuilder

func (*QueryParamsBuilder) OfferFrom

func (ub *QueryParamsBuilder) OfferFrom(sender string) *QueryParamsBuilder

func (*QueryParamsBuilder) OfferTo

func (ub *QueryParamsBuilder) OfferTo(receiver string) *QueryParamsBuilder

func (*QueryParamsBuilder) OwnedBy

func (ub *QueryParamsBuilder) OwnedBy(owner string) *QueryParamsBuilder

func (*QueryParamsBuilder) OwnedByWithTransient

func (ub *QueryParamsBuilder) OwnedByWithTransient(owner string) *QueryParamsBuilder

func (*QueryParamsBuilder) Pending

func (ub *QueryParamsBuilder) Pending(pending bool) *QueryParamsBuilder

func (*QueryParamsBuilder) ReferencedAsset

func (ub *QueryParamsBuilder) ReferencedAsset(assetID string) *QueryParamsBuilder

func (*QueryParamsBuilder) To

type ResponseParams

type ResponseParams struct {
	ID               string              `json:"id"`
	Action           OfferResponseAction `json:"action"`
	Countersignature string              `json:"countersignature"`
	// contains filtered or unexported fields
}

func NewTransferResponseParams

func NewTransferResponseParams(bitmark *Bitmark, action OfferResponseAction) *ResponseParams

func (*ResponseParams) Sign

func (r *ResponseParams) Sign(acct account.Account) error

type Share

type Share struct {
	ID        string `json:"share_id"`
	Owner     string `json:"owner"`
	Balance   uint64 `json:"balance"`
	Available uint64 `json:"available"`
}

func GetShareBalance

func GetShareBalance(shareID, owner string) (*Share, error)

type ShareGrantingParams

type ShareGrantingParams struct {
	Grant     *GrantRequest          `json:"record"`
	ExtraInfo map[string]interface{} `json:"extra_info"`
}

ShareGrantingParams is the parameter for granting shares to other accounts via core api

func NewShareGrantingParams

func NewShareGrantingParams(shareID string, receiver string, quantity uint64, extraInfo map[string]interface{}) *ShareGrantingParams

NewShareGrantingParams returns ShareGrantingParams

func (*ShareGrantingParams) BeforeBlock

func (s *ShareGrantingParams) BeforeBlock(blockNumber uint64)

BeforeBlock will assign a block number which is the deadline of this request

func (*ShareGrantingParams) Sign

func (s *ShareGrantingParams) Sign(granter account.Account) error

Sign will generate the signature for a granting request

type ShareOffer

type ShareOffer struct {
	ID        string          `json:"id"`
	ShareID   string          `json:"share_id"`
	From      string          `json:"from"`
	To        string          `json:"to"`
	Record    GrantRequest    `json:"record"`
	ExtraInfo json.RawMessage `json:"extra_info"`
	CreatedAt time.Time       `json:"created_at"`
}

func ListShareOffers

func ListShareOffers(from, to string) ([]*ShareOffer, error)

type ShareParams

type ShareParams struct {
	Share *ShareRequest `json:"share"`
}

ShareParams is the parameter for creating shares via core api

func NewShareParams

func NewShareParams(quantity uint64) *ShareParams

NewShareParams returns ShareParams

func (*ShareParams) FromBitmark

func (s *ShareParams) FromBitmark(bitmarkID string) error

FromBitmark will set the latest transaction for a target bitmark

func (*ShareParams) Sign

func (s *ShareParams) Sign(creator account.Account) error

Sign will generate the signature for a share request

type ShareRequest

type ShareRequest struct {
	Link      string `json:"link" pack:"hex32"`
	Quantity  uint64 `json:"quantity" pack:"uint64"`
	Signature string `json:"signature"`
}

Copy of bitmark share structure

type ShareSwapParams

type ShareSwapParams struct {
	Swap *SwapRequest `json:"swap"`
}

ShareSwapParams is the parameter for swaping shares between two accounts via core api

func NewShareSwapParams

func NewShareSwapParams(beforeBlock uint64) *ShareSwapParams

NewShareSwapParams returns ShareSwapParams

func (*ShareSwapParams) FromShare

func (p *ShareSwapParams) FromShare(shareID, owner string, quantity uint64) *ShareSwapParams

FromShare will assign the first share for swaping

func (*ShareSwapParams) Sign

func (p *ShareSwapParams) Sign(requester account.Account) error

Sign will generate the signature for a swaping request

func (*ShareSwapParams) ToShare

func (p *ShareSwapParams) ToShare(shareID, owner string, quantity uint64) *ShareSwapParams

ToShare will assign the second share for swaping

type SwapRequest

type SwapRequest struct {
	ShareIDOne  string `json:"shareIDOne" pack:"hex32"`   // share = issue id
	QuantityOne uint64 `json:"quantityOne" pack:"uint64"` // shares to transfer > 0
	OwnerOne    string `json:"ownerOne" pack:"account"`   // base58
	ShareIDTwo  string `json:"shareIDTwo" pack:"hex32"`   // share = issue id
	QuantityTwo uint64 `json:"quantityTwo" pack:"uint64"` // shares to transfer > 0
	OwnerTwo    string `json:"ownerTwo" pack:"account"`   // base58
	BeforeBlock uint64 `json:"beforeBlock" pack:"uint64"` // expires when chain height > before block
	Signature   string `json:"signature"`                 // hex
}

Copy of bitmark share swap structure

type SwapResponseParams

type SwapResponseParams struct {
	ID               string              `json:"id"`
	Action           OfferResponseAction `json:"action"`
	Countersignature string              `json:"countersignature"`
	// contains filtered or unexported fields
}

ShareSwapParams is the parameter for responding swaping shares between two accounts via core api

func NewSwapResponseParams

func NewSwapResponseParams(swap *SwapRequest, action OfferResponseAction) *SwapResponseParams

NewSwapResponseParams returns SwapResponseParams

func (*SwapResponseParams) Sign

func (s *SwapResponseParams) Sign(receiver account.Account) error

Sign will generate the signature for a swaping responding request

type TransferOffer

type TransferOffer struct {
	ID        string                        `json:"id"`
	From      string                        `json:"from"`
	To        string                        `json:"to"`
	Record    *CountersignedTransferRequest `json:"record"`
	ExtraInfo map[string]string             `json:"extra_info"`
	CreatedAt time.Time                     `json:"created_at"`
}

type TransferParams

type TransferParams struct {
	Transfer *TransferRequest `json:"transfer"`
}

func NewTransferParams

func NewTransferParams(receiver string) (*TransferParams, error)

func (*TransferParams) FromBitmark

func (t *TransferParams) FromBitmark(bitmarkID string) error

FromBitmark sets link asynchronously

func (*TransferParams) FromLatestTx

func (t *TransferParams) FromLatestTx(txID string)

FromLatestTx sets link synchronously

func (*TransferParams) Sign

func (t *TransferParams) Sign(sender account.Account) error

type TransferRequest

type TransferRequest struct {
	Link      string   `json:"link" pack:"hex32"`
	Escrow    *payment `json:"-" pack:"payment"` // optional escrow payment address
	Owner     string   `json:"owner" pack:"account"`
	Signature string   `json:"signature"`
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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