Here's a simple code snippet which allows you to bundle transactions if the recipients have the asset you specified in their account.
package nxt.customfilter;
import nxt.account.Account;
import nxt.blockchain.Bundler;
import nxt.blockchain.ChildTransaction;
import nxt.db.DbIterator;
import nxt.ae.Asset;
public class FilterByAsset implements Bundler.Filter {
@Override
public boolean ok(Bundler bundler, ChildTransaction childTransaction) {
String assetID = "Insert Your Asset ID Here";
try (DbIterator iterateAssets = Account.getAccountAssets(childTransaction.getRecipientId(),0,Integer.MAX_VALUE)) {
while (iterateAssets.hasNext()) {
if(iterateAssets.next().toString().contains(assetID)) return true;
}
}
return false;
}
}
customfilter is a folder I created inside src/java/nxt
So you would create a file and name it FilterByAsset.java inside customfilter and paste the above codes.
finally, add nxt.bundlingFilter=nxt.customfilter.FilterByAsset
to conf/nxt.properties and compile.
getAccountAssets method return all the assets in the recipient account and prints out accound_id, asset_id, quantity, and unconfirmedQuantity.