// GetAddressCommandCtx retrieves the ctxAddrCmd data from the request context.
// If not set the return value is "" and false.
349301
func GetAddressCommandCtx(r *http.Request) (string, bool) {
	command, ok := r.Context().Value(ctxAddrCmd).(string)
	if !ok {
		return "", false
	}
	return command, true
}
748691
func WriteAddCmd(w io.Writer, key []byte, flags, exptime, dataSize, opaque uint32) error {
	//fmt.Printf("Add: key: %v | flags: %v | exptime: %v | dataSize: %v | totalBodyLength: %v\n",
	//string(key), flags, exptime, dataSize, totalBodyLength)
	return writeDataCmdCommon(w, OpcodeAdd, key, flags, exptime, dataSize, opaque)
}
19543
func getStatesCmd(params *Parameters) *subcommands.Command {
	return &subcommands.Command{
		UsageLine: "get-states [-prefix <prefix>]",
		ShortDesc: "retrieves states",
		LongDesc:  "Retrieves the state matching the given prefix, or all states if prefix is omitted.\n\nExample:\ncrimson get-states",
		CommandRun: func() subcommands.CommandRun {
			cmd := &GetStatesCmd{}
			cmd.Initialize(params)
			cmd.Flags.StringVar(&cmd.prefix, "prefix", "", "Prefix to get the matching state for.")
			return cmd
		},
	}
}
982761
func (brs *BranchRecoveryState) GetAddr(index uint32) btcutil.Address {
	return brs.addresses[index]
}
530987
func (b *BigIP) GetVirtualAddress(vaddr string) (*VirtualAddress, error) {
	var virtualAddress VirtualAddress
	err, _ := b.getForEntity(&virtualAddress, uriLtm, uriVirtualAddress, vaddr)
	if err != nil {
		return nil, err
	}
	return &virtualAddress, nil
}
900457
func RetrieveAddressUTXOs(ctx context.Context, db *sql.DB, address string, currentBlockHeight int64) ([]apitypes.AddressTxnOutput, error) {
	stmt, err := db.Prepare(internal.SelectAddressUnspentWithTxn)
	if err != nil {
		log.Error(err)
		return nil, err
	}
	rows, err := stmt.QueryContext(ctx, address)
	_ = stmt.Close()
	if err != nil {
		log.Error(err)
		return nil, err
	}
	defer closeRows(rows)

	var outputs []apitypes.AddressTxnOutput
	for rows.Next() {
		pkScript := []byte{}
		var blockHeight, atoms int64
		var blockTime dbtypes.TimeDef
		txnOutput := apitypes.AddressTxnOutput{}
		if err = rows.Scan(&txnOutput.Address, &txnOutput.TxnID,
			&atoms, &blockHeight, &blockTime, &txnOutput.Vout, &pkScript); err != nil {
			log.Error(err)
		}
		txnOutput.BlockTime = blockTime.UNIX()
		txnOutput.ScriptPubKey = hex.EncodeToString(pkScript)
		txnOutput.Amount = dcrutil.Amount(atoms).ToCoin()
		txnOutput.Satoshis = atoms
		txnOutput.Height = blockHeight
		txnOutput.Confirmations = currentBlockHeight - blockHeight + 1
		outputs = append(outputs, txnOutput)
	}

	return outputs, nil
}
987274
func GetByAddress(c context.Context, client *Service, address string) (*ApiCommonBuildMessage, error) {
	id, _, _, _, _, err := ParseBuildAddress(address)
	if err != nil {
		return nil, err
	}

	if id != 0 {
		res, err := client.Get(id).Context(c).Do()
		switch {
		case err != nil:
			return nil, err
		case res.Error != nil && res.Error.Reason == ReasonNotFound:
			return nil, nil
		default:
			return res.Build, nil
		}
	}

	msgs, _, err := client.Search().
		Context(c).
		Tag(strpair.Format(TagBuildAddress, address)).
		IncludeExperimental(true).
		Fetch(1, nil)
	switch {
	case err != nil:
		return nil, err
	case len(msgs) == 0:
		return nil, nil
	default:
		return msgs[0], nil
	}
}
716826
func (api *Client) GetDNDInfoContext(ctx context.Context, user *string) (*DNDStatus, error) {
	values := url.Values{
		"token": {api.token},
	}
	if user != nil {
		values.Set("user", *user)
	}

	response, err := api.dndRequest(ctx, "dnd.info", values)
	if err != nil {
		return nil, err
	}
	return &response.DNDStatus, nil
}
863309
func GetTxIDCtx(r *http.Request) (*chainhash.Hash, error) {
	hashStr, ok := r.Context().Value(ctxTxHash).(string)
	if !ok {
		apiLog.Trace("txid not set")
		return nil, fmt.Errorf("txid not set")
	}
	hash, err := chainhash.NewHashFromStr(hashStr)
	if err != nil {
		apiLog.Trace("invalid hash '%s': %v", hashStr, err)
		return nil, fmt.Errorf("invalid hash '%s': %v",
			hashStr, err)
	}
	return hash, nil
}
1023689
func (db *TXDatabaseOverlay) GetTXAddress(adr string) (
	[]interfaces.ITransaction, error) {
	filtered := make([]interfaces.ITransaction, 0)

	txs, err := db.GetAllTXs()
	if err != nil {
		return nil, err
	}

	if factom.AddressStringType(adr) == factom.FactoidPub {
		for _, tx := range txs {
			for _, in := range tx.GetInputs() {
				if primitives.ConvertFctAddressToUserStr(in.GetAddress()) == adr {
					filtered = append(filtered, tx)
				}
			}
			for _, out := range tx.GetOutputs() {
				if primitives.ConvertFctAddressToUserStr(out.GetAddress()) == adr {
					filtered = append(filtered, tx)
				}
			}
		}
	} else if factom.AddressStringType(adr) == factom.ECPub {
		for _, tx := range txs {
			for _, out := range tx.GetECOutputs() {
				if primitives.ConvertECAddressToUserStr(out.GetAddress()) == adr {
					filtered = append(filtered, tx)
				}
			}
		}
	} else {
		return nil, fmt.Errorf("not a valid address")
	}

	return filtered, nil
}
752195
func (c *Cluster) GetDataPathAddress() string {
	c.mu.RLock()
	defer c.mu.RUnlock()
	if c.nr != nil {
		return c.nr.config.DataPathAddr
	}
	return ""
}
312087
func getDRACsCmd(params *Parameters) *subcommands.Command {
	return &subcommands.Command{
		UsageLine: "get-dracs [-name <name>]... [-machine <machine>]... [-mac <mac address>]... [-switch <switch>]... [-ip <ip address>]... [-vlan <id>]...",
		ShortDesc: "retrieves DRACs",
		LongDesc:  "Retrieves DRACs matching the given names and machines, or all DRACs if names and machines are omitted.\n\nExample to get all DRACs:\ncrimson get-dracs\nExample to get all DRACs in VLAN 1:\ncrimson get-dracs -vlan 1",
		CommandRun: func() subcommands.CommandRun {
			cmd := &GetDRACsCmd{}
			cmd.Initialize(params)
			cmd.Flags.Var(flag.StringSlice(&cmd.req.Names), "name", "Name of a DRAC to filter by. Can be specified multiple times.")
			cmd.Flags.Var(flag.StringSlice(&cmd.req.Machines), "machine", "Name of a machine to filter by. Can be specified multiple times.")
			cmd.Flags.Var(flag.StringSlice(&cmd.req.MacAddresses), "mac", "MAC address to filter by. Can be specified multiple times.")
			cmd.Flags.Var(flag.StringSlice(&cmd.req.Switches), "switch", "Name of a switch to filter by. Can be specified multiple times.")
			cmd.Flags.Var(flag.StringSlice(&cmd.req.Ipv4S), "ip", "IPv4 address to filter by. Can be specified multiple times.")
			cmd.Flags.Var(flag.Int64Slice(&cmd.req.Vlans), "vlan", "ID of a VLAN to filter by. Can be specified multiple times.")
			return cmd
		},
	}
}
149497
func getRawChangeAddress(icmd interface{}, w *wallet.Wallet) (interface{}, error) {
	cmd := icmd.(*btcjson.GetRawChangeAddressCmd)

	acctName := "default"
	if cmd.Account != nil {
		acctName = *cmd.Account
	}
	account, err := w.AccountNumber(waddrmgr.KeyScopeBIP0044, acctName)
	if err != nil {
		return nil, err
	}
	addr, err := w.NewChangeAddress(account, waddrmgr.KeyScopeBIP0044)
	if err != nil {
		return nil, err
	}

	// Return the new payment address string.
	return addr.EncodeAddress(), nil
}
1312397
func GetC(str, ctx string, vars ...interface{}) string {
	return GetDC(GetDomain(), str, ctx, vars...)
}
867561
func BlockReceivesToAddresses(block *dcrutil.Block, addrs map[string]TxAction,
	params *chaincfg.Params) map[string][]*dcrutil.Tx {
	addrMap := make(map[string][]*dcrutil.Tx)

	checkForAddrOut := func(blockTxs []*dcrutil.Tx) {
		for _, tx := range blockTxs {
			// Check the addresses associated with the PkScript of each TxOut
			for _, txOut := range tx.MsgTx().TxOut {
				_, txOutAddrs, _, err := txscript.ExtractPkScriptAddrs(txOut.Version,
					txOut.PkScript, params)
				if err != nil {
					fmt.Printf("ExtractPkScriptAddrs: %v", err.Error())
					continue
				}

				// Check if we are watching any address for this TxOut
				for _, txAddr := range txOutAddrs {
					addrstr := txAddr.EncodeAddress()
					if _, ok := addrs[addrstr]; ok {
						if _, gotSlice := addrMap[addrstr]; !gotSlice {
							addrMap[addrstr] = make([]*dcrutil.Tx, 0) // nil
						}
						addrMap[addrstr] = append(addrMap[addrstr], tx)
					}
				}
			}
		}
	}

	checkForAddrOut(block.Transactions())
	checkForAddrOut(block.STransactions())

	return addrMap
}
536727
func (ctxt *CredentialHelperContext) GetCredentialHelper(helper CredentialHelper, u *url.URL) (CredentialHelper, Creds) {
	rawurl := fmt.Sprintf("%s://%s%s", u.Scheme, u.Host, u.Path)
	input := Creds{"protocol": u.Scheme, "host": u.Host}
	if u.User != nil && u.User.Username() != "" {
		input["username"] = u.User.Username()
	}
	if u.Scheme == "cert" || ctxt.urlConfig.Bool("credential", rawurl, "usehttppath", false) {
		input["path"] = strings.TrimPrefix(u.Path, "/")
	}

	if helper != nil {
		return helper, input
	}

	helpers := make([]CredentialHelper, 0, 4)
	if ctxt.netrcCredHelper != nil {
		helpers = append(helpers, ctxt.netrcCredHelper)
	}
	if ctxt.cachingCredHelper != nil {
		helpers = append(helpers, ctxt.cachingCredHelper)
	}
	if ctxt.askpassCredHelper != nil {
		helper, _ := ctxt.urlConfig.Get("credential", rawurl, "helper")
		if len(helper) == 0 {
			helpers = append(helpers, ctxt.askpassCredHelper)
		}
	}

	return NewCredentialHelpers(append(helpers, ctxt.commandCredHelper)), input
}
926918
func (i ImportBinding) GetVirtualAddress(instanceID int) (string, error) {
	t := template.Must(template.New(i.Application).Funcs(funcs).Parse(i.VirtualAddress))

	var buffer bytes.Buffer
	if err := t.Execute(&buffer, struct{ InstanceID int }{instanceID}); err != nil {
		return "", &TemplateError{
			Application: i.Application,
			Field:       i.VirtualAddress,
			Message:     "could not interpret value",
		}
	}

	return buffer.String(), nil
}