btc: update uri for bech32 addresses.

This commit is contained in:
Christopher Jeffrey 2017-05-13 20:54:34 -07:00
parent 5ff46dd36d
commit 2997333122
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -88,10 +88,11 @@ URI.fromOptions = function fromOptions(options) {
* Parse and inject properties from string.
* @private
* @param {String} str
* @param {Network?} network
* @returns {URI}
*/
URI.prototype.fromString = function fromString(str) {
URI.prototype.fromString = function fromString(str, network) {
var prefix, index, query, address;
assert(typeof str === 'string');
@ -112,7 +113,7 @@ URI.prototype.fromString = function fromString(str) {
query = str.substring(index + 1);
}
this.address.fromBase58(address);
this.address.fromString(address, network);
if (!query)
return this;
@ -140,11 +141,12 @@ URI.prototype.fromString = function fromString(str) {
/**
* Instantiate uri from string.
* @param {String} str
* @param {Network?} network
* @returns {URI}
*/
URI.fromString = function fromString(str) {
return new URI().fromString(str);
URI.fromString = function fromString(str, network) {
return new URI().fromString(str, network);
};
/**
@ -156,7 +158,7 @@ URI.prototype.toString = function toString() {
var str = 'bitcoin:';
var query = [];
str += this.address.toBase58();
str += this.address.toString();
if (this.amount !== -1)
query.push('amount=' + Amount.btc(this.amount));