wallet.js
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();
			});
		});
	});
}
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();
			});
		});
	});
}
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 ( ) ; } ) ; } ) ; } ) ; }
fee_paying_wallet is used only if there are no bytes on the asset wallet, it is a sort of fallback wallet for fees
fee_paying_wallet is used only if there are no bytes on the asset wallet it is a sort of fallback wallet for fees