public class BitcoinURI extends 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 String |
BITCOIN_SCHEME
Deprecated.
|
static String |
FIELD_ADDRESS |
static String |
FIELD_AMOUNT |
static String |
FIELD_LABEL |
static String |
FIELD_MESSAGE |
static String |
FIELD_PAYMENT_REQUEST_URL |
Constructor and Description |
---|
BitcoinURI(NetworkParameters params,
String input)
Constructs a new object by trying to parse the input as a valid Bitcoin URI.
|
BitcoinURI(String uri)
Constructs a new BitcoinURI from the given string.
|
Modifier and Type | Method and Description |
---|---|
static String |
convertToBitcoinURI(Address address,
Coin amount,
String label,
String message)
Simple Bitcoin URI builder using known good fields.
|
static String |
convertToBitcoinURI(NetworkParameters params,
String address,
Coin amount,
String label,
String message)
Simple Bitcoin URI builder using known good fields.
|
Address |
getAddress()
The Bitcoin Address from the URI, if one was present.
|
Coin |
getAmount() |
String |
getLabel() |
String |
getMessage() |
Object |
getParameterByName(String name) |
String |
getPaymentRequestUrl() |
List<String> |
getPaymentRequestUrls()
Returns the URLs where a payment request (as specified in BIP 70) may be fetched.
|
String |
toString() |
public static final String FIELD_MESSAGE
public static final String FIELD_LABEL
public static final String FIELD_AMOUNT
public static final String FIELD_ADDRESS
public static final String FIELD_PAYMENT_REQUEST_URL
@Deprecated public static final String BITCOIN_SCHEME
AbstractBitcoinNetParams.BITCOIN_SCHEME
if you specifically
need Bitcoin, or use NetworkParameters.getUriScheme()
to get the scheme
from network parameters.public BitcoinURI(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, 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 String getLabel()
public String getMessage()
public final String getPaymentRequestUrl()
public List<String> getPaymentRequestUrls()
public Object getParameterByName(String name)
name
- The name of the parameterpublic static String convertToBitcoinURI(Address address, Coin amount, String label, String message)
address
- The Bitcoin addressamount
- The amountlabel
- A labelmessage
- A messagepublic static String convertToBitcoinURI(NetworkParameters params, String address, @Nullable Coin amount, @Nullable String label, @Nullable String message)
params
- The network parameters that determine which network the URI
is for.address
- The Bitcoin addressamount
- The amountlabel
- A labelmessage
- A messageCopyright © 2016. All rights reserved.