wallet_defined_by_addresses.js
function sendToPeerAllSharedAddressesHavingUnspentOutputs(device_address, asset, callbacks){
	var asset_filter = !asset || asset == "base" ? " AND outputs.asset IS NULL " : " AND outputs.asset='"+asset+"'";
	db.query(
		"SELECT DISTINCT shared_address FROM shared_address_signing_paths CROSS JOIN outputs ON shared_address_signing_paths.shared_address=outputs.address\n\
		 WHERE device_address=? AND outputs.is_spent=0" + asset_filter, [device_address], function(rows){
			if (rows.length === 0)
				return callbacks.ifNoFundedSharedAddress();
			rows.forEach(function(row){
				sendSharedAddressToPeer(device_address, row.shared_address, function(err){
					if (err)
						return console.log(err)
					console.log("Definition for " + row.shared_address + " will be sent to " + device_address);
				});
			});
				return callbacks.ifFundedSharedAddress(rows.length);
	});
}
function sendToPeerAllSharedAddressesHavingUnspentOutputs(device_address, asset, callbacks){
	var asset_filter = !asset || asset == "base" ? " AND outputs.asset IS NULL " : " AND outputs.asset='"+asset+"'";
	db.query(
		"SELECT DISTINCT shared_address FROM shared_address_signing_paths CROSS JOIN outputs ON shared_address_signing_paths.shared_address=outputs.address\n\
		 WHERE device_address=? AND outputs.is_spent=0" + asset_filter, [device_address], function(rows){
			if (rows.length === 0)
				return callbacks.ifNoFundedSharedAddress();
			rows.forEach(function(row){
				sendSharedAddressToPeer(device_address, row.shared_address, function(err){
					if (err)
						return console.log(err)
					console.log("Definition for " + row.shared_address + " will be sent to " + device_address);
				});
			});
				return callbacks.ifFundedSharedAddress(rows.length);
	});
}
function sendToPeerAllSharedAddressesHavingUnspentOutputs ( device_address , asset , callbacks ) { var asset_filter = ! asset || asset == "base" ? " AND outputs.asset IS NULL " : " AND outputs.asset='" + asset + "'" ; db . query ( "SELECT DISTINCT shared_address FROM shared_address_signing_paths CROSS JOIN outputs ON shared_address_signing_paths.shared_address=outputs.address\n\
		 WHERE device_address=? AND outputs.is_spent=0" + asset_filter , [ device_address ] , function ( rows ) { if ( rows . length === 0 ) return callbacks . ifNoFundedSharedAddress ( ) ; rows . forEach ( function ( row ) { sendSharedAddressToPeer ( device_address , row . shared_address , function ( err ) { if ( err ) return console . log ( err ) console . log ( "Definition for " + row . shared_address + " will be sent to " + device_address ) ; } ) ; } ) ; return callbacks . ifFundedSharedAddress ( rows . length ) ; } ) ; }
when a peer has lost shared address definitions after a wallet recovery, we can resend them
when a peer has lost shared address definitions after a wallet recovery we can resend them