本文整理汇总了Golang中github.com/btcsuite/btcd/chaincfg/chainhash.Hash.String方法的典型用法代码示例。如果您正苦于以下问题:Golang Hash.String方法的具体用法?Golang Hash.String怎么用?Golang Hash.String使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/btcsuite/btcd/chaincfg/chainhash.Hash
的用法示例。
在下文中一共展示了Hash.String方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: lookupTxid
// Uses the txid of the target funding transaction and asks blockchain.info's
// api for information (in json) related to that transaction.
func lookupTxid(hash *chainhash.Hash) (*blockChainInfoTx, error) {
url := "https://blockchain.info/rawtx/" + hash.String()
resp, err := http.Get(url)
if err != nil {
return nil, fmt.Errorf("Tx Lookup failed: %v", err)
}
defer resp.Body.Close()
b, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("TxInfo read failed: %s", err)
}
txinfo := &blockChainInfoTx{}
err = json.Unmarshal(b, txinfo)
if err != nil {
return nil, err
}
if txinfo.Ver != 1 {
return nil, fmt.Errorf("Blockchain.info's response seems bad: %v", txinfo)
}
return txinfo, nil
}
示例2: GetBlockAsync
// GetBlockAsync 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 GetBlock for the blocking version and more details.
func (c *Client) GetBlockAsync(blockHash *chainhash.Hash) FutureGetBlockResult {
hash := ""
if blockHash != nil {
hash = blockHash.String()
}
cmd := btcjson.NewGetBlockCmd(hash, btcjson.Bool(false), nil)
return c.sendCmd(cmd)
}
示例3: GetTxOutAsync
// GetTxOutAsync 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 GetTxOut for the blocking version and more details.
func (c *Client) GetTxOutAsync(txHash *chainhash.Hash, index uint32, mempool bool) FutureGetTxOutResult {
hash := ""
if txHash != nil {
hash = txHash.String()
}
cmd := btcjson.NewGetTxOutCmd(hash, index, &mempool)
return c.sendCmd(cmd)
}
示例4: GetBlockHeaderVerboseAsync
// GetBlockHeaderVerboseAsync 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 GetBlockHeader for the blocking version and more details.
func (c *Client) GetBlockHeaderVerboseAsync(blockHash *chainhash.Hash) FutureGetBlockHeaderVerboseResult {
hash := ""
if blockHash != nil {
hash = blockHash.String()
}
cmd := btcjson.NewGetBlockHeaderCmd(hash, btcjson.Bool(true))
return c.sendCmd(cmd)
}
示例5: GetRawTransactionAsync
// GetRawTransactionAsync 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 GetRawTransaction for the blocking version and more details.
func (c *Client) GetRawTransactionAsync(txHash *chainhash.Hash) FutureGetRawTransactionResult {
hash := ""
if txHash != nil {
hash = txHash.String()
}
cmd := btcjson.NewGetRawTransactionCmd(hash, btcjson.Int(0))
return c.sendCmd(cmd)
}
示例6: RescanEndBlockAsync
// RescanEndBlockAsync 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 RescanEndBlock for the blocking version and more details.
//
// NOTE: This is a btcd extension and requires a websocket connection.
func (c *Client) RescanEndBlockAsync(startBlock *chainhash.Hash,
addresses []btcutil.Address, outpoints []*wire.OutPoint,
endBlock *chainhash.Hash) FutureRescanResult {
// Not supported in HTTP POST mode.
if c.config.HTTPPostMode {
return newFutureError(ErrWebsocketsRequired)
}
// Ignore the notification if the client is not interested in
// notifications.
if c.ntfnHandlers == nil {
return newNilFutureResult()
}
// Convert block hashes to strings.
var startBlockHashStr, endBlockHashStr string
if startBlock != nil {
startBlockHashStr = startBlock.String()
}
if endBlock != nil {
endBlockHashStr = endBlock.String()
}
// Convert addresses to strings.
addrs := make([]string, 0, len(addresses))
for _, addr := range addresses {
addrs = append(addrs, addr.String())
}
// Convert outpoints.
ops := make([]btcjson.OutPoint, 0, len(outpoints))
for _, op := range outpoints {
ops = append(ops, newOutPointFromWire(op))
}
cmd := btcjson.NewRescanCmd(startBlockHashStr, addrs, ops,
&endBlockHashStr)
return c.sendCmd(cmd)
}