本文整理汇总了Golang中github.com/skycoin/skycoin/src/daemon.Gateway.GetUnspentOutputs方法的典型用法代码示例。如果您正苦于以下问题:Golang Gateway.GetUnspentOutputs方法的具体用法?Golang Gateway.GetUnspentOutputs怎么用?Golang Gateway.GetUnspentOutputs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/skycoin/skycoin/src/daemon.Gateway
的用法示例。
在下文中一共展示了Gateway.GetUnspentOutputs方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: getOutputsHandler
// getOutputsHandler get utxos base on the filters in url params.
// mode: GET
// url: /outputs?addrs=[:addrs]&hashes=[:hashes]
// if addrs and hashes are not specificed, return all unspent outputs.
// if both addrs and hashes are specificed, then both those filters are need to be matched.
// if only specify one filter, then return outputs match the filter.
func getOutputsHandler(gateway *daemon.Gateway) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
if r.Method == "GET" {
var addrs []string
var hashes []string
trimSpace := func(vs []string) []string {
for i := range vs {
vs[i] = strings.TrimSpace(vs[i])
}
return vs
}
addrStr := r.FormValue("addrs")
if addrStr != "" {
addrs = trimSpace(strings.Split(addrStr, ","))
}
hashStr := r.FormValue("hashes")
if hashStr != "" {
hashes = trimSpace(strings.Split(hashStr, ","))
}
filters := []daemon.OutputsFilter{}
if len(addrs) > 0 {
filters = append(filters, daemon.FbyAddresses(addrs))
}
if len(hashes) > 0 {
filters = append(filters, daemon.FbyHashes(hashes))
}
outs := gateway.GetUnspentOutputs(filters...)
wh.SendOr404(w, outs)
}
}
}