Gets information on a related user.
Includes short-circut code to skip the user look up
if the walletAddress is the only field required.
@param {string} walletAddress
@param {object} info
424548
function relatedUserResolver(walletAddress, info){
  const requestedFields = info.fieldNodes[0].selectionSet.selections
  const isIdOnly = requestedFields.filter(x => x.name.value !== 'walletAddress')
    .length === 0
  if (isIdOnly) {
    return { walletAddress: walletAddress }
  } else {
    return search.User.get(walletAddress)
  }
}
790299
function getUserInfo(auth) {
    return new Promise((resolve, reject) => {
        const oauth2 = google.oauth2({
            auth,
            version: 'v2',
        });

        oauth2.userinfo.v2.me.get((err, res) => {
            if (err) {
                reject(err);
            } else {
                resolve(res.data);
            }
            return;
        });
    });
}
997862
function readFundedAndSigningAddresses(
		asset, wallet, estimated_amount, spend_unconfirmed, fee_paying_wallet,
		arrSigningAddresses, arrSigningDeviceAddresses, handleFundedAndSigningAddresses)
{
	readFundedAddresses(asset, wallet, estimated_amount, spend_unconfirmed, function(arrFundedAddresses){
		if (arrFundedAddresses.length === 0)
			return handleFundedAndSigningAddresses([], [], []);
		var arrBaseFundedAddresses = [];
		var addSigningAddressesAndReturn = function(){
			var arrPayingAddresses = _.union(arrFundedAddresses, arrBaseFundedAddresses);
			readAdditionalSigningAddresses(arrPayingAddresses, arrSigningAddresses, arrSigningDeviceAddresses, function(arrAdditionalAddresses){
				handleFundedAndSigningAddresses(arrFundedAddresses, arrBaseFundedAddresses, arrSigningAddresses.concat(arrAdditionalAddresses));
			});
		};
		if (!asset)
			return addSigningAddressesAndReturn();
		readFundedAddresses(null, wallet, TYPICAL_FEE, spend_unconfirmed, function(_arrBaseFundedAddresses){
			// fees will be paid from the same addresses as the asset
			if (_arrBaseFundedAddresses.length > 0 || !fee_paying_wallet || fee_paying_wallet === wallet){
				arrBaseFundedAddresses = _arrBaseFundedAddresses;
				return addSigningAddressesAndReturn();
			}
			readFundedAddresses(null, fee_paying_wallet, TYPICAL_FEE, spend_unconfirmed, function(_arrBaseFundedAddresses){
				arrBaseFundedAddresses = _arrBaseFundedAddresses;
				addSigningAddressesAndReturn();
			});
		});
	});
}
1251049
function parsePrivatePaymentChain(conn, arrPrivateElements, callbacks){
	var bAllStable = true;
	var issuePrivateElement = arrPrivateElements[arrPrivateElements.length-1];
	if (!issuePrivateElement.payload || !issuePrivateElement.payload.inputs || !issuePrivateElement.payload.inputs[0])
		return callbacks.ifError("invalid issue private element");
	var asset = issuePrivateElement.payload.asset;
	if (!asset)
		return callbacks.ifError("no asset in issue private element");
	var denomination = issuePrivateElement.payload.denomination;
	if (!denomination)
		return callbacks.ifError("no denomination in issue private element");
	async.forEachOfSeries(
		arrPrivateElements,
		function(objPrivateElement, i, cb){
			if (!objPrivateElement.payload || !objPrivateElement.payload.inputs || !objPrivateElement.payload.inputs[0])
				return cb("invalid payload");
			if (!objPrivateElement.output)
				return cb("no output in private element");
			if (objPrivateElement.payload.asset !== asset)
				return cb("private element has a different asset");
			if (objPrivateElement.payload.denomination !== denomination)
				return cb("private element has a different denomination");
			var prevElement = null; 
			if (i+1 < arrPrivateElements.length){ // excluding issue transaction
				var prevElement = arrPrivateElements[i+1];
				if (prevElement.unit !== objPrivateElement.payload.inputs[0].unit)
					return cb("not referencing previous element unit");
				if (prevElement.message_index !== objPrivateElement.payload.inputs[0].message_index)
					return cb("not referencing previous element message index");
				if (prevElement.output_index !== objPrivateElement.payload.inputs[0].output_index)
					return cb("not referencing previous element output index");
			}
			validatePrivatePayment(conn, objPrivateElement, prevElement, {
				ifError: cb,
				ifOk: function(bStable, input_address){
					objPrivateElement.bStable = bStable;
					objPrivateElement.input_address = input_address;
					if (!bStable)
						bAllStable = false;
					cb();
				}
			});
		},
		function(err){
			if (err)
				return callbacks.ifError(err);
			callbacks.ifOk(bAllStable);
		}
	);
}
13876
public static AccountInfo adaptAccountInfo(CryptonitBalance cryptonitBalance, String userName) {

    // Adapt to XChange DTOs
    List<Balance> balances = new ArrayList<>();
    for (CryptonitBalance.Balance b : cryptonitBalance.getBalances()) {
      Balance xchangeBalance =
          new Balance(
              Currency.getInstance(b.getCurrency().toUpperCase()),
              b.getBalance(),
              b.getAvailable(),
              b.getReserved(),
              ZERO,
              ZERO,
              b.getBalance().subtract(b.getAvailable()).subtract(b.getReserved()),
              ZERO);
      balances.add(xchangeBalance);
    }
    return new AccountInfo(userName, cryptonitBalance.getFee(), new Wallet(balances));
  }
738925
function addSharedAddressesOfWallet(arrAddressList, handleAddedSharedAddresses){
	if (!arrAddressList || arrAddressList.length === 0 )
		return handleAddedSharedAddresses([]);
	var strAddressList = arrAddressList.map(db.escape).join(', ');
	db.query("SELECT DISTINCT shared_address FROM shared_address_signing_paths WHERE address IN("+strAddressList+")", function(rows){
		if (rows.length === 0)
			return handleAddedSharedAddresses(arrAddressList);
		var arrSharedAddresses = rows.map(function(row){ return row.shared_address; });
		var arrNewMemberAddresses = _.difference(arrSharedAddresses, arrAddressList);
		if (arrNewMemberAddresses.length === 0)
			return handleAddedSharedAddresses(arrAddressList);
		addSharedAddressesOfWallet(arrAddressList.concat(arrNewMemberAddresses), handleAddedSharedAddresses);
	});
}
529013
function parseArgs (f) {
  return function (args, opts, callback) {
    var credentials = auth(opts.req)
    var guid = credentials.name
    var walletOpts = { password: credentials.pass, apiCode: apiCode }

    if (!guid) throw 'Missing wallet guid'
    if (!walletOpts.password) throw 'Missing wallet password'

    if (args.length > f.$params.length) {
      throw 'Expected max of ' + f.$params.length + ' parameters, received ' + args.length
    }

    var params = f.$params
      .map(function (param, i) {
        return {
          name: param.split('?')[0],
          value: args[i],
          required: !~param.indexOf('?')
        }
      })
      .reduce(function (acc, param) {
        if (param.value == null && param.required) throw 'Missing parameter: ' + param.name
        acc[param.name] = param.value
        return acc
      }, {})

    var action = f.$nowallet
      ? Promise.resolve(f(params))
      : api.getWallet(guid, walletOpts).then(f.bind(f, params))

    action
      .then(callback.bind(null, null))
      .catch(callback)
  }
}
505244
def getinfo(self):
        
        try:
            old_getinfo = AuthServiceProxy(self.__service_url, 'getinfo', self.__timeout, self.__conn, True)
            res = old_getinfo()
            if 'error' not in res:
                # 0.13 and earlier
                return res

        except JSONRPCException:
            pass

        network_info = self.getnetworkinfo()
        blockchain_info = self.getblockchaininfo()
        try:
            wallet_info = self.getwalletinfo()
        except:
            wallet_info = {
                'walletversion': None,
                'balance': None,
                'keypoololdest': None,
                'keypoolsize': None,
                'paytxfee': None,
            }

        res = {
            'version': network_info['version'],
            'protocolversion': network_info['protocolversion'],
            'walletversion': wallet_info['walletversion'],
            'balance': wallet_info['balance'],
            'blocks': blockchain_info['blocks'],
            'timeoffset': network_info['timeoffset'],
            'connections': network_info['connections'],
            'proxy': network_info['networks'],
            'difficulty': blockchain_info['difficulty'],
            'testnet': blockchain_info['chain'] == 'testnet',
            'keypoololdest': wallet_info['keypoololdest'],
            'keypoolsize': wallet_info['keypoolsize'],
            'paytxfee': wallet_info['paytxfee'],
            'errors': network_info['warnings'],
        }
        
        for k in ['unlocked_until', 'relayfee', 'paytxfee']:
            if wallet_info.has_key(k):
                res[k] = wallet_info[k]

        return res
386236
function getAddressDetails(body, callback) {
	var addresses = JSON.parse(body).addresses
	if(addresses.length == 0) {
		callback(new Error('No property information for that address'), null);
	}
	else {
		var url = property_url + encodeURIComponent(addresses[0].standardizedAddress);
		request(url, function(err, resp, body) {
			callback(err, body);
		});
	}
}
496777
function deleteWallet(wallet, rejector_device_address, onDone){
	db.query("SELECT approval_date FROM extended_pubkeys WHERE wallet=? AND device_address=?", [wallet, rejector_device_address], function(rows){
		if (rows.length === 0) // you are not a member device
			return onDone();
		if (rows[0].approval_date) // you've already approved this wallet, you can't change your mind
			return onDone();
		db.query("SELECT device_address FROM extended_pubkeys WHERE wallet=?", [wallet], function(rows){
			var arrMemberAddresses = rows.map(function(row){ return row.device_address; });
			var arrQueries = [];
			db.addQuery(arrQueries, "DELETE FROM extended_pubkeys WHERE wallet=?", [wallet]);
			db.addQuery(arrQueries, "DELETE FROM wallet_signing_paths WHERE wallet=?", [wallet]);
			db.addQuery(arrQueries, "DELETE FROM wallets WHERE wallet=?", [wallet]);
			// delete unused indirect correspondents
			db.addQuery(
				arrQueries, 
				"DELETE FROM correspondent_devices WHERE is_indirect=1 AND device_address IN(?) AND NOT EXISTS ( \n\
					SELECT * FROM extended_pubkeys WHERE extended_pubkeys.device_address=correspondent_devices.device_address \n\
				)", 
				[arrMemberAddresses]
			);
			async.series(arrQueries, function(){
				eventBus.emit('wallet_declined', wallet, rejector_device_address);
				onDone();
			});
		});
	});
}
1301374
function readFundedAddresses(asset, amount, arrAvailablePayingAddresses, arrAvailableFeePayingAddresses, handleFundedAddresses){
	readAddressesFundedInAsset(asset, amount, arrAvailablePayingAddresses, function(arrAddressesFundedInAsset){
		// add other addresses to pay for commissions (in case arrAddressesFundedInAsset don't have enough bytes to pay commissions)
	//	var arrOtherAddresses = _.difference(arrAvailablePayingAddresses, arrAddressesFundedInAsset);
	//	if (arrOtherAddresses.length === 0)
	//		return handleFundedAddresses(arrAddressesFundedInAsset);
		composer.readSortedFundedAddresses(null, arrAvailableFeePayingAddresses, TYPICAL_FEE, function(arrFundedFeePayingAddresses){
		//	if (arrFundedOtherAddresses.length === 0)
		//		return handleFundedAddresses(arrAddressesFundedInAsset);
		//	handleFundedAddresses(arrAddressesFundedInAsset.concat(arrFundedOtherAddresses));
			handleFundedAddresses(arrAddressesFundedInAsset, arrFundedFeePayingAddresses);
		});
	});
}
950182
def info(ctx, objects):
    
    if not objects:
        t = [["Key", "Value"]]
        info = ctx.bitshares.rpc.get_dynamic_global_properties()
        for key in info:
            t.append([key, info[key]])
        print_table(t)

    for obj in objects:
        # Block
        if re.match("^[0-9]*$", obj):
            block = Block(obj, lazy=False, bitshares_instance=ctx.bitshares)
            t = [["Key", "Value"]]
            for key in sorted(block):
                value = block[key]
                if key == "transactions":
                    value = format_tx(value)
                t.append([key, value])
            print_table(t)
        # Object Id
        elif re.match("^\d*\.\d*\.\d*$", obj):
            data = ctx.bitshares.rpc.get_object(obj)
            if data:
                t = [["Key", "Value"]]
                for key in sorted(data):
                    value = data[key]
                    if isinstance(value, dict) or isinstance(value, list):
                        value = format_tx(value)
                    t.append([key, value])
                print_table(t)
            else:
                print_message("Object %s unknown" % obj, "warning")

        # Asset
        elif obj.upper() == obj and re.match("^[A-Z\.]*$", obj):
            data = Asset(obj)
            t = [["Key", "Value"]]
            for key in sorted(data):
                value = data[key]
                if isinstance(value, dict):
                    value = format_tx(value)
                t.append([key, value])
            print_table(t)

        # Public Key
        elif re.match("^BTS.{48,55}$", obj):
            account = ctx.bitshares.wallet.getAccountFromPublicKey(obj)
            if account:
                t = [["Account"]]
                t.append([account])
                print_table(t)
            else:
                print_message("Public Key not known: %s" % obj, "warning")

        # Account name
        elif re.match("^[a-zA-Z0-9\-\._]{2,64}$", obj):
            account = Account(obj, full=True)
            if account:
                t = [["Key", "Value"]]
                for key in sorted(account):
                    value = account[key]
                    if isinstance(value, dict) or isinstance(value, list):
                        value = format_tx(value)
                    t.append([key, value])
                print_table(t)
            else:
                print_message("Account %s unknown" % obj, "warning")

        elif ":" in obj:
            vote = ctx.bitshares.rpc.lookup_vote_ids([obj])[0]
            if vote:
                t = [["Key", "Value"]]
                for key in sorted(vote):
                    value = vote[key]
                    if isinstance(value, dict) or isinstance(value, list):
                        value = format_tx(value)
                    t.append([key, value])
                print_table(t)
            else:
                print_message("voteid %s unknown" % obj, "warning")

        else:
            print_message("Couldn't identify object to read", "warning")
1198572
def account(self, key=None, address=None, name=None):
        """"""
        if key:
            return self.client.account(key, wallet=self)
        if address:
            q = dict(address=address)
        elif name:
            q = dict(name=name)
        else:
            raise TypeError("Missing param: key, address, or name is required.")

        return Account(
            self.resource.account_query(q).get(), self.client, wallet=self)
157067
func (w *Wallet) AddressInfo(a btcutil.Address) (waddrmgr.ManagedAddress, error) {
	var managedAddress waddrmgr.ManagedAddress
	err := walletdb.View(w.db, func(tx walletdb.ReadTx) error {
		addrmgrNs := tx.ReadBucket(waddrmgrNamespaceKey)
		var err error
		managedAddress, err = w.Manager.Address(addrmgrNs, a)
		return err
	})
	return managedAddress, err
}
973623
def get_wallet_balance(wallet_name, api_key, omit_addresses=False, coin_symbol='btc'):
    '''
    
    '''
    assert is_valid_coin_symbol(coin_symbol)
    assert api_key
    assert len(wallet_name) <= 25, wallet_name
    assert isinstance(omit_addresses, bool), omit_addresses

    params = {'token': api_key}
    if omit_addresses:
        params['omitWalletAddresses'] = 'true'

    url = make_url(coin_symbol, 'addrs/{}/balance'.format(wallet_name))

    r = requests.get(url, params=params, verify=True, timeout=TIMEOUT_IN_SECONDS)
    return get_valid_json(r)
166145
def name_transfer(self, key, new_address, value=None):
        

        key_details = self.name_show(key)

        if 'code' in key_details and key_details.get('code') == -4:
            return error_reply("Key does not exist")

        # get new 'value' if given, otherwise use the old 'value'
        if value is None:
            value = json.dumps(key_details['value'])

        if not self.unlock_wallet(self.passphrase):
            error_reply("Error unlocking wallet", 403)

        # transfer the name (underlying call is still name_update)
        try:
            # update the 'value'
            reply = self.obj.name_update(key, value, new_address)
        except JSONRPCException as e:
            return e.error

        return reply
252693
async function getAccountNonce (accountId, nonce) {
  if (nonce) return nonce
  const { nonce: accountNonce } = await this.api.getAccountByPubkey(accountId).catch(() => ({ nonce: 0 }))
  return accountNonce + 1
}