1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-18 20:38:10 +00:00

Adding segwit test vector

This commit is contained in:
Karel Bilek 2017-03-31 22:19:37 +02:00 committed by Pavol Rusnak
parent 6089167f65
commit 0094706e0e
4 changed files with 1032 additions and 4 deletions

View File

@ -34,4 +34,4 @@ docker-build:
docker run --rm -v $(shell pwd)/..:/src apiaryio/emcc /bin/bash -c 'cd emscripten && make'
test-correctness: node_modules
node test-correctness.js
node test-correctness.js test-correctness-segwit-p2sh.js

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,30 @@
var crypto = require('./trezor-crypto');
var bitcoin = require('bitcoinjs-lib');
var XPUB =
'xpub6CVKsQYXc9awxgV1tWbG4foDvdcnieK2JkbpPEBKB5WwAPKBZ1mstLbKVB4ov7QzxzjaxNK6EfmNY5Jsk2cG26EVcEkycGW4tchT2dyUhrx';
var node = bitcoin.HDNode.fromBase58(XPUB).derive(0);
var nodeStruct = {
depth: node.depth,
child_num: node.index,
fingerprint: node.parentFingerprint,
chain_code: node.chainCode,
public_key: node.keyPair.getPublicKeyBuffer()
};
var addresses = crypto.deriveAddressRange(nodeStruct, 0, 999, 5, true);
var fs = require('fs');
var loaded = fs.readFileSync('test-addresses-segwit-p2sh.txt').toString().split("\n");
for (var i = 0; i < 1000; i++) {
if (loaded[i] !== addresses[i]) {
console.log("bad address", i);
process.exit(1)
}
}
console.log("Testing address ended correctly");
process.exit(0)

View File

@ -15,9 +15,6 @@ var nodeStruct = {
var addresses = crypto.deriveAddressRange(nodeStruct, 0, 999, 0, false);
// for segwit:
// var addresses = crypto.deriveAddressRange(nodeStruct, 0, 999, 5, true);
var fs = require('fs');
var loaded = fs.readFileSync('test-addresses.txt').toString().split("\n");