Represents a Helpthehomeless payment URI. Helpthehomeless URI strings is a good standard to share payment request, sometimes as a Helpthehomeless link or using a QR code.
URI Examples:
helpthehomeless:XuUGDZHrKLo841CyamDbG5W7n59epA71h2
helpthehomeless:XuUGDZHrKLo841CyamDbG5W7n59epA71h2?amount=1.2
helpthehomeless: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 Helpthehomeless is validating and parsing Helpthehomeless URIs. A URI instance exposes the address as a Helpthehomeless Address object and the amount in satoshis, if present.
The code for validating URIs looks like this:
var uriString = 'helpthehomeless:XuUGDZHrKLo841CyamDbG5W7n59epA71h2?amount=1.2';
var valid = URI.isValid(uriString);
var uri = new URI(uriString);
console.log(uri.address.network, uri.amount); // 'livenet', 120000000All 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()) //helpthehomeless:XuUGDZHrKLo841CyamDbG5W7n59epA71h2?amount=0.0001&message=My%20payment%20requestMethods toObject, toJSON and inspect remain available.
var uri = new URI("helpthehomeless:XuUGDZHrKLo841CyamDbG5W7n59epA71h2?amount=0.0001&message=My%20payment%20request>")
var uri = new URI({
address:"XuUGDZHrKLo841CyamDbG5W7n59epA71h2",
amount:"10000",
message:"My payment request"
})