-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SLP.ECPair.toSLPAddress method and tests.
- Loading branch information
Gabriel Cardona
committed
May 6, 2019
1 parent
37af3d8
commit bbbcea4
Showing
10 changed files
with
95 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
"use strict"; | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// require deps | ||
var BITBOXECPair = require("bitbox-sdk/lib/ECPair").default; | ||
var BITBOXSDK = require("bitbox-sdk"); | ||
var BITBOX = new BITBOXSDK(); | ||
var utils = require("slpjs").Utils; | ||
var ECPair = /** @class */ (function (_super) { | ||
__extends(ECPair, _super); | ||
function ECPair() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
ECPair.toSLPAddress = function (ecpair) { | ||
try { | ||
var slpAddress = utils.toSlpAddress(BITBOX.ECPair.toCashAddress(ecpair)); | ||
return slpAddress; | ||
} | ||
catch (err) { | ||
return err; | ||
} | ||
}; | ||
return ECPair; | ||
}(BITBOXECPair)); | ||
exports.default = ECPair; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// require deps | ||
const BITBOXECPair = require("bitbox-sdk/lib/ECPair").default | ||
const BITBOXSDK = require("bitbox-sdk") | ||
const BITBOX = new BITBOXSDK() | ||
const utils = require("slpjs").Utils | ||
|
||
class ECPair extends BITBOXECPair { | ||
static toSLPAddress(ecpair: any): string { | ||
try { | ||
const slpAddress: string = utils.toSlpAddress( | ||
BITBOX.ECPair.toCashAddress(ecpair) | ||
) | ||
return slpAddress | ||
} catch (err) { | ||
return err | ||
} | ||
} | ||
} | ||
|
||
export default ECPair |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
"use strict" | ||
const assert = require("assert") | ||
const slp = require("./../lib/SLP") | ||
const SLP = new slp({ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const fixtures = require("./fixtures/ECPair.json") | ||
const assert = require("assert") | ||
const assert2 = require("chai").assert | ||
const slp = require("./../lib/SLP") | ||
const SLP = new slp() | ||
|
||
// Used for debugging and iterrogating JS objects. | ||
const util = require("util") | ||
util.inspect.defaultOptions = { depth: 1 } | ||
|
||
describe("#ECPair", () => { | ||
describe("#toSLPAddress", () => { | ||
it(`should return slp address for ecpair`, async () => { | ||
fixtures.wif.forEach((wif, index) => { | ||
const ecpair = SLP.ECPair.fromWIF(wif) | ||
const slpAddr = SLP.ECPair.toSLPAddress(ecpair) | ||
assert.equal(slpAddr, fixtures.address[index]) | ||
}) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"wif": [ | ||
"cUCSrdhu7mCzx4sWqL6irqzprkofxPmLHYgkSnG2WaWVqJDXtWRS", | ||
"cNVP2nTzUMFerfpjrTuDgoFGnKAfjZznKomknUVKQSdFHqK5cRc5" | ||
], | ||
"address": [ | ||
"slptest:qq835u5srlcqwrtwt6xm4efwan30fxg9hcqag6fk03", | ||
"slptest:qrj9k49drcsk4al8wxn53hnkfvts6ew5jvv32952nh" | ||
] | ||
} |