func (c *SiadClient) LookupHost(prefix string) (hostdb.HostPublicKey, error) {
	if !strings.HasPrefix(prefix, "ed25519:") {
		prefix = "ed25519:" + prefix
	}
	hdag, err := c.siad.HostDbAllGet()
	if err != nil {
		return "", err
	}
	var hpk hostdb.HostPublicKey
	for i := range hdag.Hosts {
		key := hostdb.HostPublicKey(hdag.Hosts[i].PublicKeyString)
		if strings.HasPrefix(string(key), prefix) {
			if hpk != "" {
				return "", errors.New("ambiguous pubkey")
			}
			hpk = key
		}
	}
	if hpk == "" {
		return "", errors.New("no host with that pubkey")
	}
	return hpk, nil
}
HostDB
LookupHost returns the host public key matching the specified prefix.
package renterutil
import (
	"errors"
	"math"
	"reflect"
	"sort"
	"strings"
	"go.sia.tech/siad/crypto"
	"go.sia.tech/siad/modules"
	"go.sia.tech/siad/node/api/client"
	"go.sia.tech/siad/types"
	"lukechampine.com/frand"
	"lukechampine.com/us/hostdb"
	"lukechampine.com/us/renter"
	"lukechampine.com/us/renter/proto"
	"lukechampine.com/us/wallet"
)
var ErrNoHostAnnouncement = errors.New("host announcement not found")
type SiadClient struct {
	siad *client.Client
}
func (c *SiadClient) ChainHeight() (types.BlockHeight, error) {
	cg, err := c.siad.ConsensusGet()
	return cg.Height, err
}
func (c *SiadClient) Synced() (bool, error) {
	cg, err := c.siad.ConsensusGet()
	return cg.Synced, err
}
func (c *SiadClient) AcceptTransactionSet(txnSet []types.Transaction) error {
	if len(txnSet) == 0 {
		return errors.New("empty transaction set")
	}
	txn, parents := txnSet[len(txnSet)-1], txnSet[:len(txnSet)-1]
	return c.siad.TransactionPoolRawPost(txn, parents)
}
func (c *SiadClient) FeeEstimate() (minFee, maxFee types.Currency, err error) {
	tfg, err := c.siad.TransactionPoolFeeGet()
	return tfg.Minimum, tfg.Maximum, err
}
func (c *SiadClient) Address() (types.UnlockHash, error) {
	wag, err := c.siad.WalletAddressGet()
	return wag.Address, err
}
func (c *SiadClient) FundTransaction(txn *types.Transaction, amount types.Currency) ([]crypto.Hash, func(), error) {
	if amount.IsZero() {
		return nil, func() {}, nil
	}
	wug, err := c.siad.WalletUnspentGet()
	if err != nil {
		return nil, nil, err
	}
	outputs := wug.Outputs[:0]
	for _, o := range wug.Outputs {
		if o.FundType == types.SpecifierSiacoinOutput {
			outputs = append(outputs, o)
		}
	}
	var balance, confirmedBalance types.Currency
	for _, o := range wug.Outputs {
		balance = balance.Add(o.Value)
		if o.ConfirmationHeight != math.MaxUint64 {
			confirmedBalance = confirmedBalance.Add(o.Value)
		}
	}
	if balance.Cmp(amount) < 0 {
		return nil, nil, wallet.ErrInsufficientFunds
	} else if confirmedBalance.Cmp(amount) >= 0 {
		outputs = outputs[:0]
		for _, o := range wug.Outputs {
			if o.FundType == types.SpecifierSiacoinOutput && o.ConfirmationHeight != math.MaxUint64 {
				outputs = append(outputs, o)
			}
		}
	}
	frand.Shuffle(len(outputs), reflect.Swapper(outputs))
	var fundingOutputs []modules.UnspentOutput
	var outputSum types.Currency
	for i, o := range outputs {
		if o.FundType != types.SpecifierSiacoinOutput {
			continue
		}
		if outputSum = outputSum.Add(o.Value); outputSum.Cmp(amount) >= 0 {
			fundingOutputs = outputs[:i+1]
			break
		}
	}
	sort.Slice(fundingOutputs, func(i, j int) bool {
		return fundingOutputs[i].Value.Cmp(fundingOutputs[j].Value) < 0
	})
	for outputSum.Sub(fundingOutputs[0].Value).Cmp(amount) >= 0 {
		outputSum = outputSum.Sub(fundingOutputs[0].Value)
		fundingOutputs = fundingOutputs[1:]
	}
	var toSign []crypto.Hash
	for _, o := range fundingOutputs {
		wucg, err := c.siad.WalletUnlockConditionsGet(o.UnlockHash)
		if err != nil {
			return nil, nil, err
		}
		txn.SiacoinInputs = append(txn.SiacoinInputs, types.SiacoinInput{
			ParentID:         types.SiacoinOutputID(o.ID),
			UnlockConditions: wucg.UnlockConditions,
		})
		txn.TransactionSignatures = append(txn.TransactionSignatures, wallet.StandardTransactionSignature(crypto.Hash(o.ID)))
		toSign = append(toSign, crypto.Hash(o.ID))
	}
	if change := outputSum.Sub(amount); !change.IsZero() {
		changeAddr, err := c.Address()
		if err != nil {
			return nil, nil, err
		}
		txn.SiacoinOutputs = append(txn.SiacoinOutputs, types.SiacoinOutput{
			UnlockHash: changeAddr,
			Value:      change,
		})
	}
	return toSign, func() {}, nil  
}
func (c *SiadClient) SignTransaction(txn *types.Transaction, toSign []crypto.Hash) error {
	wspr, err := c.siad.WalletSignPost(*txn, toSign)
	if err == nil {
		*txn = wspr.Transaction
	}
	return err
}
func (c *SiadClient) UnconfirmedParents(txn types.Transaction) ([]types.Transaction, error) {
	tptg, err := c.siad.TransactionPoolTransactionsGet()
	if err != nil {
		return nil, err
	}
	outputToParent := make(map[types.OutputID]*types.Transaction)
	for i, txn := range tptg.Transactions {
		for j := range txn.SiacoinOutputs {
			scoid := txn.SiacoinOutputID(uint64(j))
			outputToParent[types.OutputID(scoid)] = &tptg.Transactions[i]
		}
	}
	var parents []types.Transaction
	seen := make(map[types.TransactionID]struct{})
	addParent := func(parent *types.Transaction) {
		txid := parent.ID()
		if _, ok := seen[txid]; !ok {
			seen[txid] = struct{}{}
			parents = append(parents, *parent)
		}
	}
	for _, sci := range txn.SiacoinInputs {
		if parent, ok := outputToParent[types.OutputID(sci.ParentID)]; ok {
			addParent(parent)
		}
	}
	return parents, nil
}