counterpartyapi

package
v0.0.0-...-485d38d Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2017 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Counterparty_DefaultDustSize uint64 = 5430
View Source
var Counterparty_DefaultTestingTxFee uint64 = 1500 // in satoshis
View Source
var Counterparty_DefaultTxFee uint64 = 10000 // in satoshis

Functions

func CalculateFeeAmount

func CalculateFeeAmount(c context.Context, amount uint64) (uint64, string, error)

Returns the total BTC that is required for the given number of transactions

func CalculateNumberOfTransactions

func CalculateNumberOfTransactions(c context.Context, amount uint64) (uint64, error)

Returns the number of transactions that can be performed with the given amount of BTC If the env value is not found in the context, calculations are defaulted to production

func CreateDividend

func CreateDividend(c context.Context, sourceAddress string, asset string, dividendAsset string, quantityPerUnit uint64, pubKeyHexString string) (string, int64, error)

Generates unsigned hex encoded transaction to pay a dividend on an asset on Counterparty

func CreateIssuance

func CreateIssuance(c context.Context, sourceAddress string, asset string, assetDescription string, quantity uint64, divisible bool, pubKeyHexString string) (string, int64, error)

func CreateNumericIssuance

func CreateNumericIssuance(c context.Context, sourceAddress string, asset string, quantity uint64, divisible bool, pubKeyHexString string) (string, string, int64, error)

Automatically generates a numeric asset name and generates unsigned hex encoded transaction to issue an asset on Counterparty Returns: randomAssetName that was generated hex string encoded transaction errorCode error

func CreateSend

func CreateSend(c context.Context, sourceAddress string, destinationAddress string, asset string, quantity uint64, pubKeyHexString string) (string, int64, error)

Generates a hex string serialed tx which contains the bitcoin transaction to send an asset from sourceAddress to destinationAddress Not exposed to the public

func GenerateRandomAssetName

func GenerateRandomAssetName(c context.Context) (string, int64, error)

func Init

func Init()

Initialises global variables and database connection for all handlers

func InitWithConfigPath

func InitWithConfigPath(configFilePath string)

func SignRawTransaction

func SignRawTransaction(c context.Context, passphrase string, rawTxHexString string) (string, error)

When given the 12 word passphrase: 1) Parses the raw TX to find the address being sent from 2) Derives the parent key and the child key for the address found in step 1) 3) Signs all the TX inputs

Assumptions 1) This is a Counterparty transaction so all inputs need to be signed with the same pubkeyhash

Types

type ApiResult

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

Create wrapper for http response and error

type Balance

type Balance struct {
	Quantity uint64 `json:"quantity"`
	Asset    string `json:"asset"`
	Address  string `json:"address"`
}

func GetBalancesByAddress

func GetBalancesByAddress(c context.Context, address string) ([]Balance, int64, error)

func GetBalancesByAddressDB

func GetBalancesByAddressDB(c context.Context, address string) ([]Balance, int64, error)

func GetBalancesByAsset

func GetBalancesByAsset(c context.Context, asset string) ([]Balance, int64, error)

func GetBalancesByAssetDB

func GetBalancesByAssetDB(c context.Context, asset string) ([]Balance, int64, error)

type Issuance

type Issuance struct {
	TxIndex     uint64 `json:"tx_index"`
	TxHash      string `json:"tx_hash"`
	BlockIndex  uint64 `json:"block_index"`
	Asset       string `json:"asset"`
	Quantity    uint64 `json:"quantity"`
	Divisible   uint64 `json:"divisible"`
	Source      string `json:"source"`
	Issuer      string `json:"issuer"`
	Transfer    uint64 `json:"transfer"`
	Description string `json:"description"`
	FeePaid     uint64 `json:"fee_paid"`
	Locked      uint64 `json:"locked"`
	Status      string `json:"status"`
}

func GetIssuances

func GetIssuances(c context.Context, asset string) ([]Issuance, int64, error)

func GetIssuancesDB

func GetIssuancesDB(c context.Context, asset string) ([]Issuance, int64, error)

type LastBlock

type LastBlock struct {
	BlockIndex uint64 `json:"block_index"`
	BlockHash  string `json:"block_hash"`
}

type ResultCreateDividend_Counterparty

type ResultCreateDividend_Counterparty struct {
	Jsonrpc string `json:"jsonrpc"`
	Id      uint32 `json:"id"`
	Result  string `json:"result"`
}

type ResultCreateIssuance_Counterparty

type ResultCreateIssuance_Counterparty struct {
	Jsonrpc string `json:"jsonrpc"`
	Id      uint32 `json:"id"`
	Result  string `json:"result"`
}

type ResultCreateSend_Counterparty

type ResultCreateSend_Counterparty struct {
	Jsonrpc string `json:"jsonrpc"`
	Id      uint32 `json:"id"`
	Result  string `json:"result"`
}

type ResultError_Counterparty

type ResultError_Counterparty struct {
	Jsonrpc string `json:"jsonrpc"`
	Id      uint32 `json:"id"`
	Error   string `json:"error"`
}

type ResultGetBalances

type ResultGetBalances struct {
	Jsonrpc string    `json:"jsonrpc"`
	Id      uint32    `json:"id"`
	Result  []Balance `json:"result"`
}

type ResultGetIssuances

type ResultGetIssuances struct {
	Jsonrpc string     `json:"jsonrpc"`
	Id      uint32     `json:"id"`
	Result  []Issuance `json:"result"`
}

type ResultGetRunningInfo

type ResultGetRunningInfo struct {
	Jsonrpc string      `json:"jsonrpc"`
	Id      uint32      `json:"id"`
	Result  RunningInfo `json:"result"`
}

type ResultGetSends

type ResultGetSends struct {
	TxIndex     uint64 `json:"tx_index"`
	TxHash      string `json:"tx_hash"`
	BlockIndex  uint64 `json:"block_index"`
	Source      string `json:"source"`
	Destination string `json:"destination"`
	Asset       string `json:"asset"`
	Quantity    uint64 `json:"quantity"`
	Validity    uint64 `json:"validity"`
	Status      string `json:"status"`
}

tx_index (integer): The transaction index tx_hash (string): The transaction hash block_index (integer): The block index (block number in the block chain) source (string): The source address of the send destination (string): The destination address of the send asset (string): The assets being sent quantity (integer): The quantities of the specified asset sent validity (string): Set to “valid” if a valid send. Any other setting signifies an invalid/improper send

func GetSendsByAddress

func GetSendsByAddress(c context.Context, address string) ([]ResultGetSends, int64, error)

func GetSendsByAddressDB

func GetSendsByAddressDB(c context.Context, address string) ([]ResultGetSends, int64, error)

type RunningInfo

type RunningInfo struct {
	DbCaughtUp           bool      `json:"db_caught_up"`
	BitCoinBlockCount    uint64    `json:"bitcoin_block_count"`
	CounterpartydVersion string    `json:"counterpartyd_version"`
	LastMessageIndex     uint64    `json:"last_message_index"`
	RunningTestnet       bool      `json:"running_testnet"`
	LastBlock            LastBlock `json:"last_block"`
}

func GetRunningInfo

func GetRunningInfo(c context.Context) (RunningInfo, int64, error)

For internal use only - don't expose to customers

Jump to

Keyboard shortcuts

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