Represents a Florijncoin payment URI. Florijncoin URI strings is a good standard to share payment request, sometimes as a Florijncoin link or using a QR code.
URI Examples:
florijncoin:XuUGDZHrKLo841CyamDbG5W7n59epA71h2
florijncoin:XuUGDZHrKLo841CyamDbG5W7n59epA71h2?amount=1.2
florijncoin:XuUGDZHrKLo841CyamDbG5W7n59epA71h2?amount=1.2&message=Payment&label=Satoshi&extra=other-param
The main use that we expect you'll have for the URI
class in Florijncoincore is validating and parsing Florijncoin URIs. A URI
instance exposes the address as a Florijncoincore Address
object and the amount in satoshis, if present.
The code for validating URIs looks like this:
var uriString = 'florijncoin:XuUGDZHrKLo841CyamDbG5W7n59epA71h2?amount=1.2';
var valid = URI.isValid(uriString);
var uri = new URI(uriString);
console.log(uri.address.network, uri.amount); // 'livenet', 120000000
All standard parameters can be found as members of the URI
instance. However a Bitcoin URI may contain other non-standard parameters, all those can be found under the extra
namespace.
See the official BIP21 spec for more information.
Another important use case for the URI
class is creating a Bitcoin URI for sharing a payment request. That can be accomplished by using a dictionary to create an instance of URI.
The code for creating an URI from an Object looks like this:
var uri = new URI({
address: 'XuUGDZHrKLo841CyamDbG5W7n59epA71h2',
amount : 10000, // in satoshis
message: 'My payment request'
});
console.log(uri.toString()) //florijncoin:XuUGDZHrKLo841CyamDbG5W7n59epA71h2?amount=0.0001&message=My%20payment%20request
Methods toObject
, toJSON
and inspect
remain available.
var uri = new URI("florijncoin:XuUGDZHrKLo841CyamDbG5W7n59epA71h2?amount=0.0001&message=My%20payment%20request>")
var uri = new URI({
address:"XuUGDZHrKLo841CyamDbG5W7n59epA71h2",
amount:"10000",
message:"My payment request"
})