Package nxt

Class FundingMonitor


  • public final class FundingMonitor
    extends java.lang.Object
    Monitor account balances based on account properties

    NXT, ASSET and CURRENCY balances can be monitored. If a balance falls below the threshold, a transaction will be submitted to transfer units from the funding account to the monitored account. A transfer will remain pending if the number of blocks since the previous transfer transaction is less than the monitor interval.

    • Field Detail

      • MIN_FUND_AMOUNT

        public static final long MIN_FUND_AMOUNT
        Minimum monitor amount
        See Also:
        Constant Field Values
      • MIN_FUND_THRESHOLD

        public static final long MIN_FUND_THRESHOLD
        Minimum monitor threshold
        See Also:
        Constant Field Values
      • MIN_FUND_INTERVAL

        public static final int MIN_FUND_INTERVAL
        Minimum funding interval
        See Also:
        Constant Field Values
    • Method Detail

      • getHoldingType

        public HoldingType getHoldingType()
        Return the monitor holding type
        Returns:
        Holding type
      • getHoldingId

        public long getHoldingId()
        Return the holding identifier
        Returns:
        Holding identifier for asset or currency
      • getProperty

        public java.lang.String getProperty()
        Return the account property name
        Returns:
        Account property
      • getAmount

        public long getAmount()
        Return the fund amount
        Returns:
        Fund amount
      • getThreshold

        public long getThreshold()
        Return the fund threshold
        Returns:
        Fund threshold
      • getInterval

        public int getInterval()
        Return the fund interval
        Returns:
        Fund interval
      • getAccountId

        public long getAccountId()
        Return the fund account identifier
        Returns:
        Account identifier
      • getAccountName

        public java.lang.String getAccountName()
        Return the fund account name
        Returns:
        Account name
      • startMonitor

        public static boolean startMonitor​(HoldingType holdingType,
                                           long holdingId,
                                           java.lang.String property,
                                           long amount,
                                           long threshold,
                                           int interval,
                                           java.lang.String secretPhrase)
        Start the monitor

        One or more funding parameters can be overridden in the account property value string: {"amount":"long","threshold":"long","interval":integer}

        Parameters:
        holdingType - Holding type
        holdingId - Asset or currency identifier, ignored for NXT monitor
        property - Account property name
        amount - Fund amount
        threshold - Fund threshold
        interval - Fund interval
        secretPhrase - Fund account secret phrase
        Returns:
        TRUE if the monitor was started
      • stopAllMonitors

        public static int stopAllMonitors()
        Stop all monitors Pending fund transactions will still be processed
        Returns:
        Number of monitors stopped
      • stopMonitor

        public static boolean stopMonitor​(HoldingType holdingType,
                                          long holdingId,
                                          java.lang.String property,
                                          long accountId)
        Stop monitor Pending fund transactions will still be processed
        Parameters:
        holdingType - Monitor holding type
        holdingId - Asset or currency identifier, ignored for NXT monitor
        property - Account property
        accountId - Fund account identifier
        Returns:
        TRUE if the monitor was stopped
      • getMonitors

        public static java.util.List<FundingMonitor> getMonitors​(Filter<FundingMonitor> filter)
        Get monitors satisfying the supplied filter
        Parameters:
        filter - Monitor filter
        Returns:
        Monitor list
      • getAllMonitors

        public static java.util.List<FundingMonitor> getAllMonitors()
        Get all monitors
        Returns:
        Account monitor list
      • getMonitoredAccounts

        public static java.util.List<FundingMonitor.MonitoredAccount> getMonitoredAccounts​(FundingMonitor monitor)
        Get all monitored accounts for a single monitor
        Parameters:
        monitor - Monitor
        Returns:
        List of monitored accounts
      • shutdown

        public static void shutdown()
        Stop monitor processing
      • hashCode

        public int hashCode()
        Return the hash code
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        Hash code
      • equals

        public boolean equals​(java.lang.Object obj)
        Check if two monitors are equal
        Overrides:
        equals in class java.lang.Object
        Parameters:
        obj - Comparison object
        Returns:
        TRUE if the objects are equal