Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix testnet WIF for derived addresses and bip47 #49

Merged
merged 1 commit into from
May 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/www/js/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -1381,19 +1381,22 @@ const calcBip47 = () => {
// make sure we have a valid seed and mnemonic
if (!getPhrase() || !bip32RootKey) return;
const mySeed = bip39.mnemonicToSeedSync(getPhrase(), getPassphrase());
const myNetwork = bip47.utils.networks[DOM.bip47Network.value];
myPayCode = bip47.fromWalletSeed(
mySeed,
0,
bip47.utils.networks[DOM.bip47Network.value]
myNetwork
);
const myNotify = myPayCode.derive(0);
const myPrvKey = myNotify.privateKey;
const myPubKey = myNotify.publicKey;
const myNotificationAddress = myPayCode.getNotificationAddress();
const myWIF = bitcoin.ECPair.fromPrivateKey(myPrvKey, {
network: myNetwork
}).toWIF();
DOM.bip47MyPaymentCode.value = myPayCode.toBase58();
DOM.bip47MyNotificationAddress.value = myNotificationAddress;
DOM.bip47MyNotificationPrvKey.value =
bitcoin.ECPair.fromPrivateKey(myPrvKey).toWIF();
DOM.bip47MyNotificationPrvKey.value = myWIF;
DOM.bip47MyNotificationPubKey.value = myPubKey.toString('hex');
fetchRobotImages();
addQRIcon(
Expand Down Expand Up @@ -1924,8 +1927,9 @@ const calculateAddresses = (startIndex = 0, endIndex = 19) => {
const address = getAddress(addressNode);
const addressPubKey = addressNode.publicKey.toString('hex');
const addressPrivKey = bitcoin.ECPair.fromPrivateKey(
addressNode.privateKey
).toWIF();
addressNode.privateKey, {
network: network
}).toWIF();
addressDataArray[i] = new AddressData(
addressPath,
address,
Expand Down