public class BitcoinURI
extends java.lang.Object
Provides a standard implementation of a Bitcoin URI with support for the following:
The following input forms are accepted:
bitcoin:<address>
bitcoin:<address>?<name1>=<value1>&<name2>=<value2>
with multiple
additional name/value pairsThe name/value pairs are processed as follows.
req-
are treated as required and if unknown or conflicting cause a parse exceptionreq-
are added to a Map, accessible by parameter namereq-
are processed unless they are malformedThe following names are known and have the following formats:
amount
decimal value to 8 dp (e.g. 0.12345678) Note that the
exponent notation is not supported any morelabel
any URL encoded alphanumericmessage
any URL encoded alphanumericModifier and Type | Field and Description |
---|---|
static java.lang.String |
BITCOIN_SCHEME
Deprecated.
|
static java.lang.String |
FIELD_ADDRESS |
static java.lang.String |
FIELD_AMOUNT |
static java.lang.String |
FIELD_LABEL |
static java.lang.String |
FIELD_MESSAGE |
static java.lang.String |
FIELD_PAYMENT_REQUEST_URL |
Constructor and Description |
---|
BitcoinURI(NetworkParameters params,
java.lang.String input)
Constructs a new object by trying to parse the input as a valid Bitcoin URI.
|
BitcoinURI(java.lang.String uri)
Constructs a new BitcoinURI from the given string.
|
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
convertToBitcoinURI(Address address,
Coin amount,
java.lang.String label,
java.lang.String message)
Simple Bitcoin URI builder using known good fields.
|
static java.lang.String |
convertToBitcoinURI(NetworkParameters params,
java.lang.String address,
Coin amount,
java.lang.String label,
java.lang.String message)
Simple Bitcoin URI builder using known good fields.
|
Address |
getAddress()
The Bitcoin address from the URI, if one was present.
|
Coin |
getAmount() |
java.lang.String |
getLabel() |
java.lang.String |
getMessage() |
java.lang.Object |
getParameterByName(java.lang.String name) |
java.lang.String |
getPaymentRequestUrl() |
java.util.List<java.lang.String> |
getPaymentRequestUrls()
Returns the URLs where a payment request (as specified in BIP 70) may be fetched.
|
java.lang.String |
toString() |
public static final java.lang.String FIELD_MESSAGE
public static final java.lang.String FIELD_LABEL
public static final java.lang.String FIELD_AMOUNT
public static final java.lang.String FIELD_ADDRESS
public static final java.lang.String FIELD_PAYMENT_REQUEST_URL
@Deprecated public static final java.lang.String BITCOIN_SCHEME
AbstractBitcoinNetParams.BITCOIN_SCHEME
if you specifically
need Bitcoin, or use NetworkParameters.getUriScheme()
to get the scheme
from network parameters.public BitcoinURI(java.lang.String uri) throws BitcoinURIParseException
uri
- The raw URI data to be parsed (see class comments for accepted formats)BitcoinURIParseException
- if the URI is not syntactically or semantically valid.public BitcoinURI(@Nullable NetworkParameters params, java.lang.String input) throws BitcoinURIParseException
params
- The network parameters that determine which network the URI is from, or null if you don't have
any expectation about what network the URI is for and wish to check yourself.input
- The raw URI data to be parsed (see class comments for accepted formats)BitcoinURIParseException
- If the input fails Bitcoin URI syntax and semantic checks.@Nullable public Address getAddress()
public Coin getAmount()
public java.lang.String getLabel()
public java.lang.String getMessage()
public final java.lang.String getPaymentRequestUrl()
public java.util.List<java.lang.String> getPaymentRequestUrls()
public java.lang.Object getParameterByName(java.lang.String name)
name
- The name of the parameterpublic java.lang.String toString()
toString
in class java.lang.Object
public static java.lang.String convertToBitcoinURI(Address address, Coin amount, java.lang.String label, java.lang.String message)
address
- The Bitcoin addressamount
- The amountlabel
- A labelmessage
- A messagepublic static java.lang.String convertToBitcoinURI(NetworkParameters params, java.lang.String address, @Nullable Coin amount, @Nullable java.lang.String label, @Nullable java.lang.String message)
params
- The network parameters that determine which network the URI
is for.address
- The Bitcoin addressamount
- The amountlabel
- A labelmessage
- A message