Support bitmessage: scheme in Address.decode

This commit is contained in:
Kagami Hiiragi 2015-03-01 20:37:22 +03:00
parent 68e5bae278
commit 542d31d387
2 changed files with 7 additions and 0 deletions

View File

@ -91,6 +91,8 @@ Address.decode = function(str) {
str = str.trim();
if (str.slice(0, 3) === "BM-") {
str = str.slice(3);
} else if (str.slice(0, 11) === "bitmessage:") {
str = str.slice(11);
}
var bytes = bs58.decode(str);

View File

@ -1205,6 +1205,11 @@ describe("High-level classes", function() {
expect(addr.ripe.toString("hex")).to.equal("003ab6655de4bd8c603eba9b00dd5970725fdd56");
});
it("should decode address for bitmessage scheme", function() {
var addr = Address.decode("bitmessage:2cTux3PGRqHTEH6wyUP2sWeT4LrsGgy63z");
expect(addr.ripe.toString("hex")).to.equal("003ab6655de4bd8c603eba9b00dd5970725fdd56");
});
it("should allow to create random Bitmessage address", function() {
this.timeout(60000);
var addr = Address.fromRandom();