Documentation ¶
Overview ¶
Package rpc provides types and methods for use in communicating with the Chia RPC
Index ¶
- Variables
- func Call(c Caller, p string, d interface{}) ([]byte, error)
- func PercentageToRoyalty(p float64) uint
- type Caller
- type Coin
- type CoinRecord
- type CoinRecordRequest
- type CoinRecordResponse
- type CoinRecordsByNameRequest
- type CoinRecordsByParentIdsRequest
- type CoinRecordsRequest
- type CoinRecordsResponse
- type Endpoint
- type Errors
- type MetadataListItem
- type MintBulkRequest
- type MintBulkResponse
- type MintRequest
- type MintResponse
- type NftWalletGetDidRequest
- type NftWalletGetDidResponse
- type Procedure
- type PushTxRequest
- type PushTxResponse
- type Sender
- type Solution
- type SpendBundle
- type SyncStatusRequest
- type SyncStatusResponse
- type UntypedRequest
- type UntypedResponse
- type WalletBalance
- type WalletBalanceRequest
- type WalletBalanceResponse
Constants ¶
This section is empty.
Variables ¶
var ( DefaultPath = ".chia" DefaultCertPath = "mainnet/config/ssl/" HomeDir = "" )
Functions ¶
func Call ¶
Call is a general endpoint call function for convenience. It takes a Caller, procedure name string, and an any data type to marshal into JSON. @TODO: Expand definition for use with interfaces. May require some renaming of Endpoint and Procedure functions as well as package interfaces rework.
func PercentageToRoyalty ¶
PercentageToRoyalty takes a percentage p%, and returns the royalty percentage uint as chia expects it. (Ex: 5%; p=5, returns 500)
Types ¶
type Coin ¶
type Coin struct { Amount uint `json:"amount"` ParentCoinInfo string `json:"parent_coin_info"` PuzzleHash string `json:"puzzle_hash"` }
Coin contains details about a specific coin.
type CoinRecord ¶
type CoinRecord struct { Coin *Coin `json:"coin"` Coinbase bool `json:"coinbase"` ConfirmedBlockIndex uint `json:"confirmed_block_index"` Spent bool `json:"spent"` SpentBlockIndex uint `json:"spent_block_index"` Timestamp uint `json:"timestamp"` }
CoinRecord contains details about a coin record.
type CoinRecordRequest ¶
type CoinRecordRequest struct {
Name string `json:"name"`
}
CoinRecordRequest is a type for making a request for a single CoinRecord by name.
func (*CoinRecordRequest) Procedure ¶
func (c *CoinRecordRequest) Procedure() Procedure
Procedure returns the Procedure which this request will use.
func (*CoinRecordRequest) Send ¶
func (c *CoinRecordRequest) Send(e *Endpoint) (*CoinRecordResponse, error)
Sends the request via an Endpoint, and returns the response, and an error. If successful, error returns nil.
func (*CoinRecordRequest) String ¶
func (c *CoinRecordRequest) String() string
String implements the fmt.Stringer interface.
type CoinRecordResponse ¶
type CoinRecordResponse struct { CoinRecord *CoinRecord `json:"coin_record"` Success bool `json:"success"` Error string `json:"error"` }
CoinRecordResponse represents the Chia RPC API's response to a CoinRecordRequest.
type CoinRecordsByNameRequest ¶
type CoinRecordsByNameRequest struct { Name []string `json:"parent_ids"` StartHeight uint `json:"start_height,omitempty"` EndHeight uint `json:"end_height,omitempty"` IncludeSpent bool `json:"include_spent_coins,omitempty"` }
CoinRecordsByNameRequest is a type for making a request for a multiple CoinRecords by coin name.
func (*CoinRecordsByNameRequest) Procedure ¶
func (c *CoinRecordsByNameRequest) Procedure() Procedure
Procedure returns the Procedure which this request will use.
func (*CoinRecordsByNameRequest) Send ¶
func (c *CoinRecordsByNameRequest) Send(e *Endpoint) (*CoinRecordsResponse, error)
Sends the request via an Endpoint, and returns the response, and an error. If successful, error returns nil.
func (*CoinRecordsByNameRequest) String ¶
func (c *CoinRecordsByNameRequest) String() string
String implements the fmt.Stringer interface.
type CoinRecordsByParentIdsRequest ¶
type CoinRecordsByParentIdsRequest struct { ParentIds []string `json:"parent_ids"` StartHeight uint `json:"start_height,omitempty"` EndHeight uint `json:"end_height,omitempty"` IncludeSpent bool `json:"include_spent_coins,omitempty"` }
CoinRecordsByParentIdsRequest is a type for making a request for a multiple CoinRecords by parent ids.
func (*CoinRecordsByParentIdsRequest) Procedure ¶
func (c *CoinRecordsByParentIdsRequest) Procedure() Procedure
Procedure returns the Procedure which this request will use.
func (*CoinRecordsByParentIdsRequest) Send ¶
func (c *CoinRecordsByParentIdsRequest) Send(e *Endpoint) (*CoinRecordsResponse, error)
Sends the request via an Endpoint, and returns the response, and an error. If successful, error returns nil.
func (*CoinRecordsByParentIdsRequest) String ¶
func (c *CoinRecordsByParentIdsRequest) String() string
String implements the fmt.Stringer interface.
type CoinRecordsRequest ¶
type CoinRecordsRequest struct { Names []string `json:"names"` ParentIds []string `json:"parent_ids"` Hints []string `json:"hints"` StartHeight uint `json:"start_height,omitempty"` EndHeight uint `json:"end_height,omitempty"` IncludeSpent bool `json:"include_spent_coins,omitempty"` }
CoinRecordsRequest is a type for making at least one request for a multiple CoinRecords by coin names, parent ids, and/or hints.
func (*CoinRecordsRequest) Procedure ¶
func (c *CoinRecordsRequest) Procedure() Procedure
Procedure returns the Procedure which this request will use. Though this type is designed to call multiple procedures, this method will always return FullNodeCoinRecordByNames.
func (*CoinRecordsRequest) Send ¶
func (c *CoinRecordsRequest) Send(e *Endpoint) (*CoinRecordsResponse, error)
Sends at least one request, of at least one CoinRecordsByN procedure, via an Endpoint, and returns the response, and any error. If successful, error returns nil.
func (*CoinRecordsRequest) String ¶
func (c *CoinRecordsRequest) String() string
String implements the fmt.Stringer interface.
type CoinRecordsResponse ¶
type CoinRecordsResponse struct { CoinRecords []*CoinRecord `json:"coin_records"` Success bool `json:"success"` Error string `json:"error"` }
CoinRecordsResponse represents the Chia RPC API's response to a CoinRecordRequest.
type Endpoint ¶
An Endpoint represents a Chia RPC endpoint. It implements Caller.
func NewEndpoint ¶
NewEndpoint returns and initializes a new *Endpoint. It returns an error on initialization faliure.
func (*Endpoint) Call ¶
Call makes a call to the Chia RPC endpoint and returns the response as a byte slice. Takes a Procedure, p, and a payload as a JSON byte slice, j.
type Errors ¶
type Errors []error
Errors is a slice of error, and itself implements the built-in error interface.
type MetadataListItem ¶
type MetadataListItem struct { Uris []string `json:"uris"` MetaUris []string `json:"meta_uris,omitempty"` LicenseUris []string `json:"license_uris,omitempty"` Hash string `json:"hash"` MetaHash string `json:"meta_hash,omitempty"` LicenseHash string `json:"license_hash,omitempty"` EditionNumber int `json:"edition_number,omitempty"` // Not in CHIP-0007, but in chia 1.4.0 as "series_total", rather than "edition_total", due to bug. This was fixed in chia 1.5.0. EditionTotal int `json:"edition_total,omitempty"` // Not in CHIP-0007, but in chia 1.4.0 as "series_number", rather than "edition_total", due to bug. This was fixed in chia 1.5.0. }
type MintBulkRequest ¶
type MintBulkRequest struct { WalletId int `json:"wallet_id"` MetadataList []*MetadataListItem `json:"metadata_list"` RoyaltyPercentage int `json:"royalty_percentage,omitempty"` RoyaltyAddress string `json:"royalty_address,omitempty"` TargetAddressList []string `json:"target_address_list,omitempty"` MintNumberStart int `json:"mint_number_start,omitempty"` MintTotal int `json:"mint_total,omitempty"` XchCoinList []string `json:"xch_coin_list,omitempty"` XchChangeTarget string `json:"xch_change_target,omitempty"` NewInnerPuzHash string `json:"new_innerpuzhash,omitempty"` NewP2PuzHash string `json:"new_p2_puzhash,omitempty"` DidCoinDict map[string]interface{} `json:"did_coin_dict,omitempty"` DidLineageParentHex string `json:"did_lineage_parent_hex,omitempty"` MintFromDid bool `json:"mint_from_did,omitempty"` Fee float64 `json:"fee,omitempty"` ReusePuzHash bool `json:"reuse_puzhash,omitempty"` }
func (*MintBulkRequest) Procedure ¶
func (m *MintBulkRequest) Procedure() Procedure
func (MintBulkRequest) Send ¶
func (m MintBulkRequest) Send(e *Endpoint) (*MintBulkResponse, error)
func (*MintBulkRequest) String ¶
func (m *MintBulkRequest) String() string
type MintBulkResponse ¶
type MintBulkResponse struct { NftIdList []string `json:"nft_id_list"` SpendBundle *SpendBundle `json:"spend_bundle"` Success bool `json:"success"` Error string `json:"error"` }
type MintRequest ¶
type MintRequest struct { WalletId int `json:"wallet_id"` Uris []string `json:"uris"` Hash string `json:"hash"` DidId string `json:"did_id,omitempty"` MetaUris []string `json:"meta_uris,omitempty"` MetaHash string `json:"meta_hash,omitempty"` LicenseUris []string `json:"license_uris,omitempty"` LicenseHash string `json:"license_hash,omitempty"` RoyaltyAddress string `json:"royalty_address,omitempty"` RoyaltyPercentage int `json:"royalty_percentage,omitempty"` TargetAddress string `json:"target_address,omitempty"` Fee float64 `json:"fee,omitempty"` SeriesNumber int `json:"series_number,omitempty"` // In CHIP-0007, but not in chia 1.4.0 as "series_number", due to bug. This has been deprecated as of chia 1.5.0, likely until NFT2. SeriesTotal int `json:"series_total,omitempty"` // In CHIP-0007, but not in chia 1.4.0 as "series_total", due to bug.. This has been deprecated as of chia 1.5.0, likely until NFT2. EditionNumber int `json:"edition_number,omitempty"` // Not in CHIP-0007, but in chia 1.4.0 as "series_total", rather than "edition_total", due to bug. This was fixed in chia 1.5.0. EditionTotal int `json:"edition_total,omitempty"` // Not in CHIP-0007, but in chia 1.4.0 as "series_number", rather than "edition_total", due to bug. This was fixed in chia 1.5.0. }
func (*MintRequest) Procedure ¶
func (m *MintRequest) Procedure() Procedure
func (MintRequest) Send ¶
func (m MintRequest) Send(e *Endpoint) (*MintResponse, error)
func (*MintRequest) String ¶
func (m *MintRequest) String() string
type MintResponse ¶
type MintResponse struct { Spend_bundle *SpendBundle Success bool `json:"success"` WalletId uint `json:"wallet_id"` Error string `json:"error"` }
type NftWalletGetDidRequest ¶
type NftWalletGetDidRequest struct {
WalletId uint `json:"wallet_id"`
}
func (*NftWalletGetDidRequest) Procedure ¶
func (w *NftWalletGetDidRequest) Procedure() Procedure
func (*NftWalletGetDidRequest) Send ¶
func (n *NftWalletGetDidRequest) Send(e *Endpoint) (*NftWalletGetDidResponse, error)
func (*NftWalletGetDidRequest) String ¶
func (n *NftWalletGetDidRequest) String() string
type NftWalletGetDidResponse ¶
type Procedure ¶
type Procedure string
Procedure represents procedure, and its value is its name.
const ( FullNodeCoinRecordByName Procedure = "get_coin_record_by_name" FullNodeCoinRecordByNames Procedure = "get_coin_record_by_names" FullNodeCoinRecordByParentIds Procedure = "get_coin_record_by_parent_ids" FullNodeCoinRecordByHints Procedure = "get_coin_record_by_hints" FullNodePushTx Procedure = "push_tx" )
type PushTxRequest ¶
type PushTxRequest struct {
SpendBundle *SpendBundle `json:"spend_bundle"`
}
PushTxRequest is a type for making a request to submit a SpendBundle to the blockchain.
func (*PushTxRequest) Procedure ¶
func (c *PushTxRequest) Procedure() Procedure
Procedure returns the Procedure which this request will use.
func (*PushTxRequest) Send ¶
func (p *PushTxRequest) Send(e *Endpoint) (*PushTxResponse, error)
Sends the request via an Endpoint, and returns the response, and an error. If successful, error returns nil.
func (*PushTxRequest) String ¶
func (p *PushTxRequest) String() string
String implements the fmt.Stringer interface.
type PushTxResponse ¶
type PushTxResponse struct { Status string `json:"status"` Success bool `json:"success"` Error string `json:"error"` }
PushTxResponse represents the Chia RPC API's response to a PushTxRequest.
type SpendBundle ¶
type SyncStatusRequest ¶
type SyncStatusRequest struct{}
func (*SyncStatusRequest) Procedure ¶
func (s *SyncStatusRequest) Procedure() Procedure
func (*SyncStatusRequest) Send ¶
func (s *SyncStatusRequest) Send(e *Endpoint) (*SyncStatusResponse, error)
func (*SyncStatusRequest) String ¶
func (s *SyncStatusRequest) String() string
type SyncStatusResponse ¶
type UntypedRequest ¶
Generic request type for use when other types won't do, or you don't want to write your own. Implements Sender.
func NewUntypedRequest ¶
func NewUntypedRequest(p Procedure) *UntypedRequest
NewUntypedRequest takes a Procedure and returns an UntypedRequest.
func (*UntypedRequest) Procedure ¶
func (u *UntypedRequest) Procedure() Procedure
Procedure returns the procedure currently assigned to this generic request.
func (*UntypedRequest) Send ¶
func (u *UntypedRequest) Send(e *Endpoint) (UntypedResponse, error)
Send sends the request via an Endpoint, and returns the result as an UntypedResponse, or nil, and an error. If successful, error returns nil.
func (*UntypedRequest) String ¶
func (u *UntypedRequest) String() string
String implements the fmt.Stringer interface.
type UntypedResponse ¶
type UntypedResponse map[string]interface{}
Generic response type for use in conjunction with UntypedRequest.
func NewUntypedResponse ¶
func NewUntypedResponse() UntypedResponse
Convenience function. May be deprecated.
type WalletBalance ¶
type WalletBalance struct { ConfirmedWalletBalance uint `json:"confirmed_wallet_balance"` Fingerprint uint `json:"fingerprint"` MaxSendAmount uint `json:"max_send_amount"` PendingChange uint `json:"pending_change"` PendingCoinRemovalCount uint `json:"pending_coin_removal_count"` SpendableBalance uint `json:"spendable_balance"` UnconfirmedWalletBalance uint `json:"unconfirmed_wallet_balance"` UnspentCoinCount uint `json:"unspent_coin_amount"` WalletId uint `json:"wallet_id"` }
type WalletBalanceRequest ¶
type WalletBalanceRequest struct {
WalletId uint `json:"wallet_id"`
}
func (*WalletBalanceRequest) Procedure ¶
func (w *WalletBalanceRequest) Procedure() Procedure
func (*WalletBalanceRequest) Send ¶
func (w *WalletBalanceRequest) Send(e *Endpoint) (*WalletBalanceResponse, error)
func (*WalletBalanceRequest) String ¶
func (w *WalletBalanceRequest) String() string
type WalletBalanceResponse ¶
type WalletBalanceResponse struct { WalletBalance *WalletBalance `json:"wallet_balance"` Success bool `json:"success"` Error string `json:"error"` }