mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-18 12:28:09 +00:00
upgrade bitcoinjs-lib, rename params
This commit is contained in:
parent
3c0176a304
commit
07200a30e6
@ -3,6 +3,6 @@
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"dependencies": {
|
||||
"bitcoinjs-lib": "^1.5.7"
|
||||
"bitcoinjs-lib": "^2.1.1"
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ var _address = _malloc(ADDRESS_SIZE);
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param {HDNode} node HDNode struct, see the definition above
|
||||
* @param {HDNode} node HDNode struct, see the definition above
|
||||
* @return {Uint8Array}
|
||||
*/
|
||||
function serializeNode(node) {
|
||||
@ -47,9 +47,9 @@ function serializeNode(node) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Uint8Array} sn serialized node, see `serializeNode`
|
||||
* @param {Number} index BIP32 index of the address
|
||||
* @param {Number} version address version byte
|
||||
* @param {Uint8Array} sn serialized node, see `serializeNode`
|
||||
* @param {Number} index BIP32 index of the address
|
||||
* @param {Number} version address version byte
|
||||
* @return {String}
|
||||
*/
|
||||
function deriveAddress(sn, index, version) {
|
||||
@ -60,17 +60,17 @@ function deriveAddress(sn, index, version) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {HDNode} node HDNode struct, see the definition above
|
||||
* @param {Number} from index of the first address
|
||||
* @param {Number} to index of the last address
|
||||
* @param {Number} version address version byte
|
||||
* @param {HDNode} node HDNode struct, see the definition above
|
||||
* @param {Number} firstIndex index of the first address
|
||||
* @param {Number} lastIndex index of the last address
|
||||
* @param {Number} version address version byte
|
||||
* @return {Array<String>}
|
||||
*/
|
||||
function deriveAddressRange(node, from, to, version) {
|
||||
function deriveAddressRange(node, firstIndex, lastIndex, version) {
|
||||
var addresses = [];
|
||||
var sn = serializeNode(node);
|
||||
var i;
|
||||
for (i = from; i <= to; i++) {
|
||||
for (i = firstIndex; i <= lastIndex; i++) {
|
||||
addresses.push(deriveAddress(sn, i, version));
|
||||
}
|
||||
return addresses;
|
||||
@ -94,13 +94,17 @@ function processMessage(event) {
|
||||
|
||||
switch (type) {
|
||||
case 'deriveAddressRange':
|
||||
var response = deriveAddressRange(
|
||||
var addresses = deriveAddressRange(
|
||||
data['node'],
|
||||
data['from'],
|
||||
data['to'],
|
||||
data['firstIndex'],
|
||||
data['lastIndex'],
|
||||
data['version']
|
||||
);
|
||||
postMessage(response);
|
||||
postMessage({
|
||||
'addresses': addresses,
|
||||
'firstIndex': data['firstIndex'],
|
||||
'lastIndex': data['lastIndex']
|
||||
});
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -11,7 +11,7 @@ var nodeStruct = {
|
||||
child_num: node.index,
|
||||
fingerprint: node.parentFingerprint,
|
||||
chain_code: node.chainCode,
|
||||
public_key: node.pubKey.toBuffer()
|
||||
public_key: node.keyPair.getPublicKeyBuffer().toString('hex')
|
||||
};
|
||||
var nodeSerialized = crypto.serializeNode(nodeStruct);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user