// UnspentOutputs fetches all unspent outputs from the wallet that match rules
// described in the passed policy.
970870
func (w *Wallet) UnspentOutputs(policy OutputSelectionPolicy) ([]*TransactionOutput, error) {
	var outputResults []*TransactionOutput
	err := walletdb.View(w.db, func(tx walletdb.ReadTx) error {
		addrmgrNs := tx.ReadBucket(waddrmgrNamespaceKey)
		txmgrNs := tx.ReadBucket(wtxmgrNamespaceKey)

		syncBlock := w.Manager.SyncedTo()

		// TODO: actually stream outputs from the db instead of fetching
		// all of them at once.
		outputs, err := w.TxStore.UnspentOutputs(txmgrNs)
		if err != nil {
			return err
		}

		for _, output := range outputs {
			// Ignore outputs that haven't reached the required
			// number of confirmations.
			if !policy.meetsRequiredConfs(output.Height, syncBlock.Height) {
				continue
			}

			// Ignore outputs that are not controlled by the account.
			_, addrs, _, err := txscript.ExtractPkScriptAddrs(output.PkScript,
				w.chainParams)
			if err != nil || len(addrs) == 0 {
				// Cannot determine which account this belongs
				// to without a valid address.  TODO: Fix this
				// by saving outputs per account, or accounts
				// per output.
				continue
			}
			_, outputAcct, err := w.Manager.AddrAccount(addrmgrNs, addrs[0])
			if err != nil {
				return err
			}
			if outputAcct != policy.Account {
				continue
			}

			// Stakebase isn't exposed by wtxmgr so those will be
			// OutputKindNormal for now.
			outputSource := OutputKindNormal
			if output.FromCoinBase {
				outputSource = OutputKindCoinbase
			}

			result := &TransactionOutput{
				OutPoint: output.OutPoint,
				Output: wire.TxOut{
					Value:    int64(output.Amount),
					PkScript: output.PkScript,
				},
				OutputKind:      outputSource,
				ContainingBlock: BlockIdentity(output.Block),
				ReceiveTime:     output.Received,
			}
			outputResults = append(outputResults, result)
		}

		return nil
	})
	return outputResults, err
}
181095
func (mf *MultiFlag) GetOutput() io.Writer {
	if w := mf.Output; w != nil {
		return w
	}
	return os.Stderr
}
1116077
func (s *CreateApplicationInput) SetOutputs(v []*Output) *CreateApplicationInput {
	s.Outputs = v
	return s
}
1140538
func ipRunOutput(cmd string, args ...interface{}) (string, error) {
	cmdStr := fmt.Sprintf(cmd, args...)
	ipArgs := strings.Split(cmdStr, " ")
	log.Infof("%s %s", ipCmd, cmdStr)
	ip := exec.Command(ipCmd, ipArgs...)
	out, err := ip.Output()
	if err != nil {
		return "", fmt.Errorf("IP run %q: %v", cmdStr, err)
	}
	return string(out), nil
}
99494
func (s *StepExecution) SetOutputs(v map[string][]*string) *StepExecution {
	s.Outputs = v
	return s
}
656473
func (b *BtcWallet) fetchOutputAddr(script []byte) (waddrmgr.ManagedAddress, error) {
	_, addrs, _, err := txscript.ExtractPkScriptAddrs(script, b.netParams)
	if err != nil {
		return nil, err
	}

	// If the case of a multi-sig output, several address may be extracted.
	// Therefore, we simply select the key for the first address we know
	// of.
	for _, addr := range addrs {
		addr, err := b.wallet.AddressInfo(addr)
		if err == nil {
			return addr, nil
		}
	}

	return nil, lnwallet.ErrNotMine
}
1175717
func (a *Agent) closeOutputs() {
	for _, output := range a.Config.Outputs {
		output.Close()
	}
}
1259991
func ParsePSOutput(output []byte) (*TopResults, error) {
	topResults := &TopResults{}

	lines := strings.Split(string(output), "\n")
	topResults.Headers = fieldsASCII(lines[0])

	pidIndex := -1
	for i, name := range topResults.Headers {
		if name == "PID" {
			pidIndex = i
		}
	}

	for _, line := range lines[1:] {
		if len(line) == 0 {
			continue
		}

		fields := fieldsASCII(line)

		if fields[pidIndex] == "-" {
			continue
		}

		process := fields[:len(topResults.Headers)-1]
		process = append(process, strings.Join(fields[len(topResults.Headers)-1:], " "))
		topResults.Processes = append(topResults.Processes, process)

	}
	return topResults, nil
}
834122
func asOutput(u *Ugen) *Ugen {
	if u.Outputs == nil {
		u.Outputs = make([]Output, u.NumOutputs)
		for i := range u.Outputs {
			u.Outputs[i] = Output(u.Rate)
		}
	}
	return u
}
798372
func (s *EncoderSettings) SetOutputGroups(v []*OutputGroup) *EncoderSettings {
	s.OutputGroups = v
	return s
}
521944
func (c *appContext) getTransactionOutput(w http.ResponseWriter, r *http.Request) {
	txid, err := m.GetTxIDCtx(r)
	if err != nil {
		http.Error(w, http.StatusText(422), 422)
		return
	}

	index := m.GetTxIOIndexCtx(r)
	if index < 0 {
		http.NotFound(w, r)
		return
	}

	allTxOut := c.BlockData.GetAllTxOut(txid)
	// allTxOut may be empty, but not a nil slice
	if allTxOut == nil {
		apiLog.Errorf("Unable to get all TxOut for transaction %s", txid)
		http.Error(w, http.StatusText(422), 422)
		return
	}

	if len(allTxOut) <= index {
		apiLog.Debugf("Index %d larger than []TxOut length %d", index, len(allTxOut))
		http.NotFound(w, r)
		return
	}

	writeJSON(w, *allTxOut[index], c.getIndentQuery(r))
}
697018
func (cs *ChangesSync) RemoveOutputChange(addr addrs.AbsOutputValue) {
	if cs == nil {
		panic("RemoveOutputChange on nil ChangesSync")
	}
	cs.lock.Lock()
	defer cs.lock.Unlock()

	addrStr := addr.String()
	for i, o := range cs.changes.Outputs {
		if o.Addr.String() != addrStr {
			continue
		}
		copy(cs.changes.Outputs[i:], cs.changes.Outputs[i+1:])
		cs.changes.Outputs = cs.changes.Outputs[:len(cs.changes.Outputs)-1]
		return
	}
}
160647
func ExecOutput(cmdline string) string {
	cmd := startCommand(cmdline)

	var out bytes.Buffer
	cmd.Stdout = &out
	err := cmd.Run()
	if err == nil {
		return out.String()
	}
	return fmt.Sprintf("Error: %s", err.Error())
}
226199
func (s *CreateJobInput) SetOutputs(v []*CreateJobOutput) *CreateJobInput {
	s.Outputs = v
	return s
}
1334003
func (a *Agent) connectOutputs(ctx context.Context) error {
	for _, output := range a.Config.Outputs {
		log.Printf("D! [agent] Attempting connection to output: %s\n", output.Name)
		err := output.Output.Connect()
		if err != nil {
			log.Printf("E! [agent] Failed to connect to output %s, retrying in 15s, "+
				"error was '%s' \n", output.Name, err)

			err := internal.SleepContext(ctx, 15*time.Second)
			if err != nil {
				return err
			}

			err = output.Output.Connect()
			if err != nil {
				return err
			}
		}
		log.Printf("D! [agent] Successfully connected to output: %s\n", output.Name)
	}
	return nil
}
1350925
func (s *Job) SetOutputs(v []*JobOutput) *Job {
	s.Outputs = v
	return s
}
76729
func (s *SqlApplicationConfigurationDescription) SetOutputDescriptions(v []*OutputDescription) *SqlApplicationConfigurationDescription {
	s.OutputDescriptions = v
	return s
}