rpcclient: Export symbols needed for custom commands (#1457)
* rpcclient: Export sendCmd and response This facilitates using custom commands with rpcclient. See https://github.com/btcsuite/btcd/issues/1083 * rpcclient: Export receiveFuture This facilitates using custom commands with rpcclient. See https://github.com/btcsuite/btcd/issues/1083 * rpcclient: Add customcommand example * rpcclient: remove "Namecoin" from customcommand readme heading
This commit is contained in:
parent
f9d72f05a4
commit
3e2d8464f1
11 changed files with 732 additions and 590 deletions
|
@ -17,12 +17,12 @@ import (
|
||||||
|
|
||||||
// FutureGetBestBlockHashResult is a future promise to deliver the result of a
|
// FutureGetBestBlockHashResult is a future promise to deliver the result of a
|
||||||
// GetBestBlockAsync RPC invocation (or an applicable error).
|
// 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.
|
// the best block in the longest block chain.
|
||||||
func (r FutureGetBestBlockHashResult) Receive() (*chainhash.Hash, error) {
|
func (r FutureGetBestBlockHashResult) Receive() (*chainhash.Hash, error) {
|
||||||
res, err := receiveFuture(r)
|
res, err := ReceiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ func (r FutureGetBestBlockHashResult) Receive() (*chainhash.Hash, error) {
|
||||||
// See GetBestBlockHash for the blocking version and more details.
|
// See GetBestBlockHash for the blocking version and more details.
|
||||||
func (c *Client) GetBestBlockHashAsync() FutureGetBestBlockHashResult {
|
func (c *Client) GetBestBlockHashAsync() FutureGetBestBlockHashResult {
|
||||||
cmd := btcjson.NewGetBestBlockHashCmd()
|
cmd := btcjson.NewGetBestBlockHashCmd()
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetBestBlockHash returns the hash of the best block in the longest block
|
// GetBestBlockHash returns the hash of the best block in the longest block
|
||||||
|
@ -75,13 +75,13 @@ func (c *Client) legacyGetBlockRequest(hash string, verbose,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// waitForGetBlockRes waits for the response of a getblock request. If the
|
// waitForGetBlockRes waits for the Response of a getblock request. If the
|
||||||
// response indicates an invalid parameter was provided, a legacy style of the
|
// Response indicates an invalid parameter was provided, a legacy style of the
|
||||||
// request is resent and its response is returned instead.
|
// request is resent and its Response is returned instead.
|
||||||
func (c *Client) waitForGetBlockRes(respChan chan *response, hash string,
|
func (c *Client) waitForGetBlockRes(respChan chan *Response, hash string,
|
||||||
verbose, verboseTx bool) ([]byte, error) {
|
verbose, verboseTx bool) ([]byte, error) {
|
||||||
|
|
||||||
res, err := receiveFuture(respChan)
|
res, err := ReceiveFuture(respChan)
|
||||||
|
|
||||||
// If we receive an invalid parameter error, then we may be
|
// If we receive an invalid parameter error, then we may be
|
||||||
// communicating with a btcd node which only understands the legacy
|
// communicating with a btcd node which only understands the legacy
|
||||||
|
@ -91,7 +91,7 @@ func (c *Client) waitForGetBlockRes(respChan chan *response, hash string,
|
||||||
return c.legacyGetBlockRequest(hash, verbose, verboseTx)
|
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
|
return res, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,10 +100,10 @@ func (c *Client) waitForGetBlockRes(respChan chan *response, hash string,
|
||||||
type FutureGetBlockResult struct {
|
type FutureGetBlockResult struct {
|
||||||
client *Client
|
client *Client
|
||||||
hash string
|
hash string
|
||||||
Response chan *response
|
Response chan *Response
|
||||||
}
|
}
|
||||||
|
|
||||||
// Receive waits for the response promised by the future and returns the raw
|
// Receive waits for the Response promised by the future and returns the raw
|
||||||
// block requested from the server given its hash.
|
// block requested from the server given its hash.
|
||||||
func (r FutureGetBlockResult) Receive() (*wire.MsgBlock, error) {
|
func (r FutureGetBlockResult) Receive() (*wire.MsgBlock, error) {
|
||||||
res, err := r.client.waitForGetBlockRes(r.Response, r.hash, false, false)
|
res, err := r.client.waitForGetBlockRes(r.Response, r.hash, false, false)
|
||||||
|
@ -148,7 +148,7 @@ func (c *Client) GetBlockAsync(blockHash *chainhash.Hash) FutureGetBlockResult {
|
||||||
return FutureGetBlockResult{
|
return FutureGetBlockResult{
|
||||||
client: c,
|
client: c,
|
||||||
hash: hash,
|
hash: hash,
|
||||||
Response: c.sendCmd(cmd),
|
Response: c.SendCmd(cmd),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,10 +165,10 @@ func (c *Client) GetBlock(blockHash *chainhash.Hash) (*wire.MsgBlock, error) {
|
||||||
type FutureGetBlockVerboseResult struct {
|
type FutureGetBlockVerboseResult struct {
|
||||||
client *Client
|
client *Client
|
||||||
hash string
|
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.
|
// structure from the server with information about the requested block.
|
||||||
func (r FutureGetBlockVerboseResult) Receive() (*btcjson.GetBlockVerboseResult, error) {
|
func (r FutureGetBlockVerboseResult) Receive() (*btcjson.GetBlockVerboseResult, error) {
|
||||||
res, err := r.client.waitForGetBlockRes(r.Response, r.hash, true, false)
|
res, err := r.client.waitForGetBlockRes(r.Response, r.hash, true, false)
|
||||||
|
@ -201,7 +201,7 @@ func (c *Client) GetBlockVerboseAsync(blockHash *chainhash.Hash) FutureGetBlockV
|
||||||
return FutureGetBlockVerboseResult{
|
return FutureGetBlockVerboseResult{
|
||||||
client: c,
|
client: c,
|
||||||
hash: hash,
|
hash: hash,
|
||||||
Response: c.sendCmd(cmd),
|
Response: c.SendCmd(cmd),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,10 +219,10 @@ func (c *Client) GetBlockVerbose(blockHash *chainhash.Hash) (*btcjson.GetBlockVe
|
||||||
type FutureGetBlockVerboseTxResult struct {
|
type FutureGetBlockVerboseTxResult struct {
|
||||||
client *Client
|
client *Client
|
||||||
hash string
|
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.
|
// version of the block including detailed information about its transactions.
|
||||||
func (r FutureGetBlockVerboseTxResult) Receive() (*btcjson.GetBlockVerboseTxResult, error) {
|
func (r FutureGetBlockVerboseTxResult) Receive() (*btcjson.GetBlockVerboseTxResult, error) {
|
||||||
res, err := r.client.waitForGetBlockRes(r.Response, r.hash, true, true)
|
res, err := r.client.waitForGetBlockRes(r.Response, r.hash, true, true)
|
||||||
|
@ -258,7 +258,7 @@ func (c *Client) GetBlockVerboseTxAsync(blockHash *chainhash.Hash) FutureGetBloc
|
||||||
return FutureGetBlockVerboseTxResult{
|
return FutureGetBlockVerboseTxResult{
|
||||||
client: c,
|
client: c,
|
||||||
hash: hash,
|
hash: hash,
|
||||||
Response: c.sendCmd(cmd),
|
Response: c.SendCmd(cmd),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,12 +273,12 @@ func (c *Client) GetBlockVerboseTx(blockHash *chainhash.Hash) (*btcjson.GetBlock
|
||||||
|
|
||||||
// FutureGetBlockCountResult is a future promise to deliver the result of a
|
// FutureGetBlockCountResult is a future promise to deliver the result of a
|
||||||
// GetBlockCountAsync RPC invocation (or an applicable error).
|
// 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.
|
// of blocks in the longest block chain.
|
||||||
func (r FutureGetBlockCountResult) Receive() (int64, error) {
|
func (r FutureGetBlockCountResult) Receive() (int64, error) {
|
||||||
res, err := receiveFuture(r)
|
res, err := ReceiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
@ -299,7 +299,7 @@ func (r FutureGetBlockCountResult) Receive() (int64, error) {
|
||||||
// See GetBlockCount for the blocking version and more details.
|
// See GetBlockCount for the blocking version and more details.
|
||||||
func (c *Client) GetBlockCountAsync() FutureGetBlockCountResult {
|
func (c *Client) GetBlockCountAsync() FutureGetBlockCountResult {
|
||||||
cmd := btcjson.NewGetBlockCountCmd()
|
cmd := btcjson.NewGetBlockCountCmd()
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetBlockCount returns the number of blocks in the longest block chain.
|
// GetBlockCount returns the number of blocks in the longest block chain.
|
||||||
|
@ -309,11 +309,11 @@ func (c *Client) GetBlockCount() (int64, error) {
|
||||||
|
|
||||||
// FutureGetChainTxStatsResult is a future promise to deliver the result of a
|
// FutureGetChainTxStatsResult is a future promise to deliver the result of a
|
||||||
// GetChainTxStatsAsync RPC invocation (or an applicable error).
|
// 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) {
|
func (r FutureGetChainTxStatsResult) Receive() (*btcjson.GetChainTxStatsResult, error) {
|
||||||
res, err := receiveFuture(r)
|
res, err := ReceiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -334,7 +334,7 @@ func (r FutureGetChainTxStatsResult) Receive() (*btcjson.GetChainTxStatsResult,
|
||||||
// See GetChainTxStats for the blocking version and more details.
|
// See GetChainTxStats for the blocking version and more details.
|
||||||
func (c *Client) GetChainTxStatsAsync() FutureGetChainTxStatsResult {
|
func (c *Client) GetChainTxStatsAsync() FutureGetChainTxStatsResult {
|
||||||
cmd := btcjson.NewGetChainTxStatsCmd(nil, nil)
|
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
|
// GetChainTxStatsNBlocksAsync returns an instance of a type that can be used to get
|
||||||
|
@ -344,7 +344,7 @@ func (c *Client) GetChainTxStatsAsync() FutureGetChainTxStatsResult {
|
||||||
// See GetChainTxStatsNBlocks for the blocking version and more details.
|
// See GetChainTxStatsNBlocks for the blocking version and more details.
|
||||||
func (c *Client) GetChainTxStatsNBlocksAsync(nBlocks int32) FutureGetChainTxStatsResult {
|
func (c *Client) GetChainTxStatsNBlocksAsync(nBlocks int32) FutureGetChainTxStatsResult {
|
||||||
cmd := btcjson.NewGetChainTxStatsCmd(&nBlocks, nil)
|
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
|
// GetChainTxStatsNBlocksBlockHashAsync returns an instance of a type that can be used to get
|
||||||
|
@ -355,7 +355,7 @@ func (c *Client) GetChainTxStatsNBlocksAsync(nBlocks int32) FutureGetChainTxStat
|
||||||
func (c *Client) GetChainTxStatsNBlocksBlockHashAsync(nBlocks int32, blockHash chainhash.Hash) FutureGetChainTxStatsResult {
|
func (c *Client) GetChainTxStatsNBlocksBlockHashAsync(nBlocks int32, blockHash chainhash.Hash) FutureGetChainTxStatsResult {
|
||||||
hash := blockHash.String()
|
hash := blockHash.String()
|
||||||
cmd := btcjson.NewGetChainTxStatsCmd(&nBlocks, &hash)
|
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.
|
// GetChainTxStats returns statistics about the total number and rate of transactions in the chain.
|
||||||
|
@ -382,12 +382,12 @@ func (c *Client) GetChainTxStatsNBlocksBlockHash(nBlocks int32, blockHash chainh
|
||||||
|
|
||||||
// FutureGetDifficultyResult is a future promise to deliver the result of a
|
// FutureGetDifficultyResult is a future promise to deliver the result of a
|
||||||
// GetDifficultyAsync RPC invocation (or an applicable error).
|
// 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.
|
// proof-of-work difficulty as a multiple of the minimum difficulty.
|
||||||
func (r FutureGetDifficultyResult) Receive() (float64, error) {
|
func (r FutureGetDifficultyResult) Receive() (float64, error) {
|
||||||
res, err := receiveFuture(r)
|
res, err := ReceiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
@ -408,7 +408,7 @@ func (r FutureGetDifficultyResult) Receive() (float64, error) {
|
||||||
// See GetDifficulty for the blocking version and more details.
|
// See GetDifficulty for the blocking version and more details.
|
||||||
func (c *Client) GetDifficultyAsync() FutureGetDifficultyResult {
|
func (c *Client) GetDifficultyAsync() FutureGetDifficultyResult {
|
||||||
cmd := btcjson.NewGetDifficultyCmd()
|
cmd := btcjson.NewGetDifficultyCmd()
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetDifficulty returns the proof-of-work difficulty as a multiple of the
|
// GetDifficulty returns the proof-of-work difficulty as a multiple of the
|
||||||
|
@ -421,7 +421,7 @@ func (c *Client) GetDifficulty() (float64, error) {
|
||||||
// GetBlockChainInfoAsync RPC invocation (or an applicable error).
|
// GetBlockChainInfoAsync RPC invocation (or an applicable error).
|
||||||
type FutureGetBlockChainInfoResult struct {
|
type FutureGetBlockChainInfoResult struct {
|
||||||
client *Client
|
client *Client
|
||||||
Response chan *response
|
Response chan *Response
|
||||||
}
|
}
|
||||||
|
|
||||||
// unmarshalPartialGetBlockChainInfoResult unmarshals the response into an
|
// unmarshalPartialGetBlockChainInfoResult unmarshals the response into an
|
||||||
|
@ -461,10 +461,10 @@ func unmarshalGetBlockChainInfoResultSoftForks(chainInfo *btcjson.GetBlockChainI
|
||||||
return nil
|
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.
|
// result provided by the server.
|
||||||
func (r FutureGetBlockChainInfoResult) Receive() (*btcjson.GetBlockChainInfoResult, error) {
|
func (r FutureGetBlockChainInfoResult) Receive() (*btcjson.GetBlockChainInfoResult, error) {
|
||||||
res, err := receiveFuture(r.Response)
|
res, err := ReceiveFuture(r.Response)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -497,7 +497,7 @@ func (c *Client) GetBlockChainInfoAsync() FutureGetBlockChainInfoResult {
|
||||||
cmd := btcjson.NewGetBlockChainInfoCmd()
|
cmd := btcjson.NewGetBlockChainInfoCmd()
|
||||||
return FutureGetBlockChainInfoResult{
|
return FutureGetBlockChainInfoResult{
|
||||||
client: c,
|
client: c,
|
||||||
Response: c.sendCmd(cmd),
|
Response: c.SendCmd(cmd),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -510,12 +510,12 @@ func (c *Client) GetBlockChainInfo() (*btcjson.GetBlockChainInfoResult, error) {
|
||||||
|
|
||||||
// FutureGetBlockFilterResult is a future promise to deliver the result of a
|
// FutureGetBlockFilterResult is a future promise to deliver the result of a
|
||||||
// GetBlockFilterAsync RPC invocation (or an applicable error).
|
// 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.
|
// result provided by the server.
|
||||||
func (r FutureGetBlockFilterResult) Receive() (*btcjson.GetBlockFilterResult, error) {
|
func (r FutureGetBlockFilterResult) Receive() (*btcjson.GetBlockFilterResult, error) {
|
||||||
res, err := receiveFuture(r)
|
res, err := ReceiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -538,7 +538,7 @@ func (c *Client) GetBlockFilterAsync(blockHash chainhash.Hash, filterType *btcjs
|
||||||
hash := blockHash.String()
|
hash := blockHash.String()
|
||||||
|
|
||||||
cmd := btcjson.NewGetBlockFilterCmd(hash, filterType)
|
cmd := btcjson.NewGetBlockFilterCmd(hash, filterType)
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetBlockFilter retrieves a BIP0157 content filter for a particular block.
|
// GetBlockFilter retrieves a BIP0157 content filter for a particular block.
|
||||||
|
@ -548,12 +548,12 @@ func (c *Client) GetBlockFilter(blockHash chainhash.Hash, filterType *btcjson.Fi
|
||||||
|
|
||||||
// FutureGetBlockHashResult is a future promise to deliver the result of a
|
// FutureGetBlockHashResult is a future promise to deliver the result of a
|
||||||
// GetBlockHashAsync RPC invocation (or an applicable error).
|
// 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.
|
// the block in the best block chain at the given height.
|
||||||
func (r FutureGetBlockHashResult) Receive() (*chainhash.Hash, error) {
|
func (r FutureGetBlockHashResult) Receive() (*chainhash.Hash, error) {
|
||||||
res, err := receiveFuture(r)
|
res, err := ReceiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -574,7 +574,7 @@ func (r FutureGetBlockHashResult) Receive() (*chainhash.Hash, error) {
|
||||||
// See GetBlockHash for the blocking version and more details.
|
// See GetBlockHash for the blocking version and more details.
|
||||||
func (c *Client) GetBlockHashAsync(blockHeight int64) FutureGetBlockHashResult {
|
func (c *Client) GetBlockHashAsync(blockHeight int64) FutureGetBlockHashResult {
|
||||||
cmd := btcjson.NewGetBlockHashCmd(blockHeight)
|
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
|
// GetBlockHash returns the hash of the block in the best block chain at the
|
||||||
|
@ -585,12 +585,12 @@ func (c *Client) GetBlockHash(blockHeight int64) (*chainhash.Hash, error) {
|
||||||
|
|
||||||
// FutureGetBlockHeaderResult is a future promise to deliver the result of a
|
// FutureGetBlockHeaderResult is a future promise to deliver the result of a
|
||||||
// GetBlockHeaderAsync RPC invocation (or an applicable error).
|
// 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.
|
// blockheader requested from the server given its hash.
|
||||||
func (r FutureGetBlockHeaderResult) Receive() (*wire.BlockHeader, error) {
|
func (r FutureGetBlockHeaderResult) Receive() (*wire.BlockHeader, error) {
|
||||||
res, err := receiveFuture(r)
|
res, err := ReceiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -629,7 +629,7 @@ func (c *Client) GetBlockHeaderAsync(blockHash *chainhash.Hash) FutureGetBlockHe
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd := btcjson.NewGetBlockHeaderCmd(hash, btcjson.Bool(false))
|
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.
|
// GetBlockHeader returns the blockheader from the server given its hash.
|
||||||
|
@ -642,12 +642,12 @@ func (c *Client) GetBlockHeader(blockHash *chainhash.Hash) (*wire.BlockHeader, e
|
||||||
|
|
||||||
// FutureGetBlockHeaderVerboseResult is a future promise to deliver the result of a
|
// FutureGetBlockHeaderVerboseResult is a future promise to deliver the result of a
|
||||||
// GetBlockAsync RPC invocation (or an applicable error).
|
// 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.
|
// data structure of the blockheader requested from the server given its hash.
|
||||||
func (r FutureGetBlockHeaderVerboseResult) Receive() (*btcjson.GetBlockHeaderVerboseResult, error) {
|
func (r FutureGetBlockHeaderVerboseResult) Receive() (*btcjson.GetBlockHeaderVerboseResult, error) {
|
||||||
res, err := receiveFuture(r)
|
res, err := ReceiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -674,7 +674,7 @@ func (c *Client) GetBlockHeaderVerboseAsync(blockHash *chainhash.Hash) FutureGet
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd := btcjson.NewGetBlockHeaderCmd(hash, btcjson.Bool(true))
|
cmd := btcjson.NewGetBlockHeaderCmd(hash, btcjson.Bool(true))
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetBlockHeaderVerbose returns a data structure with information about the
|
// GetBlockHeaderVerbose returns a data structure with information about the
|
||||||
|
@ -687,13 +687,13 @@ func (c *Client) GetBlockHeaderVerbose(blockHash *chainhash.Hash) (*btcjson.GetB
|
||||||
|
|
||||||
// FutureGetMempoolEntryResult is a future promise to deliver the result of a
|
// FutureGetMempoolEntryResult is a future promise to deliver the result of a
|
||||||
// GetMempoolEntryAsync RPC invocation (or an applicable error).
|
// 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
|
// structure with information about the transaction in the memory pool given
|
||||||
// its hash.
|
// its hash.
|
||||||
func (r FutureGetMempoolEntryResult) Receive() (*btcjson.GetMempoolEntryResult, error) {
|
func (r FutureGetMempoolEntryResult) Receive() (*btcjson.GetMempoolEntryResult, error) {
|
||||||
res, err := receiveFuture(r)
|
res, err := ReceiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -715,7 +715,7 @@ func (r FutureGetMempoolEntryResult) Receive() (*btcjson.GetMempoolEntryResult,
|
||||||
// See GetMempoolEntry for the blocking version and more details.
|
// See GetMempoolEntry for the blocking version and more details.
|
||||||
func (c *Client) GetMempoolEntryAsync(txHash string) FutureGetMempoolEntryResult {
|
func (c *Client) GetMempoolEntryAsync(txHash string) FutureGetMempoolEntryResult {
|
||||||
cmd := btcjson.NewGetMempoolEntryCmd(txHash)
|
cmd := btcjson.NewGetMempoolEntryCmd(txHash)
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetMempoolEntry returns a data structure with information about the
|
// GetMempoolEntry returns a data structure with information about the
|
||||||
|
@ -726,12 +726,12 @@ func (c *Client) GetMempoolEntry(txHash string) (*btcjson.GetMempoolEntryResult,
|
||||||
|
|
||||||
// FutureGetRawMempoolResult is a future promise to deliver the result of a
|
// FutureGetRawMempoolResult is a future promise to deliver the result of a
|
||||||
// GetRawMempoolAsync RPC invocation (or an applicable error).
|
// 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.
|
// of all transactions in the memory pool.
|
||||||
func (r FutureGetRawMempoolResult) Receive() ([]*chainhash.Hash, error) {
|
func (r FutureGetRawMempoolResult) Receive() ([]*chainhash.Hash, error) {
|
||||||
res, err := receiveFuture(r)
|
res, err := ReceiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -763,7 +763,7 @@ func (r FutureGetRawMempoolResult) Receive() ([]*chainhash.Hash, error) {
|
||||||
// See GetRawMempool for the blocking version and more details.
|
// See GetRawMempool for the blocking version and more details.
|
||||||
func (c *Client) GetRawMempoolAsync() FutureGetRawMempoolResult {
|
func (c *Client) GetRawMempoolAsync() FutureGetRawMempoolResult {
|
||||||
cmd := btcjson.NewGetRawMempoolCmd(btcjson.Bool(false))
|
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.
|
// GetRawMempool returns the hashes of all transactions in the memory pool.
|
||||||
|
@ -776,13 +776,13 @@ func (c *Client) GetRawMempool() ([]*chainhash.Hash, error) {
|
||||||
|
|
||||||
// FutureGetRawMempoolVerboseResult is a future promise to deliver the result of
|
// FutureGetRawMempoolVerboseResult is a future promise to deliver the result of
|
||||||
// a GetRawMempoolVerboseAsync RPC invocation (or an applicable error).
|
// 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 hashes to an associated data structure with information about the
|
||||||
// transaction for all transactions in the memory pool.
|
// transaction for all transactions in the memory pool.
|
||||||
func (r FutureGetRawMempoolVerboseResult) Receive() (map[string]btcjson.GetRawMempoolVerboseResult, error) {
|
func (r FutureGetRawMempoolVerboseResult) Receive() (map[string]btcjson.GetRawMempoolVerboseResult, error) {
|
||||||
res, err := receiveFuture(r)
|
res, err := ReceiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -804,7 +804,7 @@ func (r FutureGetRawMempoolVerboseResult) Receive() (map[string]btcjson.GetRawMe
|
||||||
// See GetRawMempoolVerbose for the blocking version and more details.
|
// See GetRawMempoolVerbose for the blocking version and more details.
|
||||||
func (c *Client) GetRawMempoolVerboseAsync() FutureGetRawMempoolVerboseResult {
|
func (c *Client) GetRawMempoolVerboseAsync() FutureGetRawMempoolVerboseResult {
|
||||||
cmd := btcjson.NewGetRawMempoolCmd(btcjson.Bool(true))
|
cmd := btcjson.NewGetRawMempoolCmd(btcjson.Bool(true))
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRawMempoolVerbose returns a map of transaction hashes to an associated
|
// GetRawMempoolVerbose returns a map of transaction hashes to an associated
|
||||||
|
@ -818,12 +818,12 @@ func (c *Client) GetRawMempoolVerbose() (map[string]btcjson.GetRawMempoolVerbose
|
||||||
|
|
||||||
// FutureEstimateFeeResult is a future promise to deliver the result of a
|
// FutureEstimateFeeResult is a future promise to deliver the result of a
|
||||||
// EstimateFeeAsync RPC invocation (or an applicable error).
|
// 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.
|
// provided by the server.
|
||||||
func (r FutureEstimateFeeResult) Receive() (float64, error) {
|
func (r FutureEstimateFeeResult) Receive() (float64, error) {
|
||||||
res, err := receiveFuture(r)
|
res, err := ReceiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return -1, err
|
return -1, err
|
||||||
}
|
}
|
||||||
|
@ -845,7 +845,7 @@ func (r FutureEstimateFeeResult) Receive() (float64, error) {
|
||||||
// See EstimateFee for the blocking version and more details.
|
// See EstimateFee for the blocking version and more details.
|
||||||
func (c *Client) EstimateFeeAsync(numBlocks int64) FutureEstimateFeeResult {
|
func (c *Client) EstimateFeeAsync(numBlocks int64) FutureEstimateFeeResult {
|
||||||
cmd := btcjson.NewEstimateFeeCmd(numBlocks)
|
cmd := btcjson.NewEstimateFeeCmd(numBlocks)
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// EstimateFee provides an estimated fee in bitcoins per kilobyte.
|
// EstimateFee provides an estimated fee in bitcoins per kilobyte.
|
||||||
|
@ -855,12 +855,12 @@ func (c *Client) EstimateFee(numBlocks int64) (float64, error) {
|
||||||
|
|
||||||
// FutureEstimateFeeResult is a future promise to deliver the result of a
|
// FutureEstimateFeeResult is a future promise to deliver the result of a
|
||||||
// EstimateSmartFeeAsync RPC invocation (or an applicable error).
|
// 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.
|
// estimated fee.
|
||||||
func (r FutureEstimateSmartFeeResult) Receive() (*btcjson.EstimateSmartFeeResult, error) {
|
func (r FutureEstimateSmartFeeResult) Receive() (*btcjson.EstimateSmartFeeResult, error) {
|
||||||
res, err := receiveFuture(r)
|
res, err := ReceiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -880,7 +880,7 @@ func (r FutureEstimateSmartFeeResult) Receive() (*btcjson.EstimateSmartFeeResult
|
||||||
// See EstimateSmartFee for the blocking version and more details.
|
// See EstimateSmartFee for the blocking version and more details.
|
||||||
func (c *Client) EstimateSmartFeeAsync(confTarget int64, mode *btcjson.EstimateSmartFeeMode) FutureEstimateSmartFeeResult {
|
func (c *Client) EstimateSmartFeeAsync(confTarget int64, mode *btcjson.EstimateSmartFeeMode) FutureEstimateSmartFeeResult {
|
||||||
cmd := btcjson.NewEstimateSmartFeeCmd(confTarget, mode)
|
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.
|
// EstimateSmartFee requests the server to estimate a fee level based on the given parameters.
|
||||||
|
@ -891,13 +891,13 @@ func (c *Client) EstimateSmartFee(confTarget int64, mode *btcjson.EstimateSmartF
|
||||||
// FutureVerifyChainResult is a future promise to deliver the result of a
|
// FutureVerifyChainResult is a future promise to deliver the result of a
|
||||||
// VerifyChainAsync, VerifyChainLevelAsyncRPC, or VerifyChainBlocksAsync
|
// VerifyChainAsync, VerifyChainLevelAsyncRPC, or VerifyChainBlocksAsync
|
||||||
// invocation (or an applicable error).
|
// 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
|
// or not the chain verified based on the check level and number of blocks
|
||||||
// to verify specified in the original call.
|
// to verify specified in the original call.
|
||||||
func (r FutureVerifyChainResult) Receive() (bool, error) {
|
func (r FutureVerifyChainResult) Receive() (bool, error) {
|
||||||
res, err := receiveFuture(r)
|
res, err := ReceiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
@ -918,7 +918,7 @@ func (r FutureVerifyChainResult) Receive() (bool, error) {
|
||||||
// See VerifyChain for the blocking version and more details.
|
// See VerifyChain for the blocking version and more details.
|
||||||
func (c *Client) VerifyChainAsync() FutureVerifyChainResult {
|
func (c *Client) VerifyChainAsync() FutureVerifyChainResult {
|
||||||
cmd := btcjson.NewVerifyChainCmd(nil, nil)
|
cmd := btcjson.NewVerifyChainCmd(nil, nil)
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// VerifyChain requests the server to verify the block chain database using
|
// VerifyChain requests the server to verify the block chain database using
|
||||||
|
@ -936,7 +936,7 @@ func (c *Client) VerifyChain() (bool, error) {
|
||||||
// See VerifyChainLevel for the blocking version and more details.
|
// See VerifyChainLevel for the blocking version and more details.
|
||||||
func (c *Client) VerifyChainLevelAsync(checkLevel int32) FutureVerifyChainResult {
|
func (c *Client) VerifyChainLevelAsync(checkLevel int32) FutureVerifyChainResult {
|
||||||
cmd := btcjson.NewVerifyChainCmd(&checkLevel, nil)
|
cmd := btcjson.NewVerifyChainCmd(&checkLevel, nil)
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// VerifyChainLevel requests the server to verify the block chain database using
|
// VerifyChainLevel requests the server to verify the block chain database using
|
||||||
|
@ -959,7 +959,7 @@ func (c *Client) VerifyChainLevel(checkLevel int32) (bool, error) {
|
||||||
// See VerifyChainBlocks for the blocking version and more details.
|
// See VerifyChainBlocks for the blocking version and more details.
|
||||||
func (c *Client) VerifyChainBlocksAsync(checkLevel, numBlocks int32) FutureVerifyChainResult {
|
func (c *Client) VerifyChainBlocksAsync(checkLevel, numBlocks int32) FutureVerifyChainResult {
|
||||||
cmd := btcjson.NewVerifyChainCmd(&checkLevel, &numBlocks)
|
cmd := btcjson.NewVerifyChainCmd(&checkLevel, &numBlocks)
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// VerifyChainBlocks requests the server to verify the block chain database
|
// VerifyChainBlocks requests the server to verify the block chain database
|
||||||
|
@ -979,12 +979,12 @@ func (c *Client) VerifyChainBlocks(checkLevel, numBlocks int32) (bool, error) {
|
||||||
|
|
||||||
// FutureGetTxOutResult is a future promise to deliver the result of a
|
// FutureGetTxOutResult is a future promise to deliver the result of a
|
||||||
// GetTxOutAsync RPC invocation (or an applicable error).
|
// 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.
|
// transaction given its hash.
|
||||||
func (r FutureGetTxOutResult) Receive() (*btcjson.GetTxOutResult, error) {
|
func (r FutureGetTxOutResult) Receive() (*btcjson.GetTxOutResult, error) {
|
||||||
res, err := receiveFuture(r)
|
res, err := ReceiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -1017,7 +1017,7 @@ func (c *Client) GetTxOutAsync(txHash *chainhash.Hash, index uint32, mempool boo
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd := btcjson.NewGetTxOutCmd(hash, index, &mempool)
|
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
|
// GetTxOut returns the transaction output info if it's unspent and
|
||||||
|
@ -1028,12 +1028,12 @@ func (c *Client) GetTxOut(txHash *chainhash.Hash, index uint32, mempool bool) (*
|
||||||
|
|
||||||
// FutureGetTxOutSetInfoResult is a future promise to deliver the result of a
|
// FutureGetTxOutSetInfoResult is a future promise to deliver the result of a
|
||||||
// GetTxOutSetInfoAsync RPC invocation (or an applicable error).
|
// 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.
|
// results of GetTxOutSetInfoAsync RPC invocation.
|
||||||
func (r FutureGetTxOutSetInfoResult) Receive() (*btcjson.GetTxOutSetInfoResult, error) {
|
func (r FutureGetTxOutSetInfoResult) Receive() (*btcjson.GetTxOutSetInfoResult, error) {
|
||||||
res, err := receiveFuture(r)
|
res, err := ReceiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -1055,7 +1055,7 @@ func (r FutureGetTxOutSetInfoResult) Receive() (*btcjson.GetTxOutSetInfoResult,
|
||||||
// See GetTxOutSetInfo for the blocking version and more details.
|
// See GetTxOutSetInfo for the blocking version and more details.
|
||||||
func (c *Client) GetTxOutSetInfoAsync() FutureGetTxOutSetInfoResult {
|
func (c *Client) GetTxOutSetInfoAsync() FutureGetTxOutSetInfoResult {
|
||||||
cmd := btcjson.NewGetTxOutSetInfoCmd()
|
cmd := btcjson.NewGetTxOutSetInfoCmd()
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetTxOutSetInfo returns the statistics about the unspent transaction output
|
// GetTxOutSetInfo returns the statistics about the unspent transaction output
|
||||||
|
@ -1069,15 +1069,15 @@ func (c *Client) GetTxOutSetInfo() (*btcjson.GetTxOutSetInfoResult, error) {
|
||||||
//
|
//
|
||||||
// NOTE: This is a btcsuite extension ported from
|
// NOTE: This is a btcsuite extension ported from
|
||||||
// github.com/decred/dcrrpcclient.
|
// 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.
|
// discovered rescanblocks data.
|
||||||
//
|
//
|
||||||
// NOTE: This is a btcsuite extension ported from
|
// NOTE: This is a btcsuite extension ported from
|
||||||
// github.com/decred/dcrrpcclient.
|
// github.com/decred/dcrrpcclient.
|
||||||
func (r FutureRescanBlocksResult) Receive() ([]btcjson.RescannedBlock, error) {
|
func (r FutureRescanBlocksResult) Receive() ([]btcjson.RescannedBlock, error) {
|
||||||
res, err := receiveFuture(r)
|
res, err := ReceiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -1106,7 +1106,7 @@ func (c *Client) RescanBlocksAsync(blockHashes []chainhash.Hash) FutureRescanBlo
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd := btcjson.NewRescanBlocksCmd(strBlockHashes)
|
cmd := btcjson.NewRescanBlocksCmd(strBlockHashes)
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// RescanBlocks rescans the blocks identified by blockHashes, in order, using
|
// RescanBlocks rescans the blocks identified by blockHashes, in order, using
|
||||||
|
@ -1121,12 +1121,12 @@ func (c *Client) RescanBlocks(blockHashes []chainhash.Hash) ([]btcjson.Rescanned
|
||||||
|
|
||||||
// FutureInvalidateBlockResult is a future promise to deliver the result of a
|
// FutureInvalidateBlockResult is a future promise to deliver the result of a
|
||||||
// InvalidateBlockAsync RPC invocation (or an applicable error).
|
// 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.
|
// block requested from the server given its hash.
|
||||||
func (r FutureInvalidateBlockResult) Receive() error {
|
func (r FutureInvalidateBlockResult) Receive() error {
|
||||||
_, err := receiveFuture(r)
|
_, err := ReceiveFuture(r)
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -1143,7 +1143,7 @@ func (c *Client) InvalidateBlockAsync(blockHash *chainhash.Hash) FutureInvalidat
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd := btcjson.NewInvalidateBlockCmd(hash)
|
cmd := btcjson.NewInvalidateBlockCmd(hash)
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// InvalidateBlock invalidates a specific block.
|
// InvalidateBlock invalidates a specific block.
|
||||||
|
@ -1153,12 +1153,12 @@ func (c *Client) InvalidateBlock(blockHash *chainhash.Hash) error {
|
||||||
|
|
||||||
// FutureGetCFilterResult is a future promise to deliver the result of a
|
// FutureGetCFilterResult is a future promise to deliver the result of a
|
||||||
// GetCFilterAsync RPC invocation (or an applicable error).
|
// 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.
|
// filter requested from the server given its block hash.
|
||||||
func (r FutureGetCFilterResult) Receive() (*wire.MsgCFilter, error) {
|
func (r FutureGetCFilterResult) Receive() (*wire.MsgCFilter, error) {
|
||||||
res, err := receiveFuture(r)
|
res, err := ReceiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -1197,7 +1197,7 @@ func (c *Client) GetCFilterAsync(blockHash *chainhash.Hash,
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd := btcjson.NewGetCFilterCmd(hash, filterType)
|
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.
|
// GetCFilter returns a raw filter from the server given its block hash.
|
||||||
|
@ -1208,12 +1208,12 @@ func (c *Client) GetCFilter(blockHash *chainhash.Hash,
|
||||||
|
|
||||||
// FutureGetCFilterHeaderResult is a future promise to deliver the result of a
|
// FutureGetCFilterHeaderResult is a future promise to deliver the result of a
|
||||||
// GetCFilterHeaderAsync RPC invocation (or an applicable error).
|
// 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.
|
// filter header requested from the server given its block hash.
|
||||||
func (r FutureGetCFilterHeaderResult) Receive() (*wire.MsgCFHeaders, error) {
|
func (r FutureGetCFilterHeaderResult) Receive() (*wire.MsgCFHeaders, error) {
|
||||||
res, err := receiveFuture(r)
|
res, err := ReceiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -1250,7 +1250,7 @@ func (c *Client) GetCFilterHeaderAsync(blockHash *chainhash.Hash,
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd := btcjson.NewGetCFilterHeaderCmd(hash, filterType)
|
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
|
// GetCFilterHeader returns a raw filter header from the server given its block
|
||||||
|
@ -1262,12 +1262,12 @@ func (c *Client) GetCFilterHeader(blockHash *chainhash.Hash,
|
||||||
|
|
||||||
// FutureGetBlockStatsResult is a future promise to deliver the result of a
|
// FutureGetBlockStatsResult is a future promise to deliver the result of a
|
||||||
// GetBlockStatsAsync RPC invocation (or an applicable error).
|
// 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.
|
// of a block at a certain height.
|
||||||
func (r FutureGetBlockStatsResult) Receive() (*btcjson.GetBlockStatsResult, error) {
|
func (r FutureGetBlockStatsResult) Receive() (*btcjson.GetBlockStatsResult, error) {
|
||||||
res, err := receiveFuture(r)
|
res, err := ReceiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -1292,7 +1292,7 @@ func (c *Client) GetBlockStatsAsync(hashOrHeight interface{}, stats *[]string) F
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd := btcjson.NewGetBlockStatsCmd(btcjson.HashOrHeight{Value: hashOrHeight}, stats)
|
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.
|
// GetBlockStats returns block statistics. First argument specifies height or hash of the target block.
|
||||||
|
@ -1303,12 +1303,12 @@ func (c *Client) GetBlockStats(hashOrHeight interface{}, stats *[]string) (*btcj
|
||||||
|
|
||||||
// FutureDeriveAddressesResult is a future promise to deliver the result of an
|
// FutureDeriveAddressesResult is a future promise to deliver the result of an
|
||||||
// DeriveAddressesAsync RPC invocation (or an applicable error).
|
// 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.
|
// corresponding to the given output descriptor.
|
||||||
func (r FutureDeriveAddressesResult) Receive() (*btcjson.DeriveAddressesResult, error) {
|
func (r FutureDeriveAddressesResult) Receive() (*btcjson.DeriveAddressesResult, error) {
|
||||||
res, err := receiveFuture(r)
|
res, err := ReceiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -1330,7 +1330,7 @@ func (r FutureDeriveAddressesResult) Receive() (*btcjson.DeriveAddressesResult,
|
||||||
// See DeriveAddresses for the blocking version and more details.
|
// See DeriveAddresses for the blocking version and more details.
|
||||||
func (c *Client) DeriveAddressesAsync(descriptor string, descriptorRange *btcjson.DescriptorRange) FutureDeriveAddressesResult {
|
func (c *Client) DeriveAddressesAsync(descriptor string, descriptorRange *btcjson.DescriptorRange) FutureDeriveAddressesResult {
|
||||||
cmd := btcjson.NewDeriveAddressesCmd(descriptor, descriptorRange)
|
cmd := btcjson.NewDeriveAddressesCmd(descriptor, descriptorRange)
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeriveAddresses derives one or more addresses corresponding to an output
|
// DeriveAddresses derives one or more addresses corresponding to an output
|
||||||
|
@ -1342,12 +1342,12 @@ func (c *Client) DeriveAddresses(descriptor string, descriptorRange *btcjson.Des
|
||||||
|
|
||||||
// FutureGetDescriptorInfoResult is a future promise to deliver the result of a
|
// FutureGetDescriptorInfoResult is a future promise to deliver the result of a
|
||||||
// GetDescriptorInfoAsync RPC invocation (or an applicable error).
|
// 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.
|
// info of the descriptor.
|
||||||
func (r FutureGetDescriptorInfoResult) Receive() (*btcjson.GetDescriptorInfoResult, error) {
|
func (r FutureGetDescriptorInfoResult) Receive() (*btcjson.GetDescriptorInfoResult, error) {
|
||||||
res, err := receiveFuture(r)
|
res, err := ReceiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -1369,7 +1369,7 @@ func (r FutureGetDescriptorInfoResult) Receive() (*btcjson.GetDescriptorInfoResu
|
||||||
// See GetDescriptorInfo for the blocking version and more details.
|
// See GetDescriptorInfo for the blocking version and more details.
|
||||||
func (c *Client) GetDescriptorInfoAsync(descriptor string) FutureGetDescriptorInfoResult {
|
func (c *Client) GetDescriptorInfoAsync(descriptor string) FutureGetDescriptorInfoResult {
|
||||||
cmd := btcjson.NewGetDescriptorInfoCmd(descriptor)
|
cmd := btcjson.NewGetDescriptorInfoCmd(descriptor)
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetDescriptorInfo returns the analysed info of a descriptor string, by invoking the
|
// GetDescriptorInfo returns the analysed info of a descriptor string, by invoking the
|
||||||
|
|
32
rpcclient/examples/customcommand/README.md
Normal file
32
rpcclient/examples/customcommand/README.md
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
Custom Command Example
|
||||||
|
======================
|
||||||
|
|
||||||
|
This example shows how to use custom commands with the rpcclient package, by
|
||||||
|
implementing the `name_show` command from Namecoin Core.
|
||||||
|
|
||||||
|
## Running the Example
|
||||||
|
|
||||||
|
The first step is to use `go get` to download and install the rpcclient package:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ go get github.com/btcsuite/btcd/rpcclient
|
||||||
|
```
|
||||||
|
|
||||||
|
Next, modify the `main.go` source to specify the correct RPC username and
|
||||||
|
password for the RPC server of your Namecoin Core node:
|
||||||
|
|
||||||
|
```Go
|
||||||
|
User: "yourrpcuser",
|
||||||
|
Pass: "yourrpcpass",
|
||||||
|
```
|
||||||
|
|
||||||
|
Finally, navigate to the example's directory and run it with:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ cd $GOPATH/src/github.com/btcsuite/btcd/rpcclient/examples/customcommand
|
||||||
|
$ go run *.go
|
||||||
|
```
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
This example is licensed under the [copyfree](http://copyfree.org) ISC License.
|
110
rpcclient/examples/customcommand/main.go
Normal file
110
rpcclient/examples/customcommand/main.go
Normal file
|
@ -0,0 +1,110 @@
|
||||||
|
// Copyright (c) 2014-2017 The btcsuite developers
|
||||||
|
// Copyright (c) 2019-2020 The Namecoin developers
|
||||||
|
// Use of this source code is governed by an ISC
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"log"
|
||||||
|
|
||||||
|
"github.com/btcsuite/btcd/btcjson"
|
||||||
|
"github.com/btcsuite/btcd/rpcclient"
|
||||||
|
)
|
||||||
|
|
||||||
|
// NameShowCmd defines the name_show JSON-RPC command.
|
||||||
|
type NameShowCmd struct {
|
||||||
|
Name string
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameShowResult models the data from the name_show command.
|
||||||
|
type NameShowResult struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
NameEncoding string `json:"name_encoding"`
|
||||||
|
NameError string `json:"name_error"`
|
||||||
|
Value string `json:"value"`
|
||||||
|
ValueEncoding string `json:"value_encoding"`
|
||||||
|
ValueError string `json:"value_error"`
|
||||||
|
TxID string `json:"txid"`
|
||||||
|
Vout uint32 `json:"vout"`
|
||||||
|
Address string `json:"address"`
|
||||||
|
IsMine bool `json:"ismine"`
|
||||||
|
Height int32 `json:"height"`
|
||||||
|
ExpiresIn int32 `json:"expires_in"`
|
||||||
|
Expired bool `json:"expired"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// FutureNameShowResult is a future promise to deliver the result
|
||||||
|
// of a NameShowAsync RPC invocation (or an applicable error).
|
||||||
|
type FutureNameShowResult chan *rpcclient.Response
|
||||||
|
|
||||||
|
// Receive waits for the Response promised by the future and returns detailed
|
||||||
|
// information about a name.
|
||||||
|
func (r FutureNameShowResult) Receive() (*NameShowResult, error) {
|
||||||
|
res, err := rpcclient.ReceiveFuture(r)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unmarshal result as a name_show result object
|
||||||
|
var nameShow NameShowResult
|
||||||
|
err = json.Unmarshal(res, &nameShow)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &nameShow, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameShowAsync returns an instance of a type that can be used to get the
|
||||||
|
// result of the RPC at some future time by invoking the Receive function on
|
||||||
|
// the returned instance.
|
||||||
|
//
|
||||||
|
// See NameShow for the blocking version and more details.
|
||||||
|
func NameShowAsync(c *rpcclient.Client, name string) FutureNameShowResult {
|
||||||
|
cmd := &NameShowCmd{
|
||||||
|
Name: name,
|
||||||
|
}
|
||||||
|
return c.SendCmd(cmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameShow returns detailed information about a name.
|
||||||
|
func NameShow(c *rpcclient.Client, name string) (*NameShowResult, error) {
|
||||||
|
return NameShowAsync(c, name).Receive()
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
// No special flags for commands in this file.
|
||||||
|
flags := btcjson.UsageFlag(0)
|
||||||
|
|
||||||
|
btcjson.MustRegisterCmd("name_show", (*NameShowCmd)(nil), flags)
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
// Connect to local namecoin core RPC server using HTTP POST mode.
|
||||||
|
connCfg := &rpcclient.ConnConfig{
|
||||||
|
Host: "localhost:8336",
|
||||||
|
User: "yourrpcuser",
|
||||||
|
Pass: "yourrpcpass",
|
||||||
|
HTTPPostMode: true, // Namecoin core only supports HTTP POST mode
|
||||||
|
DisableTLS: true, // Namecoin core does not provide TLS by default
|
||||||
|
}
|
||||||
|
// Notice the notification parameter is nil since notifications are
|
||||||
|
// not supported in HTTP POST mode.
|
||||||
|
client, err := rpcclient.New(connCfg, nil)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
defer client.Shutdown()
|
||||||
|
|
||||||
|
// Get the current block count.
|
||||||
|
result, err := NameShow(client, "d/namecoin")
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
value := result.Value
|
||||||
|
|
||||||
|
log.Printf("Value of d/namecoin: %s", value)
|
||||||
|
}
|
|
@ -20,13 +20,13 @@ import (
|
||||||
|
|
||||||
// FutureDebugLevelResult is a future promise to deliver the result of a
|
// FutureDebugLevelResult is a future promise to deliver the result of a
|
||||||
// DebugLevelAsync RPC invocation (or an applicable error).
|
// 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
|
// of setting the debug logging level to the passed level specification or the
|
||||||
// list of of the available subsystems for the special keyword 'show'.
|
// list of of the available subsystems for the special keyword 'show'.
|
||||||
func (r FutureDebugLevelResult) Receive() (string, error) {
|
func (r FutureDebugLevelResult) Receive() (string, error) {
|
||||||
res, err := receiveFuture(r)
|
res, err := ReceiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ func (r FutureDebugLevelResult) Receive() (string, error) {
|
||||||
// NOTE: This is a btcd extension.
|
// NOTE: This is a btcd extension.
|
||||||
func (c *Client) DebugLevelAsync(levelSpec string) FutureDebugLevelResult {
|
func (c *Client) DebugLevelAsync(levelSpec string) FutureDebugLevelResult {
|
||||||
cmd := btcjson.NewDebugLevelCmd(levelSpec)
|
cmd := btcjson.NewDebugLevelCmd(levelSpec)
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DebugLevel dynamically sets the debug logging level to the passed level
|
// 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
|
// FutureCreateEncryptedWalletResult is a future promise to deliver the error
|
||||||
// result of a CreateEncryptedWalletAsync RPC invocation.
|
// 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 {
|
func (r FutureCreateEncryptedWalletResult) Receive() error {
|
||||||
_, err := receiveFuture(r)
|
_, err := ReceiveFuture(r)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ func (r FutureCreateEncryptedWalletResult) Receive() error {
|
||||||
// NOTE: This is a btcwallet extension.
|
// NOTE: This is a btcwallet extension.
|
||||||
func (c *Client) CreateEncryptedWalletAsync(passphrase string) FutureCreateEncryptedWalletResult {
|
func (c *Client) CreateEncryptedWalletAsync(passphrase string) FutureCreateEncryptedWalletResult {
|
||||||
cmd := btcjson.NewCreateEncryptedWalletCmd(passphrase)
|
cmd := btcjson.NewCreateEncryptedWalletCmd(passphrase)
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateEncryptedWallet requests the creation of an encrypted wallet. Wallets
|
// 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
|
// FutureListAddressTransactionsResult is a future promise to deliver the result
|
||||||
// of a ListAddressTransactionsAsync RPC invocation (or an applicable error).
|
// 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.
|
// about all transactions associated with the provided addresses.
|
||||||
func (r FutureListAddressTransactionsResult) Receive() ([]btcjson.ListTransactionsResult, error) {
|
func (r FutureListAddressTransactionsResult) Receive() ([]btcjson.ListTransactionsResult, error) {
|
||||||
res, err := receiveFuture(r)
|
res, err := ReceiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -135,7 +135,7 @@ func (c *Client) ListAddressTransactionsAsync(addresses []btcutil.Address, accou
|
||||||
addrs = append(addrs, addr.EncodeAddress())
|
addrs = append(addrs, addr.EncodeAddress())
|
||||||
}
|
}
|
||||||
cmd := btcjson.NewListAddressTransactionsCmd(addrs, &account)
|
cmd := btcjson.NewListAddressTransactionsCmd(addrs, &account)
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListAddressTransactions returns information about all transactions associated
|
// 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
|
// FutureGetBestBlockResult is a future promise to deliver the result of a
|
||||||
// GetBestBlockAsync RPC invocation (or an applicable error).
|
// 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.
|
// and height of the block in the longest (best) chain.
|
||||||
func (r FutureGetBestBlockResult) Receive() (*chainhash.Hash, int32, error) {
|
func (r FutureGetBestBlockResult) Receive() (*chainhash.Hash, int32, error) {
|
||||||
res, err := receiveFuture(r)
|
res, err := ReceiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, 0, err
|
return nil, 0, err
|
||||||
}
|
}
|
||||||
|
@ -183,7 +183,7 @@ func (r FutureGetBestBlockResult) Receive() (*chainhash.Hash, int32, error) {
|
||||||
// NOTE: This is a btcd extension.
|
// NOTE: This is a btcd extension.
|
||||||
func (c *Client) GetBestBlockAsync() FutureGetBestBlockResult {
|
func (c *Client) GetBestBlockAsync() FutureGetBestBlockResult {
|
||||||
cmd := btcjson.NewGetBestBlockCmd()
|
cmd := btcjson.NewGetBestBlockCmd()
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetBestBlock returns the hash and height of the block in the longest (best)
|
// 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
|
// FutureGetCurrentNetResult is a future promise to deliver the result of a
|
||||||
// GetCurrentNetAsync RPC invocation (or an applicable error).
|
// 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.
|
// the server is running on.
|
||||||
func (r FutureGetCurrentNetResult) Receive() (wire.BitcoinNet, error) {
|
func (r FutureGetCurrentNetResult) Receive() (wire.BitcoinNet, error) {
|
||||||
res, err := receiveFuture(r)
|
res, err := ReceiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
@ -225,7 +225,7 @@ func (r FutureGetCurrentNetResult) Receive() (wire.BitcoinNet, error) {
|
||||||
// NOTE: This is a btcd extension.
|
// NOTE: This is a btcd extension.
|
||||||
func (c *Client) GetCurrentNetAsync() FutureGetCurrentNetResult {
|
func (c *Client) GetCurrentNetAsync() FutureGetCurrentNetResult {
|
||||||
cmd := btcjson.NewGetCurrentNetCmd()
|
cmd := btcjson.NewGetCurrentNetCmd()
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetCurrentNet returns the network the server is running on.
|
// 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
|
// NOTE: This is a btcsuite extension ported from
|
||||||
// github.com/decred/dcrrpcclient.
|
// 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.
|
// getheaders result.
|
||||||
//
|
//
|
||||||
// NOTE: This is a btcsuite extension ported from
|
// NOTE: This is a btcsuite extension ported from
|
||||||
// github.com/decred/dcrrpcclient.
|
// github.com/decred/dcrrpcclient.
|
||||||
func (r FutureGetHeadersResult) Receive() ([]wire.BlockHeader, error) {
|
func (r FutureGetHeadersResult) Receive() ([]wire.BlockHeader, error) {
|
||||||
res, err := receiveFuture(r)
|
res, err := ReceiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -292,7 +292,7 @@ func (c *Client) GetHeadersAsync(blockLocators []chainhash.Hash, hashStop *chain
|
||||||
hash = hashStop.String()
|
hash = hashStop.String()
|
||||||
}
|
}
|
||||||
cmd := btcjson.NewGetHeadersCmd(locators, hash)
|
cmd := btcjson.NewGetHeadersCmd(locators, hash)
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetHeaders mimics the wire protocol getheaders and headers messages by
|
// 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
|
// FutureExportWatchingWalletResult is a future promise to deliver the result of
|
||||||
// an ExportWatchingWalletAsync RPC invocation (or an applicable error).
|
// 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.
|
// exported wallet.
|
||||||
func (r FutureExportWatchingWalletResult) Receive() ([]byte, []byte, error) {
|
func (r FutureExportWatchingWalletResult) Receive() ([]byte, []byte, error) {
|
||||||
res, err := receiveFuture(r)
|
res, err := ReceiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
@ -361,7 +361,7 @@ func (r FutureExportWatchingWalletResult) Receive() ([]byte, []byte, error) {
|
||||||
// NOTE: This is a btcwallet extension.
|
// NOTE: This is a btcwallet extension.
|
||||||
func (c *Client) ExportWatchingWalletAsync(account string) FutureExportWatchingWalletResult {
|
func (c *Client) ExportWatchingWalletAsync(account string) FutureExportWatchingWalletResult {
|
||||||
cmd := btcjson.NewExportWatchingWalletCmd(&account, btcjson.Bool(true))
|
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
|
// 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
|
// FutureSessionResult is a future promise to deliver the result of a
|
||||||
// SessionAsync RPC invocation (or an applicable error).
|
// 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.
|
// session result.
|
||||||
func (r FutureSessionResult) Receive() (*btcjson.SessionResult, error) {
|
func (r FutureSessionResult) Receive() (*btcjson.SessionResult, error) {
|
||||||
res, err := receiveFuture(r)
|
res, err := ReceiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -410,7 +410,7 @@ func (c *Client) SessionAsync() FutureSessionResult {
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd := btcjson.NewSessionCmd()
|
cmd := btcjson.NewSessionCmd()
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Session returns details regarding a websocket client's current connection.
|
// 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
|
// NOTE: This is a btcsuite extension ported from
|
||||||
// github.com/decred/dcrrpcclient.
|
// 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.
|
// result.
|
||||||
//
|
//
|
||||||
// NOTE: This is a btcsuite extension ported from
|
// NOTE: This is a btcsuite extension ported from
|
||||||
// github.com/decred/dcrrpcclient.
|
// github.com/decred/dcrrpcclient.
|
||||||
func (r FutureVersionResult) Receive() (map[string]btcjson.VersionResult,
|
func (r FutureVersionResult) Receive() (map[string]btcjson.VersionResult,
|
||||||
error) {
|
error) {
|
||||||
res, err := receiveFuture(r)
|
res, err := ReceiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -461,7 +461,7 @@ func (r FutureVersionResult) Receive() (map[string]btcjson.VersionResult,
|
||||||
// github.com/decred/dcrrpcclient.
|
// github.com/decred/dcrrpcclient.
|
||||||
func (c *Client) VersionAsync() FutureVersionResult {
|
func (c *Client) VersionAsync() FutureVersionResult {
|
||||||
cmd := btcjson.NewVersionCmd()
|
cmd := btcjson.NewVersionCmd()
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Version returns information about the server's JSON-RPC API versions.
|
// Version returns information about the server's JSON-RPC API versions.
|
||||||
|
|
|
@ -103,7 +103,7 @@ type jsonRequest struct {
|
||||||
method string
|
method string
|
||||||
cmd interface{}
|
cmd interface{}
|
||||||
marshalledJSON []byte
|
marshalledJSON []byte
|
||||||
responseChan chan *response
|
responseChan chan *Response
|
||||||
}
|
}
|
||||||
|
|
||||||
// BackendVersion represents the version of the backend the client is currently
|
// 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
|
// FutureGetBulkResult waits for the responses promised by the future
|
||||||
// and returns them in a channel
|
// 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
|
// Receive waits for the response promised by the future and returns an map
|
||||||
// of results by request id
|
// of results by request id
|
||||||
func (r FutureGetBulkResult) Receive() (BulkResult, error) {
|
func (r FutureGetBulkResult) Receive() (BulkResult, error) {
|
||||||
m := make(BulkResult)
|
m := make(BulkResult)
|
||||||
res, err := receiveFuture(r)
|
res, err := ReceiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -357,9 +357,9 @@ type rawResponse struct {
|
||||||
Error *btcjson.RPCError `json:"error"`
|
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.
|
// error object was non-null.
|
||||||
type response struct {
|
type Response struct {
|
||||||
result []byte
|
result []byte
|
||||||
err error
|
err error
|
||||||
}
|
}
|
||||||
|
@ -440,7 +440,7 @@ func (c *Client) handleMessage(msg []byte) {
|
||||||
|
|
||||||
// Deliver the response.
|
// Deliver the response.
|
||||||
result, err := in.rawResponse.result()
|
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
|
// 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)
|
log.Tracef("Sending command [%s] with id %d", jReq.method, jReq.id)
|
||||||
httpResponse, err := c.httpClient.Do(details.httpRequest)
|
httpResponse, err := c.httpClient.Do(details.httpRequest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
jReq.responseChan <- &response{err: err}
|
jReq.responseChan <- &Response{err: err}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -779,7 +779,7 @@ func (c *Client) handleSendPostMessage(details *sendPostDetails) {
|
||||||
httpResponse.Body.Close()
|
httpResponse.Body.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error reading json reply: %v", err)
|
err = fmt.Errorf("error reading json reply: %v", err)
|
||||||
jReq.responseChan <- &response{err: err}
|
jReq.responseChan <- &Response{err: err}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -797,7 +797,7 @@ func (c *Client) handleSendPostMessage(details *sendPostDetails) {
|
||||||
// response bytes.
|
// response bytes.
|
||||||
err = fmt.Errorf("status code: %d, response: %q",
|
err = fmt.Errorf("status code: %d, response: %q",
|
||||||
httpResponse.StatusCode, string(respBytes))
|
httpResponse.StatusCode, string(respBytes))
|
||||||
jReq.responseChan <- &response{err: err}
|
jReq.responseChan <- &Response{err: err}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var res []byte
|
var res []byte
|
||||||
|
@ -808,7 +808,7 @@ func (c *Client) handleSendPostMessage(details *sendPostDetails) {
|
||||||
} else {
|
} else {
|
||||||
res, err = resp.result()
|
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
|
// sendPostHandler handles all outgoing messages when the client is running
|
||||||
|
@ -835,7 +835,7 @@ cleanup:
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case details := <-c.sendPostChan:
|
case details := <-c.sendPostChan:
|
||||||
details.jsonRequest.responseChan <- &response{
|
details.jsonRequest.responseChan <- &Response{
|
||||||
result: nil,
|
result: nil,
|
||||||
err: ErrClientShutdown,
|
err: ErrClientShutdown,
|
||||||
}
|
}
|
||||||
|
@ -856,7 +856,7 @@ func (c *Client) sendPostRequest(httpReq *http.Request, jReq *jsonRequest) {
|
||||||
// Don't send the message if shutting down.
|
// Don't send the message if shutting down.
|
||||||
select {
|
select {
|
||||||
case <-c.shutdown:
|
case <-c.shutdown:
|
||||||
jReq.responseChan <- &response{result: nil, err: ErrClientShutdown}
|
jReq.responseChan <- &Response{result: nil, err: ErrClientShutdown}
|
||||||
default:
|
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
|
// 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
|
// passed error waitin on the channel with the reply set to nil. This is useful
|
||||||
// to easily return errors from the various Async functions.
|
// to easily return errors from the various Async functions.
|
||||||
func newFutureError(err error) chan *response {
|
func newFutureError(err error) chan *Response {
|
||||||
responseChan := make(chan *response, 1)
|
responseChan := make(chan *Response, 1)
|
||||||
responseChan <- &response{err: err}
|
responseChan <- &Response{err: err}
|
||||||
return responseChan
|
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
|
// 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
|
// futureResult and the error in the reply from the server. This will block
|
||||||
// until the result is available on the passed channel.
|
// 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.
|
// Wait for a response on the returned channel.
|
||||||
r := <-f
|
r := <-f
|
||||||
return r.result, r.err
|
return r.result, r.err
|
||||||
|
@ -900,7 +900,7 @@ func (c *Client) sendPost(jReq *jsonRequest) {
|
||||||
bodyReader := bytes.NewReader(jReq.marshalledJSON)
|
bodyReader := bytes.NewReader(jReq.marshalledJSON)
|
||||||
httpReq, err := http.NewRequest("POST", url, bodyReader)
|
httpReq, err := http.NewRequest("POST", url, bodyReader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
jReq.responseChan <- &response{result: nil, err: err}
|
jReq.responseChan <- &Response{result: nil, err: err}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
httpReq.Close = true
|
httpReq.Close = true
|
||||||
|
@ -912,7 +912,7 @@ func (c *Client) sendPost(jReq *jsonRequest) {
|
||||||
// Configure basic access authorization.
|
// Configure basic access authorization.
|
||||||
user, pass, err := c.config.getAuth()
|
user, pass, err := c.config.getAuth()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
jReq.responseChan <- &response{result: nil, err: err}
|
jReq.responseChan <- &Response{result: nil, err: err}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
httpReq.SetBasicAuth(user, pass)
|
httpReq.SetBasicAuth(user, pass)
|
||||||
|
@ -945,7 +945,7 @@ func (c *Client) sendRequest(jReq *jsonRequest) {
|
||||||
select {
|
select {
|
||||||
case <-c.connEstablished:
|
case <-c.connEstablished:
|
||||||
default:
|
default:
|
||||||
jReq.responseChan <- &response{err: ErrClientNotConnected}
|
jReq.responseChan <- &Response{err: ErrClientNotConnected}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -954,18 +954,18 @@ func (c *Client) sendRequest(jReq *jsonRequest) {
|
||||||
// channel. Then send the marshalled request via the websocket
|
// channel. Then send the marshalled request via the websocket
|
||||||
// connection.
|
// connection.
|
||||||
if err := c.addRequest(jReq); err != nil {
|
if err := c.addRequest(jReq); err != nil {
|
||||||
jReq.responseChan <- &response{err: err}
|
jReq.responseChan <- &Response{err: err}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Tracef("Sending command [%s] with id %d", jReq.method, jReq.id)
|
log.Tracef("Sending command [%s] with id %d", jReq.method, jReq.id)
|
||||||
c.sendMessage(jReq.marshalledJSON)
|
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
|
// 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
|
// future. It handles both websocket and HTTP POST mode depending on the
|
||||||
// configuration of the client.
|
// configuration of the client.
|
||||||
func (c *Client) sendCmd(cmd interface{}) chan *response {
|
func (c *Client) SendCmd(cmd interface{}) chan *Response {
|
||||||
rpcVersion := btcjson.RpcVersion1
|
rpcVersion := btcjson.RpcVersion1
|
||||||
if c.batch {
|
if c.batch {
|
||||||
rpcVersion = btcjson.RpcVersion2
|
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.
|
// 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{
|
jReq := &jsonRequest{
|
||||||
id: id,
|
id: id,
|
||||||
method: method,
|
method: method,
|
||||||
|
@ -1004,7 +1004,7 @@ func (c *Client) sendCmd(cmd interface{}) chan *response {
|
||||||
func (c *Client) sendCmdAndWait(cmd interface{}) (interface{}, error) {
|
func (c *Client) sendCmdAndWait(cmd interface{}) (interface{}, error) {
|
||||||
// Marshal the command to JSON-RPC, send it to the connected server, and
|
// Marshal the command to JSON-RPC, send it to the connected server, and
|
||||||
// wait for a response on the returned channel.
|
// 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
|
// Disconnected returns whether or not the server is disconnected. If a
|
||||||
|
@ -1085,7 +1085,7 @@ func (c *Client) Disconnect() {
|
||||||
if c.config.DisableAutoReconnect {
|
if c.config.DisableAutoReconnect {
|
||||||
for e := c.requestList.Front(); e != nil; e = e.Next() {
|
for e := c.requestList.Front(); e != nil; e = e.Next() {
|
||||||
req := e.Value.(*jsonRequest)
|
req := e.Value.(*jsonRequest)
|
||||||
req.responseChan <- &response{
|
req.responseChan <- &Response{
|
||||||
result: nil,
|
result: nil,
|
||||||
err: ErrClientDisconnect,
|
err: ErrClientDisconnect,
|
||||||
}
|
}
|
||||||
|
@ -1113,7 +1113,7 @@ func (c *Client) Shutdown() {
|
||||||
// Send the ErrClientShutdown error to any pending requests.
|
// Send the ErrClientShutdown error to any pending requests.
|
||||||
for e := c.requestList.Front(); e != nil; e = e.Next() {
|
for e := c.requestList.Front(); e != nil; e = e.Next() {
|
||||||
req := e.Value.(*jsonRequest)
|
req := e.Value.(*jsonRequest)
|
||||||
req.responseChan <- &response{
|
req.responseChan <- &Response{
|
||||||
result: nil,
|
result: nil,
|
||||||
err: ErrClientShutdown,
|
err: ErrClientShutdown,
|
||||||
}
|
}
|
||||||
|
@ -1623,7 +1623,7 @@ func (c *Client) BackendVersion() (BackendVersion, error) {
|
||||||
|
|
||||||
func (c *Client) sendAsync() FutureGetBulkResult {
|
func (c *Client) sendAsync() FutureGetBulkResult {
|
||||||
// convert the array of marshalled json requests to a single request we can send
|
// 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("[")
|
marshalledRequest := []byte("[")
|
||||||
for iter := c.batchList.Front(); iter != nil; iter = iter.Next() {
|
for iter := c.batchList.Front(); iter != nil; iter = iter.Next() {
|
||||||
request := iter.Value.(*jsonRequest)
|
request := iter.Value.(*jsonRequest)
|
||||||
|
@ -1678,7 +1678,7 @@ func (c *Client) Send() error {
|
||||||
requestError = individualResult.Error
|
requestError = individualResult.Error
|
||||||
}
|
}
|
||||||
|
|
||||||
result := response{
|
result := Response{
|
||||||
result: fullResult,
|
result: fullResult,
|
||||||
err: requestError,
|
err: requestError,
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,12 +16,12 @@ import (
|
||||||
|
|
||||||
// FutureGenerateResult is a future promise to deliver the result of a
|
// FutureGenerateResult is a future promise to deliver the result of a
|
||||||
// GenerateAsync RPC invocation (or an applicable error).
|
// 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.
|
// block hashes generated by the call.
|
||||||
func (r FutureGenerateResult) Receive() ([]*chainhash.Hash, error) {
|
func (r FutureGenerateResult) Receive() ([]*chainhash.Hash, error) {
|
||||||
res, err := receiveFuture(r)
|
res, err := ReceiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ func (r FutureGenerateResult) Receive() ([]*chainhash.Hash, error) {
|
||||||
// See Generate for the blocking version and more details.
|
// See Generate for the blocking version and more details.
|
||||||
func (c *Client) GenerateAsync(numBlocks uint32) FutureGenerateResult {
|
func (c *Client) GenerateAsync(numBlocks uint32) FutureGenerateResult {
|
||||||
cmd := btcjson.NewGenerateCmd(numBlocks)
|
cmd := btcjson.NewGenerateCmd(numBlocks)
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate generates numBlocks blocks and returns their hashes.
|
// 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
|
// FutureGenerateToAddressResult is a future promise to deliver the result of a
|
||||||
// GenerateToAddressResult RPC invocation (or an applicable error).
|
// 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.
|
// of the generated blocks.
|
||||||
func (f FutureGenerateToAddressResult) Receive() ([]*chainhash.Hash, error) {
|
func (f FutureGenerateToAddressResult) Receive() ([]*chainhash.Hash, error) {
|
||||||
res, err := receiveFuture(f)
|
res, err := ReceiveFuture(f)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,7 @@ func (f FutureGenerateToAddressResult) Receive() ([]*chainhash.Hash, error) {
|
||||||
// See GenerateToAddress for the blocking version and more details.
|
// See GenerateToAddress for the blocking version and more details.
|
||||||
func (c *Client) GenerateToAddressAsync(numBlocks int64, address btcutil.Address, maxTries *int64) FutureGenerateToAddressResult {
|
func (c *Client) GenerateToAddressAsync(numBlocks int64, address btcutil.Address, maxTries *int64) FutureGenerateToAddressResult {
|
||||||
cmd := btcjson.NewGenerateToAddressCmd(numBlocks, address.EncodeAddress(), maxTries)
|
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.
|
// 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
|
// FutureGetGenerateResult is a future promise to deliver the result of a
|
||||||
// GetGenerateAsync RPC invocation (or an applicable error).
|
// 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.
|
// server is set to mine, otherwise false.
|
||||||
func (r FutureGetGenerateResult) Receive() (bool, error) {
|
func (r FutureGetGenerateResult) Receive() (bool, error) {
|
||||||
res, err := receiveFuture(r)
|
res, err := ReceiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
@ -137,7 +137,7 @@ func (r FutureGetGenerateResult) Receive() (bool, error) {
|
||||||
// See GetGenerate for the blocking version and more details.
|
// See GetGenerate for the blocking version and more details.
|
||||||
func (c *Client) GetGenerateAsync() FutureGetGenerateResult {
|
func (c *Client) GetGenerateAsync() FutureGetGenerateResult {
|
||||||
cmd := btcjson.NewGetGenerateCmd()
|
cmd := btcjson.NewGetGenerateCmd()
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetGenerate returns true if the server is set to mine, otherwise false.
|
// 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
|
// FutureSetGenerateResult is a future promise to deliver the result of a
|
||||||
// SetGenerateAsync RPC invocation (or an applicable error).
|
// 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.
|
// any occurred when setting the server to generate coins (mine) or not.
|
||||||
func (r FutureSetGenerateResult) Receive() error {
|
func (r FutureSetGenerateResult) Receive() error {
|
||||||
_, err := receiveFuture(r)
|
_, err := ReceiveFuture(r)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,7 +163,7 @@ func (r FutureSetGenerateResult) Receive() error {
|
||||||
// See SetGenerate for the blocking version and more details.
|
// See SetGenerate for the blocking version and more details.
|
||||||
func (c *Client) SetGenerateAsync(enable bool, numCPUs int) FutureSetGenerateResult {
|
func (c *Client) SetGenerateAsync(enable bool, numCPUs int) FutureSetGenerateResult {
|
||||||
cmd := btcjson.NewSetGenerateCmd(enable, &numCPUs)
|
cmd := btcjson.NewSetGenerateCmd(enable, &numCPUs)
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetGenerate sets the server to generate coins (mine) or not.
|
// 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
|
// FutureGetHashesPerSecResult is a future promise to deliver the result of a
|
||||||
// GetHashesPerSecAsync RPC invocation (or an applicable error).
|
// 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).
|
// hashes per second performance measurement while generating coins (mining).
|
||||||
// Zero is returned if the server is not mining.
|
// Zero is returned if the server is not mining.
|
||||||
func (r FutureGetHashesPerSecResult) Receive() (int64, error) {
|
func (r FutureGetHashesPerSecResult) Receive() (int64, error) {
|
||||||
res, err := receiveFuture(r)
|
res, err := ReceiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return -1, err
|
return -1, err
|
||||||
}
|
}
|
||||||
|
@ -201,7 +201,7 @@ func (r FutureGetHashesPerSecResult) Receive() (int64, error) {
|
||||||
// See GetHashesPerSec for the blocking version and more details.
|
// See GetHashesPerSec for the blocking version and more details.
|
||||||
func (c *Client) GetHashesPerSecAsync() FutureGetHashesPerSecResult {
|
func (c *Client) GetHashesPerSecAsync() FutureGetHashesPerSecResult {
|
||||||
cmd := btcjson.NewGetHashesPerSecCmd()
|
cmd := btcjson.NewGetHashesPerSecCmd()
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetHashesPerSec returns a recent hashes per second performance measurement
|
// GetHashesPerSec returns a recent hashes per second performance measurement
|
||||||
|
@ -213,12 +213,12 @@ func (c *Client) GetHashesPerSec() (int64, error) {
|
||||||
|
|
||||||
// FutureGetMiningInfoResult is a future promise to deliver the result of a
|
// FutureGetMiningInfoResult is a future promise to deliver the result of a
|
||||||
// GetMiningInfoAsync RPC invocation (or an applicable error).
|
// GetMiningInfoAsync RPC invocation (or an applicable error).
|
||||||
type FutureGetMiningInfoResult chan *response
|
type FutureGetMiningInfoResult chan *Response
|
||||||
|
|
||||||
// Receive waits for the response promised by the future and returns the mining
|
// Receive waits for the Response promised by the future and returns the mining
|
||||||
// information.
|
// information.
|
||||||
func (r FutureGetMiningInfoResult) Receive() (*btcjson.GetMiningInfoResult, error) {
|
func (r FutureGetMiningInfoResult) Receive() (*btcjson.GetMiningInfoResult, error) {
|
||||||
res, err := receiveFuture(r)
|
res, err := ReceiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -240,7 +240,7 @@ func (r FutureGetMiningInfoResult) Receive() (*btcjson.GetMiningInfoResult, erro
|
||||||
// See GetMiningInfo for the blocking version and more details.
|
// See GetMiningInfo for the blocking version and more details.
|
||||||
func (c *Client) GetMiningInfoAsync() FutureGetMiningInfoResult {
|
func (c *Client) GetMiningInfoAsync() FutureGetMiningInfoResult {
|
||||||
cmd := btcjson.NewGetMiningInfoCmd()
|
cmd := btcjson.NewGetMiningInfoCmd()
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetMiningInfo returns mining information.
|
// GetMiningInfo returns mining information.
|
||||||
|
@ -250,13 +250,13 @@ func (c *Client) GetMiningInfo() (*btcjson.GetMiningInfoResult, error) {
|
||||||
|
|
||||||
// FutureGetNetworkHashPS is a future promise to deliver the result of a
|
// FutureGetNetworkHashPS is a future promise to deliver the result of a
|
||||||
// GetNetworkHashPSAsync RPC invocation (or an applicable error).
|
// 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
|
// estimated network hashes per second for the block heights provided by the
|
||||||
// parameters.
|
// parameters.
|
||||||
func (r FutureGetNetworkHashPS) Receive() (int64, error) {
|
func (r FutureGetNetworkHashPS) Receive() (int64, error) {
|
||||||
res, err := receiveFuture(r)
|
res, err := ReceiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return -1, err
|
return -1, err
|
||||||
}
|
}
|
||||||
|
@ -278,7 +278,7 @@ func (r FutureGetNetworkHashPS) Receive() (int64, error) {
|
||||||
// See GetNetworkHashPS for the blocking version and more details.
|
// See GetNetworkHashPS for the blocking version and more details.
|
||||||
func (c *Client) GetNetworkHashPSAsync() FutureGetNetworkHashPS {
|
func (c *Client) GetNetworkHashPSAsync() FutureGetNetworkHashPS {
|
||||||
cmd := btcjson.NewGetNetworkHashPSCmd(nil, nil)
|
cmd := btcjson.NewGetNetworkHashPSCmd(nil, nil)
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetNetworkHashPS returns the estimated network hashes per second using the
|
// GetNetworkHashPS returns the estimated network hashes per second using the
|
||||||
|
@ -297,7 +297,7 @@ func (c *Client) GetNetworkHashPS() (int64, error) {
|
||||||
// See GetNetworkHashPS2 for the blocking version and more details.
|
// See GetNetworkHashPS2 for the blocking version and more details.
|
||||||
func (c *Client) GetNetworkHashPS2Async(blocks int) FutureGetNetworkHashPS {
|
func (c *Client) GetNetworkHashPS2Async(blocks int) FutureGetNetworkHashPS {
|
||||||
cmd := btcjson.NewGetNetworkHashPSCmd(&blocks, nil)
|
cmd := btcjson.NewGetNetworkHashPSCmd(&blocks, nil)
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetNetworkHashPS2 returns the estimated network hashes per second for the
|
// GetNetworkHashPS2 returns the estimated network hashes per second for the
|
||||||
|
@ -318,7 +318,7 @@ func (c *Client) GetNetworkHashPS2(blocks int) (int64, error) {
|
||||||
// See GetNetworkHashPS3 for the blocking version and more details.
|
// See GetNetworkHashPS3 for the blocking version and more details.
|
||||||
func (c *Client) GetNetworkHashPS3Async(blocks, height int) FutureGetNetworkHashPS {
|
func (c *Client) GetNetworkHashPS3Async(blocks, height int) FutureGetNetworkHashPS {
|
||||||
cmd := btcjson.NewGetNetworkHashPSCmd(&blocks, &height)
|
cmd := btcjson.NewGetNetworkHashPSCmd(&blocks, &height)
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetNetworkHashPS3 returns the estimated network hashes per second for the
|
// GetNetworkHashPS3 returns the estimated network hashes per second for the
|
||||||
|
@ -333,12 +333,12 @@ func (c *Client) GetNetworkHashPS3(blocks, height int) (int64, error) {
|
||||||
|
|
||||||
// FutureGetWork is a future promise to deliver the result of a
|
// FutureGetWork is a future promise to deliver the result of a
|
||||||
// GetWorkAsync RPC invocation (or an applicable error).
|
// 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.
|
// data to work on.
|
||||||
func (r FutureGetWork) Receive() (*btcjson.GetWorkResult, error) {
|
func (r FutureGetWork) Receive() (*btcjson.GetWorkResult, error) {
|
||||||
res, err := receiveFuture(r)
|
res, err := ReceiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -360,7 +360,7 @@ func (r FutureGetWork) Receive() (*btcjson.GetWorkResult, error) {
|
||||||
// See GetWork for the blocking version and more details.
|
// See GetWork for the blocking version and more details.
|
||||||
func (c *Client) GetWorkAsync() FutureGetWork {
|
func (c *Client) GetWorkAsync() FutureGetWork {
|
||||||
cmd := btcjson.NewGetWorkCmd(nil)
|
cmd := btcjson.NewGetWorkCmd(nil)
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetWork returns hash data to work on.
|
// GetWork returns hash data to work on.
|
||||||
|
@ -372,12 +372,12 @@ func (c *Client) GetWork() (*btcjson.GetWorkResult, error) {
|
||||||
|
|
||||||
// FutureGetWorkSubmit is a future promise to deliver the result of a
|
// FutureGetWorkSubmit is a future promise to deliver the result of a
|
||||||
// GetWorkSubmitAsync RPC invocation (or an applicable error).
|
// 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.
|
// or not the submitted block header was accepted.
|
||||||
func (r FutureGetWorkSubmit) Receive() (bool, error) {
|
func (r FutureGetWorkSubmit) Receive() (bool, error) {
|
||||||
res, err := receiveFuture(r)
|
res, err := ReceiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
@ -399,7 +399,7 @@ func (r FutureGetWorkSubmit) Receive() (bool, error) {
|
||||||
// See GetWorkSubmit for the blocking version and more details.
|
// See GetWorkSubmit for the blocking version and more details.
|
||||||
func (c *Client) GetWorkSubmitAsync(data string) FutureGetWorkSubmit {
|
func (c *Client) GetWorkSubmitAsync(data string) FutureGetWorkSubmit {
|
||||||
cmd := btcjson.NewGetWorkCmd(&data)
|
cmd := btcjson.NewGetWorkCmd(&data)
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetWorkSubmit submits a block header which is a solution to previously
|
// GetWorkSubmit submits a block header which is a solution to previously
|
||||||
|
@ -412,12 +412,12 @@ func (c *Client) GetWorkSubmit(data string) (bool, error) {
|
||||||
|
|
||||||
// FutureSubmitBlockResult is a future promise to deliver the result of a
|
// FutureSubmitBlockResult is a future promise to deliver the result of a
|
||||||
// SubmitBlockAsync RPC invocation (or an applicable error).
|
// 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.
|
// any occurred when submitting the block.
|
||||||
func (r FutureSubmitBlockResult) Receive() error {
|
func (r FutureSubmitBlockResult) Receive() error {
|
||||||
res, err := receiveFuture(r)
|
res, err := ReceiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -453,7 +453,7 @@ func (c *Client) SubmitBlockAsync(block *btcutil.Block, options *btcjson.SubmitB
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd := btcjson.NewSubmitBlockCmd(blockHex, options)
|
cmd := btcjson.NewSubmitBlockCmd(blockHex, options)
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SubmitBlock attempts to submit a new block into the bitcoin network.
|
// SubmitBlock attempts to submit a new block into the bitcoin network.
|
||||||
|
@ -463,12 +463,12 @@ func (c *Client) SubmitBlock(block *btcutil.Block, options *btcjson.SubmitBlockO
|
||||||
|
|
||||||
// FutureGetBlockTemplateResponse is a future promise to deliver the result of a
|
// FutureGetBlockTemplateResponse is a future promise to deliver the result of a
|
||||||
// GetBlockTemplateAsync RPC invocation (or an applicable error).
|
// 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.
|
// any occurred when retrieving the block template.
|
||||||
func (r FutureGetBlockTemplateResponse) Receive() (*btcjson.GetBlockTemplateResult, error) {
|
func (r FutureGetBlockTemplateResponse) Receive() (*btcjson.GetBlockTemplateResult, error) {
|
||||||
res, err := receiveFuture(r)
|
res, err := ReceiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -490,7 +490,7 @@ func (r FutureGetBlockTemplateResponse) Receive() (*btcjson.GetBlockTemplateResu
|
||||||
// See GetBlockTemplate for the blocking version and more details.
|
// See GetBlockTemplate for the blocking version and more details.
|
||||||
func (c *Client) GetBlockTemplateAsync(req *btcjson.TemplateRequest) FutureGetBlockTemplateResponse {
|
func (c *Client) GetBlockTemplateAsync(req *btcjson.TemplateRequest) FutureGetBlockTemplateResponse {
|
||||||
cmd := btcjson.NewGetBlockTemplateCmd(req)
|
cmd := btcjson.NewGetBlockTemplateCmd(req)
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetBlockTemplate returns a new block template for mining.
|
// GetBlockTemplate returns a new block template for mining.
|
||||||
|
|
|
@ -35,12 +35,12 @@ func (cmd AddNodeCommand) String() string {
|
||||||
|
|
||||||
// FutureAddNodeResult is a future promise to deliver the result of an
|
// FutureAddNodeResult is a future promise to deliver the result of an
|
||||||
// AddNodeAsync RPC invocation (or an applicable error).
|
// 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.
|
// any occurred when performing the specified command.
|
||||||
func (r FutureAddNodeResult) Receive() error {
|
func (r FutureAddNodeResult) Receive() error {
|
||||||
_, err := receiveFuture(r)
|
_, err := ReceiveFuture(r)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ func (r FutureAddNodeResult) Receive() error {
|
||||||
// See AddNode for the blocking version and more details.
|
// See AddNode for the blocking version and more details.
|
||||||
func (c *Client) AddNodeAsync(host string, command AddNodeCommand) FutureAddNodeResult {
|
func (c *Client) AddNodeAsync(host string, command AddNodeCommand) FutureAddNodeResult {
|
||||||
cmd := btcjson.NewAddNodeCmd(host, btcjson.AddNodeSubCmd(command))
|
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.
|
// 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
|
// FutureNodeResult is a future promise to deliver the result of a NodeAsync
|
||||||
// RPC invocation (or an applicable error).
|
// 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.
|
// any occurred when performing the specified command.
|
||||||
func (r FutureNodeResult) Receive() error {
|
func (r FutureNodeResult) Receive() error {
|
||||||
_, err := receiveFuture(r)
|
_, err := ReceiveFuture(r)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ func (r FutureNodeResult) Receive() error {
|
||||||
func (c *Client) NodeAsync(command btcjson.NodeSubCmd, host string,
|
func (c *Client) NodeAsync(command btcjson.NodeSubCmd, host string,
|
||||||
connectSubCmd *string) FutureNodeResult {
|
connectSubCmd *string) FutureNodeResult {
|
||||||
cmd := btcjson.NewNodeCmd(command, host, connectSubCmd)
|
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.
|
// 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
|
// FutureGetAddedNodeInfoResult is a future promise to deliver the result of a
|
||||||
// GetAddedNodeInfoAsync RPC invocation (or an applicable error).
|
// 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.
|
// about manually added (persistent) peers.
|
||||||
func (r FutureGetAddedNodeInfoResult) Receive() ([]btcjson.GetAddedNodeInfoResult, error) {
|
func (r FutureGetAddedNodeInfoResult) Receive() ([]btcjson.GetAddedNodeInfoResult, error) {
|
||||||
res, err := receiveFuture(r)
|
res, err := ReceiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -126,7 +126,7 @@ func (r FutureGetAddedNodeInfoResult) Receive() ([]btcjson.GetAddedNodeInfoResul
|
||||||
// See GetAddedNodeInfo for the blocking version and more details.
|
// See GetAddedNodeInfo for the blocking version and more details.
|
||||||
func (c *Client) GetAddedNodeInfoAsync(peer string) FutureGetAddedNodeInfoResult {
|
func (c *Client) GetAddedNodeInfoAsync(peer string) FutureGetAddedNodeInfoResult {
|
||||||
cmd := btcjson.NewGetAddedNodeInfoCmd(true, &peer)
|
cmd := btcjson.NewGetAddedNodeInfoCmd(true, &peer)
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAddedNodeInfo returns information about manually added (persistent) peers.
|
// 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
|
// FutureGetAddedNodeInfoNoDNSResult is a future promise to deliver the result
|
||||||
// of a GetAddedNodeInfoNoDNSAsync RPC invocation (or an applicable error).
|
// 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.
|
// manually added (persistent) peers.
|
||||||
func (r FutureGetAddedNodeInfoNoDNSResult) Receive() ([]string, error) {
|
func (r FutureGetAddedNodeInfoNoDNSResult) Receive() ([]string, error) {
|
||||||
res, err := receiveFuture(r)
|
res, err := ReceiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -166,7 +166,7 @@ func (r FutureGetAddedNodeInfoNoDNSResult) Receive() ([]string, error) {
|
||||||
// See GetAddedNodeInfoNoDNS for the blocking version and more details.
|
// See GetAddedNodeInfoNoDNS for the blocking version and more details.
|
||||||
func (c *Client) GetAddedNodeInfoNoDNSAsync(peer string) FutureGetAddedNodeInfoNoDNSResult {
|
func (c *Client) GetAddedNodeInfoNoDNSAsync(peer string) FutureGetAddedNodeInfoNoDNSResult {
|
||||||
cmd := btcjson.NewGetAddedNodeInfoCmd(false, &peer)
|
cmd := btcjson.NewGetAddedNodeInfoCmd(false, &peer)
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAddedNodeInfoNoDNS returns a list of manually added (persistent) peers.
|
// 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
|
// FutureGetConnectionCountResult is a future promise to deliver the result
|
||||||
// of a GetConnectionCountAsync RPC invocation (or an applicable error).
|
// 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.
|
// of active connections to other peers.
|
||||||
func (r FutureGetConnectionCountResult) Receive() (int64, error) {
|
func (r FutureGetConnectionCountResult) Receive() (int64, error) {
|
||||||
res, err := receiveFuture(r)
|
res, err := ReceiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
@ -207,7 +207,7 @@ func (r FutureGetConnectionCountResult) Receive() (int64, error) {
|
||||||
// See GetConnectionCount for the blocking version and more details.
|
// See GetConnectionCount for the blocking version and more details.
|
||||||
func (c *Client) GetConnectionCountAsync() FutureGetConnectionCountResult {
|
func (c *Client) GetConnectionCountAsync() FutureGetConnectionCountResult {
|
||||||
cmd := btcjson.NewGetConnectionCountCmd()
|
cmd := btcjson.NewGetConnectionCountCmd()
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetConnectionCount returns the number of active connections to other peers.
|
// 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
|
// FuturePingResult is a future promise to deliver the result of a PingAsync RPC
|
||||||
// invocation (or an applicable error).
|
// 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.
|
// of queueing a ping to be sent to each connected peer.
|
||||||
func (r FuturePingResult) Receive() error {
|
func (r FuturePingResult) Receive() error {
|
||||||
_, err := receiveFuture(r)
|
_, err := ReceiveFuture(r)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,7 +233,7 @@ func (r FuturePingResult) Receive() error {
|
||||||
// See Ping for the blocking version and more details.
|
// See Ping for the blocking version and more details.
|
||||||
func (c *Client) PingAsync() FuturePingResult {
|
func (c *Client) PingAsync() FuturePingResult {
|
||||||
cmd := btcjson.NewPingCmd()
|
cmd := btcjson.NewPingCmd()
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ping queues a ping to be sent to each connected peer.
|
// 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
|
// FutureGetNetworkInfoResult is a future promise to deliver the result of a
|
||||||
// GetNetworkInfoAsync RPC invocation (or an applicable error).
|
// 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.
|
// the current network.
|
||||||
func (r FutureGetNetworkInfoResult) Receive() (*btcjson.GetNetworkInfoResult, error) {
|
func (r FutureGetNetworkInfoResult) Receive() (*btcjson.GetNetworkInfoResult, error) {
|
||||||
res, err := receiveFuture(r)
|
res, err := ReceiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -273,7 +273,7 @@ func (r FutureGetNetworkInfoResult) Receive() (*btcjson.GetNetworkInfoResult, er
|
||||||
// See GetNetworkInfo for the blocking version and more details.
|
// See GetNetworkInfo for the blocking version and more details.
|
||||||
func (c *Client) GetNetworkInfoAsync() FutureGetNetworkInfoResult {
|
func (c *Client) GetNetworkInfoAsync() FutureGetNetworkInfoResult {
|
||||||
cmd := btcjson.NewGetNetworkInfoCmd()
|
cmd := btcjson.NewGetNetworkInfoCmd()
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetNetworkInfo returns data about the current network.
|
// 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
|
// FutureGetNodeAddressesResult is a future promise to deliver the result of a
|
||||||
// GetNodeAddressesAsync RPC invocation (or an applicable error).
|
// 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.
|
// known node addresses.
|
||||||
func (r FutureGetNodeAddressesResult) Receive() ([]btcjson.GetNodeAddressesResult, error) {
|
func (r FutureGetNodeAddressesResult) Receive() ([]btcjson.GetNodeAddressesResult, error) {
|
||||||
res, err := receiveFuture(r)
|
res, err := ReceiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -310,7 +310,7 @@ func (r FutureGetNodeAddressesResult) Receive() ([]btcjson.GetNodeAddressesResul
|
||||||
// See GetNodeAddresses for the blocking version and more details.
|
// See GetNodeAddresses for the blocking version and more details.
|
||||||
func (c *Client) GetNodeAddressesAsync(count *int32) FutureGetNodeAddressesResult {
|
func (c *Client) GetNodeAddressesAsync(count *int32) FutureGetNodeAddressesResult {
|
||||||
cmd := btcjson.NewGetNodeAddressesCmd(count)
|
cmd := btcjson.NewGetNodeAddressesCmd(count)
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetNodeAddresses returns data about known node addresses.
|
// 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
|
// FutureGetPeerInfoResult is a future promise to deliver the result of a
|
||||||
// GetPeerInfoAsync RPC invocation (or an applicable error).
|
// 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.
|
// each connected network peer.
|
||||||
func (r FutureGetPeerInfoResult) Receive() ([]btcjson.GetPeerInfoResult, error) {
|
func (r FutureGetPeerInfoResult) Receive() ([]btcjson.GetPeerInfoResult, error) {
|
||||||
res, err := receiveFuture(r)
|
res, err := ReceiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -347,7 +347,7 @@ func (r FutureGetPeerInfoResult) Receive() ([]btcjson.GetPeerInfoResult, error)
|
||||||
// See GetPeerInfo for the blocking version and more details.
|
// See GetPeerInfo for the blocking version and more details.
|
||||||
func (c *Client) GetPeerInfoAsync() FutureGetPeerInfoResult {
|
func (c *Client) GetPeerInfoAsync() FutureGetPeerInfoResult {
|
||||||
cmd := btcjson.NewGetPeerInfoCmd()
|
cmd := btcjson.NewGetPeerInfoCmd()
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetPeerInfo returns data about each connected network peer.
|
// 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
|
// FutureGetNetTotalsResult is a future promise to deliver the result of a
|
||||||
// GetNetTotalsAsync RPC invocation (or an applicable error).
|
// 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.
|
// traffic statistics.
|
||||||
func (r FutureGetNetTotalsResult) Receive() (*btcjson.GetNetTotalsResult, error) {
|
func (r FutureGetNetTotalsResult) Receive() (*btcjson.GetNetTotalsResult, error) {
|
||||||
res, err := receiveFuture(r)
|
res, err := ReceiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -384,7 +384,7 @@ func (r FutureGetNetTotalsResult) Receive() (*btcjson.GetNetTotalsResult, error)
|
||||||
// See GetNetTotals for the blocking version and more details.
|
// See GetNetTotals for the blocking version and more details.
|
||||||
func (c *Client) GetNetTotalsAsync() FutureGetNetTotalsResult {
|
func (c *Client) GetNetTotalsAsync() FutureGetNetTotalsResult {
|
||||||
cmd := btcjson.NewGetNetTotalsCmd()
|
cmd := btcjson.NewGetNetTotalsCmd()
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetNetTotals returns network traffic statistics.
|
// GetNetTotals returns network traffic statistics.
|
||||||
|
|
|
@ -69,9 +69,9 @@ func newNotificationState() *notificationState {
|
||||||
// result waiting on the channel with the reply set to nil. This is useful
|
// 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
|
// to ignore things such as notifications when the caller didn't specify any
|
||||||
// notification handlers.
|
// notification handlers.
|
||||||
func newNilFutureResult() chan *response {
|
func newNilFutureResult() chan *Response {
|
||||||
responseChan := make(chan *response, 1)
|
responseChan := make(chan *Response, 1)
|
||||||
responseChan <- &response{result: nil, err: nil}
|
responseChan <- &Response{result: nil, err: nil}
|
||||||
return responseChan
|
return responseChan
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -856,12 +856,12 @@ func parseWalletLockStateNtfnParams(params []json.RawMessage) (account string,
|
||||||
|
|
||||||
// FutureNotifyBlocksResult is a future promise to deliver the result of a
|
// FutureNotifyBlocksResult is a future promise to deliver the result of a
|
||||||
// NotifyBlocksAsync RPC invocation (or an applicable error).
|
// 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.
|
// if the registration was not successful.
|
||||||
func (r FutureNotifyBlocksResult) Receive() error {
|
func (r FutureNotifyBlocksResult) Receive() error {
|
||||||
_, err := receiveFuture(r)
|
_, err := ReceiveFuture(r)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -885,7 +885,7 @@ func (c *Client) NotifyBlocksAsync() FutureNotifyBlocksResult {
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd := btcjson.NewNotifyBlocksCmd()
|
cmd := btcjson.NewNotifyBlocksCmd()
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NotifyBlocks registers the client to receive notifications when blocks are
|
// 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).
|
// NotifySpentAsync RPC invocation (or an applicable error).
|
||||||
//
|
//
|
||||||
// Deprecated: Use FutureLoadTxFilterResult instead.
|
// 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.
|
// if the registration was not successful.
|
||||||
func (r FutureNotifySpentResult) Receive() error {
|
func (r FutureNotifySpentResult) Receive() error {
|
||||||
_, err := receiveFuture(r)
|
_, err := ReceiveFuture(r)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -931,7 +931,7 @@ func (c *Client) notifySpentInternal(outpoints []btcjson.OutPoint) FutureNotifyS
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd := btcjson.NewNotifySpentCmd(outpoints)
|
cmd := btcjson.NewNotifySpentCmd(outpoints)
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// newOutPointFromWire constructs the btcjson representation of a transaction
|
// 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))
|
ops = append(ops, newOutPointFromWire(outpoint))
|
||||||
}
|
}
|
||||||
cmd := btcjson.NewNotifySpentCmd(ops)
|
cmd := btcjson.NewNotifySpentCmd(ops)
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NotifySpent registers the client to receive notifications when the passed
|
// 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
|
// FutureNotifyNewTransactionsResult is a future promise to deliver the result
|
||||||
// of a NotifyNewTransactionsAsync RPC invocation (or an applicable error).
|
// 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.
|
// if the registration was not successful.
|
||||||
func (r FutureNotifyNewTransactionsResult) Receive() error {
|
func (r FutureNotifyNewTransactionsResult) Receive() error {
|
||||||
_, err := receiveFuture(r)
|
_, err := ReceiveFuture(r)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1019,7 +1019,7 @@ func (c *Client) NotifyNewTransactionsAsync(verbose bool) FutureNotifyNewTransac
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd := btcjson.NewNotifyNewTransactionsCmd(&verbose)
|
cmd := btcjson.NewNotifyNewTransactionsCmd(&verbose)
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NotifyNewTransactions registers the client to receive notifications every
|
// 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).
|
// NotifyReceivedAsync RPC invocation (or an applicable error).
|
||||||
//
|
//
|
||||||
// Deprecated: Use FutureLoadTxFilterResult instead.
|
// 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.
|
// if the registration was not successful.
|
||||||
func (r FutureNotifyReceivedResult) Receive() error {
|
func (r FutureNotifyReceivedResult) Receive() error {
|
||||||
_, err := receiveFuture(r)
|
_, err := ReceiveFuture(r)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1067,7 +1067,7 @@ func (c *Client) notifyReceivedInternal(addresses []string) FutureNotifyReceived
|
||||||
|
|
||||||
// Convert addresses to strings.
|
// Convert addresses to strings.
|
||||||
cmd := btcjson.NewNotifyReceivedCmd(addresses)
|
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
|
// 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())
|
addrs = append(addrs, addr.String())
|
||||||
}
|
}
|
||||||
cmd := btcjson.NewNotifyReceivedCmd(addrs)
|
cmd := btcjson.NewNotifyReceivedCmd(addrs)
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NotifyReceived registers the client to receive notifications every time a
|
// 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).
|
// or RescanEndHeightAsync RPC invocation (or an applicable error).
|
||||||
//
|
//
|
||||||
// Deprecated: Use FutureRescanBlocksResult instead.
|
// 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.
|
// if the rescan was not successful.
|
||||||
func (r FutureRescanResult) Receive() error {
|
func (r FutureRescanResult) Receive() error {
|
||||||
_, err := receiveFuture(r)
|
_, err := ReceiveFuture(r)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1185,7 +1185,7 @@ func (c *Client) RescanAsync(startBlock *chainhash.Hash,
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd := btcjson.NewRescanCmd(startBlockHashStr, addrs, ops, nil)
|
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
|
// 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,
|
cmd := btcjson.NewRescanCmd(startBlockHashStr, addrs, ops,
|
||||||
&endBlockHashStr)
|
&endBlockHashStr)
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// RescanEndHeight rescans the block chain starting from the provided starting
|
// 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
|
// NOTE: This is a btcd extension ported from github.com/decred/dcrrpcclient
|
||||||
// and requires a websocket connection.
|
// 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.
|
// if the registration was not successful.
|
||||||
//
|
//
|
||||||
// NOTE: This is a btcd extension ported from github.com/decred/dcrrpcclient
|
// NOTE: This is a btcd extension ported from github.com/decred/dcrrpcclient
|
||||||
// and requires a websocket connection.
|
// and requires a websocket connection.
|
||||||
func (r FutureLoadTxFilterResult) Receive() error {
|
func (r FutureLoadTxFilterResult) Receive() error {
|
||||||
_, err := receiveFuture(r)
|
_, err := ReceiveFuture(r)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1343,7 +1343,7 @@ func (c *Client) LoadTxFilterAsync(reload bool, addresses []btcutil.Address,
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd := btcjson.NewLoadTxFilterCmd(reload, addrStrs, outPointObjects)
|
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
|
// LoadTxFilter loads, reloads, or adds data to a websocket client's transaction
|
||||||
|
|
|
@ -13,12 +13,12 @@ import (
|
||||||
|
|
||||||
// FutureRawResult is a future promise to deliver the result of a RawRequest RPC
|
// FutureRawResult is a future promise to deliver the result of a RawRequest RPC
|
||||||
// invocation (or an applicable error).
|
// 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.
|
// response, or an error if the request was unsuccessful.
|
||||||
func (r FutureRawResult) Receive() (json.RawMessage, error) {
|
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
|
// 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
|
// 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
|
// since that relies on marshalling registered btcjson commands rather
|
||||||
// than custom commands.
|
// than custom commands.
|
||||||
id := c.NextID()
|
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.
|
// 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{
|
jReq := &jsonRequest{
|
||||||
id: id,
|
id: id,
|
||||||
method: method,
|
method: method,
|
||||||
|
|
|
@ -66,12 +66,12 @@ func (s SigHashType) String() string {
|
||||||
|
|
||||||
// FutureGetRawTransactionResult is a future promise to deliver the result of a
|
// FutureGetRawTransactionResult is a future promise to deliver the result of a
|
||||||
// GetRawTransactionAsync RPC invocation (or an applicable error).
|
// 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.
|
// transaction given its hash.
|
||||||
func (r FutureGetRawTransactionResult) Receive() (*btcutil.Tx, error) {
|
func (r FutureGetRawTransactionResult) Receive() (*btcutil.Tx, error) {
|
||||||
res, err := receiveFuture(r)
|
res, err := ReceiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,7 @@ func (c *Client) GetRawTransactionAsync(txHash *chainhash.Hash) FutureGetRawTran
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd := btcjson.NewGetRawTransactionCmd(hash, btcjson.Int(0))
|
cmd := btcjson.NewGetRawTransactionCmd(hash, btcjson.Int(0))
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRawTransaction returns a transaction given its hash.
|
// 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
|
// FutureGetRawTransactionVerboseResult is a future promise to deliver the
|
||||||
// result of a GetRawTransactionVerboseAsync RPC invocation (or an applicable
|
// result of a GetRawTransactionVerboseAsync RPC invocation (or an applicable
|
||||||
// error).
|
// 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.
|
// about a transaction given its hash.
|
||||||
func (r FutureGetRawTransactionVerboseResult) Receive() (*btcjson.TxRawResult, error) {
|
func (r FutureGetRawTransactionVerboseResult) Receive() (*btcjson.TxRawResult, error) {
|
||||||
res, err := receiveFuture(r)
|
res, err := ReceiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -155,7 +155,7 @@ func (c *Client) GetRawTransactionVerboseAsync(txHash *chainhash.Hash) FutureGet
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd := btcjson.NewGetRawTransactionCmd(hash, btcjson.Int(1))
|
cmd := btcjson.NewGetRawTransactionCmd(hash, btcjson.Int(1))
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRawTransactionVerbose returns information about a transaction given
|
// GetRawTransactionVerbose returns information about a transaction given
|
||||||
|
@ -168,12 +168,12 @@ func (c *Client) GetRawTransactionVerbose(txHash *chainhash.Hash) (*btcjson.TxRa
|
||||||
|
|
||||||
// FutureDecodeRawTransactionResult is a future promise to deliver the result
|
// FutureDecodeRawTransactionResult is a future promise to deliver the result
|
||||||
// of a DecodeRawTransactionAsync RPC invocation (or an applicable error).
|
// 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.
|
// about a transaction given its serialized bytes.
|
||||||
func (r FutureDecodeRawTransactionResult) Receive() (*btcjson.TxRawResult, error) {
|
func (r FutureDecodeRawTransactionResult) Receive() (*btcjson.TxRawResult, error) {
|
||||||
res, err := receiveFuture(r)
|
res, err := ReceiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -196,7 +196,7 @@ func (r FutureDecodeRawTransactionResult) Receive() (*btcjson.TxRawResult, error
|
||||||
func (c *Client) DecodeRawTransactionAsync(serializedTx []byte) FutureDecodeRawTransactionResult {
|
func (c *Client) DecodeRawTransactionAsync(serializedTx []byte) FutureDecodeRawTransactionResult {
|
||||||
txHex := hex.EncodeToString(serializedTx)
|
txHex := hex.EncodeToString(serializedTx)
|
||||||
cmd := btcjson.NewDecodeRawTransactionCmd(txHex)
|
cmd := btcjson.NewDecodeRawTransactionCmd(txHex)
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DecodeRawTransaction returns information about a transaction given its
|
// DecodeRawTransaction returns information about a transaction given its
|
||||||
|
@ -207,12 +207,12 @@ func (c *Client) DecodeRawTransaction(serializedTx []byte) (*btcjson.TxRawResult
|
||||||
|
|
||||||
// FutureFundRawTransactionResult is a future promise to deliver the result
|
// FutureFundRawTransactionResult is a future promise to deliver the result
|
||||||
// of a FutureFundRawTransactionAsync RPC invocation (or an applicable error).
|
// 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
|
// about a funding attempt
|
||||||
func (r FutureFundRawTransactionResult) Receive() (*btcjson.FundRawTransactionResult, error) {
|
func (r FutureFundRawTransactionResult) Receive() (*btcjson.FundRawTransactionResult, error) {
|
||||||
res, err := receiveFuture(r)
|
res, err := ReceiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -237,7 +237,7 @@ func (c *Client) FundRawTransactionAsync(tx *wire.MsgTx, opts btcjson.FundRawTra
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd := btcjson.NewFundRawTransactionCmd(txBuf.Bytes(), opts, isWitness)
|
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
|
// FundRawTransaction returns the result of trying to fund the given transaction with
|
||||||
|
@ -248,13 +248,13 @@ func (c *Client) FundRawTransaction(tx *wire.MsgTx, opts btcjson.FundRawTransact
|
||||||
|
|
||||||
// FutureCreateRawTransactionResult is a future promise to deliver the result
|
// FutureCreateRawTransactionResult is a future promise to deliver the result
|
||||||
// of a CreateRawTransactionAsync RPC invocation (or an applicable error).
|
// of a CreateRawTransactionAsync RPC invocation (or an applicable error).
|
||||||
type FutureCreateRawTransactionResult chan *response
|
type FutureCreateRawTransactionResult chan *Response
|
||||||
|
|
||||||
// Receive waits for the response promised by the future and returns a new
|
// Receive waits for the Response promised by the future and returns a new
|
||||||
// transaction spending the provided inputs and sending to the provided
|
// transaction spending the provided inputs and sending to the provided
|
||||||
// addresses.
|
// addresses.
|
||||||
func (r FutureCreateRawTransactionResult) Receive() (*wire.MsgTx, error) {
|
func (r FutureCreateRawTransactionResult) Receive() (*wire.MsgTx, error) {
|
||||||
res, err := receiveFuture(r)
|
res, err := ReceiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -298,7 +298,7 @@ func (c *Client) CreateRawTransactionAsync(inputs []btcjson.TransactionInput,
|
||||||
convertedAmts[addr.String()] = amount.ToBTC()
|
convertedAmts[addr.String()] = amount.ToBTC()
|
||||||
}
|
}
|
||||||
cmd := btcjson.NewCreateRawTransactionCmd(inputs, convertedAmts, lockTime)
|
cmd := btcjson.NewCreateRawTransactionCmd(inputs, convertedAmts, lockTime)
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateRawTransaction returns a new transaction spending the provided inputs
|
// CreateRawTransaction returns a new transaction spending the provided inputs
|
||||||
|
@ -312,13 +312,13 @@ func (c *Client) CreateRawTransaction(inputs []btcjson.TransactionInput,
|
||||||
|
|
||||||
// FutureSendRawTransactionResult is a future promise to deliver the result
|
// FutureSendRawTransactionResult is a future promise to deliver the result
|
||||||
// of a SendRawTransactionAsync RPC invocation (or an applicable error).
|
// 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
|
// of submitting the encoded transaction to the server which then relays it to
|
||||||
// the network.
|
// the network.
|
||||||
func (r FutureSendRawTransactionResult) Receive() (*chainhash.Hash, error) {
|
func (r FutureSendRawTransactionResult) Receive() (*chainhash.Hash, error) {
|
||||||
res, err := receiveFuture(r)
|
res, err := ReceiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -374,7 +374,7 @@ func (c *Client) SendRawTransactionAsync(tx *wire.MsgTx, allowHighFees bool) Fut
|
||||||
cmd = btcjson.NewSendRawTransactionCmd(txHex, &allowHighFees)
|
cmd = btcjson.NewSendRawTransactionCmd(txHex, &allowHighFees)
|
||||||
}
|
}
|
||||||
|
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SendRawTransaction submits the encoded transaction to the server which will
|
// SendRawTransaction submits the encoded transaction to the server which will
|
||||||
|
@ -386,12 +386,12 @@ func (c *Client) SendRawTransaction(tx *wire.MsgTx, allowHighFees bool) (*chainh
|
||||||
// FutureSignRawTransactionResult is a future promise to deliver the result
|
// FutureSignRawTransactionResult is a future promise to deliver the result
|
||||||
// of one of the SignRawTransactionAsync family of RPC invocations (or an
|
// of one of the SignRawTransactionAsync family of RPC invocations (or an
|
||||||
// applicable error).
|
// applicable error).
|
||||||
type FutureSignRawTransactionResult chan *response
|
type FutureSignRawTransactionResult chan *Response
|
||||||
|
|
||||||
// Receive waits for the response promised by the future and returns the
|
// Receive waits for the Response promised by the future and returns the
|
||||||
// signed transaction as well as whether or not all inputs are now signed.
|
// signed transaction as well as whether or not all inputs are now signed.
|
||||||
func (r FutureSignRawTransactionResult) Receive() (*wire.MsgTx, bool, error) {
|
func (r FutureSignRawTransactionResult) Receive() (*wire.MsgTx, bool, error) {
|
||||||
res, err := receiveFuture(r)
|
res, err := ReceiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, false, err
|
return nil, false, err
|
||||||
}
|
}
|
||||||
|
@ -435,7 +435,7 @@ func (c *Client) SignRawTransactionAsync(tx *wire.MsgTx) FutureSignRawTransactio
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd := btcjson.NewSignRawTransactionCmd(txHex, nil, nil, nil)
|
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
|
// SignRawTransaction signs inputs for the passed transaction and returns the
|
||||||
|
@ -466,7 +466,7 @@ func (c *Client) SignRawTransaction2Async(tx *wire.MsgTx, inputs []btcjson.RawTx
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd := btcjson.NewSignRawTransactionCmd(txHex, &inputs, nil, nil)
|
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
|
// SignRawTransaction2 signs inputs for the passed transaction given the list
|
||||||
|
@ -504,7 +504,7 @@ func (c *Client) SignRawTransaction3Async(tx *wire.MsgTx,
|
||||||
|
|
||||||
cmd := btcjson.NewSignRawTransactionCmd(txHex, &inputs, &privKeysWIF,
|
cmd := btcjson.NewSignRawTransactionCmd(txHex, &inputs, &privKeysWIF,
|
||||||
nil)
|
nil)
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SignRawTransaction3 signs inputs for the passed transaction given the list
|
// SignRawTransaction3 signs inputs for the passed transaction given the list
|
||||||
|
@ -552,7 +552,7 @@ func (c *Client) SignRawTransaction4Async(tx *wire.MsgTx,
|
||||||
|
|
||||||
cmd := btcjson.NewSignRawTransactionCmd(txHex, &inputs, &privKeysWIF,
|
cmd := btcjson.NewSignRawTransactionCmd(txHex, &inputs, &privKeysWIF,
|
||||||
btcjson.String(string(hashType)))
|
btcjson.String(string(hashType)))
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SignRawTransaction4 signs inputs for the passed transaction using
|
// SignRawTransaction4 signs inputs for the passed transaction using
|
||||||
|
@ -585,12 +585,12 @@ func (c *Client) SignRawTransaction4(tx *wire.MsgTx,
|
||||||
// FutureSignRawTransactionWithWalletResult is a future promise to deliver
|
// FutureSignRawTransactionWithWalletResult is a future promise to deliver
|
||||||
// the result of the SignRawTransactionWithWalletAsync RPC invocation (or
|
// the result of the SignRawTransactionWithWalletAsync RPC invocation (or
|
||||||
// an applicable error).
|
// 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.
|
// signed transaction as well as whether or not all inputs are now signed.
|
||||||
func (r FutureSignRawTransactionWithWalletResult) Receive() (*wire.MsgTx, bool, error) {
|
func (r FutureSignRawTransactionWithWalletResult) Receive() (*wire.MsgTx, bool, error) {
|
||||||
res, err := receiveFuture(r)
|
res, err := ReceiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, false, err
|
return nil, false, err
|
||||||
}
|
}
|
||||||
|
@ -634,7 +634,7 @@ func (c *Client) SignRawTransactionWithWalletAsync(tx *wire.MsgTx) FutureSignRaw
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd := btcjson.NewSignRawTransactionWithWalletCmd(txHex, nil, nil)
|
cmd := btcjson.NewSignRawTransactionWithWalletCmd(txHex, nil, nil)
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SignRawTransactionWithWallet signs inputs for the passed transaction and returns
|
// SignRawTransactionWithWallet signs inputs for the passed transaction and returns
|
||||||
|
@ -667,7 +667,7 @@ func (c *Client) SignRawTransactionWithWallet2Async(tx *wire.MsgTx,
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd := btcjson.NewSignRawTransactionWithWalletCmd(txHex, &inputs, nil)
|
cmd := btcjson.NewSignRawTransactionWithWalletCmd(txHex, &inputs, nil)
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SignRawTransactionWithWallet2 signs inputs for the passed transaction given the
|
// SignRawTransactionWithWallet2 signs inputs for the passed transaction given the
|
||||||
|
@ -705,7 +705,7 @@ func (c *Client) SignRawTransactionWithWallet3Async(tx *wire.MsgTx,
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd := btcjson.NewSignRawTransactionWithWalletCmd(txHex, &inputs, btcjson.String(string(hashType)))
|
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
|
// SignRawTransactionWithWallet3 signs inputs for the passed transaction using
|
||||||
|
@ -727,12 +727,12 @@ func (c *Client) SignRawTransactionWithWallet3(tx *wire.MsgTx,
|
||||||
|
|
||||||
// FutureSearchRawTransactionsResult is a future promise to deliver the result
|
// FutureSearchRawTransactionsResult is a future promise to deliver the result
|
||||||
// of the SearchRawTransactionsAsync RPC invocation (or an applicable error).
|
// 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.
|
// found raw transactions.
|
||||||
func (r FutureSearchRawTransactionsResult) Receive() ([]*wire.MsgTx, error) {
|
func (r FutureSearchRawTransactionsResult) Receive() ([]*wire.MsgTx, error) {
|
||||||
res, err := receiveFuture(r)
|
res, err := ReceiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -775,7 +775,7 @@ func (c *Client) SearchRawTransactionsAsync(address btcutil.Address, skip, count
|
||||||
verbose := btcjson.Int(0)
|
verbose := btcjson.Int(0)
|
||||||
cmd := btcjson.NewSearchRawTransactionsCmd(addr, verbose, &skip, &count,
|
cmd := btcjson.NewSearchRawTransactionsCmd(addr, verbose, &skip, &count,
|
||||||
nil, &reverse, &filterAddrs)
|
nil, &reverse, &filterAddrs)
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SearchRawTransactions returns transactions that involve the passed address.
|
// SearchRawTransactions returns transactions that involve the passed address.
|
||||||
|
@ -792,12 +792,12 @@ func (c *Client) SearchRawTransactions(address btcutil.Address, skip, count int,
|
||||||
// FutureSearchRawTransactionsVerboseResult is a future promise to deliver the
|
// FutureSearchRawTransactionsVerboseResult is a future promise to deliver the
|
||||||
// result of the SearchRawTransactionsVerboseAsync RPC invocation (or an
|
// result of the SearchRawTransactionsVerboseAsync RPC invocation (or an
|
||||||
// applicable error).
|
// 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.
|
// found raw transactions.
|
||||||
func (r FutureSearchRawTransactionsVerboseResult) Receive() ([]*btcjson.SearchRawTransactionsResult, error) {
|
func (r FutureSearchRawTransactionsVerboseResult) Receive() ([]*btcjson.SearchRawTransactionsResult, error) {
|
||||||
res, err := receiveFuture(r)
|
res, err := ReceiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -828,7 +828,7 @@ func (c *Client) SearchRawTransactionsVerboseAsync(address btcutil.Address, skip
|
||||||
}
|
}
|
||||||
cmd := btcjson.NewSearchRawTransactionsCmd(addr, verbose, &skip, &count,
|
cmd := btcjson.NewSearchRawTransactionsCmd(addr, verbose, &skip, &count,
|
||||||
prevOut, &reverse, filterAddrs)
|
prevOut, &reverse, filterAddrs)
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SearchRawTransactionsVerbose returns a list of data structures that describe
|
// SearchRawTransactionsVerbose returns a list of data structures that describe
|
||||||
|
@ -847,12 +847,12 @@ func (c *Client) SearchRawTransactionsVerbose(address btcutil.Address, skip,
|
||||||
|
|
||||||
// FutureDecodeScriptResult is a future promise to deliver the result
|
// FutureDecodeScriptResult is a future promise to deliver the result
|
||||||
// of a DecodeScriptAsync RPC invocation (or an applicable error).
|
// 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.
|
// about a script given its serialized bytes.
|
||||||
func (r FutureDecodeScriptResult) Receive() (*btcjson.DecodeScriptResult, error) {
|
func (r FutureDecodeScriptResult) Receive() (*btcjson.DecodeScriptResult, error) {
|
||||||
res, err := receiveFuture(r)
|
res, err := ReceiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -875,7 +875,7 @@ func (r FutureDecodeScriptResult) Receive() (*btcjson.DecodeScriptResult, error)
|
||||||
func (c *Client) DecodeScriptAsync(serializedScript []byte) FutureDecodeScriptResult {
|
func (c *Client) DecodeScriptAsync(serializedScript []byte) FutureDecodeScriptResult {
|
||||||
scriptHex := hex.EncodeToString(serializedScript)
|
scriptHex := hex.EncodeToString(serializedScript)
|
||||||
cmd := btcjson.NewDecodeScriptCmd(scriptHex)
|
cmd := btcjson.NewDecodeScriptCmd(scriptHex)
|
||||||
return c.sendCmd(cmd)
|
return c.SendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DecodeScript returns information about a script given its serialized bytes.
|
// DecodeScript returns information about a script given its serialized bytes.
|
||||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue