rpcclient: Export symbols needed for custom commands (#1457)

* rpcclient: Export sendCmd and response

This facilitates using custom commands with rpcclient.

See https://github.com/btcsuite/btcd/issues/1083

* rpcclient: Export receiveFuture

This facilitates using custom commands with rpcclient.

See https://github.com/btcsuite/btcd/issues/1083

* rpcclient: Add customcommand example

* rpcclient: remove "Namecoin" from customcommand readme heading
This commit is contained in:
JeremyRand 2021-09-02 06:39:55 +00:00 committed by GitHub
parent f9d72f05a4
commit 3e2d8464f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 732 additions and 590 deletions

View File

@ -17,12 +17,12 @@ import (
// FutureGetBestBlockHashResult is a future promise to deliver the result of a
// GetBestBlockAsync RPC invocation (or an applicable error).
type FutureGetBestBlockHashResult chan *response
type FutureGetBestBlockHashResult chan *Response
// Receive waits for the response promised by the future and returns the hash of
// Receive waits for the Response promised by the future and returns the hash of
// the best block in the longest block chain.
func (r FutureGetBestBlockHashResult) Receive() (*chainhash.Hash, error) {
res, err := receiveFuture(r)
res, err := ReceiveFuture(r)
if err != nil {
return nil, err
}
@ -43,7 +43,7 @@ func (r FutureGetBestBlockHashResult) Receive() (*chainhash.Hash, error) {
// See GetBestBlockHash for the blocking version and more details.
func (c *Client) GetBestBlockHashAsync() FutureGetBestBlockHashResult {
cmd := btcjson.NewGetBestBlockHashCmd()
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// GetBestBlockHash returns the hash of the best block in the longest block
@ -75,13 +75,13 @@ func (c *Client) legacyGetBlockRequest(hash string, verbose,
})
}
// waitForGetBlockRes waits for the response of a getblock request. If the
// response indicates an invalid parameter was provided, a legacy style of the
// request is resent and its response is returned instead.
func (c *Client) waitForGetBlockRes(respChan chan *response, hash string,
// waitForGetBlockRes waits for the Response of a getblock request. If the
// Response indicates an invalid parameter was provided, a legacy style of the
// request is resent and its Response is returned instead.
func (c *Client) waitForGetBlockRes(respChan chan *Response, hash string,
verbose, verboseTx bool) ([]byte, error) {
res, err := receiveFuture(respChan)
res, err := ReceiveFuture(respChan)
// If we receive an invalid parameter error, then we may be
// communicating with a btcd node which only understands the legacy
@ -91,7 +91,7 @@ func (c *Client) waitForGetBlockRes(respChan chan *response, hash string,
return c.legacyGetBlockRequest(hash, verbose, verboseTx)
}
// Otherwise, we can return the response as is.
// Otherwise, we can return the Response as is.
return res, err
}
@ -100,10 +100,10 @@ func (c *Client) waitForGetBlockRes(respChan chan *response, hash string,
type FutureGetBlockResult struct {
client *Client
hash string
Response chan *response
Response chan *Response
}
// Receive waits for the response promised by the future and returns the raw
// Receive waits for the Response promised by the future and returns the raw
// block requested from the server given its hash.
func (r FutureGetBlockResult) Receive() (*wire.MsgBlock, error) {
res, err := r.client.waitForGetBlockRes(r.Response, r.hash, false, false)
@ -148,7 +148,7 @@ func (c *Client) GetBlockAsync(blockHash *chainhash.Hash) FutureGetBlockResult {
return FutureGetBlockResult{
client: c,
hash: hash,
Response: c.sendCmd(cmd),
Response: c.SendCmd(cmd),
}
}
@ -165,10 +165,10 @@ func (c *Client) GetBlock(blockHash *chainhash.Hash) (*wire.MsgBlock, error) {
type FutureGetBlockVerboseResult struct {
client *Client
hash string
Response chan *response
Response chan *Response
}
// Receive waits for the response promised by the future and returns the data
// Receive waits for the Response promised by the future and returns the data
// structure from the server with information about the requested block.
func (r FutureGetBlockVerboseResult) Receive() (*btcjson.GetBlockVerboseResult, error) {
res, err := r.client.waitForGetBlockRes(r.Response, r.hash, true, false)
@ -201,7 +201,7 @@ func (c *Client) GetBlockVerboseAsync(blockHash *chainhash.Hash) FutureGetBlockV
return FutureGetBlockVerboseResult{
client: c,
hash: hash,
Response: c.sendCmd(cmd),
Response: c.SendCmd(cmd),
}
}
@ -219,10 +219,10 @@ func (c *Client) GetBlockVerbose(blockHash *chainhash.Hash) (*btcjson.GetBlockVe
type FutureGetBlockVerboseTxResult struct {
client *Client
hash string
Response chan *response
Response chan *Response
}
// Receive waits for the response promised by the future and returns a verbose
// Receive waits for the Response promised by the future and returns a verbose
// version of the block including detailed information about its transactions.
func (r FutureGetBlockVerboseTxResult) Receive() (*btcjson.GetBlockVerboseTxResult, error) {
res, err := r.client.waitForGetBlockRes(r.Response, r.hash, true, true)
@ -258,7 +258,7 @@ func (c *Client) GetBlockVerboseTxAsync(blockHash *chainhash.Hash) FutureGetBloc
return FutureGetBlockVerboseTxResult{
client: c,
hash: hash,
Response: c.sendCmd(cmd),
Response: c.SendCmd(cmd),
}
}
@ -273,12 +273,12 @@ func (c *Client) GetBlockVerboseTx(blockHash *chainhash.Hash) (*btcjson.GetBlock
// FutureGetBlockCountResult is a future promise to deliver the result of a
// GetBlockCountAsync RPC invocation (or an applicable error).
type FutureGetBlockCountResult chan *response
type FutureGetBlockCountResult chan *Response
// Receive waits for the response promised by the future and returns the number
// Receive waits for the Response promised by the future and returns the number
// of blocks in the longest block chain.
func (r FutureGetBlockCountResult) Receive() (int64, error) {
res, err := receiveFuture(r)
res, err := ReceiveFuture(r)
if err != nil {
return 0, err
}
@ -299,7 +299,7 @@ func (r FutureGetBlockCountResult) Receive() (int64, error) {
// See GetBlockCount for the blocking version and more details.
func (c *Client) GetBlockCountAsync() FutureGetBlockCountResult {
cmd := btcjson.NewGetBlockCountCmd()
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// GetBlockCount returns the number of blocks in the longest block chain.
@ -309,11 +309,11 @@ func (c *Client) GetBlockCount() (int64, error) {
// FutureGetChainTxStatsResult is a future promise to deliver the result of a
// GetChainTxStatsAsync RPC invocation (or an applicable error).
type FutureGetChainTxStatsResult chan *response
type FutureGetChainTxStatsResult chan *Response
// Receive waits for the response promised by the future and returns transaction statistics
// Receive waits for the Response promised by the future and returns transaction statistics
func (r FutureGetChainTxStatsResult) Receive() (*btcjson.GetChainTxStatsResult, error) {
res, err := receiveFuture(r)
res, err := ReceiveFuture(r)
if err != nil {
return nil, err
}
@ -334,7 +334,7 @@ func (r FutureGetChainTxStatsResult) Receive() (*btcjson.GetChainTxStatsResult,
// See GetChainTxStats for the blocking version and more details.
func (c *Client) GetChainTxStatsAsync() FutureGetChainTxStatsResult {
cmd := btcjson.NewGetChainTxStatsCmd(nil, nil)
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// GetChainTxStatsNBlocksAsync returns an instance of a type that can be used to get
@ -344,7 +344,7 @@ func (c *Client) GetChainTxStatsAsync() FutureGetChainTxStatsResult {
// See GetChainTxStatsNBlocks for the blocking version and more details.
func (c *Client) GetChainTxStatsNBlocksAsync(nBlocks int32) FutureGetChainTxStatsResult {
cmd := btcjson.NewGetChainTxStatsCmd(&nBlocks, nil)
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// GetChainTxStatsNBlocksBlockHashAsync returns an instance of a type that can be used to get
@ -355,7 +355,7 @@ func (c *Client) GetChainTxStatsNBlocksAsync(nBlocks int32) FutureGetChainTxStat
func (c *Client) GetChainTxStatsNBlocksBlockHashAsync(nBlocks int32, blockHash chainhash.Hash) FutureGetChainTxStatsResult {
hash := blockHash.String()
cmd := btcjson.NewGetChainTxStatsCmd(&nBlocks, &hash)
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// GetChainTxStats returns statistics about the total number and rate of transactions in the chain.
@ -382,12 +382,12 @@ func (c *Client) GetChainTxStatsNBlocksBlockHash(nBlocks int32, blockHash chainh
// FutureGetDifficultyResult is a future promise to deliver the result of a
// GetDifficultyAsync RPC invocation (or an applicable error).
type FutureGetDifficultyResult chan *response
type FutureGetDifficultyResult chan *Response
// Receive waits for the response promised by the future and returns the
// Receive waits for the Response promised by the future and returns the
// proof-of-work difficulty as a multiple of the minimum difficulty.
func (r FutureGetDifficultyResult) Receive() (float64, error) {
res, err := receiveFuture(r)
res, err := ReceiveFuture(r)
if err != nil {
return 0, err
}
@ -408,7 +408,7 @@ func (r FutureGetDifficultyResult) Receive() (float64, error) {
// See GetDifficulty for the blocking version and more details.
func (c *Client) GetDifficultyAsync() FutureGetDifficultyResult {
cmd := btcjson.NewGetDifficultyCmd()
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// GetDifficulty returns the proof-of-work difficulty as a multiple of the
@ -421,7 +421,7 @@ func (c *Client) GetDifficulty() (float64, error) {
// GetBlockChainInfoAsync RPC invocation (or an applicable error).
type FutureGetBlockChainInfoResult struct {
client *Client
Response chan *response
Response chan *Response
}
// unmarshalPartialGetBlockChainInfoResult unmarshals the response into an
@ -461,10 +461,10 @@ func unmarshalGetBlockChainInfoResultSoftForks(chainInfo *btcjson.GetBlockChainI
return nil
}
// Receive waits for the response promised by the future and returns chain info
// Receive waits for the Response promised by the future and returns chain info
// result provided by the server.
func (r FutureGetBlockChainInfoResult) Receive() (*btcjson.GetBlockChainInfoResult, error) {
res, err := receiveFuture(r.Response)
res, err := ReceiveFuture(r.Response)
if err != nil {
return nil, err
}
@ -497,7 +497,7 @@ func (c *Client) GetBlockChainInfoAsync() FutureGetBlockChainInfoResult {
cmd := btcjson.NewGetBlockChainInfoCmd()
return FutureGetBlockChainInfoResult{
client: c,
Response: c.sendCmd(cmd),
Response: c.SendCmd(cmd),
}
}
@ -510,12 +510,12 @@ func (c *Client) GetBlockChainInfo() (*btcjson.GetBlockChainInfoResult, error) {
// FutureGetBlockFilterResult is a future promise to deliver the result of a
// GetBlockFilterAsync RPC invocation (or an applicable error).
type FutureGetBlockFilterResult chan *response
type FutureGetBlockFilterResult chan *Response
// Receive waits for the response promised by the future and returns block filter
// Receive waits for the Response promised by the future and returns block filter
// result provided by the server.
func (r FutureGetBlockFilterResult) Receive() (*btcjson.GetBlockFilterResult, error) {
res, err := receiveFuture(r)
res, err := ReceiveFuture(r)
if err != nil {
return nil, err
}
@ -538,7 +538,7 @@ func (c *Client) GetBlockFilterAsync(blockHash chainhash.Hash, filterType *btcjs
hash := blockHash.String()
cmd := btcjson.NewGetBlockFilterCmd(hash, filterType)
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// GetBlockFilter retrieves a BIP0157 content filter for a particular block.
@ -548,12 +548,12 @@ func (c *Client) GetBlockFilter(blockHash chainhash.Hash, filterType *btcjson.Fi
// FutureGetBlockHashResult is a future promise to deliver the result of a
// GetBlockHashAsync RPC invocation (or an applicable error).
type FutureGetBlockHashResult chan *response
type FutureGetBlockHashResult chan *Response
// Receive waits for the response promised by the future and returns the hash of
// Receive waits for the Response promised by the future and returns the hash of
// the block in the best block chain at the given height.
func (r FutureGetBlockHashResult) Receive() (*chainhash.Hash, error) {
res, err := receiveFuture(r)
res, err := ReceiveFuture(r)
if err != nil {
return nil, err
}
@ -574,7 +574,7 @@ func (r FutureGetBlockHashResult) Receive() (*chainhash.Hash, error) {
// See GetBlockHash for the blocking version and more details.
func (c *Client) GetBlockHashAsync(blockHeight int64) FutureGetBlockHashResult {
cmd := btcjson.NewGetBlockHashCmd(blockHeight)
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// GetBlockHash returns the hash of the block in the best block chain at the
@ -585,12 +585,12 @@ func (c *Client) GetBlockHash(blockHeight int64) (*chainhash.Hash, error) {
// FutureGetBlockHeaderResult is a future promise to deliver the result of a
// GetBlockHeaderAsync RPC invocation (or an applicable error).
type FutureGetBlockHeaderResult chan *response
type FutureGetBlockHeaderResult chan *Response
// Receive waits for the response promised by the future and returns the
// Receive waits for the Response promised by the future and returns the
// blockheader requested from the server given its hash.
func (r FutureGetBlockHeaderResult) Receive() (*wire.BlockHeader, error) {
res, err := receiveFuture(r)
res, err := ReceiveFuture(r)
if err != nil {
return nil, err
}
@ -629,7 +629,7 @@ func (c *Client) GetBlockHeaderAsync(blockHash *chainhash.Hash) FutureGetBlockHe
}
cmd := btcjson.NewGetBlockHeaderCmd(hash, btcjson.Bool(false))
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// GetBlockHeader returns the blockheader from the server given its hash.
@ -642,12 +642,12 @@ func (c *Client) GetBlockHeader(blockHash *chainhash.Hash) (*wire.BlockHeader, e
// FutureGetBlockHeaderVerboseResult is a future promise to deliver the result of a
// GetBlockAsync RPC invocation (or an applicable error).
type FutureGetBlockHeaderVerboseResult chan *response
type FutureGetBlockHeaderVerboseResult chan *Response
// Receive waits for the response promised by the future and returns the
// Receive waits for the Response promised by the future and returns the
// data structure of the blockheader requested from the server given its hash.
func (r FutureGetBlockHeaderVerboseResult) Receive() (*btcjson.GetBlockHeaderVerboseResult, error) {
res, err := receiveFuture(r)
res, err := ReceiveFuture(r)
if err != nil {
return nil, err
}
@ -674,7 +674,7 @@ func (c *Client) GetBlockHeaderVerboseAsync(blockHash *chainhash.Hash) FutureGet
}
cmd := btcjson.NewGetBlockHeaderCmd(hash, btcjson.Bool(true))
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// GetBlockHeaderVerbose returns a data structure with information about the
@ -687,13 +687,13 @@ func (c *Client) GetBlockHeaderVerbose(blockHash *chainhash.Hash) (*btcjson.GetB
// FutureGetMempoolEntryResult is a future promise to deliver the result of a
// GetMempoolEntryAsync RPC invocation (or an applicable error).
type FutureGetMempoolEntryResult chan *response
type FutureGetMempoolEntryResult chan *Response
// Receive waits for the response promised by the future and returns a data
// Receive waits for the Response promised by the future and returns a data
// structure with information about the transaction in the memory pool given
// its hash.
func (r FutureGetMempoolEntryResult) Receive() (*btcjson.GetMempoolEntryResult, error) {
res, err := receiveFuture(r)
res, err := ReceiveFuture(r)
if err != nil {
return nil, err
}
@ -715,7 +715,7 @@ func (r FutureGetMempoolEntryResult) Receive() (*btcjson.GetMempoolEntryResult,
// See GetMempoolEntry for the blocking version and more details.
func (c *Client) GetMempoolEntryAsync(txHash string) FutureGetMempoolEntryResult {
cmd := btcjson.NewGetMempoolEntryCmd(txHash)
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// GetMempoolEntry returns a data structure with information about the
@ -726,12 +726,12 @@ func (c *Client) GetMempoolEntry(txHash string) (*btcjson.GetMempoolEntryResult,
// FutureGetRawMempoolResult is a future promise to deliver the result of a
// GetRawMempoolAsync RPC invocation (or an applicable error).
type FutureGetRawMempoolResult chan *response
type FutureGetRawMempoolResult chan *Response
// Receive waits for the response promised by the future and returns the hashes
// Receive waits for the Response promised by the future and returns the hashes
// of all transactions in the memory pool.
func (r FutureGetRawMempoolResult) Receive() ([]*chainhash.Hash, error) {
res, err := receiveFuture(r)
res, err := ReceiveFuture(r)
if err != nil {
return nil, err
}
@ -763,7 +763,7 @@ func (r FutureGetRawMempoolResult) Receive() ([]*chainhash.Hash, error) {
// See GetRawMempool for the blocking version and more details.
func (c *Client) GetRawMempoolAsync() FutureGetRawMempoolResult {
cmd := btcjson.NewGetRawMempoolCmd(btcjson.Bool(false))
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// GetRawMempool returns the hashes of all transactions in the memory pool.
@ -776,13 +776,13 @@ func (c *Client) GetRawMempool() ([]*chainhash.Hash, error) {
// FutureGetRawMempoolVerboseResult is a future promise to deliver the result of
// a GetRawMempoolVerboseAsync RPC invocation (or an applicable error).
type FutureGetRawMempoolVerboseResult chan *response
type FutureGetRawMempoolVerboseResult chan *Response
// Receive waits for the response promised by the future and returns a map of
// Receive waits for the Response promised by the future and returns a map of
// transaction hashes to an associated data structure with information about the
// transaction for all transactions in the memory pool.
func (r FutureGetRawMempoolVerboseResult) Receive() (map[string]btcjson.GetRawMempoolVerboseResult, error) {
res, err := receiveFuture(r)
res, err := ReceiveFuture(r)
if err != nil {
return nil, err
}
@ -804,7 +804,7 @@ func (r FutureGetRawMempoolVerboseResult) Receive() (map[string]btcjson.GetRawMe
// See GetRawMempoolVerbose for the blocking version and more details.
func (c *Client) GetRawMempoolVerboseAsync() FutureGetRawMempoolVerboseResult {
cmd := btcjson.NewGetRawMempoolCmd(btcjson.Bool(true))
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// GetRawMempoolVerbose returns a map of transaction hashes to an associated
@ -818,12 +818,12 @@ func (c *Client) GetRawMempoolVerbose() (map[string]btcjson.GetRawMempoolVerbose
// FutureEstimateFeeResult is a future promise to deliver the result of a
// EstimateFeeAsync RPC invocation (or an applicable error).
type FutureEstimateFeeResult chan *response
type FutureEstimateFeeResult chan *Response
// Receive waits for the response promised by the future and returns the info
// Receive waits for the Response promised by the future and returns the info
// provided by the server.
func (r FutureEstimateFeeResult) Receive() (float64, error) {
res, err := receiveFuture(r)
res, err := ReceiveFuture(r)
if err != nil {
return -1, err
}
@ -845,7 +845,7 @@ func (r FutureEstimateFeeResult) Receive() (float64, error) {
// See EstimateFee for the blocking version and more details.
func (c *Client) EstimateFeeAsync(numBlocks int64) FutureEstimateFeeResult {
cmd := btcjson.NewEstimateFeeCmd(numBlocks)
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// EstimateFee provides an estimated fee in bitcoins per kilobyte.
@ -855,12 +855,12 @@ func (c *Client) EstimateFee(numBlocks int64) (float64, error) {
// FutureEstimateFeeResult is a future promise to deliver the result of a
// EstimateSmartFeeAsync RPC invocation (or an applicable error).
type FutureEstimateSmartFeeResult chan *response
type FutureEstimateSmartFeeResult chan *Response
// Receive waits for the response promised by the future and returns the
// Receive waits for the Response promised by the future and returns the
// estimated fee.
func (r FutureEstimateSmartFeeResult) Receive() (*btcjson.EstimateSmartFeeResult, error) {
res, err := receiveFuture(r)
res, err := ReceiveFuture(r)
if err != nil {
return nil, err
}
@ -880,7 +880,7 @@ func (r FutureEstimateSmartFeeResult) Receive() (*btcjson.EstimateSmartFeeResult
// See EstimateSmartFee for the blocking version and more details.
func (c *Client) EstimateSmartFeeAsync(confTarget int64, mode *btcjson.EstimateSmartFeeMode) FutureEstimateSmartFeeResult {
cmd := btcjson.NewEstimateSmartFeeCmd(confTarget, mode)
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// EstimateSmartFee requests the server to estimate a fee level based on the given parameters.
@ -891,13 +891,13 @@ func (c *Client) EstimateSmartFee(confTarget int64, mode *btcjson.EstimateSmartF
// FutureVerifyChainResult is a future promise to deliver the result of a
// VerifyChainAsync, VerifyChainLevelAsyncRPC, or VerifyChainBlocksAsync
// invocation (or an applicable error).
type FutureVerifyChainResult chan *response
type FutureVerifyChainResult chan *Response
// Receive waits for the response promised by the future and returns whether
// Receive waits for the Response promised by the future and returns whether
// or not the chain verified based on the check level and number of blocks
// to verify specified in the original call.
func (r FutureVerifyChainResult) Receive() (bool, error) {
res, err := receiveFuture(r)
res, err := ReceiveFuture(r)
if err != nil {
return false, err
}
@ -918,7 +918,7 @@ func (r FutureVerifyChainResult) Receive() (bool, error) {
// See VerifyChain for the blocking version and more details.
func (c *Client) VerifyChainAsync() FutureVerifyChainResult {
cmd := btcjson.NewVerifyChainCmd(nil, nil)
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// VerifyChain requests the server to verify the block chain database using
@ -936,7 +936,7 @@ func (c *Client) VerifyChain() (bool, error) {
// See VerifyChainLevel for the blocking version and more details.
func (c *Client) VerifyChainLevelAsync(checkLevel int32) FutureVerifyChainResult {
cmd := btcjson.NewVerifyChainCmd(&checkLevel, nil)
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// VerifyChainLevel requests the server to verify the block chain database using
@ -959,7 +959,7 @@ func (c *Client) VerifyChainLevel(checkLevel int32) (bool, error) {
// See VerifyChainBlocks for the blocking version and more details.
func (c *Client) VerifyChainBlocksAsync(checkLevel, numBlocks int32) FutureVerifyChainResult {
cmd := btcjson.NewVerifyChainCmd(&checkLevel, &numBlocks)
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// VerifyChainBlocks requests the server to verify the block chain database
@ -979,12 +979,12 @@ func (c *Client) VerifyChainBlocks(checkLevel, numBlocks int32) (bool, error) {
// FutureGetTxOutResult is a future promise to deliver the result of a
// GetTxOutAsync RPC invocation (or an applicable error).
type FutureGetTxOutResult chan *response
type FutureGetTxOutResult chan *Response
// Receive waits for the response promised by the future and returns a
// Receive waits for the Response promised by the future and returns a
// transaction given its hash.
func (r FutureGetTxOutResult) Receive() (*btcjson.GetTxOutResult, error) {
res, err := receiveFuture(r)
res, err := ReceiveFuture(r)
if err != nil {
return nil, err
}
@ -1017,7 +1017,7 @@ func (c *Client) GetTxOutAsync(txHash *chainhash.Hash, index uint32, mempool boo
}
cmd := btcjson.NewGetTxOutCmd(hash, index, &mempool)
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// GetTxOut returns the transaction output info if it's unspent and
@ -1028,12 +1028,12 @@ func (c *Client) GetTxOut(txHash *chainhash.Hash, index uint32, mempool bool) (*
// FutureGetTxOutSetInfoResult is a future promise to deliver the result of a
// GetTxOutSetInfoAsync RPC invocation (or an applicable error).
type FutureGetTxOutSetInfoResult chan *response
type FutureGetTxOutSetInfoResult chan *Response
// Receive waits for the response promised by the future and returns the
// Receive waits for the Response promised by the future and returns the
// results of GetTxOutSetInfoAsync RPC invocation.
func (r FutureGetTxOutSetInfoResult) Receive() (*btcjson.GetTxOutSetInfoResult, error) {
res, err := receiveFuture(r)
res, err := ReceiveFuture(r)
if err != nil {
return nil, err
}
@ -1055,7 +1055,7 @@ func (r FutureGetTxOutSetInfoResult) Receive() (*btcjson.GetTxOutSetInfoResult,
// See GetTxOutSetInfo for the blocking version and more details.
func (c *Client) GetTxOutSetInfoAsync() FutureGetTxOutSetInfoResult {
cmd := btcjson.NewGetTxOutSetInfoCmd()
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// GetTxOutSetInfo returns the statistics about the unspent transaction output
@ -1069,15 +1069,15 @@ func (c *Client) GetTxOutSetInfo() (*btcjson.GetTxOutSetInfoResult, error) {
//
// NOTE: This is a btcsuite extension ported from
// github.com/decred/dcrrpcclient.
type FutureRescanBlocksResult chan *response
type FutureRescanBlocksResult chan *Response
// Receive waits for the response promised by the future and returns the
// Receive waits for the Response promised by the future and returns the
// discovered rescanblocks data.
//
// NOTE: This is a btcsuite extension ported from
// github.com/decred/dcrrpcclient.
func (r FutureRescanBlocksResult) Receive() ([]btcjson.RescannedBlock, error) {
res, err := receiveFuture(r)
res, err := ReceiveFuture(r)
if err != nil {
return nil, err
}
@ -1106,7 +1106,7 @@ func (c *Client) RescanBlocksAsync(blockHashes []chainhash.Hash) FutureRescanBlo
}
cmd := btcjson.NewRescanBlocksCmd(strBlockHashes)
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// RescanBlocks rescans the blocks identified by blockHashes, in order, using
@ -1121,12 +1121,12 @@ func (c *Client) RescanBlocks(blockHashes []chainhash.Hash) ([]btcjson.Rescanned
// FutureInvalidateBlockResult is a future promise to deliver the result of a
// InvalidateBlockAsync RPC invocation (or an applicable error).
type FutureInvalidateBlockResult chan *response
type FutureInvalidateBlockResult chan *Response
// Receive waits for the response promised by the future and returns the raw
// Receive waits for the Response promised by the future and returns the raw
// block requested from the server given its hash.
func (r FutureInvalidateBlockResult) Receive() error {
_, err := receiveFuture(r)
_, err := ReceiveFuture(r)
return err
}
@ -1143,7 +1143,7 @@ func (c *Client) InvalidateBlockAsync(blockHash *chainhash.Hash) FutureInvalidat
}
cmd := btcjson.NewInvalidateBlockCmd(hash)
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// InvalidateBlock invalidates a specific block.
@ -1153,12 +1153,12 @@ func (c *Client) InvalidateBlock(blockHash *chainhash.Hash) error {
// FutureGetCFilterResult is a future promise to deliver the result of a
// GetCFilterAsync RPC invocation (or an applicable error).
type FutureGetCFilterResult chan *response
type FutureGetCFilterResult chan *Response
// Receive waits for the response promised by the future and returns the raw
// Receive waits for the Response promised by the future and returns the raw
// filter requested from the server given its block hash.
func (r FutureGetCFilterResult) Receive() (*wire.MsgCFilter, error) {
res, err := receiveFuture(r)
res, err := ReceiveFuture(r)
if err != nil {
return nil, err
}
@ -1197,7 +1197,7 @@ func (c *Client) GetCFilterAsync(blockHash *chainhash.Hash,
}
cmd := btcjson.NewGetCFilterCmd(hash, filterType)
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// GetCFilter returns a raw filter from the server given its block hash.
@ -1208,12 +1208,12 @@ func (c *Client) GetCFilter(blockHash *chainhash.Hash,
// FutureGetCFilterHeaderResult is a future promise to deliver the result of a
// GetCFilterHeaderAsync RPC invocation (or an applicable error).
type FutureGetCFilterHeaderResult chan *response
type FutureGetCFilterHeaderResult chan *Response
// Receive waits for the response promised by the future and returns the raw
// Receive waits for the Response promised by the future and returns the raw
// filter header requested from the server given its block hash.
func (r FutureGetCFilterHeaderResult) Receive() (*wire.MsgCFHeaders, error) {
res, err := receiveFuture(r)
res, err := ReceiveFuture(r)
if err != nil {
return nil, err
}
@ -1250,7 +1250,7 @@ func (c *Client) GetCFilterHeaderAsync(blockHash *chainhash.Hash,
}
cmd := btcjson.NewGetCFilterHeaderCmd(hash, filterType)
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// GetCFilterHeader returns a raw filter header from the server given its block
@ -1262,12 +1262,12 @@ func (c *Client) GetCFilterHeader(blockHash *chainhash.Hash,
// FutureGetBlockStatsResult is a future promise to deliver the result of a
// GetBlockStatsAsync RPC invocation (or an applicable error).
type FutureGetBlockStatsResult chan *response
type FutureGetBlockStatsResult chan *Response
// Receive waits for the response promised by the future and returns statistics
// Receive waits for the Response promised by the future and returns statistics
// of a block at a certain height.
func (r FutureGetBlockStatsResult) Receive() (*btcjson.GetBlockStatsResult, error) {
res, err := receiveFuture(r)
res, err := ReceiveFuture(r)
if err != nil {
return nil, err
}
@ -1292,7 +1292,7 @@ func (c *Client) GetBlockStatsAsync(hashOrHeight interface{}, stats *[]string) F
}
cmd := btcjson.NewGetBlockStatsCmd(btcjson.HashOrHeight{Value: hashOrHeight}, stats)
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// GetBlockStats returns block statistics. First argument specifies height or hash of the target block.
@ -1303,12 +1303,12 @@ func (c *Client) GetBlockStats(hashOrHeight interface{}, stats *[]string) (*btcj
// FutureDeriveAddressesResult is a future promise to deliver the result of an
// DeriveAddressesAsync RPC invocation (or an applicable error).
type FutureDeriveAddressesResult chan *response
type FutureDeriveAddressesResult chan *Response
// Receive waits for the response promised by the future and derives one or more addresses
// Receive waits for the Response promised by the future and derives one or more addresses
// corresponding to the given output descriptor.
func (r FutureDeriveAddressesResult) Receive() (*btcjson.DeriveAddressesResult, error) {
res, err := receiveFuture(r)
res, err := ReceiveFuture(r)
if err != nil {
return nil, err
}
@ -1330,7 +1330,7 @@ func (r FutureDeriveAddressesResult) Receive() (*btcjson.DeriveAddressesResult,
// See DeriveAddresses for the blocking version and more details.
func (c *Client) DeriveAddressesAsync(descriptor string, descriptorRange *btcjson.DescriptorRange) FutureDeriveAddressesResult {
cmd := btcjson.NewDeriveAddressesCmd(descriptor, descriptorRange)
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// DeriveAddresses derives one or more addresses corresponding to an output
@ -1342,12 +1342,12 @@ func (c *Client) DeriveAddresses(descriptor string, descriptorRange *btcjson.Des
// FutureGetDescriptorInfoResult is a future promise to deliver the result of a
// GetDescriptorInfoAsync RPC invocation (or an applicable error).
type FutureGetDescriptorInfoResult chan *response
type FutureGetDescriptorInfoResult chan *Response
// Receive waits for the response promised by the future and returns the analysed
// Receive waits for the Response promised by the future and returns the analysed
// info of the descriptor.
func (r FutureGetDescriptorInfoResult) Receive() (*btcjson.GetDescriptorInfoResult, error) {
res, err := receiveFuture(r)
res, err := ReceiveFuture(r)
if err != nil {
return nil, err
}
@ -1369,7 +1369,7 @@ func (r FutureGetDescriptorInfoResult) Receive() (*btcjson.GetDescriptorInfoResu
// See GetDescriptorInfo for the blocking version and more details.
func (c *Client) GetDescriptorInfoAsync(descriptor string) FutureGetDescriptorInfoResult {
cmd := btcjson.NewGetDescriptorInfoCmd(descriptor)
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// GetDescriptorInfo returns the analysed info of a descriptor string, by invoking the

View File

@ -0,0 +1,32 @@
Custom Command Example
======================
This example shows how to use custom commands with the rpcclient package, by
implementing the `name_show` command from Namecoin Core.
## Running the Example
The first step is to use `go get` to download and install the rpcclient package:
```bash
$ go get github.com/btcsuite/btcd/rpcclient
```
Next, modify the `main.go` source to specify the correct RPC username and
password for the RPC server of your Namecoin Core node:
```Go
User: "yourrpcuser",
Pass: "yourrpcpass",
```
Finally, navigate to the example's directory and run it with:
```bash
$ cd $GOPATH/src/github.com/btcsuite/btcd/rpcclient/examples/customcommand
$ go run *.go
```
## License
This example is licensed under the [copyfree](http://copyfree.org) ISC License.

View File

@ -0,0 +1,110 @@
// Copyright (c) 2014-2017 The btcsuite developers
// Copyright (c) 2019-2020 The Namecoin developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.
package main
import (
"encoding/json"
"log"
"github.com/btcsuite/btcd/btcjson"
"github.com/btcsuite/btcd/rpcclient"
)
// NameShowCmd defines the name_show JSON-RPC command.
type NameShowCmd struct {
Name string
}
// NameShowResult models the data from the name_show command.
type NameShowResult struct {
Name string `json:"name"`
NameEncoding string `json:"name_encoding"`
NameError string `json:"name_error"`
Value string `json:"value"`
ValueEncoding string `json:"value_encoding"`
ValueError string `json:"value_error"`
TxID string `json:"txid"`
Vout uint32 `json:"vout"`
Address string `json:"address"`
IsMine bool `json:"ismine"`
Height int32 `json:"height"`
ExpiresIn int32 `json:"expires_in"`
Expired bool `json:"expired"`
}
// FutureNameShowResult is a future promise to deliver the result
// of a NameShowAsync RPC invocation (or an applicable error).
type FutureNameShowResult chan *rpcclient.Response
// Receive waits for the Response promised by the future and returns detailed
// information about a name.
func (r FutureNameShowResult) Receive() (*NameShowResult, error) {
res, err := rpcclient.ReceiveFuture(r)
if err != nil {
return nil, err
}
// Unmarshal result as a name_show result object
var nameShow NameShowResult
err = json.Unmarshal(res, &nameShow)
if err != nil {
return nil, err
}
return &nameShow, nil
}
// NameShowAsync returns an instance of a type that can be used to get the
// result of the RPC at some future time by invoking the Receive function on
// the returned instance.
//
// See NameShow for the blocking version and more details.
func NameShowAsync(c *rpcclient.Client, name string) FutureNameShowResult {
cmd := &NameShowCmd{
Name: name,
}
return c.SendCmd(cmd)
}
// NameShow returns detailed information about a name.
func NameShow(c *rpcclient.Client, name string) (*NameShowResult, error) {
return NameShowAsync(c, name).Receive()
}
func init() {
// No special flags for commands in this file.
flags := btcjson.UsageFlag(0)
btcjson.MustRegisterCmd("name_show", (*NameShowCmd)(nil), flags)
}
func main() {
// Connect to local namecoin core RPC server using HTTP POST mode.
connCfg := &rpcclient.ConnConfig{
Host: "localhost:8336",
User: "yourrpcuser",
Pass: "yourrpcpass",
HTTPPostMode: true, // Namecoin core only supports HTTP POST mode
DisableTLS: true, // Namecoin core does not provide TLS by default
}
// Notice the notification parameter is nil since notifications are
// not supported in HTTP POST mode.
client, err := rpcclient.New(connCfg, nil)
if err != nil {
log.Fatal(err)
}
defer client.Shutdown()
// Get the current block count.
result, err := NameShow(client, "d/namecoin")
if err != nil {
log.Fatal(err)
}
value := result.Value
log.Printf("Value of d/namecoin: %s", value)
}

View File

@ -20,13 +20,13 @@ import (
// FutureDebugLevelResult is a future promise to deliver the result of a
// DebugLevelAsync RPC invocation (or an applicable error).
type FutureDebugLevelResult chan *response
type FutureDebugLevelResult chan *Response
// Receive waits for the response promised by the future and returns the result
// Receive waits for the Response promised by the future and returns the result
// of setting the debug logging level to the passed level specification or the
// list of of the available subsystems for the special keyword 'show'.
func (r FutureDebugLevelResult) Receive() (string, error) {
res, err := receiveFuture(r)
res, err := ReceiveFuture(r)
if err != nil {
return "", err
}
@ -49,7 +49,7 @@ func (r FutureDebugLevelResult) Receive() (string, error) {
// NOTE: This is a btcd extension.
func (c *Client) DebugLevelAsync(levelSpec string) FutureDebugLevelResult {
cmd := btcjson.NewDebugLevelCmd(levelSpec)
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// DebugLevel dynamically sets the debug logging level to the passed level
@ -68,11 +68,11 @@ func (c *Client) DebugLevel(levelSpec string) (string, error) {
// FutureCreateEncryptedWalletResult is a future promise to deliver the error
// result of a CreateEncryptedWalletAsync RPC invocation.
type FutureCreateEncryptedWalletResult chan *response
type FutureCreateEncryptedWalletResult chan *Response
// Receive waits for and returns the error response promised by the future.
// Receive waits for and returns the error Response promised by the future.
func (r FutureCreateEncryptedWalletResult) Receive() error {
_, err := receiveFuture(r)
_, err := ReceiveFuture(r)
return err
}
@ -85,7 +85,7 @@ func (r FutureCreateEncryptedWalletResult) Receive() error {
// NOTE: This is a btcwallet extension.
func (c *Client) CreateEncryptedWalletAsync(passphrase string) FutureCreateEncryptedWalletResult {
cmd := btcjson.NewCreateEncryptedWalletCmd(passphrase)
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// CreateEncryptedWallet requests the creation of an encrypted wallet. Wallets
@ -102,12 +102,12 @@ func (c *Client) CreateEncryptedWallet(passphrase string) error {
// FutureListAddressTransactionsResult is a future promise to deliver the result
// of a ListAddressTransactionsAsync RPC invocation (or an applicable error).
type FutureListAddressTransactionsResult chan *response
type FutureListAddressTransactionsResult chan *Response
// Receive waits for the response promised by the future and returns information
// Receive waits for the Response promised by the future and returns information
// about all transactions associated with the provided addresses.
func (r FutureListAddressTransactionsResult) Receive() ([]btcjson.ListTransactionsResult, error) {
res, err := receiveFuture(r)
res, err := ReceiveFuture(r)
if err != nil {
return nil, err
}
@ -135,7 +135,7 @@ func (c *Client) ListAddressTransactionsAsync(addresses []btcutil.Address, accou
addrs = append(addrs, addr.EncodeAddress())
}
cmd := btcjson.NewListAddressTransactionsCmd(addrs, &account)
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// ListAddressTransactions returns information about all transactions associated
@ -148,12 +148,12 @@ func (c *Client) ListAddressTransactions(addresses []btcutil.Address, account st
// FutureGetBestBlockResult is a future promise to deliver the result of a
// GetBestBlockAsync RPC invocation (or an applicable error).
type FutureGetBestBlockResult chan *response
type FutureGetBestBlockResult chan *Response
// Receive waits for the response promised by the future and returns the hash
// Receive waits for the Response promised by the future and returns the hash
// and height of the block in the longest (best) chain.
func (r FutureGetBestBlockResult) Receive() (*chainhash.Hash, int32, error) {
res, err := receiveFuture(r)
res, err := ReceiveFuture(r)
if err != nil {
return nil, 0, err
}
@ -183,7 +183,7 @@ func (r FutureGetBestBlockResult) Receive() (*chainhash.Hash, int32, error) {
// NOTE: This is a btcd extension.
func (c *Client) GetBestBlockAsync() FutureGetBestBlockResult {
cmd := btcjson.NewGetBestBlockCmd()
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// GetBestBlock returns the hash and height of the block in the longest (best)
@ -196,12 +196,12 @@ func (c *Client) GetBestBlock() (*chainhash.Hash, int32, error) {
// FutureGetCurrentNetResult is a future promise to deliver the result of a
// GetCurrentNetAsync RPC invocation (or an applicable error).
type FutureGetCurrentNetResult chan *response
type FutureGetCurrentNetResult chan *Response
// Receive waits for the response promised by the future and returns the network
// Receive waits for the Response promised by the future and returns the network
// the server is running on.
func (r FutureGetCurrentNetResult) Receive() (wire.BitcoinNet, error) {
res, err := receiveFuture(r)
res, err := ReceiveFuture(r)
if err != nil {
return 0, err
}
@ -225,7 +225,7 @@ func (r FutureGetCurrentNetResult) Receive() (wire.BitcoinNet, error) {
// NOTE: This is a btcd extension.
func (c *Client) GetCurrentNetAsync() FutureGetCurrentNetResult {
cmd := btcjson.NewGetCurrentNetCmd()
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// GetCurrentNet returns the network the server is running on.
@ -240,15 +240,15 @@ func (c *Client) GetCurrentNet() (wire.BitcoinNet, error) {
//
// NOTE: This is a btcsuite extension ported from
// github.com/decred/dcrrpcclient.
type FutureGetHeadersResult chan *response
type FutureGetHeadersResult chan *Response
// Receive waits for the response promised by the future and returns the
// Receive waits for the Response promised by the future and returns the
// getheaders result.
//
// NOTE: This is a btcsuite extension ported from
// github.com/decred/dcrrpcclient.
func (r FutureGetHeadersResult) Receive() ([]wire.BlockHeader, error) {
res, err := receiveFuture(r)
res, err := ReceiveFuture(r)
if err != nil {
return nil, err
}
@ -292,7 +292,7 @@ func (c *Client) GetHeadersAsync(blockLocators []chainhash.Hash, hashStop *chain
hash = hashStop.String()
}
cmd := btcjson.NewGetHeadersCmd(locators, hash)
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// GetHeaders mimics the wire protocol getheaders and headers messages by
@ -307,12 +307,12 @@ func (c *Client) GetHeaders(blockLocators []chainhash.Hash, hashStop *chainhash.
// FutureExportWatchingWalletResult is a future promise to deliver the result of
// an ExportWatchingWalletAsync RPC invocation (or an applicable error).
type FutureExportWatchingWalletResult chan *response
type FutureExportWatchingWalletResult chan *Response
// Receive waits for the response promised by the future and returns the
// Receive waits for the Response promised by the future and returns the
// exported wallet.
func (r FutureExportWatchingWalletResult) Receive() ([]byte, []byte, error) {
res, err := receiveFuture(r)
res, err := ReceiveFuture(r)
if err != nil {
return nil, nil, err
}
@ -361,7 +361,7 @@ func (r FutureExportWatchingWalletResult) Receive() ([]byte, []byte, error) {
// NOTE: This is a btcwallet extension.
func (c *Client) ExportWatchingWalletAsync(account string) FutureExportWatchingWalletResult {
cmd := btcjson.NewExportWatchingWalletCmd(&account, btcjson.Bool(true))
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// ExportWatchingWallet returns the raw bytes for a watching-only version of
@ -376,12 +376,12 @@ func (c *Client) ExportWatchingWallet(account string) ([]byte, []byte, error) {
// FutureSessionResult is a future promise to deliver the result of a
// SessionAsync RPC invocation (or an applicable error).
type FutureSessionResult chan *response
type FutureSessionResult chan *Response
// Receive waits for the response promised by the future and returns the
// Receive waits for the Response promised by the future and returns the
// session result.
func (r FutureSessionResult) Receive() (*btcjson.SessionResult, error) {
res, err := receiveFuture(r)
res, err := ReceiveFuture(r)
if err != nil {
return nil, err
}
@ -410,7 +410,7 @@ func (c *Client) SessionAsync() FutureSessionResult {
}
cmd := btcjson.NewSessionCmd()
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// Session returns details regarding a websocket client's current connection.
@ -427,16 +427,16 @@ func (c *Client) Session() (*btcjson.SessionResult, error) {
//
// NOTE: This is a btcsuite extension ported from
// github.com/decred/dcrrpcclient.
type FutureVersionResult chan *response
type FutureVersionResult chan *Response
// Receive waits for the response promised by the future and returns the version
// Receive waits for the Response promised by the future and returns the version
// result.
//
// NOTE: This is a btcsuite extension ported from
// github.com/decred/dcrrpcclient.
func (r FutureVersionResult) Receive() (map[string]btcjson.VersionResult,
error) {
res, err := receiveFuture(r)
res, err := ReceiveFuture(r)
if err != nil {
return nil, err
}
@ -461,7 +461,7 @@ func (r FutureVersionResult) Receive() (map[string]btcjson.VersionResult,
// github.com/decred/dcrrpcclient.
func (c *Client) VersionAsync() FutureVersionResult {
cmd := btcjson.NewVersionCmd()
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// Version returns information about the server's JSON-RPC API versions.

View File

@ -103,7 +103,7 @@ type jsonRequest struct {
method string
cmd interface{}
marshalledJSON []byte
responseChan chan *response
responseChan chan *Response
}
// BackendVersion represents the version of the backend the client is currently
@ -300,13 +300,13 @@ func (c *Client) trackRegisteredNtfns(cmd interface{}) {
// FutureGetBulkResult waits for the responses promised by the future
// and returns them in a channel
type FutureGetBulkResult chan *response
type FutureGetBulkResult chan *Response
// Receive waits for the response promised by the future and returns an map
// of results by request id
func (r FutureGetBulkResult) Receive() (BulkResult, error) {
m := make(BulkResult)
res, err := receiveFuture(r)
res, err := ReceiveFuture(r)
if err != nil {
return nil, err
}
@ -357,9 +357,9 @@ type rawResponse struct {
Error *btcjson.RPCError `json:"error"`
}
// response is the raw bytes of a JSON-RPC result, or the error if the response
// Response is the raw bytes of a JSON-RPC result, or the error if the response
// error object was non-null.
type response struct {
type Response struct {
result []byte
err error
}
@ -440,7 +440,7 @@ func (c *Client) handleMessage(msg []byte) {
// Deliver the response.
result, err := in.rawResponse.result()
request.responseChan <- &response{result: result, err: err}
request.responseChan <- &Response{result: result, err: err}
}
// shouldLogReadError returns whether or not the passed error, which is expected
@ -770,7 +770,7 @@ func (c *Client) handleSendPostMessage(details *sendPostDetails) {
log.Tracef("Sending command [%s] with id %d", jReq.method, jReq.id)
httpResponse, err := c.httpClient.Do(details.httpRequest)
if err != nil {
jReq.responseChan <- &response{err: err}
jReq.responseChan <- &Response{err: err}
return
}
@ -779,7 +779,7 @@ func (c *Client) handleSendPostMessage(details *sendPostDetails) {
httpResponse.Body.Close()
if err != nil {
err = fmt.Errorf("error reading json reply: %v", err)
jReq.responseChan <- &response{err: err}
jReq.responseChan <- &Response{err: err}
return
}
@ -797,7 +797,7 @@ func (c *Client) handleSendPostMessage(details *sendPostDetails) {
// response bytes.
err = fmt.Errorf("status code: %d, response: %q",
httpResponse.StatusCode, string(respBytes))
jReq.responseChan <- &response{err: err}
jReq.responseChan <- &Response{err: err}
return
}
var res []byte
@ -808,7 +808,7 @@ func (c *Client) handleSendPostMessage(details *sendPostDetails) {
} else {
res, err = resp.result()
}
jReq.responseChan <- &response{result: res, err: err}
jReq.responseChan <- &Response{result: res, err: err}
}
// sendPostHandler handles all outgoing messages when the client is running
@ -835,7 +835,7 @@ cleanup:
for {
select {
case details := <-c.sendPostChan:
details.jsonRequest.responseChan <- &response{
details.jsonRequest.responseChan <- &Response{
result: nil,
err: ErrClientShutdown,
}
@ -856,7 +856,7 @@ func (c *Client) sendPostRequest(httpReq *http.Request, jReq *jsonRequest) {
// Don't send the message if shutting down.
select {
case <-c.shutdown:
jReq.responseChan <- &response{result: nil, err: ErrClientShutdown}
jReq.responseChan <- &Response{result: nil, err: ErrClientShutdown}
default:
}
@ -869,17 +869,17 @@ func (c *Client) sendPostRequest(httpReq *http.Request, jReq *jsonRequest) {
// newFutureError returns a new future result channel that already has the
// passed error waitin on the channel with the reply set to nil. This is useful
// to easily return errors from the various Async functions.
func newFutureError(err error) chan *response {
responseChan := make(chan *response, 1)
responseChan <- &response{err: err}
func newFutureError(err error) chan *Response {
responseChan := make(chan *Response, 1)
responseChan <- &Response{err: err}
return responseChan
}
// receiveFuture receives from the passed futureResult channel to extract a
// ReceiveFuture receives from the passed futureResult channel to extract a
// reply or any errors. The examined errors include an error in the
// futureResult and the error in the reply from the server. This will block
// until the result is available on the passed channel.
func receiveFuture(f chan *response) ([]byte, error) {
func ReceiveFuture(f chan *Response) ([]byte, error) {
// Wait for a response on the returned channel.
r := <-f
return r.result, r.err
@ -900,7 +900,7 @@ func (c *Client) sendPost(jReq *jsonRequest) {
bodyReader := bytes.NewReader(jReq.marshalledJSON)
httpReq, err := http.NewRequest("POST", url, bodyReader)
if err != nil {
jReq.responseChan <- &response{result: nil, err: err}
jReq.responseChan <- &Response{result: nil, err: err}
return
}
httpReq.Close = true
@ -912,7 +912,7 @@ func (c *Client) sendPost(jReq *jsonRequest) {
// Configure basic access authorization.
user, pass, err := c.config.getAuth()
if err != nil {
jReq.responseChan <- &response{result: nil, err: err}
jReq.responseChan <- &Response{result: nil, err: err}
return
}
httpReq.SetBasicAuth(user, pass)
@ -945,7 +945,7 @@ func (c *Client) sendRequest(jReq *jsonRequest) {
select {
case <-c.connEstablished:
default:
jReq.responseChan <- &response{err: ErrClientNotConnected}
jReq.responseChan <- &Response{err: ErrClientNotConnected}
return
}
@ -954,18 +954,18 @@ func (c *Client) sendRequest(jReq *jsonRequest) {
// channel. Then send the marshalled request via the websocket
// connection.
if err := c.addRequest(jReq); err != nil {
jReq.responseChan <- &response{err: err}
jReq.responseChan <- &Response{err: err}
return
}
log.Tracef("Sending command [%s] with id %d", jReq.method, jReq.id)
c.sendMessage(jReq.marshalledJSON)
}
// sendCmd sends the passed command to the associated server and returns a
// SendCmd sends the passed command to the associated server and returns a
// response channel on which the reply will be delivered at some point in the
// future. It handles both websocket and HTTP POST mode depending on the
// configuration of the client.
func (c *Client) sendCmd(cmd interface{}) chan *response {
func (c *Client) SendCmd(cmd interface{}) chan *Response {
rpcVersion := btcjson.RpcVersion1
if c.batch {
rpcVersion = btcjson.RpcVersion2
@ -984,7 +984,7 @@ func (c *Client) sendCmd(cmd interface{}) chan *response {
}
// Generate the request and send it along with a channel to respond on.
responseChan := make(chan *response, 1)
responseChan := make(chan *Response, 1)
jReq := &jsonRequest{
id: id,
method: method,
@ -1004,7 +1004,7 @@ func (c *Client) sendCmd(cmd interface{}) chan *response {
func (c *Client) sendCmdAndWait(cmd interface{}) (interface{}, error) {
// Marshal the command to JSON-RPC, send it to the connected server, and
// wait for a response on the returned channel.
return receiveFuture(c.sendCmd(cmd))
return ReceiveFuture(c.SendCmd(cmd))
}
// Disconnected returns whether or not the server is disconnected. If a
@ -1085,7 +1085,7 @@ func (c *Client) Disconnect() {
if c.config.DisableAutoReconnect {
for e := c.requestList.Front(); e != nil; e = e.Next() {
req := e.Value.(*jsonRequest)
req.responseChan <- &response{
req.responseChan <- &Response{
result: nil,
err: ErrClientDisconnect,
}
@ -1113,7 +1113,7 @@ func (c *Client) Shutdown() {
// Send the ErrClientShutdown error to any pending requests.
for e := c.requestList.Front(); e != nil; e = e.Next() {
req := e.Value.(*jsonRequest)
req.responseChan <- &response{
req.responseChan <- &Response{
result: nil,
err: ErrClientShutdown,
}
@ -1623,7 +1623,7 @@ func (c *Client) BackendVersion() (BackendVersion, error) {
func (c *Client) sendAsync() FutureGetBulkResult {
// convert the array of marshalled json requests to a single request we can send
responseChan := make(chan *response, 1)
responseChan := make(chan *Response, 1)
marshalledRequest := []byte("[")
for iter := c.batchList.Front(); iter != nil; iter = iter.Next() {
request := iter.Value.(*jsonRequest)
@ -1678,7 +1678,7 @@ func (c *Client) Send() error {
requestError = individualResult.Error
}
result := response{
result := Response{
result: fullResult,
err: requestError,
}

View File

@ -16,12 +16,12 @@ import (
// FutureGenerateResult is a future promise to deliver the result of a
// GenerateAsync RPC invocation (or an applicable error).
type FutureGenerateResult chan *response
type FutureGenerateResult chan *Response
// Receive waits for the response promised by the future and returns a list of
// Receive waits for the Response promised by the future and returns a list of
// block hashes generated by the call.
func (r FutureGenerateResult) Receive() ([]*chainhash.Hash, error) {
res, err := receiveFuture(r)
res, err := ReceiveFuture(r)
if err != nil {
return nil, err
}
@ -53,7 +53,7 @@ func (r FutureGenerateResult) Receive() ([]*chainhash.Hash, error) {
// See Generate for the blocking version and more details.
func (c *Client) GenerateAsync(numBlocks uint32) FutureGenerateResult {
cmd := btcjson.NewGenerateCmd(numBlocks)
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// Generate generates numBlocks blocks and returns their hashes.
@ -63,12 +63,12 @@ func (c *Client) Generate(numBlocks uint32) ([]*chainhash.Hash, error) {
// FutureGenerateToAddressResult is a future promise to deliver the result of a
// GenerateToAddressResult RPC invocation (or an applicable error).
type FutureGenerateToAddressResult chan *response
type FutureGenerateToAddressResult chan *Response
// Receive waits for the response promised by the future and returns the hashes of
// Receive waits for the Response promised by the future and returns the hashes of
// of the generated blocks.
func (f FutureGenerateToAddressResult) Receive() ([]*chainhash.Hash, error) {
res, err := receiveFuture(f)
res, err := ReceiveFuture(f)
if err != nil {
return nil, err
}
@ -100,7 +100,7 @@ func (f FutureGenerateToAddressResult) Receive() ([]*chainhash.Hash, error) {
// See GenerateToAddress for the blocking version and more details.
func (c *Client) GenerateToAddressAsync(numBlocks int64, address btcutil.Address, maxTries *int64) FutureGenerateToAddressResult {
cmd := btcjson.NewGenerateToAddressCmd(numBlocks, address.EncodeAddress(), maxTries)
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// GenerateToAddress generates numBlocks blocks to the given address and returns their hashes.
@ -110,12 +110,12 @@ func (c *Client) GenerateToAddress(numBlocks int64, address btcutil.Address, max
// FutureGetGenerateResult is a future promise to deliver the result of a
// GetGenerateAsync RPC invocation (or an applicable error).
type FutureGetGenerateResult chan *response
type FutureGetGenerateResult chan *Response
// Receive waits for the response promised by the future and returns true if the
// Receive waits for the Response promised by the future and returns true if the
// server is set to mine, otherwise false.
func (r FutureGetGenerateResult) Receive() (bool, error) {
res, err := receiveFuture(r)
res, err := ReceiveFuture(r)
if err != nil {
return false, err
}
@ -137,7 +137,7 @@ func (r FutureGetGenerateResult) Receive() (bool, error) {
// See GetGenerate for the blocking version and more details.
func (c *Client) GetGenerateAsync() FutureGetGenerateResult {
cmd := btcjson.NewGetGenerateCmd()
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// GetGenerate returns true if the server is set to mine, otherwise false.
@ -147,12 +147,12 @@ func (c *Client) GetGenerate() (bool, error) {
// FutureSetGenerateResult is a future promise to deliver the result of a
// SetGenerateAsync RPC invocation (or an applicable error).
type FutureSetGenerateResult chan *response
type FutureSetGenerateResult chan *Response
// Receive waits for the response promised by the future and returns an error if
// Receive waits for the Response promised by the future and returns an error if
// any occurred when setting the server to generate coins (mine) or not.
func (r FutureSetGenerateResult) Receive() error {
_, err := receiveFuture(r)
_, err := ReceiveFuture(r)
return err
}
@ -163,7 +163,7 @@ func (r FutureSetGenerateResult) Receive() error {
// See SetGenerate for the blocking version and more details.
func (c *Client) SetGenerateAsync(enable bool, numCPUs int) FutureSetGenerateResult {
cmd := btcjson.NewSetGenerateCmd(enable, &numCPUs)
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// SetGenerate sets the server to generate coins (mine) or not.
@ -173,13 +173,13 @@ func (c *Client) SetGenerate(enable bool, numCPUs int) error {
// FutureGetHashesPerSecResult is a future promise to deliver the result of a
// GetHashesPerSecAsync RPC invocation (or an applicable error).
type FutureGetHashesPerSecResult chan *response
type FutureGetHashesPerSecResult chan *Response
// Receive waits for the response promised by the future and returns a recent
// Receive waits for the Response promised by the future and returns a recent
// hashes per second performance measurement while generating coins (mining).
// Zero is returned if the server is not mining.
func (r FutureGetHashesPerSecResult) Receive() (int64, error) {
res, err := receiveFuture(r)
res, err := ReceiveFuture(r)
if err != nil {
return -1, err
}
@ -201,7 +201,7 @@ func (r FutureGetHashesPerSecResult) Receive() (int64, error) {
// See GetHashesPerSec for the blocking version and more details.
func (c *Client) GetHashesPerSecAsync() FutureGetHashesPerSecResult {
cmd := btcjson.NewGetHashesPerSecCmd()
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// GetHashesPerSec returns a recent hashes per second performance measurement
@ -213,12 +213,12 @@ func (c *Client) GetHashesPerSec() (int64, error) {
// FutureGetMiningInfoResult is a future promise to deliver the result of a
// GetMiningInfoAsync RPC invocation (or an applicable error).
type FutureGetMiningInfoResult chan *response
type FutureGetMiningInfoResult chan *Response
// Receive waits for the response promised by the future and returns the mining
// Receive waits for the Response promised by the future and returns the mining
// information.
func (r FutureGetMiningInfoResult) Receive() (*btcjson.GetMiningInfoResult, error) {
res, err := receiveFuture(r)
res, err := ReceiveFuture(r)
if err != nil {
return nil, err
}
@ -240,7 +240,7 @@ func (r FutureGetMiningInfoResult) Receive() (*btcjson.GetMiningInfoResult, erro
// See GetMiningInfo for the blocking version and more details.
func (c *Client) GetMiningInfoAsync() FutureGetMiningInfoResult {
cmd := btcjson.NewGetMiningInfoCmd()
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// GetMiningInfo returns mining information.
@ -250,13 +250,13 @@ func (c *Client) GetMiningInfo() (*btcjson.GetMiningInfoResult, error) {
// FutureGetNetworkHashPS is a future promise to deliver the result of a
// GetNetworkHashPSAsync RPC invocation (or an applicable error).
type FutureGetNetworkHashPS chan *response
type FutureGetNetworkHashPS chan *Response
// Receive waits for the response promised by the future and returns the
// Receive waits for the Response promised by the future and returns the
// estimated network hashes per second for the block heights provided by the
// parameters.
func (r FutureGetNetworkHashPS) Receive() (int64, error) {
res, err := receiveFuture(r)
res, err := ReceiveFuture(r)
if err != nil {
return -1, err
}
@ -278,7 +278,7 @@ func (r FutureGetNetworkHashPS) Receive() (int64, error) {
// See GetNetworkHashPS for the blocking version and more details.
func (c *Client) GetNetworkHashPSAsync() FutureGetNetworkHashPS {
cmd := btcjson.NewGetNetworkHashPSCmd(nil, nil)
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// GetNetworkHashPS returns the estimated network hashes per second using the
@ -297,7 +297,7 @@ func (c *Client) GetNetworkHashPS() (int64, error) {
// See GetNetworkHashPS2 for the blocking version and more details.
func (c *Client) GetNetworkHashPS2Async(blocks int) FutureGetNetworkHashPS {
cmd := btcjson.NewGetNetworkHashPSCmd(&blocks, nil)
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// GetNetworkHashPS2 returns the estimated network hashes per second for the
@ -318,7 +318,7 @@ func (c *Client) GetNetworkHashPS2(blocks int) (int64, error) {
// See GetNetworkHashPS3 for the blocking version and more details.
func (c *Client) GetNetworkHashPS3Async(blocks, height int) FutureGetNetworkHashPS {
cmd := btcjson.NewGetNetworkHashPSCmd(&blocks, &height)
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// GetNetworkHashPS3 returns the estimated network hashes per second for the
@ -333,12 +333,12 @@ func (c *Client) GetNetworkHashPS3(blocks, height int) (int64, error) {
// FutureGetWork is a future promise to deliver the result of a
// GetWorkAsync RPC invocation (or an applicable error).
type FutureGetWork chan *response
type FutureGetWork chan *Response
// Receive waits for the response promised by the future and returns the hash
// Receive waits for the Response promised by the future and returns the hash
// data to work on.
func (r FutureGetWork) Receive() (*btcjson.GetWorkResult, error) {
res, err := receiveFuture(r)
res, err := ReceiveFuture(r)
if err != nil {
return nil, err
}
@ -360,7 +360,7 @@ func (r FutureGetWork) Receive() (*btcjson.GetWorkResult, error) {
// See GetWork for the blocking version and more details.
func (c *Client) GetWorkAsync() FutureGetWork {
cmd := btcjson.NewGetWorkCmd(nil)
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// GetWork returns hash data to work on.
@ -372,12 +372,12 @@ func (c *Client) GetWork() (*btcjson.GetWorkResult, error) {
// FutureGetWorkSubmit is a future promise to deliver the result of a
// GetWorkSubmitAsync RPC invocation (or an applicable error).
type FutureGetWorkSubmit chan *response
type FutureGetWorkSubmit chan *Response
// Receive waits for the response promised by the future and returns whether
// Receive waits for the Response promised by the future and returns whether
// or not the submitted block header was accepted.
func (r FutureGetWorkSubmit) Receive() (bool, error) {
res, err := receiveFuture(r)
res, err := ReceiveFuture(r)
if err != nil {
return false, err
}
@ -399,7 +399,7 @@ func (r FutureGetWorkSubmit) Receive() (bool, error) {
// See GetWorkSubmit for the blocking version and more details.
func (c *Client) GetWorkSubmitAsync(data string) FutureGetWorkSubmit {
cmd := btcjson.NewGetWorkCmd(&data)
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// GetWorkSubmit submits a block header which is a solution to previously
@ -412,12 +412,12 @@ func (c *Client) GetWorkSubmit(data string) (bool, error) {
// FutureSubmitBlockResult is a future promise to deliver the result of a
// SubmitBlockAsync RPC invocation (or an applicable error).
type FutureSubmitBlockResult chan *response
type FutureSubmitBlockResult chan *Response
// Receive waits for the response promised by the future and returns an error if
// Receive waits for the Response promised by the future and returns an error if
// any occurred when submitting the block.
func (r FutureSubmitBlockResult) Receive() error {
res, err := receiveFuture(r)
res, err := ReceiveFuture(r)
if err != nil {
return err
}
@ -453,7 +453,7 @@ func (c *Client) SubmitBlockAsync(block *btcutil.Block, options *btcjson.SubmitB
}
cmd := btcjson.NewSubmitBlockCmd(blockHex, options)
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// SubmitBlock attempts to submit a new block into the bitcoin network.
@ -463,12 +463,12 @@ func (c *Client) SubmitBlock(block *btcutil.Block, options *btcjson.SubmitBlockO
// FutureGetBlockTemplateResponse is a future promise to deliver the result of a
// GetBlockTemplateAsync RPC invocation (or an applicable error).
type FutureGetBlockTemplateResponse chan *response
type FutureGetBlockTemplateResponse chan *Response
// Receive waits for the response promised by the future and returns an error if
// Receive waits for the Response promised by the future and returns an error if
// any occurred when retrieving the block template.
func (r FutureGetBlockTemplateResponse) Receive() (*btcjson.GetBlockTemplateResult, error) {
res, err := receiveFuture(r)
res, err := ReceiveFuture(r)
if err != nil {
return nil, err
}
@ -490,7 +490,7 @@ func (r FutureGetBlockTemplateResponse) Receive() (*btcjson.GetBlockTemplateResu
// See GetBlockTemplate for the blocking version and more details.
func (c *Client) GetBlockTemplateAsync(req *btcjson.TemplateRequest) FutureGetBlockTemplateResponse {
cmd := btcjson.NewGetBlockTemplateCmd(req)
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// GetBlockTemplate returns a new block template for mining.

View File

@ -35,12 +35,12 @@ func (cmd AddNodeCommand) String() string {
// FutureAddNodeResult is a future promise to deliver the result of an
// AddNodeAsync RPC invocation (or an applicable error).
type FutureAddNodeResult chan *response
type FutureAddNodeResult chan *Response
// Receive waits for the response promised by the future and returns an error if
// Receive waits for the Response promised by the future and returns an error if
// any occurred when performing the specified command.
func (r FutureAddNodeResult) Receive() error {
_, err := receiveFuture(r)
_, err := ReceiveFuture(r)
return err
}
@ -51,7 +51,7 @@ func (r FutureAddNodeResult) Receive() error {
// See AddNode for the blocking version and more details.
func (c *Client) AddNodeAsync(host string, command AddNodeCommand) FutureAddNodeResult {
cmd := btcjson.NewAddNodeCmd(host, btcjson.AddNodeSubCmd(command))
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// AddNode attempts to perform the passed command on the passed persistent peer.
@ -65,12 +65,12 @@ func (c *Client) AddNode(host string, command AddNodeCommand) error {
// FutureNodeResult is a future promise to deliver the result of a NodeAsync
// RPC invocation (or an applicable error).
type FutureNodeResult chan *response
type FutureNodeResult chan *Response
// Receive waits for the response promised by the future and returns an error if
// Receive waits for the Response promised by the future and returns an error if
// any occurred when performing the specified command.
func (r FutureNodeResult) Receive() error {
_, err := receiveFuture(r)
_, err := ReceiveFuture(r)
return err
}
@ -82,7 +82,7 @@ func (r FutureNodeResult) Receive() error {
func (c *Client) NodeAsync(command btcjson.NodeSubCmd, host string,
connectSubCmd *string) FutureNodeResult {
cmd := btcjson.NewNodeCmd(command, host, connectSubCmd)
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// Node attempts to perform the passed node command on the host.
@ -99,12 +99,12 @@ func (c *Client) Node(command btcjson.NodeSubCmd, host string,
// FutureGetAddedNodeInfoResult is a future promise to deliver the result of a
// GetAddedNodeInfoAsync RPC invocation (or an applicable error).
type FutureGetAddedNodeInfoResult chan *response
type FutureGetAddedNodeInfoResult chan *Response
// Receive waits for the response promised by the future and returns information
// Receive waits for the Response promised by the future and returns information
// about manually added (persistent) peers.
func (r FutureGetAddedNodeInfoResult) Receive() ([]btcjson.GetAddedNodeInfoResult, error) {
res, err := receiveFuture(r)
res, err := ReceiveFuture(r)
if err != nil {
return nil, err
}
@ -126,7 +126,7 @@ func (r FutureGetAddedNodeInfoResult) Receive() ([]btcjson.GetAddedNodeInfoResul
// See GetAddedNodeInfo for the blocking version and more details.
func (c *Client) GetAddedNodeInfoAsync(peer string) FutureGetAddedNodeInfoResult {
cmd := btcjson.NewGetAddedNodeInfoCmd(true, &peer)
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// GetAddedNodeInfo returns information about manually added (persistent) peers.
@ -139,12 +139,12 @@ func (c *Client) GetAddedNodeInfo(peer string) ([]btcjson.GetAddedNodeInfoResult
// FutureGetAddedNodeInfoNoDNSResult is a future promise to deliver the result
// of a GetAddedNodeInfoNoDNSAsync RPC invocation (or an applicable error).
type FutureGetAddedNodeInfoNoDNSResult chan *response
type FutureGetAddedNodeInfoNoDNSResult chan *Response
// Receive waits for the response promised by the future and returns a list of
// Receive waits for the Response promised by the future and returns a list of
// manually added (persistent) peers.
func (r FutureGetAddedNodeInfoNoDNSResult) Receive() ([]string, error) {
res, err := receiveFuture(r)
res, err := ReceiveFuture(r)
if err != nil {
return nil, err
}
@ -166,7 +166,7 @@ func (r FutureGetAddedNodeInfoNoDNSResult) Receive() ([]string, error) {
// See GetAddedNodeInfoNoDNS for the blocking version and more details.
func (c *Client) GetAddedNodeInfoNoDNSAsync(peer string) FutureGetAddedNodeInfoNoDNSResult {
cmd := btcjson.NewGetAddedNodeInfoCmd(false, &peer)
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// GetAddedNodeInfoNoDNS returns a list of manually added (persistent) peers.
@ -180,12 +180,12 @@ func (c *Client) GetAddedNodeInfoNoDNS(peer string) ([]string, error) {
// FutureGetConnectionCountResult is a future promise to deliver the result
// of a GetConnectionCountAsync RPC invocation (or an applicable error).
type FutureGetConnectionCountResult chan *response
type FutureGetConnectionCountResult chan *Response
// Receive waits for the response promised by the future and returns the number
// Receive waits for the Response promised by the future and returns the number
// of active connections to other peers.
func (r FutureGetConnectionCountResult) Receive() (int64, error) {
res, err := receiveFuture(r)
res, err := ReceiveFuture(r)
if err != nil {
return 0, err
}
@ -207,7 +207,7 @@ func (r FutureGetConnectionCountResult) Receive() (int64, error) {
// See GetConnectionCount for the blocking version and more details.
func (c *Client) GetConnectionCountAsync() FutureGetConnectionCountResult {
cmd := btcjson.NewGetConnectionCountCmd()
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// GetConnectionCount returns the number of active connections to other peers.
@ -217,12 +217,12 @@ func (c *Client) GetConnectionCount() (int64, error) {
// FuturePingResult is a future promise to deliver the result of a PingAsync RPC
// invocation (or an applicable error).
type FuturePingResult chan *response
type FuturePingResult chan *Response
// Receive waits for the response promised by the future and returns the result
// Receive waits for the Response promised by the future and returns the result
// of queueing a ping to be sent to each connected peer.
func (r FuturePingResult) Receive() error {
_, err := receiveFuture(r)
_, err := ReceiveFuture(r)
return err
}
@ -233,7 +233,7 @@ func (r FuturePingResult) Receive() error {
// See Ping for the blocking version and more details.
func (c *Client) PingAsync() FuturePingResult {
cmd := btcjson.NewPingCmd()
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// Ping queues a ping to be sent to each connected peer.
@ -246,12 +246,12 @@ func (c *Client) Ping() error {
// FutureGetNetworkInfoResult is a future promise to deliver the result of a
// GetNetworkInfoAsync RPC invocation (or an applicable error).
type FutureGetNetworkInfoResult chan *response
type FutureGetNetworkInfoResult chan *Response
// Receive waits for the response promised by the future and returns data about
// Receive waits for the Response promised by the future and returns data about
// the current network.
func (r FutureGetNetworkInfoResult) Receive() (*btcjson.GetNetworkInfoResult, error) {
res, err := receiveFuture(r)
res, err := ReceiveFuture(r)
if err != nil {
return nil, err
}
@ -273,7 +273,7 @@ func (r FutureGetNetworkInfoResult) Receive() (*btcjson.GetNetworkInfoResult, er
// See GetNetworkInfo for the blocking version and more details.
func (c *Client) GetNetworkInfoAsync() FutureGetNetworkInfoResult {
cmd := btcjson.NewGetNetworkInfoCmd()
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// GetNetworkInfo returns data about the current network.
@ -283,12 +283,12 @@ func (c *Client) GetNetworkInfo() (*btcjson.GetNetworkInfoResult, error) {
// FutureGetNodeAddressesResult is a future promise to deliver the result of a
// GetNodeAddressesAsync RPC invocation (or an applicable error).
type FutureGetNodeAddressesResult chan *response
type FutureGetNodeAddressesResult chan *Response
// Receive waits for the response promised by the future and returns data about
// Receive waits for the Response promised by the future and returns data about
// known node addresses.
func (r FutureGetNodeAddressesResult) Receive() ([]btcjson.GetNodeAddressesResult, error) {
res, err := receiveFuture(r)
res, err := ReceiveFuture(r)
if err != nil {
return nil, err
}
@ -310,7 +310,7 @@ func (r FutureGetNodeAddressesResult) Receive() ([]btcjson.GetNodeAddressesResul
// See GetNodeAddresses for the blocking version and more details.
func (c *Client) GetNodeAddressesAsync(count *int32) FutureGetNodeAddressesResult {
cmd := btcjson.NewGetNodeAddressesCmd(count)
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// GetNodeAddresses returns data about known node addresses.
@ -320,12 +320,12 @@ func (c *Client) GetNodeAddresses(count *int32) ([]btcjson.GetNodeAddressesResul
// FutureGetPeerInfoResult is a future promise to deliver the result of a
// GetPeerInfoAsync RPC invocation (or an applicable error).
type FutureGetPeerInfoResult chan *response
type FutureGetPeerInfoResult chan *Response
// Receive waits for the response promised by the future and returns data about
// Receive waits for the Response promised by the future and returns data about
// each connected network peer.
func (r FutureGetPeerInfoResult) Receive() ([]btcjson.GetPeerInfoResult, error) {
res, err := receiveFuture(r)
res, err := ReceiveFuture(r)
if err != nil {
return nil, err
}
@ -347,7 +347,7 @@ func (r FutureGetPeerInfoResult) Receive() ([]btcjson.GetPeerInfoResult, error)
// See GetPeerInfo for the blocking version and more details.
func (c *Client) GetPeerInfoAsync() FutureGetPeerInfoResult {
cmd := btcjson.NewGetPeerInfoCmd()
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// GetPeerInfo returns data about each connected network peer.
@ -357,12 +357,12 @@ func (c *Client) GetPeerInfo() ([]btcjson.GetPeerInfoResult, error) {
// FutureGetNetTotalsResult is a future promise to deliver the result of a
// GetNetTotalsAsync RPC invocation (or an applicable error).
type FutureGetNetTotalsResult chan *response
type FutureGetNetTotalsResult chan *Response
// Receive waits for the response promised by the future and returns network
// Receive waits for the Response promised by the future and returns network
// traffic statistics.
func (r FutureGetNetTotalsResult) Receive() (*btcjson.GetNetTotalsResult, error) {
res, err := receiveFuture(r)
res, err := ReceiveFuture(r)
if err != nil {
return nil, err
}
@ -384,7 +384,7 @@ func (r FutureGetNetTotalsResult) Receive() (*btcjson.GetNetTotalsResult, error)
// See GetNetTotals for the blocking version and more details.
func (c *Client) GetNetTotalsAsync() FutureGetNetTotalsResult {
cmd := btcjson.NewGetNetTotalsCmd()
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// GetNetTotals returns network traffic statistics.

View File

@ -69,9 +69,9 @@ func newNotificationState() *notificationState {
// result waiting on the channel with the reply set to nil. This is useful
// to ignore things such as notifications when the caller didn't specify any
// notification handlers.
func newNilFutureResult() chan *response {
responseChan := make(chan *response, 1)
responseChan <- &response{result: nil, err: nil}
func newNilFutureResult() chan *Response {
responseChan := make(chan *Response, 1)
responseChan <- &Response{result: nil, err: nil}
return responseChan
}
@ -856,12 +856,12 @@ func parseWalletLockStateNtfnParams(params []json.RawMessage) (account string,
// FutureNotifyBlocksResult is a future promise to deliver the result of a
// NotifyBlocksAsync RPC invocation (or an applicable error).
type FutureNotifyBlocksResult chan *response
type FutureNotifyBlocksResult chan *Response
// Receive waits for the response promised by the future and returns an error
// Receive waits for the Response promised by the future and returns an error
// if the registration was not successful.
func (r FutureNotifyBlocksResult) Receive() error {
_, err := receiveFuture(r)
_, err := ReceiveFuture(r)
return err
}
@ -885,7 +885,7 @@ func (c *Client) NotifyBlocksAsync() FutureNotifyBlocksResult {
}
cmd := btcjson.NewNotifyBlocksCmd()
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// NotifyBlocks registers the client to receive notifications when blocks are
@ -906,12 +906,12 @@ func (c *Client) NotifyBlocks() error {
// NotifySpentAsync RPC invocation (or an applicable error).
//
// Deprecated: Use FutureLoadTxFilterResult instead.
type FutureNotifySpentResult chan *response
type FutureNotifySpentResult chan *Response
// Receive waits for the response promised by the future and returns an error
// Receive waits for the Response promised by the future and returns an error
// if the registration was not successful.
func (r FutureNotifySpentResult) Receive() error {
_, err := receiveFuture(r)
_, err := ReceiveFuture(r)
return err
}
@ -931,7 +931,7 @@ func (c *Client) notifySpentInternal(outpoints []btcjson.OutPoint) FutureNotifyS
}
cmd := btcjson.NewNotifySpentCmd(outpoints)
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// newOutPointFromWire constructs the btcjson representation of a transaction
@ -969,7 +969,7 @@ func (c *Client) NotifySpentAsync(outpoints []*wire.OutPoint) FutureNotifySpentR
ops = append(ops, newOutPointFromWire(outpoint))
}
cmd := btcjson.NewNotifySpentCmd(ops)
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// NotifySpent registers the client to receive notifications when the passed
@ -990,12 +990,12 @@ func (c *Client) NotifySpent(outpoints []*wire.OutPoint) error {
// FutureNotifyNewTransactionsResult is a future promise to deliver the result
// of a NotifyNewTransactionsAsync RPC invocation (or an applicable error).
type FutureNotifyNewTransactionsResult chan *response
type FutureNotifyNewTransactionsResult chan *Response
// Receive waits for the response promised by the future and returns an error
// Receive waits for the Response promised by the future and returns an error
// if the registration was not successful.
func (r FutureNotifyNewTransactionsResult) Receive() error {
_, err := receiveFuture(r)
_, err := ReceiveFuture(r)
return err
}
@ -1019,7 +1019,7 @@ func (c *Client) NotifyNewTransactionsAsync(verbose bool) FutureNotifyNewTransac
}
cmd := btcjson.NewNotifyNewTransactionsCmd(&verbose)
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// NotifyNewTransactions registers the client to receive notifications every
@ -1041,12 +1041,12 @@ func (c *Client) NotifyNewTransactions(verbose bool) error {
// NotifyReceivedAsync RPC invocation (or an applicable error).
//
// Deprecated: Use FutureLoadTxFilterResult instead.
type FutureNotifyReceivedResult chan *response
type FutureNotifyReceivedResult chan *Response
// Receive waits for the response promised by the future and returns an error
// Receive waits for the Response promised by the future and returns an error
// if the registration was not successful.
func (r FutureNotifyReceivedResult) Receive() error {
_, err := receiveFuture(r)
_, err := ReceiveFuture(r)
return err
}
@ -1067,7 +1067,7 @@ func (c *Client) notifyReceivedInternal(addresses []string) FutureNotifyReceived
// Convert addresses to strings.
cmd := btcjson.NewNotifyReceivedCmd(addresses)
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// NotifyReceivedAsync returns an instance of a type that can be used to get the
@ -1097,7 +1097,7 @@ func (c *Client) NotifyReceivedAsync(addresses []btcutil.Address) FutureNotifyRe
addrs = append(addrs, addr.String())
}
cmd := btcjson.NewNotifyReceivedCmd(addrs)
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// NotifyReceived registers the client to receive notifications every time a
@ -1127,12 +1127,12 @@ func (c *Client) NotifyReceived(addresses []btcutil.Address) error {
// or RescanEndHeightAsync RPC invocation (or an applicable error).
//
// Deprecated: Use FutureRescanBlocksResult instead.
type FutureRescanResult chan *response
type FutureRescanResult chan *Response
// Receive waits for the response promised by the future and returns an error
// Receive waits for the Response promised by the future and returns an error
// if the rescan was not successful.
func (r FutureRescanResult) Receive() error {
_, err := receiveFuture(r)
_, err := ReceiveFuture(r)
return err
}
@ -1185,7 +1185,7 @@ func (c *Client) RescanAsync(startBlock *chainhash.Hash,
}
cmd := btcjson.NewRescanCmd(startBlockHashStr, addrs, ops, nil)
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// Rescan rescans the block chain starting from the provided starting block to
@ -1270,7 +1270,7 @@ func (c *Client) RescanEndBlockAsync(startBlock *chainhash.Hash,
cmd := btcjson.NewRescanCmd(startBlockHashStr, addrs, ops,
&endBlockHashStr)
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// RescanEndHeight rescans the block chain starting from the provided starting
@ -1307,15 +1307,15 @@ func (c *Client) RescanEndHeight(startBlock *chainhash.Hash,
//
// NOTE: This is a btcd extension ported from github.com/decred/dcrrpcclient
// and requires a websocket connection.
type FutureLoadTxFilterResult chan *response
type FutureLoadTxFilterResult chan *Response
// Receive waits for the response promised by the future and returns an error
// Receive waits for the Response promised by the future and returns an error
// if the registration was not successful.
//
// NOTE: This is a btcd extension ported from github.com/decred/dcrrpcclient
// and requires a websocket connection.
func (r FutureLoadTxFilterResult) Receive() error {
_, err := receiveFuture(r)
_, err := ReceiveFuture(r)
return err
}
@ -1343,7 +1343,7 @@ func (c *Client) LoadTxFilterAsync(reload bool, addresses []btcutil.Address,
}
cmd := btcjson.NewLoadTxFilterCmd(reload, addrStrs, outPointObjects)
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// LoadTxFilter loads, reloads, or adds data to a websocket client's transaction

View File

@ -13,12 +13,12 @@ import (
// FutureRawResult is a future promise to deliver the result of a RawRequest RPC
// invocation (or an applicable error).
type FutureRawResult chan *response
type FutureRawResult chan *Response
// Receive waits for the response promised by the future and returns the raw
// Receive waits for the Response promised by the future and returns the raw
// response, or an error if the request was unsuccessful.
func (r FutureRawResult) Receive() (json.RawMessage, error) {
return receiveFuture(r)
return ReceiveFuture(r)
}
// RawRequestAsync returns an instance of a type that can be used to get the
@ -39,7 +39,7 @@ func (c *Client) RawRequestAsync(method string, params []json.RawMessage) Future
}
// Create a raw JSON-RPC request using the provided method and params
// and marshal it. This is done rather than using the sendCmd function
// and marshal it. This is done rather than using the SendCmd function
// since that relies on marshalling registered btcjson commands rather
// than custom commands.
id := c.NextID()
@ -55,7 +55,7 @@ func (c *Client) RawRequestAsync(method string, params []json.RawMessage) Future
}
// Generate the request and send it along with a channel to respond on.
responseChan := make(chan *response, 1)
responseChan := make(chan *Response, 1)
jReq := &jsonRequest{
id: id,
method: method,

View File

@ -66,12 +66,12 @@ func (s SigHashType) String() string {
// FutureGetRawTransactionResult is a future promise to deliver the result of a
// GetRawTransactionAsync RPC invocation (or an applicable error).
type FutureGetRawTransactionResult chan *response
type FutureGetRawTransactionResult chan *Response
// Receive waits for the response promised by the future and returns a
// Receive waits for the Response promised by the future and returns a
// transaction given its hash.
func (r FutureGetRawTransactionResult) Receive() (*btcutil.Tx, error) {
res, err := receiveFuture(r)
res, err := ReceiveFuture(r)
if err != nil {
return nil, err
}
@ -109,7 +109,7 @@ func (c *Client) GetRawTransactionAsync(txHash *chainhash.Hash) FutureGetRawTran
}
cmd := btcjson.NewGetRawTransactionCmd(hash, btcjson.Int(0))
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// GetRawTransaction returns a transaction given its hash.
@ -123,12 +123,12 @@ func (c *Client) GetRawTransaction(txHash *chainhash.Hash) (*btcutil.Tx, error)
// FutureGetRawTransactionVerboseResult is a future promise to deliver the
// result of a GetRawTransactionVerboseAsync RPC invocation (or an applicable
// error).
type FutureGetRawTransactionVerboseResult chan *response
type FutureGetRawTransactionVerboseResult chan *Response
// Receive waits for the response promised by the future and returns information
// Receive waits for the Response promised by the future and returns information
// about a transaction given its hash.
func (r FutureGetRawTransactionVerboseResult) Receive() (*btcjson.TxRawResult, error) {
res, err := receiveFuture(r)
res, err := ReceiveFuture(r)
if err != nil {
return nil, err
}
@ -155,7 +155,7 @@ func (c *Client) GetRawTransactionVerboseAsync(txHash *chainhash.Hash) FutureGet
}
cmd := btcjson.NewGetRawTransactionCmd(hash, btcjson.Int(1))
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// GetRawTransactionVerbose returns information about a transaction given
@ -168,12 +168,12 @@ func (c *Client) GetRawTransactionVerbose(txHash *chainhash.Hash) (*btcjson.TxRa
// FutureDecodeRawTransactionResult is a future promise to deliver the result
// of a DecodeRawTransactionAsync RPC invocation (or an applicable error).
type FutureDecodeRawTransactionResult chan *response
type FutureDecodeRawTransactionResult chan *Response
// Receive waits for the response promised by the future and returns information
// Receive waits for the Response promised by the future and returns information
// about a transaction given its serialized bytes.
func (r FutureDecodeRawTransactionResult) Receive() (*btcjson.TxRawResult, error) {
res, err := receiveFuture(r)
res, err := ReceiveFuture(r)
if err != nil {
return nil, err
}
@ -196,7 +196,7 @@ func (r FutureDecodeRawTransactionResult) Receive() (*btcjson.TxRawResult, error
func (c *Client) DecodeRawTransactionAsync(serializedTx []byte) FutureDecodeRawTransactionResult {
txHex := hex.EncodeToString(serializedTx)
cmd := btcjson.NewDecodeRawTransactionCmd(txHex)
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// DecodeRawTransaction returns information about a transaction given its
@ -207,12 +207,12 @@ func (c *Client) DecodeRawTransaction(serializedTx []byte) (*btcjson.TxRawResult
// FutureFundRawTransactionResult is a future promise to deliver the result
// of a FutureFundRawTransactionAsync RPC invocation (or an applicable error).
type FutureFundRawTransactionResult chan *response
type FutureFundRawTransactionResult chan *Response
// Receive waits for the response promised by the future and returns information
// Receive waits for the Response promised by the future and returns information
// about a funding attempt
func (r FutureFundRawTransactionResult) Receive() (*btcjson.FundRawTransactionResult, error) {
res, err := receiveFuture(r)
res, err := ReceiveFuture(r)
if err != nil {
return nil, err
}
@ -237,7 +237,7 @@ func (c *Client) FundRawTransactionAsync(tx *wire.MsgTx, opts btcjson.FundRawTra
}
cmd := btcjson.NewFundRawTransactionCmd(txBuf.Bytes(), opts, isWitness)
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// FundRawTransaction returns the result of trying to fund the given transaction with
@ -248,13 +248,13 @@ func (c *Client) FundRawTransaction(tx *wire.MsgTx, opts btcjson.FundRawTransact
// FutureCreateRawTransactionResult is a future promise to deliver the result
// of a CreateRawTransactionAsync RPC invocation (or an applicable error).
type FutureCreateRawTransactionResult chan *response
type FutureCreateRawTransactionResult chan *Response
// Receive waits for the response promised by the future and returns a new
// Receive waits for the Response promised by the future and returns a new
// transaction spending the provided inputs and sending to the provided
// addresses.
func (r FutureCreateRawTransactionResult) Receive() (*wire.MsgTx, error) {
res, err := receiveFuture(r)
res, err := ReceiveFuture(r)
if err != nil {
return nil, err
}
@ -298,7 +298,7 @@ func (c *Client) CreateRawTransactionAsync(inputs []btcjson.TransactionInput,
convertedAmts[addr.String()] = amount.ToBTC()
}
cmd := btcjson.NewCreateRawTransactionCmd(inputs, convertedAmts, lockTime)
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// CreateRawTransaction returns a new transaction spending the provided inputs
@ -312,13 +312,13 @@ func (c *Client) CreateRawTransaction(inputs []btcjson.TransactionInput,
// FutureSendRawTransactionResult is a future promise to deliver the result
// of a SendRawTransactionAsync RPC invocation (or an applicable error).
type FutureSendRawTransactionResult chan *response
type FutureSendRawTransactionResult chan *Response
// Receive waits for the response promised by the future and returns the result
// Receive waits for the Response promised by the future and returns the result
// of submitting the encoded transaction to the server which then relays it to
// the network.
func (r FutureSendRawTransactionResult) Receive() (*chainhash.Hash, error) {
res, err := receiveFuture(r)
res, err := ReceiveFuture(r)
if err != nil {
return nil, err
}
@ -374,7 +374,7 @@ func (c *Client) SendRawTransactionAsync(tx *wire.MsgTx, allowHighFees bool) Fut
cmd = btcjson.NewSendRawTransactionCmd(txHex, &allowHighFees)
}
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// SendRawTransaction submits the encoded transaction to the server which will
@ -386,12 +386,12 @@ func (c *Client) SendRawTransaction(tx *wire.MsgTx, allowHighFees bool) (*chainh
// FutureSignRawTransactionResult is a future promise to deliver the result
// of one of the SignRawTransactionAsync family of RPC invocations (or an
// applicable error).
type FutureSignRawTransactionResult chan *response
type FutureSignRawTransactionResult chan *Response
// Receive waits for the response promised by the future and returns the
// Receive waits for the Response promised by the future and returns the
// signed transaction as well as whether or not all inputs are now signed.
func (r FutureSignRawTransactionResult) Receive() (*wire.MsgTx, bool, error) {
res, err := receiveFuture(r)
res, err := ReceiveFuture(r)
if err != nil {
return nil, false, err
}
@ -435,7 +435,7 @@ func (c *Client) SignRawTransactionAsync(tx *wire.MsgTx) FutureSignRawTransactio
}
cmd := btcjson.NewSignRawTransactionCmd(txHex, nil, nil, nil)
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// SignRawTransaction signs inputs for the passed transaction and returns the
@ -466,7 +466,7 @@ func (c *Client) SignRawTransaction2Async(tx *wire.MsgTx, inputs []btcjson.RawTx
}
cmd := btcjson.NewSignRawTransactionCmd(txHex, &inputs, nil, nil)
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// SignRawTransaction2 signs inputs for the passed transaction given the list
@ -504,7 +504,7 @@ func (c *Client) SignRawTransaction3Async(tx *wire.MsgTx,
cmd := btcjson.NewSignRawTransactionCmd(txHex, &inputs, &privKeysWIF,
nil)
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// SignRawTransaction3 signs inputs for the passed transaction given the list
@ -552,7 +552,7 @@ func (c *Client) SignRawTransaction4Async(tx *wire.MsgTx,
cmd := btcjson.NewSignRawTransactionCmd(txHex, &inputs, &privKeysWIF,
btcjson.String(string(hashType)))
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// SignRawTransaction4 signs inputs for the passed transaction using
@ -585,12 +585,12 @@ func (c *Client) SignRawTransaction4(tx *wire.MsgTx,
// FutureSignRawTransactionWithWalletResult is a future promise to deliver
// the result of the SignRawTransactionWithWalletAsync RPC invocation (or
// an applicable error).
type FutureSignRawTransactionWithWalletResult chan *response
type FutureSignRawTransactionWithWalletResult chan *Response
// Receive waits for the response promised by the future and returns the
// Receive waits for the Response promised by the future and returns the
// signed transaction as well as whether or not all inputs are now signed.
func (r FutureSignRawTransactionWithWalletResult) Receive() (*wire.MsgTx, bool, error) {
res, err := receiveFuture(r)
res, err := ReceiveFuture(r)
if err != nil {
return nil, false, err
}
@ -634,7 +634,7 @@ func (c *Client) SignRawTransactionWithWalletAsync(tx *wire.MsgTx) FutureSignRaw
}
cmd := btcjson.NewSignRawTransactionWithWalletCmd(txHex, nil, nil)
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// SignRawTransactionWithWallet signs inputs for the passed transaction and returns
@ -667,7 +667,7 @@ func (c *Client) SignRawTransactionWithWallet2Async(tx *wire.MsgTx,
}
cmd := btcjson.NewSignRawTransactionWithWalletCmd(txHex, &inputs, nil)
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// SignRawTransactionWithWallet2 signs inputs for the passed transaction given the
@ -705,7 +705,7 @@ func (c *Client) SignRawTransactionWithWallet3Async(tx *wire.MsgTx,
}
cmd := btcjson.NewSignRawTransactionWithWalletCmd(txHex, &inputs, btcjson.String(string(hashType)))
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// SignRawTransactionWithWallet3 signs inputs for the passed transaction using
@ -727,12 +727,12 @@ func (c *Client) SignRawTransactionWithWallet3(tx *wire.MsgTx,
// FutureSearchRawTransactionsResult is a future promise to deliver the result
// of the SearchRawTransactionsAsync RPC invocation (or an applicable error).
type FutureSearchRawTransactionsResult chan *response
type FutureSearchRawTransactionsResult chan *Response
// Receive waits for the response promised by the future and returns the
// Receive waits for the Response promised by the future and returns the
// found raw transactions.
func (r FutureSearchRawTransactionsResult) Receive() ([]*wire.MsgTx, error) {
res, err := receiveFuture(r)
res, err := ReceiveFuture(r)
if err != nil {
return nil, err
}
@ -775,7 +775,7 @@ func (c *Client) SearchRawTransactionsAsync(address btcutil.Address, skip, count
verbose := btcjson.Int(0)
cmd := btcjson.NewSearchRawTransactionsCmd(addr, verbose, &skip, &count,
nil, &reverse, &filterAddrs)
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// SearchRawTransactions returns transactions that involve the passed address.
@ -792,12 +792,12 @@ func (c *Client) SearchRawTransactions(address btcutil.Address, skip, count int,
// FutureSearchRawTransactionsVerboseResult is a future promise to deliver the
// result of the SearchRawTransactionsVerboseAsync RPC invocation (or an
// applicable error).
type FutureSearchRawTransactionsVerboseResult chan *response
type FutureSearchRawTransactionsVerboseResult chan *Response
// Receive waits for the response promised by the future and returns the
// Receive waits for the Response promised by the future and returns the
// found raw transactions.
func (r FutureSearchRawTransactionsVerboseResult) Receive() ([]*btcjson.SearchRawTransactionsResult, error) {
res, err := receiveFuture(r)
res, err := ReceiveFuture(r)
if err != nil {
return nil, err
}
@ -828,7 +828,7 @@ func (c *Client) SearchRawTransactionsVerboseAsync(address btcutil.Address, skip
}
cmd := btcjson.NewSearchRawTransactionsCmd(addr, verbose, &skip, &count,
prevOut, &reverse, filterAddrs)
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// SearchRawTransactionsVerbose returns a list of data structures that describe
@ -847,12 +847,12 @@ func (c *Client) SearchRawTransactionsVerbose(address btcutil.Address, skip,
// FutureDecodeScriptResult is a future promise to deliver the result
// of a DecodeScriptAsync RPC invocation (or an applicable error).
type FutureDecodeScriptResult chan *response
type FutureDecodeScriptResult chan *Response
// Receive waits for the response promised by the future and returns information
// Receive waits for the Response promised by the future and returns information
// about a script given its serialized bytes.
func (r FutureDecodeScriptResult) Receive() (*btcjson.DecodeScriptResult, error) {
res, err := receiveFuture(r)
res, err := ReceiveFuture(r)
if err != nil {
return nil, err
}
@ -875,7 +875,7 @@ func (r FutureDecodeScriptResult) Receive() (*btcjson.DecodeScriptResult, error)
func (c *Client) DecodeScriptAsync(serializedScript []byte) FutureDecodeScriptResult {
scriptHex := hex.EncodeToString(serializedScript)
cmd := btcjson.NewDecodeScriptCmd(scriptHex)
return c.sendCmd(cmd)
return c.SendCmd(cmd)
}
// DecodeScript returns information about a script given its serialized bytes.

File diff suppressed because it is too large Load Diff