Update for recent chainhash-related API changes. (#81)
This updates all code to make use of the new chainhash package since the old wire.ShaHash type and related functions have been removed in favor of the abstracted package. Also, while here, rename all variables that included sha in their name to include hash instead.
This commit is contained in:
parent
5f19113422
commit
c39e35318d
7 changed files with 105 additions and 99 deletions
35
chain.go
35
chain.go
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (c) 2014-2015 The btcsuite developers
|
// Copyright (c) 2014-2016 The btcsuite developers
|
||||||
// Use of this source code is governed by an ISC
|
// Use of this source code is governed by an ISC
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/btcsuite/btcd/btcjson"
|
"github.com/btcsuite/btcd/btcjson"
|
||||||
|
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||||
"github.com/btcsuite/btcd/wire"
|
"github.com/btcsuite/btcd/wire"
|
||||||
"github.com/btcsuite/btcutil"
|
"github.com/btcsuite/btcutil"
|
||||||
)
|
)
|
||||||
|
@ -20,7 +21,7 @@ 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() (*wire.ShaHash, 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
|
||||||
|
@ -32,7 +33,7 @@ func (r FutureGetBestBlockHashResult) Receive() (*wire.ShaHash, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return wire.NewShaHashFromStr(txHashStr)
|
return chainhash.NewHashFromStr(txHashStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetBestBlockHashAsync returns an instance of a type that can be used to get
|
// GetBestBlockHashAsync returns an instance of a type that can be used to get
|
||||||
|
@ -47,7 +48,7 @@ func (c *Client) GetBestBlockHashAsync() FutureGetBestBlockHashResult {
|
||||||
|
|
||||||
// GetBestBlockHash returns the hash of the best block in the longest block
|
// GetBestBlockHash returns the hash of the best block in the longest block
|
||||||
// chain.
|
// chain.
|
||||||
func (c *Client) GetBestBlockHash() (*wire.ShaHash, error) {
|
func (c *Client) GetBestBlockHash() (*chainhash.Hash, error) {
|
||||||
return c.GetBestBlockHashAsync().Receive()
|
return c.GetBestBlockHashAsync().Receive()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +91,7 @@ func (r FutureGetBlockResult) Receive() (*btcutil.Block, error) {
|
||||||
// returned instance.
|
// returned instance.
|
||||||
//
|
//
|
||||||
// See GetBlock for the blocking version and more details.
|
// See GetBlock for the blocking version and more details.
|
||||||
func (c *Client) GetBlockAsync(blockHash *wire.ShaHash) FutureGetBlockResult {
|
func (c *Client) GetBlockAsync(blockHash *chainhash.Hash) FutureGetBlockResult {
|
||||||
hash := ""
|
hash := ""
|
||||||
if blockHash != nil {
|
if blockHash != nil {
|
||||||
hash = blockHash.String()
|
hash = blockHash.String()
|
||||||
|
@ -104,7 +105,7 @@ func (c *Client) GetBlockAsync(blockHash *wire.ShaHash) FutureGetBlockResult {
|
||||||
//
|
//
|
||||||
// See GetBlockVerbose to retrieve a data structure with information about the
|
// See GetBlockVerbose to retrieve a data structure with information about the
|
||||||
// block instead.
|
// block instead.
|
||||||
func (c *Client) GetBlock(blockHash *wire.ShaHash) (*btcutil.Block, error) {
|
func (c *Client) GetBlock(blockHash *chainhash.Hash) (*btcutil.Block, error) {
|
||||||
return c.GetBlockAsync(blockHash).Receive()
|
return c.GetBlockAsync(blockHash).Receive()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,7 +135,7 @@ func (r FutureGetBlockVerboseResult) Receive() (*btcjson.GetBlockVerboseResult,
|
||||||
// the returned instance.
|
// the returned instance.
|
||||||
//
|
//
|
||||||
// See GetBlockVerbose for the blocking version and more details.
|
// See GetBlockVerbose for the blocking version and more details.
|
||||||
func (c *Client) GetBlockVerboseAsync(blockHash *wire.ShaHash, verboseTx bool) FutureGetBlockVerboseResult {
|
func (c *Client) GetBlockVerboseAsync(blockHash *chainhash.Hash, verboseTx bool) FutureGetBlockVerboseResult {
|
||||||
hash := ""
|
hash := ""
|
||||||
if blockHash != nil {
|
if blockHash != nil {
|
||||||
hash = blockHash.String()
|
hash = blockHash.String()
|
||||||
|
@ -148,7 +149,7 @@ func (c *Client) GetBlockVerboseAsync(blockHash *wire.ShaHash, verboseTx bool) F
|
||||||
// about a block given its hash.
|
// about a block given its hash.
|
||||||
//
|
//
|
||||||
// See GetBlock to retrieve a raw block instead.
|
// See GetBlock to retrieve a raw block instead.
|
||||||
func (c *Client) GetBlockVerbose(blockHash *wire.ShaHash, verboseTx bool) (*btcjson.GetBlockVerboseResult, error) {
|
func (c *Client) GetBlockVerbose(blockHash *chainhash.Hash, verboseTx bool) (*btcjson.GetBlockVerboseResult, error) {
|
||||||
return c.GetBlockVerboseAsync(blockHash, verboseTx).Receive()
|
return c.GetBlockVerboseAsync(blockHash, verboseTx).Receive()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,7 +232,7 @@ 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() (*wire.ShaHash, 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
|
||||||
|
@ -243,7 +244,7 @@ func (r FutureGetBlockHashResult) Receive() (*wire.ShaHash, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return wire.NewShaHashFromStr(txHashStr)
|
return chainhash.NewHashFromStr(txHashStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetBlockHashAsync returns an instance of a type that can be used to get the
|
// GetBlockHashAsync returns an instance of a type that can be used to get the
|
||||||
|
@ -258,7 +259,7 @@ func (c *Client) GetBlockHashAsync(blockHeight int64) FutureGetBlockHashResult {
|
||||||
|
|
||||||
// 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
|
||||||
// given height.
|
// given height.
|
||||||
func (c *Client) GetBlockHash(blockHeight int64) (*wire.ShaHash, error) {
|
func (c *Client) GetBlockHash(blockHeight int64) (*chainhash.Hash, error) {
|
||||||
return c.GetBlockHashAsync(blockHeight).Receive()
|
return c.GetBlockHashAsync(blockHeight).Receive()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,7 +269,7 @@ 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() ([]*wire.ShaHash, 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
|
||||||
|
@ -282,9 +283,9 @@ func (r FutureGetRawMempoolResult) Receive() ([]*wire.ShaHash, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a slice of ShaHash arrays from the string slice.
|
// Create a slice of ShaHash arrays from the string slice.
|
||||||
txHashes := make([]*wire.ShaHash, 0, len(txHashStrs))
|
txHashes := make([]*chainhash.Hash, 0, len(txHashStrs))
|
||||||
for _, hashStr := range txHashStrs {
|
for _, hashStr := range txHashStrs {
|
||||||
txHash, err := wire.NewShaHashFromStr(hashStr)
|
txHash, err := chainhash.NewHashFromStr(hashStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -308,7 +309,7 @@ func (c *Client) GetRawMempoolAsync() FutureGetRawMempoolResult {
|
||||||
//
|
//
|
||||||
// See GetRawMempoolVerbose to retrieve data structures with information about
|
// See GetRawMempoolVerbose to retrieve data structures with information about
|
||||||
// the transactions instead.
|
// the transactions instead.
|
||||||
func (c *Client) GetRawMempool() ([]*wire.ShaHash, error) {
|
func (c *Client) GetRawMempool() ([]*chainhash.Hash, error) {
|
||||||
return c.GetRawMempoolAsync().Receive()
|
return c.GetRawMempoolAsync().Receive()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -476,7 +477,7 @@ func (r FutureGetTxOutResult) Receive() (*btcjson.GetTxOutResult, error) {
|
||||||
// the returned instance.
|
// the returned instance.
|
||||||
//
|
//
|
||||||
// See GetTxOut for the blocking version and more details.
|
// See GetTxOut for the blocking version and more details.
|
||||||
func (c *Client) GetTxOutAsync(txHash *wire.ShaHash, index uint32, mempool bool) FutureGetTxOutResult {
|
func (c *Client) GetTxOutAsync(txHash *chainhash.Hash, index uint32, mempool bool) FutureGetTxOutResult {
|
||||||
hash := ""
|
hash := ""
|
||||||
if txHash != nil {
|
if txHash != nil {
|
||||||
hash = txHash.String()
|
hash = txHash.String()
|
||||||
|
@ -488,6 +489,6 @@ func (c *Client) GetTxOutAsync(txHash *wire.ShaHash, index uint32, mempool bool)
|
||||||
|
|
||||||
// GetTxOut returns the transaction output info if it's unspent and
|
// GetTxOut returns the transaction output info if it's unspent and
|
||||||
// nil, otherwise.
|
// nil, otherwise.
|
||||||
func (c *Client) GetTxOut(txHash *wire.ShaHash, index uint32, mempool bool) (*btcjson.GetTxOutResult, error) {
|
func (c *Client) GetTxOut(txHash *chainhash.Hash, index uint32, mempool bool) (*btcjson.GetTxOutResult, error) {
|
||||||
return c.GetTxOutAsync(txHash, index, mempool).Receive()
|
return c.GetTxOutAsync(txHash, index, mempool).Receive()
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/btcsuite/btcd/wire"
|
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||||
"github.com/btcsuite/btcrpcclient"
|
"github.com/btcsuite/btcrpcclient"
|
||||||
"github.com/btcsuite/btcutil"
|
"github.com/btcsuite/btcutil"
|
||||||
)
|
)
|
||||||
|
@ -21,10 +21,10 @@ func main() {
|
||||||
// for notifications. See the documentation of the btcrpcclient
|
// for notifications. See the documentation of the btcrpcclient
|
||||||
// NotificationHandlers type for more details about each handler.
|
// NotificationHandlers type for more details about each handler.
|
||||||
ntfnHandlers := btcrpcclient.NotificationHandlers{
|
ntfnHandlers := btcrpcclient.NotificationHandlers{
|
||||||
OnBlockConnected: func(hash *wire.ShaHash, height int32, time time.Time) {
|
OnBlockConnected: func(hash *chainhash.Hash, height int32, time time.Time) {
|
||||||
log.Printf("Block connected: %v (%d) %v", hash, height, time)
|
log.Printf("Block connected: %v (%d) %v", hash, height, time)
|
||||||
},
|
},
|
||||||
OnBlockDisconnected: func(hash *wire.ShaHash, height int32, time time.Time) {
|
OnBlockDisconnected: func(hash *chainhash.Hash, height int32, time time.Time) {
|
||||||
log.Printf("Block disconnected: %v (%d) %v", hash, height, time)
|
log.Printf("Block disconnected: %v (%d) %v", hash, height, time)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/btcsuite/btcd/btcjson"
|
"github.com/btcsuite/btcd/btcjson"
|
||||||
|
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||||
"github.com/btcsuite/btcd/wire"
|
"github.com/btcsuite/btcd/wire"
|
||||||
"github.com/btcsuite/btcutil"
|
"github.com/btcsuite/btcutil"
|
||||||
)
|
)
|
||||||
|
@ -148,7 +149,7 @@ 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() (*wire.ShaHash, 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
|
||||||
|
@ -162,7 +163,7 @@ func (r FutureGetBestBlockResult) Receive() (*wire.ShaHash, int32, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert to hash from string.
|
// Convert to hash from string.
|
||||||
hash, err := wire.NewShaHashFromStr(bestBlock.Hash)
|
hash, err := chainhash.NewHashFromStr(bestBlock.Hash)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, 0, err
|
return nil, 0, err
|
||||||
}
|
}
|
||||||
|
@ -186,7 +187,7 @@ func (c *Client) GetBestBlockAsync() FutureGetBestBlockResult {
|
||||||
// chain.
|
// chain.
|
||||||
//
|
//
|
||||||
// NOTE: This is a btcd extension.
|
// NOTE: This is a btcd extension.
|
||||||
func (c *Client) GetBestBlock() (*wire.ShaHash, int32, error) {
|
func (c *Client) GetBestBlock() (*chainhash.Hash, int32, error) {
|
||||||
return c.GetBestBlockAsync().Receive()
|
return c.GetBestBlockAsync().Receive()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
15
mining.go
15
mining.go
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (c) 2014-2015 The btcsuite developers
|
// Copyright (c) 2014-2016 The btcsuite developers
|
||||||
// Use of this source code is governed by an ISC
|
// Use of this source code is governed by an ISC
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"github.com/btcsuite/btcd/btcjson"
|
"github.com/btcsuite/btcd/btcjson"
|
||||||
"github.com/btcsuite/btcd/wire"
|
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||||
"github.com/btcsuite/btcutil"
|
"github.com/btcsuite/btcutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ 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() ([]*wire.ShaHash, 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
|
||||||
|
@ -33,10 +33,11 @@ func (r FutureGenerateResult) Receive() ([]*wire.ShaHash, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert each block hash to a wire.ShaHash and store a pointer to each.
|
// Convert each block hash to a chainhash.Hash and store a pointer to
|
||||||
convertedResult := make([]*wire.ShaHash, len(result))
|
// each.
|
||||||
|
convertedResult := make([]*chainhash.Hash, len(result))
|
||||||
for i, hashString := range result {
|
for i, hashString := range result {
|
||||||
convertedResult[i], err = wire.NewShaHashFromStr(hashString)
|
convertedResult[i], err = chainhash.NewHashFromStr(hashString)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -56,7 +57,7 @@ func (c *Client) GenerateAsync(numBlocks uint32) FutureGenerateResult {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate generates numBlocks blocks and returns their hashes.
|
// Generate generates numBlocks blocks and returns their hashes.
|
||||||
func (c *Client) Generate(numBlocks uint32) ([]*wire.ShaHash, error) {
|
func (c *Client) Generate(numBlocks uint32) ([]*chainhash.Hash, error) {
|
||||||
return c.GenerateAsync(numBlocks).Receive()
|
return c.GenerateAsync(numBlocks).Receive()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
79
notify.go
79
notify.go
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (c) 2014-2015 The btcsuite developers
|
// Copyright (c) 2014-2016 The btcsuite developers
|
||||||
// Use of this source code is governed by an ISC
|
// Use of this source code is governed by an ISC
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/btcsuite/btcd/btcjson"
|
"github.com/btcsuite/btcd/btcjson"
|
||||||
|
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||||
"github.com/btcsuite/btcd/wire"
|
"github.com/btcsuite/btcd/wire"
|
||||||
"github.com/btcsuite/btcutil"
|
"github.com/btcsuite/btcutil"
|
||||||
)
|
)
|
||||||
|
@ -96,13 +97,13 @@ type NotificationHandlers struct {
|
||||||
// (best) chain. It will only be invoked if a preceding call to
|
// (best) chain. It will only be invoked if a preceding call to
|
||||||
// NotifyBlocks has been made to register for the notification and the
|
// NotifyBlocks has been made to register for the notification and the
|
||||||
// function is non-nil.
|
// function is non-nil.
|
||||||
OnBlockConnected func(hash *wire.ShaHash, height int32, t time.Time)
|
OnBlockConnected func(hash *chainhash.Hash, height int32, t time.Time)
|
||||||
|
|
||||||
// OnBlockDisconnected is invoked when a block is disconnected from the
|
// OnBlockDisconnected is invoked when a block is disconnected from the
|
||||||
// longest (best) chain. It will only be invoked if a preceding call to
|
// longest (best) chain. It will only be invoked if a preceding call to
|
||||||
// NotifyBlocks has been made to register for the notification and the
|
// NotifyBlocks has been made to register for the notification and the
|
||||||
// function is non-nil.
|
// function is non-nil.
|
||||||
OnBlockDisconnected func(hash *wire.ShaHash, height int32, t time.Time)
|
OnBlockDisconnected func(hash *chainhash.Hash, height int32, t time.Time)
|
||||||
|
|
||||||
// OnRecvTx is invoked when a transaction that receives funds to a
|
// OnRecvTx is invoked when a transaction that receives funds to a
|
||||||
// registered address is received into the memory pool and also
|
// registered address is received into the memory pool and also
|
||||||
|
@ -128,18 +129,18 @@ type NotificationHandlers struct {
|
||||||
// signaled on this notification, rather than relying on the return
|
// signaled on this notification, rather than relying on the return
|
||||||
// result of a rescan request, due to how btcd may send various rescan
|
// result of a rescan request, due to how btcd may send various rescan
|
||||||
// notifications after the rescan request has already returned.
|
// notifications after the rescan request has already returned.
|
||||||
OnRescanFinished func(hash *wire.ShaHash, height int32, blkTime time.Time)
|
OnRescanFinished func(hash *chainhash.Hash, height int32, blkTime time.Time)
|
||||||
|
|
||||||
// OnRescanProgress is invoked periodically when a rescan is underway.
|
// OnRescanProgress is invoked periodically when a rescan is underway.
|
||||||
// It will only be invoked if a preceding call to Rescan or
|
// It will only be invoked if a preceding call to Rescan or
|
||||||
// RescanEndHeight has been made and the function is non-nil.
|
// RescanEndHeight has been made and the function is non-nil.
|
||||||
OnRescanProgress func(hash *wire.ShaHash, height int32, blkTime time.Time)
|
OnRescanProgress func(hash *chainhash.Hash, height int32, blkTime time.Time)
|
||||||
|
|
||||||
// OnTxAccepted is invoked when a transaction is accepted into the
|
// OnTxAccepted is invoked when a transaction is accepted into the
|
||||||
// memory pool. It will only be invoked if a preceding call to
|
// memory pool. It will only be invoked if a preceding call to
|
||||||
// NotifyNewTransactions with the verbose flag set to false has been
|
// NotifyNewTransactions with the verbose flag set to false has been
|
||||||
// made to register for the notification and the function is non-nil.
|
// made to register for the notification and the function is non-nil.
|
||||||
OnTxAccepted func(hash *wire.ShaHash, amount btcutil.Amount)
|
OnTxAccepted func(hash *chainhash.Hash, amount btcutil.Amount)
|
||||||
|
|
||||||
// OnTxAccepted is invoked when a transaction is accepted into the
|
// OnTxAccepted is invoked when a transaction is accepted into the
|
||||||
// memory pool. It will only be invoked if a preceding call to
|
// memory pool. It will only be invoked if a preceding call to
|
||||||
|
@ -194,14 +195,14 @@ func (c *Client) handleNotification(ntfn *rawNotification) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
blockSha, blockHeight, blockTime, err := parseChainNtfnParams(ntfn.Params)
|
blockHash, blockHeight, blockTime, err := parseChainNtfnParams(ntfn.Params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warnf("Received invalid block connected "+
|
log.Warnf("Received invalid block connected "+
|
||||||
"notification: %v", err)
|
"notification: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
c.ntfnHandlers.OnBlockConnected(blockSha, blockHeight, blockTime)
|
c.ntfnHandlers.OnBlockConnected(blockHash, blockHeight, blockTime)
|
||||||
|
|
||||||
// OnBlockDisconnected
|
// OnBlockDisconnected
|
||||||
case btcjson.BlockDisconnectedNtfnMethod:
|
case btcjson.BlockDisconnectedNtfnMethod:
|
||||||
|
@ -211,14 +212,14 @@ func (c *Client) handleNotification(ntfn *rawNotification) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
blockSha, blockHeight, blockTime, err := parseChainNtfnParams(ntfn.Params)
|
blockHash, blockHeight, blockTime, err := parseChainNtfnParams(ntfn.Params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warnf("Received invalid block connected "+
|
log.Warnf("Received invalid block connected "+
|
||||||
"notification: %v", err)
|
"notification: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
c.ntfnHandlers.OnBlockDisconnected(blockSha, blockHeight, blockTime)
|
c.ntfnHandlers.OnBlockDisconnected(blockHash, blockHeight, blockTime)
|
||||||
|
|
||||||
// OnRecvTx
|
// OnRecvTx
|
||||||
case btcjson.RecvTxNtfnMethod:
|
case btcjson.RecvTxNtfnMethod:
|
||||||
|
@ -398,7 +399,7 @@ func (e wrongNumParams) Error() string {
|
||||||
|
|
||||||
// parseChainNtfnParams parses out the block hash and height from the parameters
|
// parseChainNtfnParams parses out the block hash and height from the parameters
|
||||||
// of blockconnected and blockdisconnected notifications.
|
// of blockconnected and blockdisconnected notifications.
|
||||||
func parseChainNtfnParams(params []json.RawMessage) (*wire.ShaHash,
|
func parseChainNtfnParams(params []json.RawMessage) (*chainhash.Hash,
|
||||||
int32, time.Time, error) {
|
int32, time.Time, error) {
|
||||||
|
|
||||||
if len(params) != 3 {
|
if len(params) != 3 {
|
||||||
|
@ -406,8 +407,8 @@ func parseChainNtfnParams(params []json.RawMessage) (*wire.ShaHash,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unmarshal first parameter as a string.
|
// Unmarshal first parameter as a string.
|
||||||
var blockShaStr string
|
var blockHashStr string
|
||||||
err := json.Unmarshal(params[0], &blockShaStr)
|
err := json.Unmarshal(params[0], &blockHashStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, 0, time.Time{}, err
|
return nil, 0, time.Time{}, err
|
||||||
}
|
}
|
||||||
|
@ -426,8 +427,8 @@ func parseChainNtfnParams(params []json.RawMessage) (*wire.ShaHash,
|
||||||
return nil, 0, time.Time{}, err
|
return nil, 0, time.Time{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create ShaHash from block sha string.
|
// Create hash from block hash string.
|
||||||
blockSha, err := wire.NewShaHashFromStr(blockShaStr)
|
blockHash, err := chainhash.NewHashFromStr(blockHashStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, 0, time.Time{}, err
|
return nil, 0, time.Time{}, err
|
||||||
}
|
}
|
||||||
|
@ -435,7 +436,7 @@ func parseChainNtfnParams(params []json.RawMessage) (*wire.ShaHash,
|
||||||
// Create time.Time from unix time.
|
// Create time.Time from unix time.
|
||||||
blockTime := time.Unix(blockTimeUnix, 0)
|
blockTime := time.Unix(blockTimeUnix, 0)
|
||||||
|
|
||||||
return blockSha, blockHeight, blockTime, nil
|
return blockHash, blockHeight, blockTime, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// parseChainTxNtfnParams parses out the transaction and optional details about
|
// parseChainTxNtfnParams parses out the transaction and optional details about
|
||||||
|
@ -477,14 +478,14 @@ func parseChainTxNtfnParams(params []json.RawMessage) (*btcutil.Tx,
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Change recvtx and redeemingtx callback signatures to use
|
// TODO: Change recvtx and redeemingtx callback signatures to use
|
||||||
// nicer types for details about the block (block sha as a
|
// nicer types for details about the block (block hash as a
|
||||||
// wire.ShaHash, block time as a time.Time, etc.).
|
// chainhash.Hash, block time as a time.Time, etc.).
|
||||||
return btcutil.NewTx(&msgTx), block, nil
|
return btcutil.NewTx(&msgTx), block, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// parseRescanProgressParams parses out the height of the last rescanned block
|
// parseRescanProgressParams parses out the height of the last rescanned block
|
||||||
// from the parameters of rescanfinished and rescanprogress notifications.
|
// from the parameters of rescanfinished and rescanprogress notifications.
|
||||||
func parseRescanProgressParams(params []json.RawMessage) (*wire.ShaHash, int32, time.Time, error) {
|
func parseRescanProgressParams(params []json.RawMessage) (*chainhash.Hash, int32, time.Time, error) {
|
||||||
if len(params) != 3 {
|
if len(params) != 3 {
|
||||||
return nil, 0, time.Time{}, wrongNumParams(len(params))
|
return nil, 0, time.Time{}, wrongNumParams(len(params))
|
||||||
}
|
}
|
||||||
|
@ -511,7 +512,7 @@ func parseRescanProgressParams(params []json.RawMessage) (*wire.ShaHash, int32,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decode string encoding of block hash.
|
// Decode string encoding of block hash.
|
||||||
hash, err := wire.NewShaHashFromStr(hashStr)
|
hash, err := chainhash.NewHashFromStr(hashStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, 0, time.Time{}, err
|
return nil, 0, time.Time{}, err
|
||||||
}
|
}
|
||||||
|
@ -521,7 +522,7 @@ func parseRescanProgressParams(params []json.RawMessage) (*wire.ShaHash, int32,
|
||||||
|
|
||||||
// parseTxAcceptedNtfnParams parses out the transaction hash and total amount
|
// parseTxAcceptedNtfnParams parses out the transaction hash and total amount
|
||||||
// from the parameters of a txaccepted notification.
|
// from the parameters of a txaccepted notification.
|
||||||
func parseTxAcceptedNtfnParams(params []json.RawMessage) (*wire.ShaHash,
|
func parseTxAcceptedNtfnParams(params []json.RawMessage) (*chainhash.Hash,
|
||||||
btcutil.Amount, error) {
|
btcutil.Amount, error) {
|
||||||
|
|
||||||
if len(params) != 2 {
|
if len(params) != 2 {
|
||||||
|
@ -529,8 +530,8 @@ func parseTxAcceptedNtfnParams(params []json.RawMessage) (*wire.ShaHash,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unmarshal first parameter as a string.
|
// Unmarshal first parameter as a string.
|
||||||
var txShaStr string
|
var txHashStr string
|
||||||
err := json.Unmarshal(params[0], &txShaStr)
|
err := json.Unmarshal(params[0], &txHashStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, 0, err
|
return nil, 0, err
|
||||||
}
|
}
|
||||||
|
@ -549,12 +550,12 @@ func parseTxAcceptedNtfnParams(params []json.RawMessage) (*wire.ShaHash,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decode string encoding of transaction sha.
|
// Decode string encoding of transaction sha.
|
||||||
txSha, err := wire.NewShaHashFromStr(txShaStr)
|
txHash, err := chainhash.NewHashFromStr(txHashStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, 0, err
|
return nil, 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return txSha, btcutil.Amount(amt), nil
|
return txHash, btcutil.Amount(amt), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// parseTxAcceptedVerboseNtfnParams parses out details about a raw transaction
|
// parseTxAcceptedVerboseNtfnParams parses out details about a raw transaction
|
||||||
|
@ -959,7 +960,7 @@ func (r FutureRescanResult) Receive() error {
|
||||||
// reconnect.
|
// reconnect.
|
||||||
//
|
//
|
||||||
// NOTE: This is a btcd extension and requires a websocket connection.
|
// NOTE: This is a btcd extension and requires a websocket connection.
|
||||||
func (c *Client) RescanAsync(startBlock *wire.ShaHash,
|
func (c *Client) RescanAsync(startBlock *chainhash.Hash,
|
||||||
addresses []btcutil.Address,
|
addresses []btcutil.Address,
|
||||||
outpoints []*wire.OutPoint) FutureRescanResult {
|
outpoints []*wire.OutPoint) FutureRescanResult {
|
||||||
|
|
||||||
|
@ -975,9 +976,9 @@ func (c *Client) RescanAsync(startBlock *wire.ShaHash,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert block hashes to strings.
|
// Convert block hashes to strings.
|
||||||
var startBlockShaStr string
|
var startBlockHashStr string
|
||||||
if startBlock != nil {
|
if startBlock != nil {
|
||||||
startBlockShaStr = startBlock.String()
|
startBlockHashStr = startBlock.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert addresses to strings.
|
// Convert addresses to strings.
|
||||||
|
@ -992,7 +993,7 @@ func (c *Client) RescanAsync(startBlock *wire.ShaHash,
|
||||||
ops = append(ops, newOutPointFromWire(op))
|
ops = append(ops, newOutPointFromWire(op))
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd := btcjson.NewRescanCmd(startBlockShaStr, addrs, ops, nil)
|
cmd := btcjson.NewRescanCmd(startBlockHashStr, addrs, ops, nil)
|
||||||
return c.sendCmd(cmd)
|
return c.sendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1022,7 +1023,7 @@ func (c *Client) RescanAsync(startBlock *wire.ShaHash,
|
||||||
// reconnect.
|
// reconnect.
|
||||||
//
|
//
|
||||||
// NOTE: This is a btcd extension and requires a websocket connection.
|
// NOTE: This is a btcd extension and requires a websocket connection.
|
||||||
func (c *Client) Rescan(startBlock *wire.ShaHash,
|
func (c *Client) Rescan(startBlock *chainhash.Hash,
|
||||||
addresses []btcutil.Address,
|
addresses []btcutil.Address,
|
||||||
outpoints []*wire.OutPoint) error {
|
outpoints []*wire.OutPoint) error {
|
||||||
|
|
||||||
|
@ -1036,9 +1037,9 @@ func (c *Client) Rescan(startBlock *wire.ShaHash,
|
||||||
// See RescanEndBlock for the blocking version and more details.
|
// See RescanEndBlock for the blocking version and more details.
|
||||||
//
|
//
|
||||||
// NOTE: This is a btcd extension and requires a websocket connection.
|
// NOTE: This is a btcd extension and requires a websocket connection.
|
||||||
func (c *Client) RescanEndBlockAsync(startBlock *wire.ShaHash,
|
func (c *Client) RescanEndBlockAsync(startBlock *chainhash.Hash,
|
||||||
addresses []btcutil.Address, outpoints []*wire.OutPoint,
|
addresses []btcutil.Address, outpoints []*wire.OutPoint,
|
||||||
endBlock *wire.ShaHash) FutureRescanResult {
|
endBlock *chainhash.Hash) FutureRescanResult {
|
||||||
|
|
||||||
// Not supported in HTTP POST mode.
|
// Not supported in HTTP POST mode.
|
||||||
if c.config.HTTPPostMode {
|
if c.config.HTTPPostMode {
|
||||||
|
@ -1052,12 +1053,12 @@ func (c *Client) RescanEndBlockAsync(startBlock *wire.ShaHash,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert block hashes to strings.
|
// Convert block hashes to strings.
|
||||||
var startBlockShaStr, endBlockShaStr string
|
var startBlockHashStr, endBlockHashStr string
|
||||||
if startBlock != nil {
|
if startBlock != nil {
|
||||||
startBlockShaStr = startBlock.String()
|
startBlockHashStr = startBlock.String()
|
||||||
}
|
}
|
||||||
if endBlock != nil {
|
if endBlock != nil {
|
||||||
endBlockShaStr = endBlock.String()
|
endBlockHashStr = endBlock.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert addresses to strings.
|
// Convert addresses to strings.
|
||||||
|
@ -1072,8 +1073,8 @@ func (c *Client) RescanEndBlockAsync(startBlock *wire.ShaHash,
|
||||||
ops = append(ops, newOutPointFromWire(op))
|
ops = append(ops, newOutPointFromWire(op))
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd := btcjson.NewRescanCmd(startBlockShaStr, addrs, ops,
|
cmd := btcjson.NewRescanCmd(startBlockHashStr, addrs, ops,
|
||||||
&endBlockShaStr)
|
&endBlockHashStr)
|
||||||
return c.sendCmd(cmd)
|
return c.sendCmd(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1096,9 +1097,9 @@ func (c *Client) RescanEndBlockAsync(startBlock *wire.ShaHash,
|
||||||
// See Rescan to also perform a rescan through current end of the longest chain.
|
// See Rescan to also perform a rescan through current end of the longest chain.
|
||||||
//
|
//
|
||||||
// NOTE: This is a btcd extension and requires a websocket connection.
|
// NOTE: This is a btcd extension and requires a websocket connection.
|
||||||
func (c *Client) RescanEndHeight(startBlock *wire.ShaHash,
|
func (c *Client) RescanEndHeight(startBlock *chainhash.Hash,
|
||||||
addresses []btcutil.Address, outpoints []*wire.OutPoint,
|
addresses []btcutil.Address, outpoints []*wire.OutPoint,
|
||||||
endBlock *wire.ShaHash) error {
|
endBlock *chainhash.Hash) error {
|
||||||
|
|
||||||
return c.RescanEndBlockAsync(startBlock, addresses, outpoints,
|
return c.RescanEndBlockAsync(startBlock, addresses, outpoints,
|
||||||
endBlock).Receive()
|
endBlock).Receive()
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (c) 2014-2015 The btcsuite developers
|
// Copyright (c) 2014-2016 The btcsuite developers
|
||||||
// Use of this source code is governed by an ISC
|
// Use of this source code is governed by an ISC
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/btcsuite/btcd/btcjson"
|
"github.com/btcsuite/btcd/btcjson"
|
||||||
|
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||||
"github.com/btcsuite/btcd/wire"
|
"github.com/btcsuite/btcd/wire"
|
||||||
"github.com/btcsuite/btcutil"
|
"github.com/btcsuite/btcutil"
|
||||||
)
|
)
|
||||||
|
@ -95,7 +96,7 @@ func (r FutureGetRawTransactionResult) Receive() (*btcutil.Tx, error) {
|
||||||
// the returned instance.
|
// the returned instance.
|
||||||
//
|
//
|
||||||
// See GetRawTransaction for the blocking version and more details.
|
// See GetRawTransaction for the blocking version and more details.
|
||||||
func (c *Client) GetRawTransactionAsync(txHash *wire.ShaHash) FutureGetRawTransactionResult {
|
func (c *Client) GetRawTransactionAsync(txHash *chainhash.Hash) FutureGetRawTransactionResult {
|
||||||
hash := ""
|
hash := ""
|
||||||
if txHash != nil {
|
if txHash != nil {
|
||||||
hash = txHash.String()
|
hash = txHash.String()
|
||||||
|
@ -109,7 +110,7 @@ func (c *Client) GetRawTransactionAsync(txHash *wire.ShaHash) FutureGetRawTransa
|
||||||
//
|
//
|
||||||
// See GetRawTransactionVerbose to obtain additional information about the
|
// See GetRawTransactionVerbose to obtain additional information about the
|
||||||
// transaction.
|
// transaction.
|
||||||
func (c *Client) GetRawTransaction(txHash *wire.ShaHash) (*btcutil.Tx, error) {
|
func (c *Client) GetRawTransaction(txHash *chainhash.Hash) (*btcutil.Tx, error) {
|
||||||
return c.GetRawTransactionAsync(txHash).Receive()
|
return c.GetRawTransactionAsync(txHash).Receive()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,7 +142,7 @@ func (r FutureGetRawTransactionVerboseResult) Receive() (*btcjson.TxRawResult, e
|
||||||
// function on the returned instance.
|
// function on the returned instance.
|
||||||
//
|
//
|
||||||
// See GetRawTransactionVerbose for the blocking version and more details.
|
// See GetRawTransactionVerbose for the blocking version and more details.
|
||||||
func (c *Client) GetRawTransactionVerboseAsync(txHash *wire.ShaHash) FutureGetRawTransactionVerboseResult {
|
func (c *Client) GetRawTransactionVerboseAsync(txHash *chainhash.Hash) FutureGetRawTransactionVerboseResult {
|
||||||
hash := ""
|
hash := ""
|
||||||
if txHash != nil {
|
if txHash != nil {
|
||||||
hash = txHash.String()
|
hash = txHash.String()
|
||||||
|
@ -155,7 +156,7 @@ func (c *Client) GetRawTransactionVerboseAsync(txHash *wire.ShaHash) FutureGetRa
|
||||||
// its hash.
|
// its hash.
|
||||||
//
|
//
|
||||||
// See GetRawTransaction to obtain only the transaction already deserialized.
|
// See GetRawTransaction to obtain only the transaction already deserialized.
|
||||||
func (c *Client) GetRawTransactionVerbose(txHash *wire.ShaHash) (*btcjson.TxRawResult, error) {
|
func (c *Client) GetRawTransactionVerbose(txHash *chainhash.Hash) (*btcjson.TxRawResult, error) {
|
||||||
return c.GetRawTransactionVerboseAsync(txHash).Receive()
|
return c.GetRawTransactionVerboseAsync(txHash).Receive()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,7 +264,7 @@ 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() (*wire.ShaHash, 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
|
||||||
|
@ -276,7 +277,7 @@ func (r FutureSendRawTransactionResult) Receive() (*wire.ShaHash, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return wire.NewShaHashFromStr(txHashStr)
|
return chainhash.NewHashFromStr(txHashStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SendRawTransactionAsync returns an instance of a type that can be used to get
|
// SendRawTransactionAsync returns an instance of a type that can be used to get
|
||||||
|
@ -301,7 +302,7 @@ func (c *Client) SendRawTransactionAsync(tx *wire.MsgTx, allowHighFees bool) Fut
|
||||||
|
|
||||||
// SendRawTransaction submits the encoded transaction to the server which will
|
// SendRawTransaction submits the encoded transaction to the server which will
|
||||||
// then relay it to the network.
|
// then relay it to the network.
|
||||||
func (c *Client) SendRawTransaction(tx *wire.MsgTx, allowHighFees bool) (*wire.ShaHash, error) {
|
func (c *Client) SendRawTransaction(tx *wire.MsgTx, allowHighFees bool) (*chainhash.Hash, error) {
|
||||||
return c.SendRawTransactionAsync(tx, allowHighFees).Receive()
|
return c.SendRawTransactionAsync(tx, allowHighFees).Receive()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
45
wallet.go
45
wallet.go
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (c) 2014-2015 The btcsuite developers
|
// Copyright (c) 2014-2016 The btcsuite developers
|
||||||
// Use of this source code is governed by an ISC
|
// Use of this source code is governed by an ISC
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ import (
|
||||||
|
|
||||||
"github.com/btcsuite/btcd/btcjson"
|
"github.com/btcsuite/btcd/btcjson"
|
||||||
"github.com/btcsuite/btcd/chaincfg"
|
"github.com/btcsuite/btcd/chaincfg"
|
||||||
|
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||||
"github.com/btcsuite/btcd/wire"
|
"github.com/btcsuite/btcd/wire"
|
||||||
"github.com/btcsuite/btcutil"
|
"github.com/btcsuite/btcutil"
|
||||||
)
|
)
|
||||||
|
@ -45,7 +46,7 @@ func (r FutureGetTransactionResult) Receive() (*btcjson.GetTransactionResult, er
|
||||||
// the returned instance.
|
// the returned instance.
|
||||||
//
|
//
|
||||||
// See GetTransaction for the blocking version and more details.
|
// See GetTransaction for the blocking version and more details.
|
||||||
func (c *Client) GetTransactionAsync(txHash *wire.ShaHash) FutureGetTransactionResult {
|
func (c *Client) GetTransactionAsync(txHash *chainhash.Hash) FutureGetTransactionResult {
|
||||||
hash := ""
|
hash := ""
|
||||||
if txHash != nil {
|
if txHash != nil {
|
||||||
hash = txHash.String()
|
hash = txHash.String()
|
||||||
|
@ -58,7 +59,7 @@ func (c *Client) GetTransactionAsync(txHash *wire.ShaHash) FutureGetTransactionR
|
||||||
// GetTransaction returns detailed information about a wallet transaction.
|
// GetTransaction returns detailed information about a wallet transaction.
|
||||||
//
|
//
|
||||||
// See GetRawTransaction to return the raw transaction instead.
|
// See GetRawTransaction to return the raw transaction instead.
|
||||||
func (c *Client) GetTransaction(txHash *wire.ShaHash) (*btcjson.GetTransactionResult, error) {
|
func (c *Client) GetTransaction(txHash *chainhash.Hash) (*btcjson.GetTransactionResult, error) {
|
||||||
return c.GetTransactionAsync(txHash).Receive()
|
return c.GetTransactionAsync(txHash).Receive()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,7 +269,7 @@ func (r FutureListSinceBlockResult) Receive() (*btcjson.ListSinceBlockResult, er
|
||||||
// the returned instance.
|
// the returned instance.
|
||||||
//
|
//
|
||||||
// See ListSinceBlock for the blocking version and more details.
|
// See ListSinceBlock for the blocking version and more details.
|
||||||
func (c *Client) ListSinceBlockAsync(blockHash *wire.ShaHash) FutureListSinceBlockResult {
|
func (c *Client) ListSinceBlockAsync(blockHash *chainhash.Hash) FutureListSinceBlockResult {
|
||||||
var hash *string
|
var hash *string
|
||||||
if blockHash != nil {
|
if blockHash != nil {
|
||||||
hash = btcjson.String(blockHash.String())
|
hash = btcjson.String(blockHash.String())
|
||||||
|
@ -283,7 +284,7 @@ func (c *Client) ListSinceBlockAsync(blockHash *wire.ShaHash) FutureListSinceBlo
|
||||||
// minimum confirmations as a filter.
|
// minimum confirmations as a filter.
|
||||||
//
|
//
|
||||||
// See ListSinceBlockMinConf to override the minimum number of confirmations.
|
// See ListSinceBlockMinConf to override the minimum number of confirmations.
|
||||||
func (c *Client) ListSinceBlock(blockHash *wire.ShaHash) (*btcjson.ListSinceBlockResult, error) {
|
func (c *Client) ListSinceBlock(blockHash *chainhash.Hash) (*btcjson.ListSinceBlockResult, error) {
|
||||||
return c.ListSinceBlockAsync(blockHash).Receive()
|
return c.ListSinceBlockAsync(blockHash).Receive()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -292,7 +293,7 @@ func (c *Client) ListSinceBlock(blockHash *wire.ShaHash) (*btcjson.ListSinceBloc
|
||||||
// function on the returned instance.
|
// function on the returned instance.
|
||||||
//
|
//
|
||||||
// See ListSinceBlockMinConf for the blocking version and more details.
|
// See ListSinceBlockMinConf for the blocking version and more details.
|
||||||
func (c *Client) ListSinceBlockMinConfAsync(blockHash *wire.ShaHash, minConfirms int) FutureListSinceBlockResult {
|
func (c *Client) ListSinceBlockMinConfAsync(blockHash *chainhash.Hash, minConfirms int) FutureListSinceBlockResult {
|
||||||
var hash *string
|
var hash *string
|
||||||
if blockHash != nil {
|
if blockHash != nil {
|
||||||
hash = btcjson.String(blockHash.String())
|
hash = btcjson.String(blockHash.String())
|
||||||
|
@ -307,7 +308,7 @@ func (c *Client) ListSinceBlockMinConfAsync(blockHash *wire.ShaHash, minConfirms
|
||||||
// number of minimum confirmations as a filter.
|
// number of minimum confirmations as a filter.
|
||||||
//
|
//
|
||||||
// See ListSinceBlock to use the default minimum number of confirmations.
|
// See ListSinceBlock to use the default minimum number of confirmations.
|
||||||
func (c *Client) ListSinceBlockMinConf(blockHash *wire.ShaHash, minConfirms int) (*btcjson.ListSinceBlockResult, error) {
|
func (c *Client) ListSinceBlockMinConf(blockHash *chainhash.Hash, minConfirms int) (*btcjson.ListSinceBlockResult, error) {
|
||||||
return c.ListSinceBlockMinConfAsync(blockHash, minConfirms).Receive()
|
return c.ListSinceBlockMinConfAsync(blockHash, minConfirms).Receive()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -386,7 +387,7 @@ func (r FutureListLockUnspentResult) Receive() ([]*wire.OutPoint, error) {
|
||||||
// Create a slice of outpoints from the transaction input structs.
|
// Create a slice of outpoints from the transaction input structs.
|
||||||
ops := make([]*wire.OutPoint, len(inputs))
|
ops := make([]*wire.OutPoint, len(inputs))
|
||||||
for i, input := range inputs {
|
for i, input := range inputs {
|
||||||
sha, err := wire.NewShaHashFromStr(input.Txid)
|
sha, err := chainhash.NewHashFromStr(input.Txid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -451,7 +452,7 @@ type FutureSendToAddressResult chan *response
|
||||||
|
|
||||||
// Receive waits for the response promised by the future and returns the hash
|
// Receive waits for the response promised by the future and returns the hash
|
||||||
// of the transaction sending the passed amount to the given address.
|
// of the transaction sending the passed amount to the given address.
|
||||||
func (r FutureSendToAddressResult) Receive() (*wire.ShaHash, error) {
|
func (r FutureSendToAddressResult) Receive() (*chainhash.Hash, error) {
|
||||||
res, err := receiveFuture(r)
|
res, err := receiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -464,7 +465,7 @@ func (r FutureSendToAddressResult) Receive() (*wire.ShaHash, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return wire.NewShaHashFromStr(txHash)
|
return chainhash.NewHashFromStr(txHash)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SendToAddressAsync returns an instance of a type that can be used to get the
|
// SendToAddressAsync returns an instance of a type that can be used to get the
|
||||||
|
@ -486,7 +487,7 @@ func (c *Client) SendToAddressAsync(address btcutil.Address, amount btcutil.Amou
|
||||||
//
|
//
|
||||||
// NOTE: This function requires to the wallet to be unlocked. See the
|
// NOTE: This function requires to the wallet to be unlocked. See the
|
||||||
// WalletPassphrase function for more details.
|
// WalletPassphrase function for more details.
|
||||||
func (c *Client) SendToAddress(address btcutil.Address, amount btcutil.Amount) (*wire.ShaHash, error) {
|
func (c *Client) SendToAddress(address btcutil.Address, amount btcutil.Amount) (*chainhash.Hash, error) {
|
||||||
return c.SendToAddressAsync(address, amount).Receive()
|
return c.SendToAddressAsync(address, amount).Receive()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -517,7 +518,7 @@ func (c *Client) SendToAddressCommentAsync(address btcutil.Address,
|
||||||
//
|
//
|
||||||
// NOTE: This function requires to the wallet to be unlocked. See the
|
// NOTE: This function requires to the wallet to be unlocked. See the
|
||||||
// WalletPassphrase function for more details.
|
// WalletPassphrase function for more details.
|
||||||
func (c *Client) SendToAddressComment(address btcutil.Address, amount btcutil.Amount, comment, commentTo string) (*wire.ShaHash, error) {
|
func (c *Client) SendToAddressComment(address btcutil.Address, amount btcutil.Amount, comment, commentTo string) (*chainhash.Hash, error) {
|
||||||
return c.SendToAddressCommentAsync(address, amount, comment,
|
return c.SendToAddressCommentAsync(address, amount, comment,
|
||||||
commentTo).Receive()
|
commentTo).Receive()
|
||||||
}
|
}
|
||||||
|
@ -530,7 +531,7 @@ type FutureSendFromResult chan *response
|
||||||
// Receive waits for the response promised by the future and returns the hash
|
// Receive waits for the response promised by the future and returns the hash
|
||||||
// of the transaction sending amount to the given address using the provided
|
// of the transaction sending amount to the given address using the provided
|
||||||
// account as a source of funds.
|
// account as a source of funds.
|
||||||
func (r FutureSendFromResult) Receive() (*wire.ShaHash, error) {
|
func (r FutureSendFromResult) Receive() (*chainhash.Hash, error) {
|
||||||
res, err := receiveFuture(r)
|
res, err := receiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -543,7 +544,7 @@ func (r FutureSendFromResult) Receive() (*wire.ShaHash, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return wire.NewShaHashFromStr(txHash)
|
return chainhash.NewHashFromStr(txHash)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SendFromAsync returns an instance of a type that can be used to get the
|
// SendFromAsync returns an instance of a type that can be used to get the
|
||||||
|
@ -566,7 +567,7 @@ func (c *Client) SendFromAsync(fromAccount string, toAddress btcutil.Address, am
|
||||||
//
|
//
|
||||||
// NOTE: This function requires to the wallet to be unlocked. See the
|
// NOTE: This function requires to the wallet to be unlocked. See the
|
||||||
// WalletPassphrase function for more details.
|
// WalletPassphrase function for more details.
|
||||||
func (c *Client) SendFrom(fromAccount string, toAddress btcutil.Address, amount btcutil.Amount) (*wire.ShaHash, error) {
|
func (c *Client) SendFrom(fromAccount string, toAddress btcutil.Address, amount btcutil.Amount) (*chainhash.Hash, error) {
|
||||||
return c.SendFromAsync(fromAccount, toAddress, amount).Receive()
|
return c.SendFromAsync(fromAccount, toAddress, amount).Receive()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -591,7 +592,7 @@ func (c *Client) SendFromMinConfAsync(fromAccount string, toAddress btcutil.Addr
|
||||||
//
|
//
|
||||||
// NOTE: This function requires to the wallet to be unlocked. See the
|
// NOTE: This function requires to the wallet to be unlocked. See the
|
||||||
// WalletPassphrase function for more details.
|
// WalletPassphrase function for more details.
|
||||||
func (c *Client) SendFromMinConf(fromAccount string, toAddress btcutil.Address, amount btcutil.Amount, minConfirms int) (*wire.ShaHash, error) {
|
func (c *Client) SendFromMinConf(fromAccount string, toAddress btcutil.Address, amount btcutil.Amount, minConfirms int) (*chainhash.Hash, error) {
|
||||||
return c.SendFromMinConfAsync(fromAccount, toAddress, amount,
|
return c.SendFromMinConfAsync(fromAccount, toAddress, amount,
|
||||||
minConfirms).Receive()
|
minConfirms).Receive()
|
||||||
}
|
}
|
||||||
|
@ -624,7 +625,7 @@ func (c *Client) SendFromCommentAsync(fromAccount string,
|
||||||
// WalletPassphrase function for more details.
|
// WalletPassphrase function for more details.
|
||||||
func (c *Client) SendFromComment(fromAccount string, toAddress btcutil.Address,
|
func (c *Client) SendFromComment(fromAccount string, toAddress btcutil.Address,
|
||||||
amount btcutil.Amount, minConfirms int,
|
amount btcutil.Amount, minConfirms int,
|
||||||
comment, commentTo string) (*wire.ShaHash, error) {
|
comment, commentTo string) (*chainhash.Hash, error) {
|
||||||
|
|
||||||
return c.SendFromCommentAsync(fromAccount, toAddress, amount,
|
return c.SendFromCommentAsync(fromAccount, toAddress, amount,
|
||||||
minConfirms, comment, commentTo).Receive()
|
minConfirms, comment, commentTo).Receive()
|
||||||
|
@ -638,7 +639,7 @@ type FutureSendManyResult chan *response
|
||||||
// Receive waits for the response promised by the future and returns the hash
|
// Receive waits for the response promised by the future and returns the hash
|
||||||
// of the transaction sending multiple amounts to multiple addresses using the
|
// of the transaction sending multiple amounts to multiple addresses using the
|
||||||
// provided account as a source of funds.
|
// provided account as a source of funds.
|
||||||
func (r FutureSendManyResult) Receive() (*wire.ShaHash, error) {
|
func (r FutureSendManyResult) Receive() (*chainhash.Hash, error) {
|
||||||
res, err := receiveFuture(r)
|
res, err := receiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -651,7 +652,7 @@ func (r FutureSendManyResult) Receive() (*wire.ShaHash, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return wire.NewShaHashFromStr(txHash)
|
return chainhash.NewHashFromStr(txHash)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SendManyAsync returns an instance of a type that can be used to get the
|
// SendManyAsync returns an instance of a type that can be used to get the
|
||||||
|
@ -676,7 +677,7 @@ func (c *Client) SendManyAsync(fromAccount string, amounts map[btcutil.Address]b
|
||||||
//
|
//
|
||||||
// NOTE: This function requires to the wallet to be unlocked. See the
|
// NOTE: This function requires to the wallet to be unlocked. See the
|
||||||
// WalletPassphrase function for more details.
|
// WalletPassphrase function for more details.
|
||||||
func (c *Client) SendMany(fromAccount string, amounts map[btcutil.Address]btcutil.Amount) (*wire.ShaHash, error) {
|
func (c *Client) SendMany(fromAccount string, amounts map[btcutil.Address]btcutil.Amount) (*chainhash.Hash, error) {
|
||||||
return c.SendManyAsync(fromAccount, amounts).Receive()
|
return c.SendManyAsync(fromAccount, amounts).Receive()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -709,7 +710,7 @@ func (c *Client) SendManyMinConfAsync(fromAccount string,
|
||||||
// WalletPassphrase function for more details.
|
// WalletPassphrase function for more details.
|
||||||
func (c *Client) SendManyMinConf(fromAccount string,
|
func (c *Client) SendManyMinConf(fromAccount string,
|
||||||
amounts map[btcutil.Address]btcutil.Amount,
|
amounts map[btcutil.Address]btcutil.Amount,
|
||||||
minConfirms int) (*wire.ShaHash, error) {
|
minConfirms int) (*chainhash.Hash, error) {
|
||||||
|
|
||||||
return c.SendManyMinConfAsync(fromAccount, amounts, minConfirms).Receive()
|
return c.SendManyMinConfAsync(fromAccount, amounts, minConfirms).Receive()
|
||||||
}
|
}
|
||||||
|
@ -744,7 +745,7 @@ func (c *Client) SendManyCommentAsync(fromAccount string,
|
||||||
// WalletPassphrase function for more details.
|
// WalletPassphrase function for more details.
|
||||||
func (c *Client) SendManyComment(fromAccount string,
|
func (c *Client) SendManyComment(fromAccount string,
|
||||||
amounts map[btcutil.Address]btcutil.Amount, minConfirms int,
|
amounts map[btcutil.Address]btcutil.Amount, minConfirms int,
|
||||||
comment string) (*wire.ShaHash, error) {
|
comment string) (*chainhash.Hash, error) {
|
||||||
|
|
||||||
return c.SendManyCommentAsync(fromAccount, amounts, minConfirms,
|
return c.SendManyCommentAsync(fromAccount, amounts, minConfirms,
|
||||||
comment).Receive()
|
comment).Receive()
|
||||||
|
|
Loading…
Reference in a new issue