Documentation
¶
Index ¶
- Variables
- func DecodePublicKey(pubKey string) (*secp256k1.PublicKey, error)
- func GetPublicKeyString(pubKey *secp256k1.PublicKey) *string
- func GphBase58CheckDecode(input string) ([]byte, [1]byte, error)
- func GphBase58Encode(input []byte, version [1]byte) string
- func HashTx(tx []byte) []byte
- func HashTxForSig(tx []byte, chainID ...string) ([]byte, error)
- func SerializeTx(tx HiveTransaction) ([]byte, error)
- func SignDigest(digest []byte, wif *string) ([]byte, error)
- func WriteUvarint(w io.Writer, x uint64) error
- func WriteVarint(w io.Writer, x int64) error
- type AccountCreateOperation
- type AccountData
- type AccountUpdateOperation
- type Authority
- type Auths
- type Block
- type CancelTransferFromSavings
- type ClaimAccountOperation
- type ClaimRewardOperation
- type CustomJsonOperation
- type CustomTime
- type HiveOperation
- type HiveRpcNode
- func (h *HiveRpcNode) Broadcast(ops []HiveOperation, wif *string) (string, error)
- func (h *HiveRpcNode) BroadcastJson(reqAuth []string, reqPostAuth []string, id string, cj string, wif *string) (string, error)
- func (h *HiveRpcNode) BroadcastRaw(tx HiveTransaction) (string, error)
- func (h *HiveRpcNode) ClaimRewards(Account string, wif *string) (string, error)
- func (h *HiveRpcNode) FetchVirtualOps(blockHeight int, onlyVirtual bool, IncludeReversible bool) ([]VirtualOp, error)
- func (h *HiveRpcNode) GetAccount(accountNames []string) ([]AccountData, error)
- func (h *HiveRpcNode) GetBlock(blockNum int) (Block, error)
- func (h *HiveRpcNode) GetBlockRange(startBlock int, count int) ([]Block, error)
- func (h *HiveRpcNode) GetDynamicGlobalProps() ([]byte, error)
- func (h *HiveRpcNode) GetSigningData() (signingDataFromChain, error)
- func (h *HiveRpcNode) GetTransaction(txId string, includeReversible bool) ([]byte, error)
- func (h *HiveRpcNode) StreamBlocks() (<-chan Block, error)
- func (h *HiveRpcNode) Transfer(from string, to string, amount string, memo string, wif *string) (string, error)
- func (h *HiveRpcNode) UpdateAccount(account string, owner *Auths, active *Auths, posting *Auths, ...) (string, error)
- func (h *HiveRpcNode) VotePost(voter string, author string, permlink string, weight int, wif *string) (string, error)
- type HiveTransaction
- type KeyPair
- type NodeStats
- type Operation
- type RC
- type Transaction
- type TransactionQueryParams
- type TransferFromSavings
- type TransferOperation
- type TransferToSavings
- type TransferToVesting
- type VirtualOp
Constants ¶
This section is empty.
Variables ¶
var OperationType = operationTypes{
Vote: "vote_operation",
Comment: "comment_operation",
Transfer: "transfer_operation",
TransferToVesting: "transfer_to_vesting_operation",
WithdrawVesting: "withdraw_vesting_operation",
LimitOrderCreate: "limit_order_create_operation",
LimitOrderCancel: "limit_order_cancel_operation",
FeedPublish: "feed_publish_operation",
Convert: "convert_operation",
AccountCreate: "account_create_operation",
AccountUpdate: "account_update_operation",
WitnessUpdate: "witness_update_operation",
AccountWitnessVote: "account_witness_vote_operation",
AccountWitnessProxy: "account_witness_proxy_operation",
Pow: "pow_operation",
Custom: "custom_operation",
ReportOverProduction: "report_over_production_operation",
DeleteComment: "delete_comment_operation",
CustomJson: "custom_json_operation",
CommentOptions: "comment_options_operation",
SetWithdrawVestingRoute: "set_withdraw_vesting_route_operation",
LimitOrderCreate2: "limit_order_create2_operation",
ClaimAccount: "claim_account_operation",
CreateClaimedAccount: "create_claimed_account_operation",
RequestAccountRecovery: "request_account_recovery_operation",
RecoverAccount: "recover_account_operation",
ChangeRecoveryAccount: "change_recovery_account_operation",
EscrowTransfer: "escrow_transfer_operation",
EscrowDispute: "escrow_dispute_operation",
EscrowRelease: "escrow_release_operation",
Pow2: "pow2_operation",
EscrowApprove: "escrow_approve_operation",
TransferToSavings: "transfer_to_savings_operation",
TransferFromSavings: "transfer_from_savings_operation",
CancelTransferFromSavings: "cancel_transfer_from_savings_operation",
CustomBinary: "custom_binary_operation",
DeclineVotingRights: "decline_voting_rights_operation",
ResetAccount: "reset_account_operation",
SetResetAccount: "set_reset_account_operation",
ClaimRewardBalance: "claim_reward_balance_operation",
DelegateVestingShares: "delegate_vesting_shares_operation",
AccountCreateWithDelegation: "account_create_with_delegation_operation",
WitnessSetProperties: "witness_set_properties_operation",
AccountUpdate2: "account_update2_operation",
CreateProposal: "create_proposal_operation",
UpdateProposalVotes: "update_proposal_votes_operation",
RemoveProposal: "remove_proposal_operation",
UpdateProposal: "update_proposal_operation",
CollateralizedConvert: "collateralized_convert_operation",
RecurrentTransfer: "recurrent_transfer_operation",
}
var PublicKeyPrefix = "STM"
Functions ¶
func DecodePublicKey ¶
Decodes a base58 Hive public key to secp256k1 public key
func GetPublicKeyString ¶
func GphBase58Encode ¶
func SerializeTx ¶
func SerializeTx(tx HiveTransaction) ([]byte, error)
func WriteUvarint ¶
todo: UNTESTED encodes a uint64 into a variable-length byte slice and writes it to w
Types ¶
type AccountCreateOperation ¶
type AccountCreateOperation struct {
Fee string `json:"fee"`
Creator string `json:"creator"`
NewAccountName string `json:"new_account_name"`
Owner Auths `json:"owner"`
Active Auths `json:"active"`
Posting Auths `json:"posting"`
MemoKey string `json:"memo_key"`
JsonMetadata string `json:"json_metadata"`
}
func (AccountCreateOperation) OpName ¶
func (o AccountCreateOperation) OpName() string
func (AccountCreateOperation) SerializeOp ¶
func (a AccountCreateOperation) SerializeOp() ([]byte, error)
type AccountData ¶
type AccountData struct {
ID int64 `json:"id"`
Name string `json:"name"`
Owner Authority `json:"owner"`
Active Authority `json:"active"`
Posting Authority `json:"posting"`
MemoKey string `json:"memo_key"`
JSONMetadata string `json:"json_metadata"`
Proxy string `json:"proxy"`
LastOwnerUpdate CustomTime `json:"last_owner_update"`
LastAccountUpdate CustomTime `json:"last_account_update"`
Created CustomTime `json:"created"`
Mined bool `json:"mined"`
RecoveryAccount string `json:"recovery_account"`
LastAccountRecovery CustomTime `json:"last_account_recovery"`
CommentCount int32 `json:"comment_count"`
LifetimeVoteCount int32 `json:"lifetime_vote_count"`
PostCount int32 `json:"post_count"`
CanVote bool `json:"can_vote"`
VotingPower int16 `json:"voting_power"`
LastVoteTime CustomTime `json:"last_vote_time"`
Balance string `json:"balance"`
SavingsBalance string `json:"savings_balance"`
HbdBalance string `json:"hbd_balance"`
HbdSeconds string `json:"hbd_seconds"`
HbdSecondsLastUpdate CustomTime `json:"hbd_seconds_last_update"`
HbdLastInterestPayment CustomTime `json:"hbd_last_interest_payment"`
SavingsHbdBalance string `json:"savings_hbd_balance"`
SavingsHbdSeconds string `json:"savings_hbd_seconds"`
SavingsHbdLastUpdate CustomTime `json:"savings_hbd_last_update"`
SavingsHbdLastInterestPayment CustomTime `json:"savings_hbd_last_interest_payment"`
SavingsWithdrawRequests int32 `json:"savings_withdraw_requests"`
RewardHbdBalance string `json:"reward_hbd_balance"`
RewardHiveBalance string `json:"reward_hive_balance"`
RewardVestingBalance string `json:"reward_vesting_balance"`
RewardVestingHive string `json:"reward_vesting_hive"`
VestingWithdrawRate string `json:"vesting_withdraw_rate"`
NextVestingWithdrawal CustomTime `json:"next_vesting_withdrawal"`
Withdrawn int64 `json:"withdrawn"`
ToWithdraw int64 `json:"to_withdraw"`
WithdrawRoutes int32 `json:"withdraw_routes"`
CurationRewards int64 `json:"curation_rewards"`
PostingRewards int64 `json:"posting_rewards"`
ProxiedVsfVotes []int64 `json:"proxied_vsf_votes"`
WitnessesVotedFor int32 `json:"witnesses_voted_for"`
LastPost CustomTime `json:"last_post"`
LastRootPost CustomTime `json:"last_root_post"`
AverageBandwidth string `json:"average_bandwidth"`
LifetimeBandwidth string `json:"lifetime_bandwidth"`
LastBandwidthUpdate CustomTime `json:"last_bandwidth_update"`
PostVotingPower string `json:"post_voting_power"`
Reputation int64 `json:"reputation"`
PostBandwidth int64 `json:"post_bandwidth"`
PendingClaimedAccounts int32 `json:"pending_claimed_accounts"`
PendingTransfers int32 `json:"pending_transfers"`
PreviousOwnerUpdate CustomTime `json:"previous_owner_update"`
TransferHistory []interface{} `json:"transfer_history"`
MarketHistory []interface{} `json:"market_history"`
PostHistory []interface{} `json:"post_history"`
VoteHistory []interface{} `json:"vote_history"`
OtherHistory []interface{} `json:"other_history"`
WitnessVotes []string `json:"witness_votes"`
TagsUsage []interface{} `json:"tags_usage"`
GuestBloggers []interface{} `json:"guest_bloggers"`
DelayedVotes []interface{} `json:"delayed_votes"`
VotingManabar RC `json:"voting_manabar"`
DownvoteManabar RC `json:"downvote_manabar"`
GovernanceVoteExpirationTs CustomTime `json:"governance_vote_expiration_ts"`
PostingJSONMetadata string `json:"posting_json_metadata"`
}
type AccountUpdateOperation ¶
type AccountUpdateOperation struct {
Account string `json:"account"`
// optional: auths
Owner *Auths `json:"owner"`
Active *Auths `json:"active"`
Posting *Auths `json:"posting"`
MemoKey string `json:"memo_key"`
JsonMetadata string `json:"json_metadata"`
// contains filtered or unexported fields
}
ref: https://developers.hive.io/apidefinitions/#broadcast_ops_account_update
func (AccountUpdateOperation) OpName ¶
func (o AccountUpdateOperation) OpName() string
func (AccountUpdateOperation) SerializeOp ¶
func (a AccountUpdateOperation) SerializeOp() ([]byte, error)
type Authority ¶
type Authority struct {
AccountAuths [][]interface{} `json:"account_auths"`
KeyAuths [][]interface{} `json:"key_auths"`
WeightThreshold int `json:"weight_threshold"`
}
type Auths ¶
type Auths struct {
WeightThreshold int `json:"weight_threshold"`
AccountAuths [][2]interface{} `json:"account_auths"` // tuple (string, int)
KeyAuths [][2]interface{} `json:"key_auths"` // tuple (string, int)
}
type Block ¶
type Block struct {
BlockNumber int
BlockID string `json:"block_id"`
Previous string `json:"previous"`
Timestamp string `json:"timestamp"`
Witness string `json:"witness"`
TransactionMerkleRoot string `json:"transaction_merkle_root"`
Transactions []Transaction `json:"transactions"`
Extensions []interface{} `json:"extensions"`
SigningKey string `json:"signing_key"`
TransactionIds []string `json:"transaction_ids"`
WitnessSignature string `json:"witness_signature"`
}
type CancelTransferFromSavings ¶
type CancelTransferFromSavings struct {
From string `json:"from"`
RequestId int `json:"request_id"`
}
func (CancelTransferFromSavings) OpName ¶
func (o CancelTransferFromSavings) OpName() string
func (CancelTransferFromSavings) SerializeOp ¶
func (o CancelTransferFromSavings) SerializeOp() ([]byte, error)
type ClaimAccountOperation ¶
func (ClaimAccountOperation) OpName ¶
func (o ClaimAccountOperation) OpName() string
func (ClaimAccountOperation) SerializeOp ¶
func (o ClaimAccountOperation) SerializeOp() ([]byte, error)
type ClaimRewardOperation ¶
type ClaimRewardOperation struct {
Account string `json:"account"`
RewardHBD string `json:"reward_hbd"`
RewardHIVE string `json:"reward_hive"`
RewardVests string `json:"reward_vests"`
// contains filtered or unexported fields
}
func (ClaimRewardOperation) OpName ¶
func (o ClaimRewardOperation) OpName() string
func (ClaimRewardOperation) SerializeOp ¶
func (o ClaimRewardOperation) SerializeOp() ([]byte, error)
type CustomJsonOperation ¶
type CustomJsonOperation struct {
RequiredAuths []string `json:"required_auths"`
RequiredPostingAuths []string `json:"required_posting_auths"`
Id string `json:"id"`
Json string `json:"json"`
// contains filtered or unexported fields
}
func (CustomJsonOperation) OpName ¶
func (o CustomJsonOperation) OpName() string
func (CustomJsonOperation) SerializeOp ¶
func (o CustomJsonOperation) SerializeOp() ([]byte, error)
type CustomTime ¶
func (CustomTime) ToTime ¶
func (ct CustomTime) ToTime() time.Time
func (*CustomTime) UnmarshalJSON ¶
func (ct *CustomTime) UnmarshalJSON(b []byte) error
type HiveOperation ¶
type HiveRpcNode ¶
type HiveRpcNode struct {
MaxConn int
MaxBatch int
NoBroadcast bool
ChainID string
// RpcTimeout bounds a single node RPC round-trip (HG-H7). Zero falls back to
// defaultRpcTimeout so struct-literal construction is still protected.
RpcTimeout time.Duration
// contains filtered or unexported fields
}
func NewHiveRpc ¶
func NewHiveRpc(addrs []string) *HiveRpcNode
func NewHiveRpcWithOpts ¶
func NewHiveRpcWithOpts(addrs []string, maxConn int, maxBatch int) *HiveRpcNode
func (*HiveRpcNode) Broadcast ¶
func (h *HiveRpcNode) Broadcast(ops []HiveOperation, wif *string) (string, error)
func (*HiveRpcNode) BroadcastJson ¶
func (*HiveRpcNode) BroadcastRaw ¶
func (h *HiveRpcNode) BroadcastRaw(tx HiveTransaction) (string, error)
func (*HiveRpcNode) ClaimRewards ¶
func (h *HiveRpcNode) ClaimRewards(Account string, wif *string) (string, error)
func (*HiveRpcNode) FetchVirtualOps ¶
func (*HiveRpcNode) GetAccount ¶
func (h *HiveRpcNode) GetAccount(accountNames []string) ([]AccountData, error)
func (*HiveRpcNode) GetBlockRange ¶
func (h *HiveRpcNode) GetBlockRange(startBlock int, count int) ([]Block, error)
func (*HiveRpcNode) GetDynamicGlobalProps ¶
func (h *HiveRpcNode) GetDynamicGlobalProps() ([]byte, error)
func (*HiveRpcNode) GetSigningData ¶
func (h *HiveRpcNode) GetSigningData() (signingDataFromChain, error)
func (*HiveRpcNode) GetTransaction ¶
func (h *HiveRpcNode) GetTransaction(txId string, includeReversible bool) ([]byte, error)
func (*HiveRpcNode) StreamBlocks ¶
func (h *HiveRpcNode) StreamBlocks() (<-chan Block, error)
type HiveTransaction ¶
type HiveTransaction struct {
RefBlockNum uint16 `json:"ref_block_num"`
RefBlockPrefix uint32 `json:"ref_block_prefix"`
Expiration string `json:"expiration"`
Operations []HiveOperation `json:"-"`
OperationsJs [][2]interface{} `json:"operations"`
Extensions []string `json:"extensions"`
Signatures []string `json:"signatures"`
}
func (*HiveTransaction) AddSig ¶
func (t *HiveTransaction) AddSig(sig string)
func (*HiveTransaction) GenerateTrxId ¶
func (t *HiveTransaction) GenerateTrxId() (string, error)
func (*HiveTransaction) Sign ¶
func (t *HiveTransaction) Sign(keyPair KeyPair, chainId ...string) (string, error)
func (*HiveTransaction) ValidateExpiration ¶
func (t *HiveTransaction) ValidateExpiration(now time.Time) error
ValidateExpiration reports an error if the transaction's Expiration is malformed or not strictly in the future relative to `now` (compared in UTC, the timezone Hive uses for the expiration field).
review7 HG-M16: Sign() is a pure signing primitive and is deliberately left time-independent — a tx must be re-signable/reproducible (fixed-vector tests sign a tx dated 2016), so Sign() cannot reject an expired tx without breaking deterministic signing. Callers that build a tx for broadcast should call ValidateExpiration(time.Now().UTC()) first, so they don't sign and broadcast a tx the node will only reject as expired.
type KeyPair ¶
type KeyPair struct {
PrivateKey *secp256k1.PrivateKey
PublicKey *secp256k1.PublicKey
}
func KeyPairFromBytes ¶
func KeyPairFromWif ¶
Gets a KeyPair from a given WIF String
func (*KeyPair) GetPublicKeyString ¶
type Transaction ¶
type Transaction struct {
Expiration string `json:"expiration"`
Extensions []interface{} `json:"extensions"`
Operations []Operation `json:"operations"`
RefBlockNum uint16 `json:"ref_block_num"`
RefBlockPrefix uint32 `json:"ref_block_prefix"`
Signatures []string `json:"signatures"`
RequiredAuths []string `json:"required_auths,omitempty"`
RequiredPostingAuths []string `json:"required_posting_auths,omitempty"`
}
type TransactionQueryParams ¶
type TransferFromSavings ¶
type TransferFromSavings struct {
Amount string `json:"amount"`
From string `json:"from"`
To string `json:"to"`
Memo string `json:"memo"`
RequestId int `json:"request_id"`
}
func (TransferFromSavings) OpName ¶
func (o TransferFromSavings) OpName() string
func (TransferFromSavings) SerializeOp ¶
func (o TransferFromSavings) SerializeOp() ([]byte, error)
type TransferOperation ¶
type TransferOperation struct {
From string `json:"from"`
To string `json:"to"`
Amount string `json:"amount"`
Memo string `json:"memo"`
}
func (TransferOperation) OpName ¶
func (o TransferOperation) OpName() string
func (TransferOperation) SerializeOp ¶
func (o TransferOperation) SerializeOp() ([]byte, error)
type TransferToSavings ¶
type TransferToSavings struct {
Amount string `json:"amount"`
From string `json:"from"`
To string `json:"to"`
Memo string `json:"memo"`
}
func (TransferToSavings) OpName ¶
func (o TransferToSavings) OpName() string
func (TransferToSavings) SerializeOp ¶
func (o TransferToSavings) SerializeOp() ([]byte, error)
type TransferToVesting ¶
type TransferToVesting struct {
From string `json:"from"`
To string `json:"to"`
Amount string `json:"amount"`
}
func (TransferToVesting) OpName ¶
func (o TransferToVesting) OpName() string
func (TransferToVesting) SerializeOp ¶
func (o TransferToVesting) SerializeOp() ([]byte, error)
type VirtualOp ¶
type VirtualOp struct {
Block int `json:"block"`
Op struct {
Type string `json:"type"`
Value map[string]interface{} `json:"value"`
} `json:"op"`
OpInTrx int `json:"op_in_trx"`
TrxId string `json:"trx_id"`
TrxInBlock int `json:"trx_in_block"`
VirtualOp bool `json:"virtual_op"`
OperationId int `json:"operation_id"`
Timestamp string `json:"timestamp"`
}