本文整理汇总了Golang中github.com/btcsuite/btcwallet/wtxmgr.Store.UnspentOutputs方法的典型用法代码示例。如果您正苦于以下问题:Golang Store.UnspentOutputs方法的具体用法?Golang Store.UnspentOutputs怎么用?Golang Store.UnspentOutputs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/btcsuite/btcwallet/wtxmgr.Store
的用法示例。
在下文中一共展示了Store.UnspentOutputs方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: getEligibleInputs
// getEligibleInputs returns eligible inputs with addresses between startAddress
// and the last used address of lastSeriesID. They're reverse ordered based on
// their address.
func (p *Pool) getEligibleInputs(store *wtxmgr.Store, startAddress WithdrawalAddress,
lastSeriesID uint32, dustThreshold btcutil.Amount, chainHeight int32,
minConf int) ([]credit, error) {
if p.Series(lastSeriesID) == nil {
str := fmt.Sprintf("lastSeriesID (%d) does not exist", lastSeriesID)
return nil, newError(ErrSeriesNotExists, str, nil)
}
unspents, err := store.UnspentOutputs()
if err != nil {
return nil, newError(ErrInputSelection, "failed to get unspent outputs", err)
}
addrMap, err := groupCreditsByAddr(unspents, p.manager.ChainParams())
if err != nil {
return nil, err
}
var inputs []credit
address := startAddress
for {
log.Debugf("Looking for eligible inputs at address %v", address.addrIdentifier())
if candidates, ok := addrMap[address.addr.EncodeAddress()]; ok {
var eligibles []credit
for _, c := range candidates {
candidate := newCredit(c, address)
if p.isCreditEligible(candidate, minConf, chainHeight, dustThreshold) {
eligibles = append(eligibles, candidate)
}
}
inputs = append(inputs, eligibles...)
}
nAddr, err := nextAddr(p, address.seriesID, address.branch, address.index, lastSeriesID+1)
if err != nil {
return nil, newError(ErrInputSelection, "failed to get next withdrawal address", err)
} else if nAddr == nil {
log.Debugf("getEligibleInputs: reached last addr, stopping")
break
}
address = *nAddr
}
sort.Sort(sort.Reverse(byAddress(inputs)))
return inputs, nil
}