-
Notifications
You must be signed in to change notification settings - Fork 129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use this version of bip32 to port some code? #78
Comments
Your code doesn't do anything with bip32. It creates the You essentially are just using I am confused as to what you are asking here. |
The definition for Qtum Wallet: |
Pass I don't even know what You aren't giving me enough information. |
Hi, I show you the original code using old version of 'bitcoinjs-lib': messagePrefix: string // HDWallet https://en.bitcoin.it/wiki/BIP_0032 pubKeyHash: number /** */
} => The old code seems to be good for old version of 'bitcoinjs-lib', but I want to use new version, I have no idea on how to port from old 'bitcoinjs-lib' to new version. |
This still doesn't tell me what Did you read the examples? Like this one? In this example, the variable |
Hello: |
Please read the example I posted. In response to your explanation: Yes, I know what ethers is. When I say "What is ethers?" it means "What is this doing here in the code? Why are you using it? Is there a specific reason why it needs to be used in this way?" To give another example of this English used in a different context: If you hand me a pizza with a dead bird on top of it, and I say "What is this bird?" I am not asking you to link a Wikipedia article on the exact species of bird and all the information about the bird's migration patterns. I am asking "Under the pretense that dead birds shouldn't be on top of pizza, I would like to ask you why there is a bird on this pizza when there is no need. Did you put it there? Did the store clerk put it there? Is this a special exotic pizza where I'm supposed to eat the dead bird?" etc. but all of that is shortened down to "What is this bird?" |
Hi, import { HDNode, ECPair } from "bitcoinjs-lib"
} |
Please click this link and read the example: https://github.com/bitcoinjs/bitcoinjs-lib/blob/v6.1.1/test/integration/bip32.spec.ts#L103-L120 |
Hi, I read the example, but I have some strange issues with the following code: const bip32 = BIP32Factory(ecc); const bip32 = BIP32Factory(ecc); => |
Hello:
I want to port some old code to new code. I am trying to create some QTUM wallet, which has the derivePath of "m/88'/0'/0'".
The Wallet definition for QTUM looks like this:
export class Wallet {
public address: string
private insight: Insight
constructor(public keyPair: bip32.BIP32Interface,
public network: INetworkInfo)
{
this.address = this.keyPair.toBase58();
this.insight = Insight.forNetwork(this.network)
}
I want to use the following TS code:
import * as ecc from 'tiny-secp256k1';
import { BIP32Factory } from 'bip32';
export class Network {
constructor(public info: INetworkInfo) {}
/**
*/
public fromMnemonic(mnemonic: string, password?: string): Wallet {
const hdNode = ethers.HDNodeWallet.fromMnemonic(mnemonic, password);
const accountNode = hdNode.derivePath("m/88'/0'/0'");
const privateKey = accountNode.privateKey;
const bip32 = BIP32Factory(ecc);
const chainCode = accountNode.chainCode;
const node = bip32.fromPrivateKey(Buffer.from(privateKey), Buffer.from(chainCode));
const keyPair = KeyPair.fromPrivateKey(Buffer.from(privateKey));
return new Wallet(keyPair, this.info);
}
But the keyPair is not correct. I think keyPair is only one data type for private_key and public_key, right?
However, I don’t know how to get a public key from the private key.
Please let me know how can I make the code to work?
PS: I am using Node.js version 20.2 on Windows 10 (22H2)
Thanks,
The text was updated successfully, but these errors were encountered: