}),\r
\r
suite('Block signing using official test vectors', async () => {\r
- const { ADDRESS_0, BIP39_SEED, BLAKE2B_ADDRESS_1, BLAKE2B_PUBLIC_1, BLAKE2B_SEED, OPEN_BLOCK, PASSWORD, PRIVATE_0, RECEIVE_BLOCK, SEND_BLOCK } = NANO_TEST_VECTORS\r
+ const { ADDRESS_0, BIP39_SEED, BLAKE2B_ADDRESS_1, BLAKE2B_PUBLIC_1, BLAKE2B_SEED, OPEN_BLOCK, PASSWORD, PUBLIC_0, PRIVATE_0, RECEIVE_BLOCK, SEND_BLOCK } = NANO_TEST_VECTORS\r
\r
await test('sign open block with BLAKE2b wallet', async () => {\r
const wallet = await Wallet.load('BLAKE2b', PASSWORD, BLAKE2B_SEED)\r
\r
const block = new Block(BLAKE2B_ADDRESS_1, '0', OPEN_BLOCK.previous, OPEN_BLOCK.representative)\r
.receive(OPEN_BLOCK.link, OPEN_BLOCK.balance)\r
- const signature = await wallet.sign(1, block, 'hex')\r
- assert.equal(block.signature, signature)\r
+ await wallet.sign(1, block)\r
assert.ok(await block.verify(BLAKE2B_PUBLIC_1))\r
\r
await wallet.destroy()\r
\r
const block = new Block(ADDRESS_0, '0', OPEN_BLOCK.previous, OPEN_BLOCK.representative)\r
.receive(OPEN_BLOCK.link, OPEN_BLOCK.balance)\r
- const signature = await wallet.sign(0, block, 'hex')\r
- assert.equal(block.signature, signature)\r
+ await wallet.sign(0, block)\r
+ assert.ok(await block.verify(PUBLIC_0))\r
\r
await wallet.destroy()\r
})\r
*/
let Account
/**
-* @type {typeof import('../dist/types.d.ts').Bip44Wallet}
+* @type {typeof import('../dist/types.d.ts').Wallet}
*/
-let Bip44Wallet
+let Wallet
/**
* @type {typeof import('../dist/types.d.ts').Rpc}
*/
let Rpc
if (isNode) {
- ({ Account, Bip44Wallet, Rpc } = await import('../dist/nodejs.min.js'))
+ ({ Account, Wallet, Rpc } = await import('../dist/nodejs.min.js'))
} else {
- ({ Account, Bip44Wallet, Rpc } = await import('../dist/browser.min.js'))
+ ({ Account, Wallet, Rpc } = await import('../dist/browser.min.js'))
}
const rpc = new Rpc(env.NODE_URL ?? '', env.API_KEY_NAME)
suite('Refreshing account info', { skip: true }, async () => {
await test('fetch balance, frontier, and representative', async () => {
- const wallet = await Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)
+ const wallet = await Wallet.load('BIP-44', NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)
const account = await wallet.account()
await account.refresh(rpc)
})
await test('throw when refreshing unopened account', async () => {
- const wallet = await Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)
+ const wallet = await Wallet.load('BIP-44', NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)
const account = await wallet.account(0x7fffffff)
})
await test('throw when referencing invalid account index', async () => {
- const wallet = await Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)
+ const wallet = await Wallet.load('BIP-44', NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)
await assert.rejects(wallet.account(0x80000000),
})
await test('throw with invalid node', async () => {
- const wallet = await Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)
+ const wallet = await Wallet.load('BIP-44', NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)
const invalidNode = new Rpc('http://invalid.com')
const account = await wallet.account()
suite('Fetch next unopened account', { skip: true }, async () => {
await test('return correct account from test vector', async () => {
- const wallet = await Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)
+ const wallet = await Wallet.load('BIP-44', NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)
const account = await wallet.unopened(rpc)
})
await test('return successfully for small batch size', async () => {
- const wallet = await Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)
+ const wallet = await Wallet.load('BIP-44', NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)
const account = await wallet.unopened(rpc, 1)
})
await test('return successfully for large batch size', async () => {
- const wallet = await Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)
+ const wallet = await Wallet.load('BIP-44', NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)
const account = await wallet.unopened(rpc, 100)
})
await test('should throw on invalid node URL', async () => {
- const wallet = await Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)
+ const wallet = await Wallet.load('BIP-44', NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)
//@ts-expect-error
})
await test('should throw on invalid batch size', async () => {
- const wallet = await Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)
+ const wallet = await Wallet.load('BIP-44', NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)
//@ts-expect-error
suite('Refreshing wallet accounts', { skip: true }, async () => {
await test('should get balance, frontier, and representative for one account', async () => {
- const wallet = await Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)
+ const wallet = await Wallet.load('BIP-44', NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)
const accounts = await wallet.refresh(rpc)
const account = accounts[0]
})
await test('should get balance, frontier, and representative for multiple accounts', async () => {
- const wallet = await Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)
+ const wallet = await Wallet.load('BIP-44', NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)
const accounts = await wallet.refresh(rpc, 0, 2)
})
await test('should handle failure gracefully', async () => {
- const wallet = await Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)
+ const wallet = await Wallet.load('BIP-44', NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)
await assert.resolves(wallet.refresh(rpc, 0, 20))