From 80ed067eefa85af77516c50e1abdae3746e449b6 Mon Sep 17 00:00:00 2001 From: JeremyRand <244188+JeremyRand@users.noreply.github.com> Date: Thu, 2 Sep 2021 06:39:55 +0000 Subject: [PATCH] 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 --- rpcclient/chain.go | 230 +++++----- rpcclient/examples/customcommand/README.md | 32 ++ rpcclient/examples/customcommand/main.go | 110 +++++ rpcclient/extensions.go | 72 +-- rpcclient/infrastructure.go | 58 +-- rpcclient/mining.go | 96 ++-- rpcclient/net.go | 80 ++-- rpcclient/notify.go | 60 +-- rpcclient/rawrequest.go | 10 +- rpcclient/rawtransactions.go | 104 ++--- rpcclient/wallet.go | 496 ++++++++++----------- 11 files changed, 745 insertions(+), 603 deletions(-) create mode 100644 rpcclient/examples/customcommand/README.md create mode 100644 rpcclient/examples/customcommand/main.go diff --git a/rpcclient/chain.go b/rpcclient/chain.go index 9f35b90893..a251e96466 100644 --- a/rpcclient/chain.go +++ b/rpcclient/chain.go @@ -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 @@ -85,13 +85,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 @@ -102,7 +102,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 } @@ -111,7 +111,7 @@ func (c *Client) waitForGetBlockRes(respChan chan *response, hash string, type FutureGetBlockResult struct { client *Client hash string - Response chan *response + Response chan *Response } func (r FutureGetBlockResult) ReceiveBlock() (*btcjson.GetBlockVerboseResult, error) { @@ -130,7 +130,7 @@ func (r FutureGetBlockResult) ReceiveBlock() (*btcjson.GetBlockVerboseResult, er return &block, nil } -// 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) @@ -175,7 +175,7 @@ func (c *Client) GetBlockAsync(blockHash *chainhash.Hash) FutureGetBlockResult { return FutureGetBlockResult{ client: c, hash: hash, - Response: c.sendCmd(cmd), + Response: c.SendCmd(cmd), } } @@ -192,10 +192,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) @@ -228,7 +228,7 @@ func (c *Client) GetBlockVerboseAsync(blockHash *chainhash.Hash) FutureGetBlockV return FutureGetBlockVerboseResult{ client: c, hash: hash, - Response: c.sendCmd(cmd), + Response: c.SendCmd(cmd), } } @@ -246,10 +246,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) @@ -285,7 +285,7 @@ func (c *Client) GetBlockVerboseTxAsync(blockHash *chainhash.Hash) FutureGetBloc return FutureGetBlockVerboseTxResult{ client: c, hash: hash, - Response: c.sendCmd(cmd), + Response: c.SendCmd(cmd), } } @@ -300,12 +300,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 } @@ -326,7 +326,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. @@ -336,11 +336,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 } @@ -361,7 +361,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 @@ -371,7 +371,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 @@ -382,7 +382,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. @@ -409,12 +409,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 } @@ -435,7 +435,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 @@ -448,7 +448,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 @@ -488,10 +488,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 } @@ -524,7 +524,7 @@ func (c *Client) GetBlockChainInfoAsync() FutureGetBlockChainInfoResult { cmd := btcjson.NewGetBlockChainInfoCmd() return FutureGetBlockChainInfoResult{ client: c, - Response: c.sendCmd(cmd), + Response: c.SendCmd(cmd), } } @@ -537,12 +537,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 } @@ -565,7 +565,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. @@ -575,12 +575,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 } @@ -601,7 +601,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 @@ -612,12 +612,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 } @@ -656,7 +656,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. @@ -669,12 +669,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 } @@ -701,7 +701,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 @@ -714,13 +714,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 } @@ -742,7 +742,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 @@ -753,12 +753,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 } @@ -790,7 +790,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. @@ -803,13 +803,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 } @@ -831,7 +831,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 @@ -845,12 +845,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 } @@ -872,7 +872,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. @@ -882,12 +882,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 } @@ -907,7 +907,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. @@ -918,13 +918,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 } @@ -945,7 +945,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 @@ -963,7 +963,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 @@ -986,7 +986,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 @@ -1006,12 +1006,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 } @@ -1044,7 +1044,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 @@ -1055,12 +1055,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 } @@ -1082,7 +1082,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 @@ -1096,15 +1096,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 } @@ -1133,7 +1133,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 @@ -1148,12 +1148,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 } @@ -1170,7 +1170,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. @@ -1180,12 +1180,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 } @@ -1224,7 +1224,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. @@ -1235,12 +1235,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 } @@ -1277,7 +1277,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 @@ -1289,12 +1289,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 } @@ -1319,7 +1319,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. @@ -1330,12 +1330,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 } @@ -1357,7 +1357,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 @@ -1369,12 +1369,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 } @@ -1396,7 +1396,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 diff --git a/rpcclient/examples/customcommand/README.md b/rpcclient/examples/customcommand/README.md new file mode 100644 index 0000000000..0e36d649cc --- /dev/null +++ b/rpcclient/examples/customcommand/README.md @@ -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. diff --git a/rpcclient/examples/customcommand/main.go b/rpcclient/examples/customcommand/main.go new file mode 100644 index 0000000000..1e14c06fe4 --- /dev/null +++ b/rpcclient/examples/customcommand/main.go @@ -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) +} diff --git a/rpcclient/extensions.go b/rpcclient/extensions.go index d16cd5252e..c8615293e3 100644 --- a/rpcclient/extensions.go +++ b/rpcclient/extensions.go @@ -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. diff --git a/rpcclient/infrastructure.go b/rpcclient/infrastructure.go index 798f027911..7255289282 100644 --- a/rpcclient/infrastructure.go +++ b/rpcclient/infrastructure.go @@ -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, } diff --git a/rpcclient/mining.go b/rpcclient/mining.go index 05d7c8b452..db2fc843c8 100644 --- a/rpcclient/mining.go +++ b/rpcclient/mining.go @@ -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,21 +213,21 @@ 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. +// Receive waits for the Response promised by the future. func (r FutureGetMiningInfoResult) ReceiveFuture() ([]byte, error) { - res, err := receiveFuture(r) + res, err := ReceiveFuture(r) if err != nil { return nil, err } return res, nil } -// 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 } @@ -249,7 +249,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. @@ -259,13 +259,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 } @@ -287,7 +287,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 @@ -306,7 +306,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 @@ -327,7 +327,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 @@ -342,12 +342,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 } @@ -369,7 +369,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. @@ -381,12 +381,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 } @@ -408,7 +408,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 @@ -421,12 +421,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 } @@ -462,7 +462,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. @@ -472,12 +472,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 } @@ -499,7 +499,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. diff --git a/rpcclient/net.go b/rpcclient/net.go index 8c191ff66f..da2006c224 100644 --- a/rpcclient/net.go +++ b/rpcclient/net.go @@ -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. diff --git a/rpcclient/notify.go b/rpcclient/notify.go index 1feb755605..6879099acd 100644 --- a/rpcclient/notify.go +++ b/rpcclient/notify.go @@ -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 diff --git a/rpcclient/rawrequest.go b/rpcclient/rawrequest.go index baead8bb90..f446b0082b 100644 --- a/rpcclient/rawrequest.go +++ b/rpcclient/rawrequest.go @@ -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, diff --git a/rpcclient/rawtransactions.go b/rpcclient/rawtransactions.go index 7a00628132..cd319a7014 100644 --- a/rpcclient/rawtransactions.go +++ b/rpcclient/rawtransactions.go @@ -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 } @@ -159,7 +159,7 @@ func (c *Client) GetRawTransactionVerboseAsync(txHash *chainhash.Hash) FutureGet func (c *Client) GetRawTransactionVerboseStrAsync(hash string) FutureGetRawTransactionVerboseResult { cmd := btcjson.NewGetRawTransactionCmd(hash, btcjson.Int(1)) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // GetRawTransactionVerbose returns information about a transaction given @@ -172,12 +172,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 } @@ -200,7 +200,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 @@ -211,12 +211,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 } @@ -241,7 +241,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 @@ -252,10 +252,10 @@ 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 func (r FutureCreateRawTransactionResult) ReceiveFuture() (string, error) { - res, err := receiveFuture(r) + res, err := ReceiveFuture(r) if err != nil { return "", err } @@ -270,11 +270,11 @@ func (r FutureCreateRawTransactionResult) ReceiveFuture() (string, error) { return txHex, nil } -// 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 } @@ -323,7 +323,7 @@ func (c *Client) CreateRawTransactionAsync(inputs []btcjson.TransactionInput, func (c *Client) CreateRawTransaction2Async(inputs []btcjson.TransactionInput, amounts map[string]float64, lockTime *int64) FutureCreateRawTransactionResult { cmd := btcjson.NewCreateRawTransactionCmd(inputs, amounts, lockTime) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // CreateRawTransaction returns a new transaction spending the provided inputs @@ -337,13 +337,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 } @@ -402,7 +402,7 @@ func (c *Client) SendHexRawTransactionAsync(txHex string, allowHighFees bool) Fu cmd = btcjson.NewSendRawTransactionCmd(txHex, &allowHighFees) } - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // SendRawTransaction submits the encoded transaction to the server which will @@ -414,10 +414,10 @@ 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 func (r FutureSignRawTransactionResult) ReceiveFuture() (string, bool, error) { - res, err := receiveFuture(r) + res, err := ReceiveFuture(r) if err != nil { return "", false, err } @@ -431,10 +431,10 @@ func (r FutureSignRawTransactionResult) ReceiveFuture() (string, bool, error) { return signRawTxResult.Hex, signRawTxResult.Complete, nil } -// 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 } @@ -478,12 +478,12 @@ func (c *Client) SignRawTransactionAsync(tx *wire.MsgTx) FutureSignRawTransactio } cmd := btcjson.NewSignRawTransactionCmd(txHex, nil, nil, nil) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } func (c *Client) SignHexRawTransactionAsync(txHex string) FutureSignRawTransactionResult { 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 @@ -514,7 +514,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 @@ -552,7 +552,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 @@ -600,7 +600,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 @@ -633,12 +633,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 } @@ -682,7 +682,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 @@ -715,7 +715,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 @@ -753,7 +753,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 @@ -775,12 +775,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 } @@ -823,7 +823,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. @@ -840,12 +840,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 } @@ -876,7 +876,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 @@ -895,12 +895,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 } @@ -923,7 +923,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. diff --git a/rpcclient/wallet.go b/rpcclient/wallet.go index 89eb0c8b82..96d25c4ac8 100644 --- a/rpcclient/wallet.go +++ b/rpcclient/wallet.go @@ -22,12 +22,12 @@ import ( // FutureGetTransactionResult is a future promise to deliver the result // of a GetTransactionAsync or GetTransactionWatchOnlyAsync RPC invocation // (or an applicable error). -type FutureGetTransactionResult chan *response +type FutureGetTransactionResult chan *Response -// Receive waits for the response promised by the future and returns detailed +// Receive waits for the Response promised by the future and returns detailed // information about a wallet transaction. func (r FutureGetTransactionResult) Receive() (*btcjson.GetTransactionResult, error) { - res, err := receiveFuture(r) + res, err := ReceiveFuture(r) if err != nil { return nil, err } @@ -57,7 +57,7 @@ func (c *Client) GetTransactionAsync(txHash *chainhash.Hash) FutureGetTransactio func (c *Client) GetTransactionStrAsync(txHash string) FutureGetTransactionResult { cmd := btcjson.NewGetTransactionCmd(txHash, nil) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // GetTransaction returns detailed information about a wallet transaction. @@ -79,7 +79,7 @@ func (c *Client) GetTransactionWatchOnlyAsync(txHash *chainhash.Hash, watchOnly } cmd := btcjson.NewGetTransactionCmd(hash, &watchOnly) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // GetTransactionWatchOnly returns detailed information about a wallet @@ -92,12 +92,12 @@ func (c *Client) GetTransactionWatchOnly(txHash *chainhash.Hash, watchOnly bool) // FutureListTransactionsResult is a future promise to deliver the result of a // ListTransactionsAsync, ListTransactionsCountAsync, or // ListTransactionsCountFromAsync RPC invocation (or an applicable error). -type FutureListTransactionsResult chan *response +type FutureListTransactionsResult 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 // the most recent transactions. func (r FutureListTransactionsResult) Receive() ([]btcjson.ListTransactionsResult, error) { - res, err := receiveFuture(r) + res, err := ReceiveFuture(r) if err != nil { return nil, err } @@ -119,7 +119,7 @@ func (r FutureListTransactionsResult) Receive() ([]btcjson.ListTransactionsResul // See ListTransactions for the blocking version and more details. func (c *Client) ListTransactionsAsync(account string) FutureListTransactionsResult { cmd := btcjson.NewListTransactionsCmd(&account, nil, nil, nil) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // ListTransactions returns a list of the most recent transactions. @@ -137,7 +137,7 @@ func (c *Client) ListTransactions(account string) ([]btcjson.ListTransactionsRes // See ListTransactionsCount for the blocking version and more details. func (c *Client) ListTransactionsCountAsync(account string, count int) FutureListTransactionsResult { cmd := btcjson.NewListTransactionsCmd(&account, &count, nil, nil) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // ListTransactionsCount returns a list of the most recent transactions up @@ -156,7 +156,7 @@ func (c *Client) ListTransactionsCount(account string, count int) ([]btcjson.Lis // See ListTransactionsCountFrom for the blocking version and more details. func (c *Client) ListTransactionsCountFromAsync(account string, count, from int) FutureListTransactionsResult { cmd := btcjson.NewListTransactionsCmd(&account, &count, &from, nil) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // ListTransactionsCountFrom returns a list of the most recent transactions up @@ -174,7 +174,7 @@ func (c *Client) ListTransactionsCountFrom(account string, count, from int) ([]b // See ListTransactionsCountFromWatchOnly for the blocking version and more details. func (c *Client) ListTransactionsCountFromWatchOnlyAsync(account string, count, from int, watchOnly bool) FutureListTransactionsResult { cmd := btcjson.NewListTransactionsCmd(&account, &count, &from, &watchOnly) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // ListTransactionsCountFromWatchOnly returns a list of the most recent transactions up @@ -189,15 +189,15 @@ func (c *Client) ListTransactionsCountFromWatchOnly(account string, count, from // FutureListUnspentResult is a future promise to deliver the result of a // ListUnspentAsync, ListUnspentMinAsync, ListUnspentMinMaxAsync, or // ListUnspentMinMaxAddressesAsync RPC invocation (or an applicable error). -type FutureListUnspentResult chan *response +type FutureListUnspentResult chan *Response -// Receive waits for the response promised by the future and returns all +// Receive waits for the Response promised by the future and returns all // unspent wallet transaction outputs returned by the RPC call. If the // future wac returned by a call to ListUnspentMinAsync, ListUnspentMinMaxAsync, // or ListUnspentMinMaxAddressesAsync, the range may be limited by the // parameters of the RPC invocation. func (r FutureListUnspentResult) Receive() ([]btcjson.ListUnspentResult, error) { - res, err := receiveFuture(r) + res, err := ReceiveFuture(r) if err != nil { return nil, err } @@ -219,7 +219,7 @@ func (r FutureListUnspentResult) Receive() ([]btcjson.ListUnspentResult, error) // See ListUnspent for the blocking version and more details. func (c *Client) ListUnspentAsync() FutureListUnspentResult { cmd := btcjson.NewListUnspentCmd(nil, nil, nil) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // ListUnspentMinAsync returns an instance of a type that can be used to get @@ -229,7 +229,7 @@ func (c *Client) ListUnspentAsync() FutureListUnspentResult { // See ListUnspentMin for the blocking version and more details. func (c *Client) ListUnspentMinAsync(minConf int) FutureListUnspentResult { cmd := btcjson.NewListUnspentCmd(&minConf, nil, nil) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // ListUnspentMinMaxAsync returns an instance of a type that can be used to get @@ -239,7 +239,7 @@ func (c *Client) ListUnspentMinAsync(minConf int) FutureListUnspentResult { // See ListUnspentMinMax for the blocking version and more details. func (c *Client) ListUnspentMinMaxAsync(minConf, maxConf int) FutureListUnspentResult { cmd := btcjson.NewListUnspentCmd(&minConf, &maxConf, nil) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // ListUnspentMinMaxAddressesAsync returns an instance of a type that can be @@ -254,7 +254,7 @@ func (c *Client) ListUnspentMinMaxAddressesAsync(minConf, maxConf int, addrs []b } cmd := btcjson.NewListUnspentCmd(&minConf, &maxConf, &addrStrs) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // ListUnspent returns all unspent transaction outputs known to a wallet, using @@ -288,13 +288,13 @@ func (c *Client) ListUnspentMinMaxAddresses(minConf, maxConf int, addrs []btcuti // FutureListSinceBlockResult is a future promise to deliver the result of a // ListSinceBlockAsync or ListSinceBlockMinConfAsync RPC invocation (or an // applicable error). -type FutureListSinceBlockResult chan *response +type FutureListSinceBlockResult chan *Response -// Receive waits for the response promised by the future and returns all +// Receive waits for the Response promised by the future and returns all // transactions added in blocks since the specified block hash, or all // transactions if it is nil. func (r FutureListSinceBlockResult) Receive() (*btcjson.ListSinceBlockResult, error) { - res, err := receiveFuture(r) + res, err := ReceiveFuture(r) if err != nil { return nil, err } @@ -321,7 +321,7 @@ func (c *Client) ListSinceBlockAsync(blockHash *chainhash.Hash) FutureListSinceB } cmd := btcjson.NewListSinceBlockCmd(hash, nil, nil) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // ListSinceBlock returns all transactions added in blocks since the specified @@ -346,7 +346,7 @@ func (c *Client) ListSinceBlockMinConfAsync(blockHash *chainhash.Hash, minConfir } cmd := btcjson.NewListSinceBlockCmd(hash, &minConfirms, nil) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // ListSinceBlockMinConf returns all transactions added in blocks since the @@ -370,7 +370,7 @@ func (c *Client) ListSinceBlockMinConfWatchOnlyAsync(blockHash *chainhash.Hash, } cmd := btcjson.NewListSinceBlockCmd(hash, &minConfirms, &watchOnly) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // ListSinceBlockMinConfWatchOnly returns all transactions added in blocks since the @@ -388,12 +388,12 @@ func (c *Client) ListSinceBlockMinConfWatchOnly(blockHash *chainhash.Hash, minCo // FutureLockUnspentResult is a future promise to deliver the error result of a // LockUnspentAsync RPC invocation. -type FutureLockUnspentResult chan *response +type FutureLockUnspentResult 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 locking or unlocking the unspent output(s). func (r FutureLockUnspentResult) Receive() error { - _, err := receiveFuture(r) + _, err := ReceiveFuture(r) return err } @@ -411,7 +411,7 @@ func (c *Client) LockUnspentAsync(unlock bool, ops []*wire.OutPoint) FutureLockU } } cmd := btcjson.NewLockUnspentCmd(unlock, outputs) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // LockUnspent marks outputs as locked or unlocked, depending on the value of @@ -437,12 +437,12 @@ func (c *Client) LockUnspent(unlock bool, ops []*wire.OutPoint) error { // FutureListLockUnspentResult is a future promise to deliver the result of a // ListLockUnspentAsync RPC invocation (or an applicable error). -type FutureListLockUnspentResult chan *response +type FutureListLockUnspentResult 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 all currently locked unspent outputs. func (r FutureListLockUnspentResult) Receive() ([]*wire.OutPoint, error) { - res, err := receiveFuture(r) + res, err := ReceiveFuture(r) if err != nil { return nil, err } @@ -474,7 +474,7 @@ func (r FutureListLockUnspentResult) Receive() ([]*wire.OutPoint, error) { // See ListLockUnspent for the blocking version and more details. func (c *Client) ListLockUnspentAsync() FutureListLockUnspentResult { cmd := btcjson.NewListLockUnspentCmd() - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // ListLockUnspent returns a slice of outpoints for all unspent outputs marked @@ -486,13 +486,13 @@ func (c *Client) ListLockUnspent() ([]*wire.OutPoint, error) { // FutureSetTxFeeResult is a future promise to deliver the result of a // SetTxFeeAsync RPC invocation (or an applicable error). -type FutureSetTxFeeResult chan *response +type FutureSetTxFeeResult 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 an optional transaction fee per KB that helps ensure transactions // are processed quickly. Most transaction are 1KB. func (r FutureSetTxFeeResult) Receive() error { - _, err := receiveFuture(r) + _, err := ReceiveFuture(r) return err } @@ -503,7 +503,7 @@ func (r FutureSetTxFeeResult) Receive() error { // See SetTxFee for the blocking version and more details. func (c *Client) SetTxFeeAsync(fee btcutil.Amount) FutureSetTxFeeResult { cmd := btcjson.NewSetTxFeeCmd(fee.ToBTC()) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // SetTxFee sets an optional transaction fee per KB that helps ensure @@ -514,12 +514,12 @@ func (c *Client) SetTxFee(fee btcutil.Amount) error { // FutureSendToAddressResult is a future promise to deliver the result of a // SendToAddressAsync RPC invocation (or an applicable error). -type FutureSendToAddressResult chan *response +type FutureSendToAddressResult 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 // of the transaction sending the passed amount to the given address. func (r FutureSendToAddressResult) Receive() (*chainhash.Hash, error) { - res, err := receiveFuture(r) + res, err := ReceiveFuture(r) if err != nil { return nil, err } @@ -542,7 +542,7 @@ func (r FutureSendToAddressResult) Receive() (*chainhash.Hash, error) { func (c *Client) SendToAddressAsync(address btcutil.Address, amount btcutil.Amount) FutureSendToAddressResult { addr := address.EncodeAddress() cmd := btcjson.NewSendToAddressCmd(addr, amount.ToBTC(), nil, nil) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // SendToAddress sends the passed amount to the given address. @@ -569,7 +569,7 @@ func (c *Client) SendToAddressCommentAsync(address btcutil.Address, addr := address.EncodeAddress() cmd := btcjson.NewSendToAddressCmd(addr, amount.ToBTC(), &comment, &commentTo) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // SendToAddressComment sends the passed amount to the given address and stores @@ -592,13 +592,13 @@ func (c *Client) SendToAddressComment(address btcutil.Address, amount btcutil.Am // FutureSendFromResult is a future promise to deliver the result of a // SendFromAsync, SendFromMinConfAsync, or SendFromCommentAsync RPC invocation // (or an applicable error). -type FutureSendFromResult chan *response +type FutureSendFromResult 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 // of the transaction sending amount to the given address using the provided // account as a source of funds. func (r FutureSendFromResult) Receive() (*chainhash.Hash, error) { - res, err := receiveFuture(r) + res, err := ReceiveFuture(r) if err != nil { return nil, err } @@ -622,7 +622,7 @@ func (c *Client) SendFromAsync(fromAccount string, toAddress btcutil.Address, am addr := toAddress.EncodeAddress() cmd := btcjson.NewSendFromCmd(fromAccount, addr, amount.ToBTC(), nil, nil, nil) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // SendFrom sends the passed amount to the given address using the provided @@ -646,7 +646,7 @@ func (c *Client) SendFromMinConfAsync(fromAccount string, toAddress btcutil.Addr addr := toAddress.EncodeAddress() cmd := btcjson.NewSendFromCmd(fromAccount, addr, amount.ToBTC(), &minConfirms, nil, nil) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // SendFromMinConf sends the passed amount to the given address using the @@ -675,7 +675,7 @@ func (c *Client) SendFromCommentAsync(fromAccount string, addr := toAddress.EncodeAddress() cmd := btcjson.NewSendFromCmd(fromAccount, addr, amount.ToBTC(), &minConfirms, &comment, &commentTo) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // SendFromComment sends the passed amount to the given address using the @@ -700,13 +700,13 @@ func (c *Client) SendFromComment(fromAccount string, toAddress btcutil.Address, // FutureSendManyResult is a future promise to deliver the result of a // SendManyAsync, SendManyMinConfAsync, or SendManyCommentAsync RPC invocation // (or an applicable error). -type FutureSendManyResult chan *response +type FutureSendManyResult 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 // of the transaction sending multiple amounts to multiple addresses using the // provided account as a source of funds. func (r FutureSendManyResult) Receive() (*chainhash.Hash, error) { - res, err := receiveFuture(r) + res, err := ReceiveFuture(r) if err != nil { return nil, err } @@ -732,7 +732,7 @@ func (c *Client) SendManyAsync(fromAccount string, amounts map[btcutil.Address]b convertedAmounts[addr.EncodeAddress()] = amount.ToBTC() } cmd := btcjson.NewSendManyCmd(fromAccount, convertedAmounts, nil, nil) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // SendMany sends multiple amounts to multiple addresses using the provided @@ -762,7 +762,7 @@ func (c *Client) SendManyMinConfAsync(fromAccount string, } cmd := btcjson.NewSendManyCmd(fromAccount, convertedAmounts, &minConfirms, nil) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // SendManyMinConf sends multiple amounts to multiple addresses using the @@ -796,7 +796,7 @@ func (c *Client) SendManyCommentAsync(fromAccount string, } cmd := btcjson.NewSendManyCmd(fromAccount, convertedAmounts, &minConfirms, &comment) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // SendManyComment sends multiple amounts to multiple addresses using the @@ -824,15 +824,15 @@ func (c *Client) SendManyComment(fromAccount string, // FutureAddMultisigAddressResult is a future promise to deliver the result of a // AddMultisigAddressAsync RPC invocation (or an applicable error). type FutureAddMultisigAddressResult struct { - responseChannel chan *response + responseChannel chan *Response network *chaincfg.Params } -// Receive waits for the response promised by the future and returns the +// Receive waits for the Response promised by the future and returns the // multisignature address that requires the specified number of signatures for // the provided addresses. func (r FutureAddMultisigAddressResult) Receive() (btcutil.Address, error) { - res, err := receiveFuture(r.responseChannel) + res, err := ReceiveFuture(r.responseChannel) if err != nil { return nil, err } @@ -861,7 +861,7 @@ func (c *Client) AddMultisigAddressAsync(requiredSigs int, addresses []btcutil.A cmd := btcjson.NewAddMultisigAddressCmd(requiredSigs, addrs, &account) result := FutureAddMultisigAddressResult{ network: c.chainParams, - responseChannel: c.sendCmd(cmd), + responseChannel: c.SendCmd(cmd), } return result } @@ -874,12 +874,12 @@ func (c *Client) AddMultisigAddress(requiredSigs int, addresses []btcutil.Addres // FutureCreateMultisigResult is a future promise to deliver the result of a // CreateMultisigAsync RPC invocation (or an applicable error). -type FutureCreateMultisigResult chan *response +type FutureCreateMultisigResult 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 // multisignature address and script needed to redeem it. func (r FutureCreateMultisigResult) Receive() (*btcjson.CreateMultiSigResult, error) { - res, err := receiveFuture(r) + res, err := ReceiveFuture(r) if err != nil { return nil, err } @@ -906,7 +906,7 @@ func (c *Client) CreateMultisigAsync(requiredSigs int, addresses []btcutil.Addre } cmd := btcjson.NewCreateMultisigCmd(requiredSigs, addrs) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // CreateMultisig creates a multisignature address that requires the specified @@ -918,12 +918,12 @@ func (c *Client) CreateMultisig(requiredSigs int, addresses []btcutil.Address) ( // FutureCreateNewAccountResult is a future promise to deliver the result of a // CreateNewAccountAsync RPC invocation (or an applicable error). -type FutureCreateNewAccountResult chan *response +type FutureCreateNewAccountResult 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 // result of creating new account. func (r FutureCreateNewAccountResult) Receive() error { - _, err := receiveFuture(r) + _, err := ReceiveFuture(r) return err } @@ -934,7 +934,7 @@ func (r FutureCreateNewAccountResult) Receive() error { // See CreateNewAccount for the blocking version and more details. func (c *Client) CreateNewAccountAsync(account string) FutureCreateNewAccountResult { cmd := btcjson.NewCreateNewAccountCmd(account) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // CreateNewAccount creates a new wallet account. @@ -944,12 +944,12 @@ func (c *Client) CreateNewAccount(account string) error { // FutureCreateWalletResult is a future promise to deliver the result of a // CreateWalletAsync RPC invocation (or an applicable error). -type FutureCreateWalletResult chan *response +type FutureCreateWalletResult 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 // result of creating a new wallet. func (r FutureCreateWalletResult) Receive() (*btcjson.CreateWalletResult, error) { - res, err := receiveFuture(r) + res, err := ReceiveFuture(r) if err != nil { return nil, err } @@ -1011,7 +1011,7 @@ func (c *Client) CreateWalletAsync(name string, opts ...CreateWalletOpt) FutureC opt(cmd) } - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // CreateWallet creates a new wallet account, with the possibility to use @@ -1029,12 +1029,12 @@ func (c *Client) CreateWallet(name string, opts ...CreateWalletOpt) (*btcjson.Cr // FutureGetAddressInfoResult is a future promise to deliver the result of an // GetAddressInfoAsync RPC invocation (or an applicable error). -type FutureGetAddressInfoResult chan *response +type FutureGetAddressInfoResult chan *Response -// Receive waits for the response promised by the future and returns the information +// Receive waits for the Response promised by the future and returns the information // about the given bitcoin address. func (r FutureGetAddressInfoResult) Receive() (*btcjson.GetAddressInfoResult, error) { - res, err := receiveFuture(r) + res, err := ReceiveFuture(r) if err != nil { return nil, err } @@ -1054,7 +1054,7 @@ func (r FutureGetAddressInfoResult) Receive() (*btcjson.GetAddressInfoResult, er // See GetAddressInfo for the blocking version and more details. func (c *Client) GetAddressInfoAsync(address string) FutureGetAddressInfoResult { cmd := btcjson.NewGetAddressInfoCmd(address) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // GetAddressInfo returns information about the given bitcoin address. @@ -1065,14 +1065,14 @@ func (c *Client) GetAddressInfo(address string) (*btcjson.GetAddressInfoResult, // FutureGetNewAddressResult is a future promise to deliver the result of a // GetNewAddressAsync RPC invocation (or an applicable error). type FutureGetNewAddressResult struct { - responseChannel chan *response + responseChannel chan *Response network *chaincfg.Params } -// 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 // address. func (r FutureGetNewAddressResult) ReceiveFuture() (string, error) { - res, err := receiveFuture(r.responseChannel) + res, err := ReceiveFuture(r.responseChannel) if err != nil { return "", err } @@ -1087,10 +1087,10 @@ func (r FutureGetNewAddressResult) ReceiveFuture() (string, error) { return addr, nil } -// 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 // address. func (r FutureGetNewAddressResult) Receive() (btcutil.Address, error) { - res, err := receiveFuture(r.responseChannel) + res, err := ReceiveFuture(r.responseChannel) if err != nil { return nil, err } @@ -1114,7 +1114,7 @@ func (c *Client) GetNewAddressAsync(account string) FutureGetNewAddressResult { cmd := btcjson.NewGetNewAddressCmd(&account) result := FutureGetNewAddressResult{ network: c.chainParams, - responseChannel: c.sendCmd(cmd), + responseChannel: c.SendCmd(cmd), } return result } @@ -1128,15 +1128,15 @@ func (c *Client) GetNewAddress(account string) (btcutil.Address, error) { // FutureGetRawChangeAddressResult is a future promise to deliver the result of // a GetRawChangeAddressAsync RPC invocation (or an applicable error). type FutureGetRawChangeAddressResult struct { - responseChannel chan *response + responseChannel chan *Response network *chaincfg.Params } -// 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 // address for receiving change that will be associated with the provided // account. Note that this is only for raw transactions and NOT for normal use. func (r FutureGetRawChangeAddressResult) Receive() (btcutil.Address, error) { - res, err := receiveFuture(r.responseChannel) + res, err := ReceiveFuture(r.responseChannel) if err != nil { return nil, err } @@ -1160,7 +1160,7 @@ func (c *Client) GetRawChangeAddressAsync(account string) FutureGetRawChangeAddr cmd := btcjson.NewGetRawChangeAddressCmd(&account) result := FutureGetRawChangeAddressResult{ network: c.chainParams, - responseChannel: c.sendCmd(cmd), + responseChannel: c.SendCmd(cmd), } return result } @@ -1175,14 +1175,14 @@ func (c *Client) GetRawChangeAddress(account string) (btcutil.Address, error) { // FutureAddWitnessAddressResult is a future promise to deliver the result of // a AddWitnessAddressAsync RPC invocation (or an applicable error). type FutureAddWitnessAddressResult struct { - responseChannel chan *response + responseChannel chan *Response network *chaincfg.Params } -// Receive waits for the response promised by the future and returns the new +// Receive waits for the Response promised by the future and returns the new // address. func (r FutureAddWitnessAddressResult) Receive() (btcutil.Address, error) { - res, err := receiveFuture(r.responseChannel) + res, err := ReceiveFuture(r.responseChannel) if err != nil { return nil, err } @@ -1206,7 +1206,7 @@ func (c *Client) AddWitnessAddressAsync(address string) FutureAddWitnessAddressR cmd := btcjson.NewAddWitnessAddressCmd(address) response := FutureAddWitnessAddressResult{ network: c.chainParams, - responseChannel: c.sendCmd(cmd), + responseChannel: c.SendCmd(cmd), } return response } @@ -1220,14 +1220,14 @@ func (c *Client) AddWitnessAddress(address string) (btcutil.Address, error) { // FutureGetAccountAddressResult is a future promise to deliver the result of a // GetAccountAddressAsync RPC invocation (or an applicable error). type FutureGetAccountAddressResult struct { - responseChannel chan *response + responseChannel chan *Response network *chaincfg.Params } -// Receive waits for the response promised by the future and returns the current +// Receive waits for the Response promised by the future and returns the current // Bitcoin address for receiving payments to the specified account. func (r FutureGetAccountAddressResult) Receive() (btcutil.Address, error) { - res, err := receiveFuture(r.responseChannel) + res, err := ReceiveFuture(r.responseChannel) if err != nil { return nil, err } @@ -1251,7 +1251,7 @@ func (c *Client) GetAccountAddressAsync(account string) FutureGetAccountAddressR cmd := btcjson.NewGetAccountAddressCmd(account) result := FutureGetAccountAddressResult{ network: c.chainParams, - responseChannel: c.sendCmd(cmd), + responseChannel: c.SendCmd(cmd), } return result } @@ -1264,12 +1264,12 @@ func (c *Client) GetAccountAddress(account string) (btcutil.Address, error) { // FutureGetAccountResult is a future promise to deliver the result of a // GetAccountAsync RPC invocation (or an applicable error). -type FutureGetAccountResult chan *response +type FutureGetAccountResult chan *Response -// Receive waits for the response promised by the future and returns the account +// Receive waits for the Response promised by the future and returns the account // associated with the passed address. func (r FutureGetAccountResult) Receive() (string, error) { - res, err := receiveFuture(r) + res, err := ReceiveFuture(r) if err != nil { return "", err } @@ -1292,7 +1292,7 @@ func (r FutureGetAccountResult) Receive() (string, error) { func (c *Client) GetAccountAsync(address btcutil.Address) FutureGetAccountResult { addr := address.EncodeAddress() cmd := btcjson.NewGetAccountCmd(addr) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // GetAccount returns the account associated with the passed address. @@ -1302,12 +1302,12 @@ func (c *Client) GetAccount(address btcutil.Address) (string, error) { // FutureSetAccountResult is a future promise to deliver the result of a // SetAccountAsync RPC invocation (or an applicable error). -type FutureSetAccountResult chan *response +type FutureSetAccountResult 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 account to be associated with the passed address. func (r FutureSetAccountResult) Receive() error { - _, err := receiveFuture(r) + _, err := ReceiveFuture(r) return err } @@ -1319,7 +1319,7 @@ func (r FutureSetAccountResult) Receive() error { func (c *Client) SetAccountAsync(address btcutil.Address, account string) FutureSetAccountResult { addr := address.EncodeAddress() cmd := btcjson.NewSetAccountCmd(addr, account) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // SetAccount sets the account associated with the passed address. @@ -1330,14 +1330,14 @@ func (c *Client) SetAccount(address btcutil.Address, account string) error { // FutureGetAddressesByAccountResult is a future promise to deliver the result // of a GetAddressesByAccountAsync RPC invocation (or an applicable error). type FutureGetAddressesByAccountResult struct { - responseChannel chan *response + responseChannel chan *Response network *chaincfg.Params } -// Receive waits for the response promised by the future and returns the list of +// Receive waits for the Response promised by the future and returns the list of // addresses associated with the passed account. func (r FutureGetAddressesByAccountResult) Receive() ([]btcutil.Address, error) { - res, err := receiveFuture(r.responseChannel) + res, err := ReceiveFuture(r.responseChannel) if err != nil { return nil, err } @@ -1369,7 +1369,7 @@ func (c *Client) GetAddressesByAccountAsync(account string) FutureGetAddressesBy cmd := btcjson.NewGetAddressesByAccountCmd(account) result := FutureGetAddressesByAccountResult{ network: c.chainParams, - responseChannel: c.sendCmd(cmd), + responseChannel: c.SendCmd(cmd), } return result } @@ -1383,12 +1383,12 @@ func (c *Client) GetAddressesByAccount(account string) ([]btcutil.Address, error // FutureMoveResult is a future promise to deliver the result of a MoveAsync, // MoveMinConfAsync, or MoveCommentAsync RPC invocation (or an applicable // error). -type FutureMoveResult chan *response +type FutureMoveResult 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 the move operation. func (r FutureMoveResult) Receive() (bool, error) { - res, err := receiveFuture(r) + res, err := ReceiveFuture(r) if err != nil { return false, err } @@ -1411,7 +1411,7 @@ func (r FutureMoveResult) Receive() (bool, error) { func (c *Client) MoveAsync(fromAccount, toAccount string, amount btcutil.Amount) FutureMoveResult { cmd := btcjson.NewMoveCmd(fromAccount, toAccount, amount.ToBTC(), nil, nil) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // Move moves specified amount from one account in your wallet to another. Only @@ -1432,7 +1432,7 @@ func (c *Client) MoveMinConfAsync(fromAccount, toAccount string, cmd := btcjson.NewMoveCmd(fromAccount, toAccount, amount.ToBTC(), &minConfirms, nil) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // MoveMinConf moves specified amount from one account in your wallet to @@ -1455,7 +1455,7 @@ func (c *Client) MoveCommentAsync(fromAccount, toAccount string, cmd := btcjson.NewMoveCmd(fromAccount, toAccount, amount.ToBTC(), &minConfirms, &comment) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // MoveComment moves specified amount from one account in your wallet to @@ -1473,12 +1473,12 @@ func (c *Client) MoveComment(fromAccount, toAccount string, amount btcutil.Amoun // FutureRenameAccountResult is a future promise to deliver the result of a // RenameAccountAsync RPC invocation (or an applicable error). -type FutureRenameAccountResult chan *response +type FutureRenameAccountResult 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 // result of creating new account. func (r FutureRenameAccountResult) Receive() error { - _, err := receiveFuture(r) + _, err := ReceiveFuture(r) return err } @@ -1489,7 +1489,7 @@ func (r FutureRenameAccountResult) Receive() error { // See RenameAccount for the blocking version and more details. func (c *Client) RenameAccountAsync(oldAccount, newAccount string) FutureRenameAccountResult { cmd := btcjson.NewRenameAccountCmd(oldAccount, newAccount) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // RenameAccount creates a new wallet account. @@ -1499,12 +1499,12 @@ func (c *Client) RenameAccount(oldAccount, newAccount string) error { // FutureValidateAddressResult is a future promise to deliver the result of a // ValidateAddressAsync RPC invocation (or an applicable error). -type FutureValidateAddressResult chan *response +type FutureValidateAddressResult 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 the given bitcoin address. func (r FutureValidateAddressResult) Receive() (*btcjson.ValidateAddressWalletResult, error) { - res, err := receiveFuture(r) + res, err := ReceiveFuture(r) if err != nil { return nil, err } @@ -1527,7 +1527,7 @@ func (r FutureValidateAddressResult) Receive() (*btcjson.ValidateAddressWalletRe func (c *Client) ValidateAddressAsync(address btcutil.Address) FutureValidateAddressResult { addr := address.EncodeAddress() cmd := btcjson.NewValidateAddressCmd(addr) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // ValidateAddress returns information about the given bitcoin address. @@ -1537,12 +1537,12 @@ func (c *Client) ValidateAddress(address btcutil.Address) (*btcjson.ValidateAddr // FutureKeyPoolRefillResult is a future promise to deliver the result of a // KeyPoolRefillAsync RPC invocation (or an applicable error). -type FutureKeyPoolRefillResult chan *response +type FutureKeyPoolRefillResult 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 refilling the key pool. func (r FutureKeyPoolRefillResult) Receive() error { - _, err := receiveFuture(r) + _, err := ReceiveFuture(r) return err } @@ -1553,7 +1553,7 @@ func (r FutureKeyPoolRefillResult) Receive() error { // See KeyPoolRefill for the blocking version and more details. func (c *Client) KeyPoolRefillAsync() FutureKeyPoolRefillResult { cmd := btcjson.NewKeyPoolRefillCmd(nil) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // KeyPoolRefill fills the key pool as necessary to reach the default size. @@ -1570,7 +1570,7 @@ func (c *Client) KeyPoolRefill() error { // See KeyPoolRefillSize for the blocking version and more details. func (c *Client) KeyPoolRefillSizeAsync(newSize uint) FutureKeyPoolRefillResult { cmd := btcjson.NewKeyPoolRefillCmd(&newSize) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // KeyPoolRefillSize fills the key pool as necessary to reach the specified @@ -1586,12 +1586,12 @@ func (c *Client) KeyPoolRefillSize(newSize uint) error { // FutureListAccountsResult is a future promise to deliver the result of a // ListAccountsAsync or ListAccountsMinConfAsync RPC invocation (or an // applicable error). -type FutureListAccountsResult chan *response +type FutureListAccountsResult chan *Response -// Receive waits for the response promised by the future and returns returns a +// Receive waits for the Response promised by the future and returns returns a // map of account names and their associated balances. func (r FutureListAccountsResult) Receive() (map[string]btcutil.Amount, error) { - res, err := receiveFuture(r) + res, err := ReceiveFuture(r) if err != nil { return nil, err } @@ -1623,7 +1623,7 @@ func (r FutureListAccountsResult) Receive() (map[string]btcutil.Amount, error) { // See ListAccounts for the blocking version and more details. func (c *Client) ListAccountsAsync() FutureListAccountsResult { cmd := btcjson.NewListAccountsCmd(nil) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // ListAccounts returns a map of account names and their associated balances @@ -1641,7 +1641,7 @@ func (c *Client) ListAccounts() (map[string]btcutil.Amount, error) { // See ListAccountsMinConf for the blocking version and more details. func (c *Client) ListAccountsMinConfAsync(minConfirms int) FutureListAccountsResult { cmd := btcjson.NewListAccountsCmd(&minConfirms) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // ListAccountsMinConf returns a map of account names and their associated @@ -1655,12 +1655,12 @@ func (c *Client) ListAccountsMinConf(minConfirms int) (map[string]btcutil.Amount // FutureGetBalanceResult is a future promise to deliver the result of a // GetBalanceAsync or GetBalanceMinConfAsync RPC invocation (or an applicable // error). -type FutureGetBalanceResult chan *response +type FutureGetBalanceResult 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 // available balance from the server for the specified account. func (r FutureGetBalanceResult) Receive() (btcutil.Amount, error) { - res, err := receiveFuture(r) + res, err := ReceiveFuture(r) if err != nil { return 0, err } @@ -1684,12 +1684,12 @@ func (r FutureGetBalanceResult) Receive() (btcutil.Amount, error) { // that the result is expected to be a string which is then parsed into // a float64 value // This is required for compatibility with servers like blockchain.info -type FutureGetBalanceParseResult chan *response +type FutureGetBalanceParseResult 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 // available balance from the server for the specified account. func (r FutureGetBalanceParseResult) Receive() (btcutil.Amount, error) { - res, err := receiveFuture(r) + res, err := ReceiveFuture(r) if err != nil { return 0, err } @@ -1724,7 +1724,7 @@ func (c *Client) GetBalanceAsync(account ...string) FutureGetBalanceResult { accountPtr = &account[0] } cmd := btcjson.NewGetBalanceCmd(accountPtr, nil) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // GetBalance returns the available balance from the server for the specified @@ -1743,7 +1743,7 @@ func (c *Client) GetBalance(account ...string) (btcutil.Amount, error) { // See GetBalanceMinConf for the blocking version and more details. func (c *Client) GetBalanceMinConfAsync(account string, minConfirms int) FutureGetBalanceResult { cmd := btcjson.NewGetBalanceCmd(&account, &minConfirms) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // GetBalanceMinConf returns the available balance from the server for the @@ -1761,12 +1761,12 @@ func (c *Client) GetBalanceMinConf(account string, minConfirms int) (btcutil.Amo // FutureGetBalancesResult is a future promise to deliver the result of a // GetBalancesAsync RPC invocation (or an applicable error). -type FutureGetBalancesResult chan *response +type FutureGetBalancesResult 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 // available balances from the server. func (r FutureGetBalancesResult) Receive() (*btcjson.GetBalancesResult, error) { - res, err := receiveFuture(r) + res, err := ReceiveFuture(r) if err != nil { return nil, err } @@ -1788,7 +1788,7 @@ func (r FutureGetBalancesResult) Receive() (*btcjson.GetBalancesResult, error) { // See GetBalances for the blocking version and more details. func (c *Client) GetBalancesAsync() FutureGetBalancesResult { cmd := btcjson.NewGetBalancesCmd() - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // GetBalances returns the available balances from the server. @@ -1799,12 +1799,12 @@ func (c *Client) GetBalances() (*btcjson.GetBalancesResult, error) { // FutureGetReceivedByAccountResult is a future promise to deliver the result of // a GetReceivedByAccountAsync or GetReceivedByAccountMinConfAsync RPC // invocation (or an applicable error). -type FutureGetReceivedByAccountResult chan *response +type FutureGetReceivedByAccountResult chan *Response -// Receive waits for the response promised by the future and returns the total +// Receive waits for the Response promised by the future and returns the total // amount received with the specified account. func (r FutureGetReceivedByAccountResult) Receive() (btcutil.Amount, error) { - res, err := receiveFuture(r) + res, err := ReceiveFuture(r) if err != nil { return 0, err } @@ -1831,7 +1831,7 @@ func (r FutureGetReceivedByAccountResult) Receive() (btcutil.Amount, error) { // See GetReceivedByAccount for the blocking version and more details. func (c *Client) GetReceivedByAccountAsync(account string) FutureGetReceivedByAccountResult { cmd := btcjson.NewGetReceivedByAccountCmd(account, nil) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // GetReceivedByAccount returns the total amount received with the specified @@ -1850,7 +1850,7 @@ func (c *Client) GetReceivedByAccount(account string) (btcutil.Amount, error) { // See GetReceivedByAccountMinConf for the blocking version and more details. func (c *Client) GetReceivedByAccountMinConfAsync(account string, minConfirms int) FutureGetReceivedByAccountResult { cmd := btcjson.NewGetReceivedByAccountCmd(account, &minConfirms) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // GetReceivedByAccountMinConf returns the total amount received with the @@ -1864,12 +1864,12 @@ func (c *Client) GetReceivedByAccountMinConf(account string, minConfirms int) (b // FutureGetUnconfirmedBalanceResult is a future promise to deliver the result // of a GetUnconfirmedBalanceAsync RPC invocation (or an applicable error). -type FutureGetUnconfirmedBalanceResult chan *response +type FutureGetUnconfirmedBalanceResult chan *Response -// Receive waits for the response promised by the future and returns returns the +// Receive waits for the Response promised by the future and returns returns the // unconfirmed balance from the server for the specified account. func (r FutureGetUnconfirmedBalanceResult) Receive() (btcutil.Amount, error) { - res, err := receiveFuture(r) + res, err := ReceiveFuture(r) if err != nil { return 0, err } @@ -1896,7 +1896,7 @@ func (r FutureGetUnconfirmedBalanceResult) Receive() (btcutil.Amount, error) { // See GetUnconfirmedBalance for the blocking version and more details. func (c *Client) GetUnconfirmedBalanceAsync(account string) FutureGetUnconfirmedBalanceResult { cmd := btcjson.NewGetUnconfirmedBalanceCmd(&account) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // GetUnconfirmedBalance returns the unconfirmed balance from the server for @@ -1908,12 +1908,12 @@ func (c *Client) GetUnconfirmedBalance(account string) (btcutil.Amount, error) { // FutureGetReceivedByAddressResult is a future promise to deliver the result of // a GetReceivedByAddressAsync or GetReceivedByAddressMinConfAsync RPC // invocation (or an applicable error). -type FutureGetReceivedByAddressResult chan *response +type FutureGetReceivedByAddressResult chan *Response -// Receive waits for the response promised by the future and returns the total +// Receive waits for the Response promised by the future and returns the total // amount received by the specified address. func (r FutureGetReceivedByAddressResult) Receive() (btcutil.Amount, error) { - res, err := receiveFuture(r) + res, err := ReceiveFuture(r) if err != nil { return 0, err } @@ -1941,7 +1941,7 @@ func (r FutureGetReceivedByAddressResult) Receive() (btcutil.Amount, error) { func (c *Client) GetReceivedByAddressAsync(address btcutil.Address) FutureGetReceivedByAddressResult { addr := address.EncodeAddress() cmd := btcjson.NewGetReceivedByAddressCmd(addr, nil) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } @@ -1962,7 +1962,7 @@ func (c *Client) GetReceivedByAddress(address btcutil.Address) (btcutil.Amount, func (c *Client) GetReceivedByAddressMinConfAsync(address btcutil.Address, minConfirms int) FutureGetReceivedByAddressResult { addr := address.EncodeAddress() cmd := btcjson.NewGetReceivedByAddressCmd(addr, &minConfirms) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // GetReceivedByAddressMinConf returns the total amount received by the specified @@ -1976,12 +1976,12 @@ func (c *Client) GetReceivedByAddressMinConf(address btcutil.Address, minConfirm // FutureListAddressGroupingsResult is a future promise to deliver the result // of a ListAddressGroupingsAsync RPC invocation (or an applicable // error). -type FutureListAddressGroupingsResult chan *response +type FutureListAddressGroupingsResult 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 // balances by account. func (r FutureListAddressGroupingsResult) Receive() ([]btcjson.ListAddressGroupingsResult, error) { - res, err := receiveFuture(r) + res, err := ReceiveFuture(r) if err != nil { return nil, err } @@ -2008,7 +2008,7 @@ func (r FutureListAddressGroupingsResult) Receive() ([]btcjson.ListAddressGroupi // See ListAddressGroupings for the blocking version and more details. func (c *Client) ListAddressGroupingsAsync() FutureListAddressGroupingsResult { cmd := btcjson.NewListAddressGroupingsCmd() - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // ListAddressGroupings lists balances by account using the default number @@ -2023,12 +2023,12 @@ func (c *Client) ListAddressGroupings() ([]btcjson.ListAddressGroupingsResult, e // of a ListReceivedByAccountAsync, ListReceivedByAccountMinConfAsync, or // ListReceivedByAccountIncludeEmptyAsync RPC invocation (or an applicable // error). -type FutureListReceivedByAccountResult chan *response +type FutureListReceivedByAccountResult 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 // balances by account. func (r FutureListReceivedByAccountResult) Receive() ([]btcjson.ListReceivedByAccountResult, error) { - res, err := receiveFuture(r) + res, err := ReceiveFuture(r) if err != nil { return nil, err } @@ -2050,7 +2050,7 @@ func (r FutureListReceivedByAccountResult) Receive() ([]btcjson.ListReceivedByAc // See ListReceivedByAccount for the blocking version and more details. func (c *Client) ListReceivedByAccountAsync() FutureListReceivedByAccountResult { cmd := btcjson.NewListReceivedByAccountCmd(nil, nil, nil) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // ListReceivedByAccount lists balances by account using the default number @@ -2071,7 +2071,7 @@ func (c *Client) ListReceivedByAccount() ([]btcjson.ListReceivedByAccountResult, // See ListReceivedByAccountMinConf for the blocking version and more details. func (c *Client) ListReceivedByAccountMinConfAsync(minConfirms int) FutureListReceivedByAccountResult { cmd := btcjson.NewListReceivedByAccountCmd(&minConfirms, nil, nil) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // ListReceivedByAccountMinConf lists balances by account using the specified @@ -2093,7 +2093,7 @@ func (c *Client) ListReceivedByAccountMinConf(minConfirms int) ([]btcjson.ListRe func (c *Client) ListReceivedByAccountIncludeEmptyAsync(minConfirms int, includeEmpty bool) FutureListReceivedByAccountResult { cmd := btcjson.NewListReceivedByAccountCmd(&minConfirms, &includeEmpty, nil) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // ListReceivedByAccountIncludeEmpty lists balances by account using the @@ -2110,12 +2110,12 @@ func (c *Client) ListReceivedByAccountIncludeEmpty(minConfirms int, includeEmpty // of a ListReceivedByAddressAsync, ListReceivedByAddressMinConfAsync, or // ListReceivedByAddressIncludeEmptyAsync RPC invocation (or an applicable // error). -type FutureListReceivedByAddressResult chan *response +type FutureListReceivedByAddressResult 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 // balances by address. func (r FutureListReceivedByAddressResult) Receive() ([]btcjson.ListReceivedByAddressResult, error) { - res, err := receiveFuture(r) + res, err := ReceiveFuture(r) if err != nil { return nil, err } @@ -2137,7 +2137,7 @@ func (r FutureListReceivedByAddressResult) Receive() ([]btcjson.ListReceivedByAd // See ListReceivedByAddress for the blocking version and more details. func (c *Client) ListReceivedByAddressAsync() FutureListReceivedByAddressResult { cmd := btcjson.NewListReceivedByAddressCmd(nil, nil, nil) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // ListReceivedByAddress lists balances by address using the default number @@ -2158,7 +2158,7 @@ func (c *Client) ListReceivedByAddress() ([]btcjson.ListReceivedByAddressResult, // See ListReceivedByAddressMinConf for the blocking version and more details. func (c *Client) ListReceivedByAddressMinConfAsync(minConfirms int) FutureListReceivedByAddressResult { cmd := btcjson.NewListReceivedByAddressCmd(&minConfirms, nil, nil) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // ListReceivedByAddressMinConf lists balances by address using the specified @@ -2180,7 +2180,7 @@ func (c *Client) ListReceivedByAddressMinConf(minConfirms int) ([]btcjson.ListRe func (c *Client) ListReceivedByAddressIncludeEmptyAsync(minConfirms int, includeEmpty bool) FutureListReceivedByAddressResult { cmd := btcjson.NewListReceivedByAddressCmd(&minConfirms, &includeEmpty, nil) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // ListReceivedByAddressIncludeEmpty lists balances by address using the @@ -2199,12 +2199,12 @@ func (c *Client) ListReceivedByAddressIncludeEmpty(minConfirms int, includeEmpty // FutureWalletLockResult is a future promise to deliver the result of a // WalletLockAsync RPC invocation (or an applicable error). -type FutureWalletLockResult chan *response +type FutureWalletLockResult 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 locking the wallet. func (r FutureWalletLockResult) Receive() error { - _, err := receiveFuture(r) + _, err := ReceiveFuture(r) return err } @@ -2215,7 +2215,7 @@ func (r FutureWalletLockResult) Receive() error { // See WalletLock for the blocking version and more details. func (c *Client) WalletLockAsync() FutureWalletLockResult { cmd := btcjson.NewWalletLockCmd() - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // WalletLock locks the wallet by removing the encryption key from memory. @@ -2238,12 +2238,12 @@ func (c *Client) WalletPassphrase(passphrase string, timeoutSecs int64) error { // FutureWalletPassphraseChangeResult is a future promise to deliver the result // of a WalletPassphraseChangeAsync RPC invocation (or an applicable error). -type FutureWalletPassphraseChangeResult chan *response +type FutureWalletPassphraseChangeResult 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 changing the wallet passphrase. func (r FutureWalletPassphraseChangeResult) Receive() error { - _, err := receiveFuture(r) + _, err := ReceiveFuture(r) return err } @@ -2254,7 +2254,7 @@ func (r FutureWalletPassphraseChangeResult) Receive() error { // See WalletPassphraseChange for the blocking version and more details. func (c *Client) WalletPassphraseChangeAsync(old, new string) FutureWalletPassphraseChangeResult { cmd := btcjson.NewWalletPassphraseChangeCmd(old, new) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // WalletPassphraseChange changes the wallet passphrase from the specified old @@ -2269,12 +2269,12 @@ func (c *Client) WalletPassphraseChange(old, new string) error { // FutureSignMessageResult is a future promise to deliver the result of a // SignMessageAsync RPC invocation (or an applicable error). -type FutureSignMessageResult chan *response +type FutureSignMessageResult chan *Response -// Receive waits for the response promised by the future and returns the message +// Receive waits for the Response promised by the future and returns the message // signed with the private key of the specified address. func (r FutureSignMessageResult) Receive() (string, error) { - res, err := receiveFuture(r) + res, err := ReceiveFuture(r) if err != nil { return "", err } @@ -2297,7 +2297,7 @@ func (r FutureSignMessageResult) Receive() (string, error) { func (c *Client) SignMessageAsync(address btcutil.Address, message string) FutureSignMessageResult { addr := address.EncodeAddress() cmd := btcjson.NewSignMessageCmd(addr, message) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // SignMessage signs a message with the private key of the specified address. @@ -2310,12 +2310,12 @@ func (c *Client) SignMessage(address btcutil.Address, message string) (string, e // FutureVerifyMessageResult is a future promise to deliver the result of a // VerifyMessageAsync RPC invocation (or an applicable error). -type FutureVerifyMessageResult chan *response +type FutureVerifyMessageResult chan *Response -// Receive waits for the response promised by the future and returns whether or +// Receive waits for the Response promised by the future and returns whether or // not the message was successfully verified. func (r FutureVerifyMessageResult) Receive() (bool, error) { - res, err := receiveFuture(r) + res, err := ReceiveFuture(r) if err != nil { return false, err } @@ -2338,7 +2338,7 @@ func (r FutureVerifyMessageResult) Receive() (bool, error) { func (c *Client) VerifyMessageAsync(address btcutil.Address, signature, message string) FutureVerifyMessageResult { addr := address.EncodeAddress() cmd := btcjson.NewVerifyMessageCmd(addr, signature, message) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // VerifyMessage verifies a signed message. @@ -2355,13 +2355,13 @@ func (c *Client) VerifyMessage(address btcutil.Address, signature, message strin // FutureDumpPrivKeyResult is a future promise to deliver the result of a // DumpPrivKeyAsync RPC invocation (or an applicable error). -type FutureDumpPrivKeyResult chan *response +type FutureDumpPrivKeyResult chan *Response -// Receive waits for the response promised by the future and returns the private +// Receive waits for the Response promised by the future and returns the private // key corresponding to the passed address encoded in the wallet import format // (WIF) func (r FutureDumpPrivKeyResult) Receive() (*btcutil.WIF, error) { - res, err := receiveFuture(r) + res, err := ReceiveFuture(r) if err != nil { return nil, err } @@ -2384,7 +2384,7 @@ func (r FutureDumpPrivKeyResult) Receive() (*btcutil.WIF, error) { func (c *Client) DumpPrivKeyAsync(address btcutil.Address) FutureDumpPrivKeyResult { addr := address.EncodeAddress() cmd := btcjson.NewDumpPrivKeyCmd(addr) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // DumpPrivKey gets the private key corresponding to the passed address encoded @@ -2398,12 +2398,12 @@ func (c *Client) DumpPrivKey(address btcutil.Address) (*btcutil.WIF, error) { // FutureImportAddressResult is a future promise to deliver the result of an // ImportAddressAsync RPC invocation (or an applicable error). -type FutureImportAddressResult chan *response +type FutureImportAddressResult 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 importing the passed public address. func (r FutureImportAddressResult) Receive() error { - _, err := receiveFuture(r) + _, err := ReceiveFuture(r) return err } @@ -2414,7 +2414,7 @@ func (r FutureImportAddressResult) Receive() error { // See ImportAddress for the blocking version and more details. func (c *Client) ImportAddressAsync(address string) FutureImportAddressResult { cmd := btcjson.NewImportAddressCmd(address, "", nil) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // ImportAddress imports the passed public address. @@ -2429,7 +2429,7 @@ func (c *Client) ImportAddress(address string) error { // See ImportAddress for the blocking version and more details. func (c *Client) ImportAddressRescanAsync(address string, account string, rescan bool) FutureImportAddressResult { cmd := btcjson.NewImportAddressCmd(address, account, &rescan) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // ImportAddressRescan imports the passed public address. When rescan is true, @@ -2440,12 +2440,12 @@ func (c *Client) ImportAddressRescan(address string, account string, rescan bool // FutureImportMultiResult is a future promise to deliver the result of an // ImportMultiAsync RPC invocation (or an applicable error). -type FutureImportMultiResult chan *response +type FutureImportMultiResult 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 importing multiple addresses/scripts. func (r FutureImportMultiResult) Receive() (btcjson.ImportMultiResults, error) { - res, err := receiveFuture(r) + res, err := ReceiveFuture(r) if err != nil { return nil, err } @@ -2465,7 +2465,7 @@ func (r FutureImportMultiResult) Receive() (btcjson.ImportMultiResults, error) { // See ImportMulti for the blocking version and more details. func (c *Client) ImportMultiAsync(requests []btcjson.ImportMultiRequest, options *btcjson.ImportMultiOptions) FutureImportMultiResult { cmd := btcjson.NewImportMultiCmd(requests, options) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // ImportMulti imports addresses/scripts, optionally rescanning the blockchain @@ -2478,13 +2478,13 @@ func (c *Client) ImportMulti(requests []btcjson.ImportMultiRequest, options *btc // FutureImportPrivKeyResult is a future promise to deliver the result of an // ImportPrivKeyAsync RPC invocation (or an applicable error). -type FutureImportPrivKeyResult chan *response +type FutureImportPrivKeyResult 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 importing the passed private key which must be the wallet import format // (WIF). func (r FutureImportPrivKeyResult) Receive() error { - _, err := receiveFuture(r) + _, err := ReceiveFuture(r) return err } @@ -2500,7 +2500,7 @@ func (c *Client) ImportPrivKeyAsync(privKeyWIF *btcutil.WIF) FutureImportPrivKey } cmd := btcjson.NewImportPrivKeyCmd(wif, nil, nil) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // ImportPrivKey imports the passed private key which must be the wallet import @@ -2521,7 +2521,7 @@ func (c *Client) ImportPrivKeyLabelAsync(privKeyWIF *btcutil.WIF, label string) } cmd := btcjson.NewImportPrivKeyCmd(wif, &label, nil) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // ImportPrivKeyLabel imports the passed private key which must be the wallet import @@ -2542,7 +2542,7 @@ func (c *Client) ImportPrivKeyRescanAsync(privKeyWIF *btcutil.WIF, label string, } cmd := btcjson.NewImportPrivKeyCmd(wif, &label, &rescan) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // ImportPrivKeyRescan imports the passed private key which must be the wallet import @@ -2554,12 +2554,12 @@ func (c *Client) ImportPrivKeyRescan(privKeyWIF *btcutil.WIF, label string, resc // FutureImportPubKeyResult is a future promise to deliver the result of an // ImportPubKeyAsync RPC invocation (or an applicable error). -type FutureImportPubKeyResult chan *response +type FutureImportPubKeyResult 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 importing the passed public key. func (r FutureImportPubKeyResult) Receive() error { - _, err := receiveFuture(r) + _, err := ReceiveFuture(r) return err } @@ -2570,7 +2570,7 @@ func (r FutureImportPubKeyResult) Receive() error { // See ImportPubKey for the blocking version and more details. func (c *Client) ImportPubKeyAsync(pubKey string) FutureImportPubKeyResult { cmd := btcjson.NewImportPubKeyCmd(pubKey, nil) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // ImportPubKey imports the passed public key. @@ -2585,7 +2585,7 @@ func (c *Client) ImportPubKey(pubKey string) error { // See ImportPubKey for the blocking version and more details. func (c *Client) ImportPubKeyRescanAsync(pubKey string, rescan bool) FutureImportPubKeyResult { cmd := btcjson.NewImportPubKeyCmd(pubKey, &rescan) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // ImportPubKeyRescan imports the passed public key. When rescan is true, the @@ -2603,21 +2603,21 @@ func (c *Client) ImportPubKeyRescan(pubKey string, rescan bool) error { // FutureGetInfoResult is a future promise to deliver the result of a // GetInfoAsync RPC invocation (or an applicable error). -type FutureGetInfoResult chan *response +type FutureGetInfoResult chan *Response -// Receive waits for the response promised by the future. +// Receive waits for the Response promised by the future. func (r FutureGetInfoResult) ReceiveFuture() ([]byte, error) { - res, err := receiveFuture(r) + res, err := ReceiveFuture(r) if err != nil { return nil, err } return res, nil } -// 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 FutureGetInfoResult) Receive() (*btcjson.InfoWalletResult, error) { - res, err := receiveFuture(r) + res, err := ReceiveFuture(r) if err != nil { return nil, err } @@ -2639,7 +2639,7 @@ func (r FutureGetInfoResult) Receive() (*btcjson.InfoWalletResult, error) { // See GetInfo for the blocking version and more details. func (c *Client) GetInfoAsync() FutureGetInfoResult { cmd := btcjson.NewGetInfoCmd() - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // GetInfo returns miscellaneous info regarding the RPC server. The returned @@ -2651,13 +2651,13 @@ func (c *Client) GetInfo() (*btcjson.InfoWalletResult, error) { // FutureImportPubKeyResult is a future promise to deliver the result of an // WalletCreateFundedPsbt RPC invocation (or an applicable error). -type FutureWalletCreateFundedPsbtResult chan *response +type FutureWalletCreateFundedPsbtResult 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 // partially signed transaction in PSBT format along with the resulting fee // and change output index. func (r FutureWalletCreateFundedPsbtResult) Receive() (*btcjson.WalletCreateFundedPsbtResult, error) { - res, err := receiveFuture(r) + res, err := ReceiveFuture(r) if err != nil { return nil, err } @@ -2682,7 +2682,7 @@ func (c *Client) WalletCreateFundedPsbtAsync( options *btcjson.WalletCreateFundedPsbtOpts, bip32Derivs *bool, ) FutureWalletCreateFundedPsbtResult { cmd := btcjson.NewWalletCreateFundedPsbtCmd(inputs, outputs, locktime, options, bip32Derivs) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // WalletCreateFundedPsbt creates and funds a transaction in the Partially @@ -2697,13 +2697,13 @@ func (c *Client) WalletCreateFundedPsbt( // FutureWalletProcessPsbtResult is a future promise to deliver the result of a // WalletCreateFundedPsb RPC invocation (or an applicable error). -type FutureWalletProcessPsbtResult chan *response +type FutureWalletProcessPsbtResult chan *Response -// Receive waits for the response promised by the future and returns an updated +// Receive waits for the Response promised by the future and returns an updated // PSBT with signed inputs from the wallet and a boolen indicating if the the // transaction has a complete set of signatures. func (r FutureWalletProcessPsbtResult) Receive() (*btcjson.WalletProcessPsbtResult, error) { - res, err := receiveFuture(r) + res, err := ReceiveFuture(r) if err != nil { return nil, err } @@ -2727,7 +2727,7 @@ func (c *Client) WalletProcessPsbtAsync( psbt string, sign *bool, sighashType SigHashType, bip32Derivs *bool, ) FutureWalletProcessPsbtResult { cmd := btcjson.NewWalletProcessPsbtCmd(psbt, sign, btcjson.String(sighashType.String()), bip32Derivs) - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // WalletProcessPsbt updates a PSBT with input information from our wallet and @@ -2740,12 +2740,12 @@ func (c *Client) WalletProcessPsbt( // FutureGetWalletInfoResult is a future promise to deliver the result of an // GetWalletInfoAsync RPC invocation (or an applicable error). -type FutureGetWalletInfoResult chan *response +type FutureGetWalletInfoResult 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 wallet state info. func (r FutureGetWalletInfoResult) Receive() (*btcjson.GetWalletInfoResult, error) { - res, err := receiveFuture(r) + res, err := ReceiveFuture(r) if err != nil { return nil, err } @@ -2765,7 +2765,7 @@ func (r FutureGetWalletInfoResult) Receive() (*btcjson.GetWalletInfoResult, erro // See GetWalletInfo for the blocking version and more details. func (c *Client) GetWalletInfoAsync() FutureGetWalletInfoResult { cmd := btcjson.NewGetWalletInfoCmd() - return c.sendCmd(cmd) + return c.SendCmd(cmd) } // GetWalletInfo returns various wallet state info. @@ -2775,11 +2775,11 @@ func (c *Client) GetWalletInfo() (*btcjson.GetWalletInfoResult, error) { // FutureBackupWalletResult is a future promise to deliver the result of an // BackupWalletAsync RPC invocation (or an applicable error) -type FutureBackupWalletResult chan *response +type FutureBackupWalletResult chan *Response -// Receive waits for the response promised by the future +// Receive waits for the Response promised by the future func (r FutureBackupWalletResult) Receive() error { - _, err := receiveFuture(r) + _, err := ReceiveFuture(r) return err } @@ -2789,7 +2789,7 @@ func (r FutureBackupWalletResult) Receive() error { // // See BackupWallet for the blocking version and more details. func (c *Client) BackupWalletAsync(destination string) FutureBackupWalletResult { - return c.sendCmd(btcjson.NewBackupWalletCmd(destination)) + return c.SendCmd(btcjson.NewBackupWalletCmd(destination)) } // BackupWallet safely copies current wallet file to destination, which can @@ -2800,11 +2800,11 @@ func (c *Client) BackupWallet(destination string) error { // FutureDumpWalletResult is a future promise to deliver the result of an // DumpWallet RPC invocation (or an applicable error) -type FutureDumpWalletResult chan *response +type FutureDumpWalletResult chan *Response -// Receive waits for the response promised by the future +// Receive waits for the Response promised by the future func (r FutureDumpWalletResult) Receive() (*btcjson.DumpWalletResult, error) { - bytes, err := receiveFuture(r) + bytes, err := ReceiveFuture(r) if err != nil { return nil, err } @@ -2820,7 +2820,7 @@ func (r FutureDumpWalletResult) Receive() (*btcjson.DumpWalletResult, error) { // // See DumpWalletAsync for the blocking version and more details. func (c *Client) DumpWalletAsync(destination string) FutureDumpWalletResult { - return c.sendCmd(btcjson.NewDumpWalletCmd(destination)) + return c.SendCmd(btcjson.NewDumpWalletCmd(destination)) } // DumpWallet dumps all wallet keys in a human-readable format to a server-side file. @@ -2830,11 +2830,11 @@ func (c *Client) DumpWallet(destination string) (*btcjson.DumpWalletResult, erro // FutureImportWalletResult is a future promise to deliver the result of an // ImportWalletAsync RPC invocation (or an applicable error) -type FutureImportWalletResult chan *response +type FutureImportWalletResult chan *Response -// Receive waits for the response promised by the future +// Receive waits for the Response promised by the future func (r FutureImportWalletResult) Receive() error { - _, err := receiveFuture(r) + _, err := ReceiveFuture(r) return err } @@ -2844,7 +2844,7 @@ func (r FutureImportWalletResult) Receive() error { // // See ImportWallet for the blocking version and more details. func (c *Client) ImportWalletAsync(filename string) FutureImportWalletResult { - return c.sendCmd(btcjson.NewImportWalletCmd(filename)) + return c.SendCmd(btcjson.NewImportWalletCmd(filename)) } // ImportWallet imports keys from a wallet dump file (see DumpWallet). @@ -2854,11 +2854,11 @@ func (c *Client) ImportWallet(filename string) error { // FutureUnloadWalletResult is a future promise to deliver the result of an // UnloadWalletAsync RPC invocation (or an applicable error) -type FutureUnloadWalletResult chan *response +type FutureUnloadWalletResult chan *Response -// Receive waits for the response promised by the future +// Receive waits for the Response promised by the future func (r FutureUnloadWalletResult) Receive() error { - _, err := receiveFuture(r) + _, err := ReceiveFuture(r) return err } @@ -2868,7 +2868,7 @@ func (r FutureUnloadWalletResult) Receive() error { // // See UnloadWallet for the blocking version and more details. func (c *Client) UnloadWalletAsync(walletName *string) FutureUnloadWalletResult { - return c.sendCmd(btcjson.NewUnloadWalletCmd(walletName)) + return c.SendCmd(btcjson.NewUnloadWalletCmd(walletName)) } // UnloadWallet unloads the referenced wallet. If the RPC server URL already @@ -2880,11 +2880,11 @@ func (c *Client) UnloadWallet(walletName *string) error { // FutureLoadWalletResult is a future promise to deliver the result of an // LoadWalletAsync RPC invocation (or an applicable error) -type FutureLoadWalletResult chan *response +type FutureLoadWalletResult chan *Response -// Receive waits for the response promised by the future +// Receive waits for the Response promised by the future func (r FutureLoadWalletResult) Receive() (*btcjson.LoadWalletResult, error) { - bytes, err := receiveFuture(r) + bytes, err := ReceiveFuture(r) if err != nil { return nil, err } @@ -2899,7 +2899,7 @@ func (r FutureLoadWalletResult) Receive() (*btcjson.LoadWalletResult, error) { // // See LoadWallet for the blocking version and more details. func (c *Client) LoadWalletAsync(walletName string) FutureLoadWalletResult { - return c.sendCmd(btcjson.NewLoadWalletCmd(walletName)) + return c.SendCmd(btcjson.NewLoadWalletCmd(walletName)) } // LoadWallet loads a wallet from a wallet file or directory.