Skip to content

Commit 0baab65

Browse files
authored
Merge pull request #46 from Developerayo/patch/bitcoin
fix param order for bitcoin wallets gen
2 parents fa9cc19 + 6eb3b0a commit 0baab65

File tree

3 files changed

+30
-4
lines changed

3 files changed

+30
-4
lines changed

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
"start": "tsdx watch",
1515
"build": "tsdx build",
1616
"test": "tsdx test",
17+
"test:btc": "tsdx test --testPathPattern=bitcoin",
18+
"test:eth": "tsdx test --testPathPattern=ethereum",
19+
"test:sol": "tsdx test --testPathPattern=solana",
20+
"test:tron": "tsdx test --testPathPattern=tron",
21+
"test:waves": "tsdx test --testPathPattern=waves",
1722
"lint": "tsdx lint",
1823
"prepare": "tsdx build",
1924
"size": "size-limit",

src/services/wallet/index.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,18 @@ function generateWalletFromMnemonic(args: GenerateWalletFromMnemonicPayload) {
110110
throw new Error('Invalid network');
111111
}
112112

113-
return helper.generateWalletFromMnemonic(
114-
args.mnemonic,
115-
args.derivationPath
116-
);
113+
if (args.network.startsWith('bitcoin')) {
114+
return helper.generateWalletFromMnemonic(
115+
args.network,
116+
args.mnemonic,
117+
args.derivationPath
118+
);
119+
} else {
120+
return helper.generateWalletFromMnemonic(
121+
args.mnemonic,
122+
args.derivationPath
123+
);
124+
}
117125
} catch (error) {
118126
throw error;
119127
}

test/wallet.bitcoin.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ describe('MultichainCryptoWallet Bitcoin tests', () => {
2121
network: 'bitcoin', // 'bitcoin' or 'bitcoin-testnet'
2222
});
2323

24+
console.log('Wallet:', {
25+
address: wallet.address,
26+
privateKey: wallet.privateKey,
27+
mnemonic: wallet.mnemonic,
28+
});
29+
2430
expect(typeof wallet).toBe('object');
2531
});
2632

@@ -31,6 +37,13 @@ describe('MultichainCryptoWallet Bitcoin tests', () => {
3137
derivationPath: "m/44'/0'/0'/0/0", // Leave empty to use default derivation path
3238
network: 'bitcoin', // 'bitcoin' or 'bitcoin-testnet'
3339
});
40+
41+
console.log('Wallet from mnemonic:', {
42+
address: wallet.address,
43+
privateKey: wallet.privateKey,
44+
mnemonic: wallet.mnemonic,
45+
});
46+
3447
expect(wallet.address).toBe('1NV8FPKDW1hxJFxc2dNVZDAp7iCqxCLeFu');
3548
expect(wallet.privateKey).toBe(
3649
'KxqTGtCMnX6oL9rxynDKCRJXt64Gm5ame4AEQcYncFhSSUxFBkeJ'

0 commit comments

Comments
 (0)