wallet_defined_by_keys.js
function issueOrSelectNextAddress(wallet, is_change, handleAddress){
	readNextAddressIndex(wallet, is_change, function(next_index){
		if (next_index < MAX_BIP44_GAP)
			return issueAddress(wallet, is_change, next_index, handleAddress);
		readLastUsedAddressIndex(wallet, is_change, function(last_used_index){
			if (last_used_index === null || next_index - last_used_index >= MAX_BIP44_GAP)
				selectRandomAddress(wallet, is_change, last_used_index, handleAddress);
			else
				issueAddress(wallet, is_change, next_index, handleAddress);
		});
	});
}
function issueOrSelectNextAddress(wallet, is_change, handleAddress){
	readNextAddressIndex(wallet, is_change, function(next_index){
		if (next_index < MAX_BIP44_GAP)
			return issueAddress(wallet, is_change, next_index, handleAddress);
		readLastUsedAddressIndex(wallet, is_change, function(last_used_index){
			if (last_used_index === null || next_index - last_used_index >= MAX_BIP44_GAP)
				selectRandomAddress(wallet, is_change, last_used_index, handleAddress);
			else
				issueAddress(wallet, is_change, next_index, handleAddress);
		});
	});
}
function issueOrSelectNextAddress ( wallet , is_change , handleAddress ) { readNextAddressIndex ( wallet , is_change , function ( next_index ) { if ( next_index < MAX_BIP44_GAP ) return issueAddress ( wallet , is_change , next_index , handleAddress ) ; readLastUsedAddressIndex ( wallet , is_change , function ( last_used_index ) { if ( last_used_index === null || next_index - last_used_index >= MAX_BIP44_GAP ) selectRandomAddress ( wallet , is_change , last_used_index , handleAddress ) ; else issueAddress ( wallet , is_change , next_index , handleAddress ) ; } ) ; } ) ; }
selects one of recent addresses if the gap is too large, otherwise issues a new address
selects one of recent addresses if the gap is too large otherwise issues a new address