Class LnUrl

  • Direct Known Subclasses:
    LnAddress

    public class LnUrl
    extends java.lang.Object
    A lnurl or lud16 URL.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.time.Duration DEFAULT_TIMEOUT  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
        LnUrl​(java.lang.String lnurl)  
      protected LnUrl​(java.net.URI url)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static LnUrl encode​(java.lang.String url)
      Encode an url to a lnurl bech32 representation.
      static LnUrl encode​(java.net.URI url)
      Encode an url to a lnurl bech32 representation.
      boolean equals​(java.lang.Object obj)  
      <T extends LnUrlService>
      org.ngengine.platform.AsyncTask<T>
      getService()
      Get an handler for the underlying service offered by this LNURL.
      <T extends LnUrlService>
      org.ngengine.platform.AsyncTask<T>
      getService​(java.time.Duration timeout)
      Get an handler for the underlying service offered by this LNURL.
      java.lang.String getTag()
      The tag for this LNURL service if applicable.
      int hashCode()  
      static void registerServiceFactory​(LnUrlServiceFactory factory)  
      java.lang.String toBech32()
      Return the bech32 representation of the LNURL.
      java.lang.String toLnUrlLink()
      Returns a link that can be used in a browser or app to open the LNURL.
      java.lang.String toString()  
      java.net.URI toURI()
      The decoded java URI representation of the LNURL after it is decoded from bech32.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • DEFAULT_TIMEOUT

        public static final java.time.Duration DEFAULT_TIMEOUT
    • Constructor Detail

      • LnUrl

        public LnUrl​(java.lang.String lnurl)
              throws java.net.URISyntaxException
        Throws:
        java.net.URISyntaxException
      • LnUrl

        protected LnUrl​(java.net.URI url)
                 throws java.net.URISyntaxException
        Throws:
        java.net.URISyntaxException
    • Method Detail

      • registerServiceFactory

        public static void registerServiceFactory​(LnUrlServiceFactory factory)
      • encode

        public static LnUrl encode​(java.net.URI url)
                            throws org.ngengine.bech32.Bech32DecodingException,
                                   org.ngengine.bech32.Bech32InvalidChecksumException,
                                   org.ngengine.bech32.Bech32InvalidRangeException,
                                   java.net.URISyntaxException,
                                   org.ngengine.bech32.Bech32EncodingException
        Encode an url to a lnurl bech32 representation.
        Throws:
        org.ngengine.bech32.Bech32DecodingException
        org.ngengine.bech32.Bech32InvalidChecksumException
        org.ngengine.bech32.Bech32InvalidRangeException
        java.net.URISyntaxException
        org.ngengine.bech32.Bech32EncodingException
      • encode

        public static LnUrl encode​(java.lang.String url)
                            throws org.ngengine.bech32.Bech32DecodingException,
                                   org.ngengine.bech32.Bech32InvalidChecksumException,
                                   org.ngengine.bech32.Bech32InvalidRangeException,
                                   java.net.URISyntaxException,
                                   org.ngengine.bech32.Bech32EncodingException
        Encode an url to a lnurl bech32 representation.
        Throws:
        org.ngengine.bech32.Bech32DecodingException
        org.ngengine.bech32.Bech32InvalidChecksumException
        org.ngengine.bech32.Bech32InvalidRangeException
        java.net.URISyntaxException
        org.ngengine.bech32.Bech32EncodingException
      • toLnUrlLink

        public java.lang.String toLnUrlLink()
        Returns a link that can be used in a browser or app to open the LNURL.
        Returns:
        A link in the format "lightning:bech32"
      • toURI

        public java.net.URI toURI()
        The decoded java URI representation of the LNURL after it is decoded from bech32. This can be used to fetch the service with any http client.
        Returns:
        The decoded URI of the LNURL.
      • toBech32

        public java.lang.String toBech32()
        Return the bech32 representation of the LNURL. The classic shareable representation of a LNURL.
        Returns:
        The bech32 encoded LNURL string.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • getTag

        public java.lang.String getTag()
        The tag for this LNURL service if applicable.
      • getService

        public <T extends LnUrlService> org.ngengine.platform.AsyncTask<T> getService()
                                                                               throws LnUrlException
        Get an handler for the underlying service offered by this LNURL.
        Type Parameters:
        T - The type of the service to be returned.
        Returns:
        An AsyncTask that will return the service when completed.
        Throws:
        LnUrlException
      • getService

        public <T extends LnUrlService> org.ngengine.platform.AsyncTask<T> getService​(java.time.Duration timeout)
                                                                               throws LnUrlException
        Get an handler for the underlying service offered by this LNURL.
        Type Parameters:
        T - The type of the service to be returned.
        Parameters:
        timeout - The timeout for the request to fetch the service.
        Returns:
        An AsyncTask that will return the service when completed.
        Throws:
        LnUrlException