bMultiAuthored includes all addresses, not just those that pay arrAddresses is paying addresses
550374
function pickDivisibleCoinsForAmount(conn, objAsset, arrAddresses, last_ball_mci, amount, bMultiAuthored, onDone){
	var asset = objAsset ? objAsset.asset : null;
	console.log("pick coins "+asset+" amount "+amount);
	var is_base = objAsset ? 0 : 1;
	var arrInputsWithProofs = [];
	var total_amount = 0;
	var required_amount = amount;
	
	// adds element to arrInputsWithProofs
	function addInput(input){
		total_amount += input.amount;
		var objInputWithProof = {input: input};
		if (objAsset && objAsset.is_private){ // for type=payment only
			var spend_proof = objectHash.getBase64Hash({
				asset: asset,
				amount: input.amount,
				address: input.address,
				unit: input.unit,
				message_index: input.message_index,
				output_index: input.output_index,
				blinding: input.blinding
			});
			var objSpendProof = {spend_proof: spend_proof};
			if (bMultiAuthored)
				objSpendProof.address = input.address;
			objInputWithProof.spend_proof = objSpendProof;
		}
		if (!bMultiAuthored || !input.type)
			delete input.address;
		delete input.amount;
		delete input.blinding;
		arrInputsWithProofs.push(objInputWithProof);
	}
   
	// first, try to find a coin just bigger than the required amount
	function pickOneCoinJustBiggerAndContinue(){
		if (amount === Infinity)
			return pickMultipleCoinsAndContinue();
		var more = is_base ? '>' : '>=';
		conn.query(
			"SELECT unit, message_index, output_index, amount, blinding, address \n\
			FROM outputs \n\
			CROSS JOIN units USING(unit) \n\
			WHERE address IN(?) AND asset"+(asset ? "="+conn.escape(asset) : " IS NULL")+" AND is_spent=0 AND amount "+more+" ? \n\
				AND is_stable=1 AND sequence='good' AND main_chain_index<=?  \n\
			ORDER BY amount LIMIT 1", 
			[arrSpendableAddresses, amount+is_base*TRANSFER_INPUT_SIZE, last_ball_mci],
			function(rows){
				if (rows.length === 1){
					var input = rows[0];
					// default type is "transfer"
					addInput(input);
					onDone(arrInputsWithProofs, total_amount);
				}
				else
					pickMultipleCoinsAndContinue();
			}
		);
	}
	
	// then, try to add smaller coins until we accumulate the target amount
	function pickMultipleCoinsAndContinue(){
		conn.query(
			"SELECT unit, message_index, output_index, amount, address, blinding \n\
			FROM outputs \n\
			CROSS JOIN units USING(unit) \n\
			WHERE address IN(?) AND asset"+(asset ? "="+conn.escape(asset) : " IS NULL")+" AND is_spent=0 \n\
				AND is_stable=1 AND sequence='good' AND main_chain_index<=?  \n\
			ORDER BY amount DESC",
			[arrSpendableAddresses, last_ball_mci],
			function(rows){
				async.eachSeries(
					rows,
					function(row, cb){
						var input = row;
						objectHash.cleanNulls(input);
						required_amount += is_base*TRANSFER_INPUT_SIZE;
						addInput(input);
						// if we allow equality, we might get 0 amount for change which is invalid
						var bFound = is_base ? (total_amount > required_amount) : (total_amount >= required_amount);
						bFound ? cb('found') : cb();
					},
					function(err){
						if (err === 'found')
							onDone(arrInputsWithProofs, total_amount);
						else if (asset)
							issueAsset();
						else{
							// pow modi
							//addHeadersCommissionInputs();
							finish();
						}
					}
				);
			}
		);
	}
	
	// pow del
	// function addHeadersCommissionInputs(){
	// 	addMcInputs("headers_commission", HEADERS_COMMISSION_INPUT_SIZE,
	// 		headers_commission.getMaxSpendableMciForLastBallMci(last_ball_mci), addWitnessingInputs);
	// }
	
	// function addWitnessingInputs(){
	// 	addMcInputs("witnessing", WITNESSING_INPUT_SIZE, paid_witnessing.getMaxSpendableMciForLastBallMci(last_ball_mci), issueAsset);
	// }
	
	// function addMcInputs(type, input_size, max_mci, onStillNotEnough){
	// 	async.eachSeries(
	// 		arrAddresses,
	// 		function(address, cb){
	// 			var target_amount = required_amount + input_size + (bMultiAuthored ? ADDRESS_SIZE : 0) - total_amount;
	// 			mc_outputs.findMcIndexIntervalToTargetAmount(conn, type, address, max_mci, target_amount, {
	// 				ifNothing: cb,
	// 				ifFound: function(from_mc_index, to_mc_index, earnings, bSufficient){
	// 					if (earnings === 0)
	// 						throw Error("earnings === 0");
	// 					total_amount += earnings;
	// 					var input = {
	// 						type: type,
	// 						from_main_chain_index: from_mc_index,
	// 						to_main_chain_index: to_mc_index
	// 					};
	// 					var full_input_size = input_size;
	// 					if (bMultiAuthored){
	// 						full_input_size += ADDRESS_SIZE; // address length
	// 						input.address = address;
	// 					}
	// 					required_amount += full_input_size;
	// 					arrInputsWithProofs.push({input: input});
	// 					(total_amount > required_amount)
	// 						? cb("found") // break eachSeries
	// 						: cb(); // try next address
	// 				}
	// 			});
	// 		},
	// 		function(err){
	// 			if (!err)
	// 				console.log(arrAddresses+" "+type+": got only "+total_amount+" out of required "+required_amount);
	// 			(err === "found") ? onDone(arrInputsWithProofs, total_amount) : onStillNotEnough();
	// 		}
	// 	);
	// }
	
	function issueAsset(){
		if (!asset)
			return finish();
		else{
			if (amount === Infinity && !objAsset.cap) // don't try to create infinite issue
				return onDone(null);
		}
		console.log("will try to issue asset "+asset);
		// for issue, we use full list of addresses rather than spendable addresses
		if (objAsset.issued_by_definer_only && arrAddresses.indexOf(objAsset.definer_address) === -1)
			return finish();
		var issuer_address = objAsset.issued_by_definer_only ? objAsset.definer_address : arrAddresses[0];
		var issue_amount = objAsset.cap || (required_amount - total_amount) || 1; // 1 currency unit in case required_amount = total_amount
		
		function addIssueInput(serial_number){
			total_amount += issue_amount;
			var input = {
				type: "issue",
				amount: issue_amount,
				serial_number: serial_number
			};
			if (bMultiAuthored)
				input.address = issuer_address;
			var objInputWithProof = {input: input};
			if (objAsset && objAsset.is_private){
				var spend_proof = objectHash.getBase64Hash({
					asset: asset,
					amount: issue_amount,
					denomination: 1,
					address: issuer_address,
					serial_number: serial_number
				});
				var objSpendProof = {spend_proof: spend_proof};
				if (bMultiAuthored)
					objSpendProof.address = input.address;
				objInputWithProof.spend_proof = objSpendProof;
			}
			arrInputsWithProofs.push(objInputWithProof);
			var bFound = is_base ? (total_amount > required_amount) : (total_amount >= required_amount);
			bFound ? onDone(arrInputsWithProofs, total_amount) : finish();
		}
		
		if (objAsset.cap){
			conn.query("SELECT 1 FROM inputs WHERE type='issue' AND asset=?", [asset], function(rows){
				if (rows.length > 0) // already issued
					return finish();
				addIssueInput(1);
			});
		}
		else{
			conn.query(
				"SELECT MAX(serial_number) AS max_serial_number FROM inputs WHERE type='issue' AND asset=? AND address=?", 
				[asset, issuer_address], 
				function(rows){
					var max_serial_number = (rows.length === 0) ? 0 : rows[0].max_serial_number;
					addIssueInput(max_serial_number+1);
				}
			);
		}
	}
	
	function finish(){
		if (amount === Infinity && arrInputsWithProofs.length > 0)
			onDone(arrInputsWithProofs, total_amount);
		else
			onDone(null);
	}
	
	var arrSpendableAddresses = arrAddresses.concat(); // cloning
	if (objAsset && objAsset.auto_destroy){
		var i = arrAddresses.indexOf(objAsset.definer_address);
		if (i>=0)
			arrSpendableAddresses.splice(i, 1);
	}
	if (arrSpendableAddresses.length > 0)
		pickOneCoinJustBiggerAndContinue();
	else
		issueAsset();
}
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();
			});
		});
	});
}
784606
function createAdditionalMessages(conn, last_ball_mci, bMultiAuthored, arrPayingAddresses, onDone){
			var arrAssetPayingAddresses = _.intersection(arrPayingAddresses, params.paying_addresses);
			storage.loadAssetWithListOfAttestedAuthors(conn, params.asset, last_ball_mci, arrAssetPayingAddresses, function(err, objAsset){
				if (err)
					return onDone(err);
				if (!objAsset.fixed_denominations)
					return onDone("divisible asset type");
				if (!objAsset.is_transferrable && params.to_address !== objAsset.definer_address && arrAssetPayingAddresses.indexOf(objAsset.definer_address) === -1)
					return onDone("the asset is not transferrable and definer not found on either side of the deal");
				if (objAsset.cosigned_by_definer && arrPayingAddresses.concat(params.signing_addresses || []).indexOf(objAsset.definer_address) === -1)
					return onDone("the asset must be cosigned by definer");
				if (objAsset.spender_attested && objAsset.arrAttestedAddresses.length === 0)
					return onDone("none of the authors is attested");

				var target_amount = params.to_address ? params.amount : params.asset_outputs[0].amount;
				var to_address = params.to_address ? params.to_address : params.asset_outputs[0].address;
				pickIndivisibleCoinsForAmount(
					conn, objAsset, arrAssetPayingAddresses, last_ball_mci, 
					to_address, params.change_address,
					target_amount, params.tolerance_plus || 0, params.tolerance_minus || 0, 
					bMultiAuthored, params.spend_unconfirmed || 'own',
					function(err, arrPayloadsWithProofs){
						if (!arrPayloadsWithProofs)
							return onDone({
								error_code: "NOT_ENOUGH_FUNDS", 
								error: err
							});
						var arrMessages = [];
						var assocPrivatePayloads = {};
						for (var i=0; i<arrPayloadsWithProofs.length; i++){
							var payload = arrPayloadsWithProofs[i].payload;
							var payload_hash;// = objectHash.getBase64Hash(payload);
							var bJsonBased = (last_ball_mci >= constants.timestampUpgradeMci);
							if (objAsset.is_private){
								payload.outputs.forEach(function(o){
									o.output_hash = objectHash.getBase64Hash({address: o.address, blinding: o.blinding});
								});
								var hidden_payload = _.cloneDeep(payload);
								hidden_payload.outputs.forEach(function(o){
									delete o.address;
									delete o.blinding;
								});
								payload_hash = objectHash.getBase64Hash(hidden_payload, bJsonBased);
							}
							else
								payload_hash = objectHash.getBase64Hash(payload, bJsonBased);
							var objMessage = {
								app: "payment",
								payload_location: objAsset.is_private ? "none" : "inline",
								payload_hash: payload_hash
							};
							if (objAsset.is_private){
								assocPrivatePayloads[payload_hash] = payload;
								objMessage.spend_proofs = [arrPayloadsWithProofs[i].spend_proof];
							}
							else
								objMessage.payload = payload;
							arrMessages.push(objMessage);
						}
						// messages are sorted in descending order by denomination of the coin, so shuffle them to avoid giving any clues
						shuffleArray(arrMessages);
						console.log("composed messages "+JSON.stringify(arrMessages));
						onDone(null, arrMessages, assocPrivatePayloads);
					}
				);
			});
		}
382898
def get_address_transactions(self, address_id, **params):
        """"""
        return self.api_client.get_address_transactions(self.id, address_id, **params)
294533
def get_addresses(self, account_id, **params):
        """"""
        response = self._get('v2', 'accounts', account_id, 'addresses', params=params)
        return self._make_api_object(response, Address)
1307495
function determineIfIncludesMeAndRewriteDeviceAddress(assocSignersByPath, handleResult){
	var assocMemberAddresses = {};
	var bHasMyDeviceAddress = false;
	for (var signing_path in assocSignersByPath){
		var signerInfo = assocSignersByPath[signing_path];
		if (signerInfo.device_address === device.getMyDeviceAddress())
			bHasMyDeviceAddress = true;
		if (signerInfo.address)
			assocMemberAddresses[signerInfo.address] = true;
	}
	var arrMemberAddresses = Object.keys(assocMemberAddresses);
	if (arrMemberAddresses.length === 0)
		return handleResult("no member addresses?");
	db.query(
		"SELECT address, 'my' AS type FROM my_addresses WHERE address IN(?) \n\
		UNION \n\
		SELECT shared_address AS address, 'shared' AS type FROM shared_addresses WHERE shared_address IN(?)", 
		[arrMemberAddresses, arrMemberAddresses],
		function(rows){
		//	handleResult(rows.length === arrMyMemberAddresses.length ? null : "Some of my member addresses not found");
			if (rows.length === 0)
				return handleResult("I am not a member of this shared address");
			var arrMyMemberAddresses = rows.filter(function(row){ return (row.type === 'my'); }).map(function(row){ return row.address; });
			// rewrite device address for my addresses
			if (!bHasMyDeviceAddress){
				for (var signing_path in assocSignersByPath){
					var signerInfo = assocSignersByPath[signing_path];
					if (signerInfo.address && arrMyMemberAddresses.indexOf(signerInfo.address) >= 0)
						signerInfo.device_address = device.getMyDeviceAddress();
				}
			}
			handleResult();
		}
	);
}
1065640
def ContainsAddressStr(self, address):
        
        for key, contract in self._contracts.items():
            if contract.Address == address:
                return True
        return False
83296
function checkDepositAddressSpend(){
								if (objUnit.authors.length !== 2)
									return cb();	
									
								// console.log("===================Start to check spend deposit balance");
								var supernodes = objUnit.authors.filter( function (author) { return author.address != owner_address });
								var coAuthorAddr = supernodes[0].address ;
								// Check owner address is kind of deposit address  
								// console.log("===================coAuthorAddr: "+ coAuthorAddr +" | owner_address: " +owner_address);
								deposit.getSupernodeByDepositAddress(conn, owner_address, function(err, supernodeinfo){
									if(err){
										// no correspont supernode which indicates owner_address is not deposit address
										return cb();
									}
									// console.log("===================Deposit address: " + owner_address + "  supernode address: "+ supernodeinfo[0].address);
									// owner_address is deposit address
									deposit.hasInvalidUnitsFromHistory(conn, supernodeinfo[0].address, function (err, isInvalid){
										if(err) //normal tranaction
											return cb(err);
										
										round.getLastCoinbaseUnitRoundIndex(conn, supernodeinfo[0].address, function(err, lastCoinBaseRound){
											if(err)
												return cb(err);
											// console.log("===================got last coin base round is : "+ lastCoinBaseRound);
											round.getCurrentRoundIndex(conn, function(latestRoundIndex){
												if (constants.FOUNDATION_SAFE_ADDRESS === coAuthorAddr){ // foundation spend deposit condition
													if(!isInvalid) // supernode is good condition
														return cb("supernode [" + supernodeinfo[0].address + "] don not submit bad joints, Foundation can not spend its deposit balance ");
													if(lastCoinBaseRound === 0 ) // never participate in minning and no coinbase  record
														return cb("supernode [" + supernodeinfo[0].address + "] don not submit coinbase unit,  Foundation can not spend its deposit balance ");
													
													// console.log("===================got current  round is : "+ latestRoundIndex);
													// check if delay n round to spend 
													if((latestRoundIndex - lastCoinBaseRound) < constants.COUNT_ROUNDS_FOR_FOUNDATION_SPEND_DEPOSIT){
														return cb("Foundation safe address can not spend deposit contract balance before ")
													}
													return cb(); // OK condition
												}
												else if(coAuthorAddr === supernodeinfo[0].safe_address){ // condition for supernode spend the deposit balance
													if(lastCoinBaseRound === 0 ) // not mine at all, take it anytime
														return cb();
													if(isInvalid)
														return cb("supernode [" + supernodeinfo[0].address + "] submit bad joints, can not spend its deposit balance ");
													
													// console.log("===================got current  round is : "+ latestRoundIndex);
													if((latestRoundIndex - lastCoinBaseRound) < constants.COUNT_ROUNDS_FOR_SUPERNODE_SPEND_DEPOSIT){
														return cb("supernode can not spend deposit contract balance before round " + (lastCoinBaseRound + constants.COUNT_ROUNDS_FOR_SUPERNODE_SPEND_DEPOSIT));
													}

													// console.log("===================OK to spend deposit balance");
													return cb();  // OK condition
												}
												return cb("unknown user:" + coAuthorAddr +" try to spend deposit :" + owner_address );
											});
										});
										
									});		
								});
							}
149394
def get_unspents(address, bitcoind):
    
    assert BLOCKSTACK_TEST, 'get_unspents can only be used in test mode!'

    addresses = [address]
    
    min_confirmations = 0
    max_confirmation = 2000000000  # just a very large number for max
    unspents = bitcoind.listunspent(min_confirmations, max_confirmation, addresses)

    if BLOCKSTACK_TEST and len(unspents) == 0:
        try:
            bitcoind.importaddress(str(address))
            unspents = bitcoind.listunspent(min_confirmations, max_confirmation, addresses)
        except Exception as e:
            return format_unspents([])

    return format_unspents(unspents)
1204371
def remove_all_matching(self, address=None, name=None):
        
        if self.entries:
            if address and name:
                func = lambda entry: not entry.is_real_entry() or (entry.address != address and name not in entry.names)
            elif address:
                func = lambda entry: not entry.is_real_entry() or entry.address != address
            elif name:
                func = lambda entry: not entry.is_real_entry() or name not in entry.names
            else:
                raise ValueError('No address or name was specified for removal.')
            self.entries = list(filter(func, self.entries))
1350297
function pushIps(addresses, announced, useInternalAddresses) {
	if (!useInternalAddresses) {
		addresses = addresses.filter((address) => address.internal === false);
	}

	addresses = addresses
		.filter((address) => address.family === 'IPv4')
		.map((address) => address.address);

	return announced.concat(addresses);
}
1217399
function(apiKey, contactId, creditCardId,
        payPlanId, productIds, subscriptionPlanIds, processSpecials,
        promoCodes, _leadAffiliatedId, _affiliatedId) {}
365841
function composeMinimalJoint(params){
	var estimated_amount = (params.send_all || params.retrieveMessages) ? 0 : params.outputs.reduce(function(acc, output){ return acc+output.amount; }, 0) + TYPICAL_FEE;
	readSortedFundedAddresses(null, params.available_paying_addresses, estimated_amount, params.spend_unconfirmed || 'own', function(arrFundedPayingAddresses){
		if (arrFundedPayingAddresses.length === 0)
			return params.callbacks.ifNotEnoughFunds("all paying addresses are unfunded");
		var minimal_params = _.clone(params);
		delete minimal_params.available_paying_addresses;
		minimal_params.minimal = true;
		minimal_params.paying_addresses = arrFundedPayingAddresses;
		composeJoint(minimal_params);
	});
}
954525
def get_addresses(self, fetch=False):
        """"""
        return Addresses(self.resource.addresses, self.client, populate=fetch)
1145391
public boolean containsMembers(Address ... mbrs) {
        if(mbrs == null || members == null)
            return false;
        for(Address mbr: mbrs) {
            if(!containsMember(mbr))
                return false;
        }
        return true;
    }
1210717
def _get_addresses(self, address_data, retain_name=False):
        
        if retain_name:
            raise NotImplementedError(
                "Not yet implemented, but will need client-code changes too"
            )

        # We trust than an email address contains an "@" after
        # email.utils.getaddresses has done the hard work. If we wanted
        # to we could use a regex to check for greater email validity

        # NB: getaddresses expects a list, so ensure we feed it appropriately
        if isinstance(address_data, str):
            if "[" not in address_data:
                # Definitely turn these into a list
                # NB: this is pretty assumptive, but still prob OK
                address_data = [address_data]

        output = [x[1] for x in getaddresses(address_data) if "@" in x[1]]
        return output
221068
def all_neighbour_nodes(chain_state: ChainState) -> Set[Address]:
    
    addresses = set()

    for payment_network in chain_state.identifiers_to_paymentnetworks.values():
        for token_network in payment_network.tokenidentifiers_to_tokennetworks.values():
            channel_states = token_network.channelidentifiers_to_channels.values()
            for channel_state in channel_states:
                addresses.add(channel_state.partner_state.address)

    return addresses