Skip to content

Commit f008f34

Browse files
committed
Fix bug in getBackupSigningKey
This function was missing a function application at the end, meaning that its return type was function and not string as it should be. This has now been fixed. It took me a bit too long to find this bug so included in this commit is a small change to make the code a bit less compact by declaring the return value from getBackupSigningKey to an appropriately named local variable. Also improves nomenclature in getBackupSigningKey by explictly distinguishing between regular private keys and extended private keys.
1 parent 92fcff3 commit f008f34

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

app/sign.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,14 @@ const promptForConfirmationAndKey = function(recoveryRequest, outputs, skipConfi
120120

121121
/**
122122
* Gets the backup private key that can be used to sign the transaction.
123-
* @param key The provided private key.
123+
* @param xprv The provided extended private key (BIP32).
124124
* @param expectedXpub The public key specified with the request.
125125
* @returns The private key to sign the transaction.
126126
*/
127-
const getBackupSigningKey = function(key, expectedXpub) {
128-
const backupKeyNode = getHDNodeAndVerify(key, expectedXpub);
127+
const getBackupSigningKey = function(xprv, expectedXpub) {
128+
const backupKeyNode = getHDNodeAndVerify(xprv, expectedXpub);
129129

130-
return backupKeyNode.keyPair.getPrivateKeyBuffer;
130+
return backupKeyNode.keyPair.getPrivateKeyBuffer();
131131
}
132132

133133
const handleSignUtxo = function(recoveryRequest, key, skipConfirm) {
@@ -237,8 +237,9 @@ const signEthTx = function(recoveryRequest, key, skipConfirm, isToken) {
237237
}
238238

239239
key = promptForConfirmationAndKey(recoveryRequest, outputs, skipConfirm, key);
240+
const signingKey = getBackupSigningKey(key, recoveryRequest.backupKey);
240241

241-
transaction.sign(getBackupSigningKey(key, recoveryRequest.backupKey));
242+
transaction.sign(signingKey);
242243

243244
return transaction.serialize().toString('hex');
244245
};
@@ -258,8 +259,9 @@ const handleSignTrx = function(recoveryRequest, key, skipConfirm) {
258259
});
259260

260261
key = promptForConfirmationAndKey(recoveryRequest, outputs, skipConfirm, key);
262+
const signingKey = getBackupSigningKey(key, recoveryRequest.backupKey);
261263

262-
builder.sign({ key: getBackupSigningKey(key, recoveryRequest.backupKey) });
264+
builder.sign({ key: signingKey });
263265
return JSON.stringify(builder.build().toJson());
264266
};
265267

0 commit comments

Comments
 (0)