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:
parent
6089167f65
commit
0094706e0e
@ -34,4 +34,4 @@ docker-build:
|
|||||||
docker run --rm -v $(shell pwd)/..:/src apiaryio/emcc /bin/bash -c 'cd emscripten && make'
|
docker run --rm -v $(shell pwd)/..:/src apiaryio/emcc /bin/bash -c 'cd emscripten && make'
|
||||||
|
|
||||||
test-correctness: node_modules
|
test-correctness: node_modules
|
||||||
node test-correctness.js
|
node test-correctness.js test-correctness-segwit-p2sh.js
|
||||||
|
1001
emscripten/test-addresses-segwit-p2sh.txt
Normal file
1001
emscripten/test-addresses-segwit-p2sh.txt
Normal file
File diff suppressed because it is too large
Load Diff
30
emscripten/test-correctness-segwit-p2sh.js
Normal file
30
emscripten/test-correctness-segwit-p2sh.js
Normal 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)
|
||||||
|
|
@ -15,9 +15,6 @@ var nodeStruct = {
|
|||||||
|
|
||||||
var addresses = crypto.deriveAddressRange(nodeStruct, 0, 999, 0, false);
|
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 fs = require('fs');
|
||||||
var loaded = fs.readFileSync('test-addresses.txt').toString().split("\n");
|
var loaded = fs.readFileSync('test-addresses.txt').toString().split("\n");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user