LtbLightning / bdk-rn

Bitcoin Development Kit - React Native Module
MIT License
51 stars 15 forks source link

Typo's in the examples in README.md #66

Closed CandidateBlock closed 1 year ago

CandidateBlock commented 1 year ago

Hi Bitcoin Zavior, thanks for writing this code to bridge react-native to BDK. This is the first time using and just noticed a few Typo's (I think) on the examples (which are now very different to the tutorial you did with with Conor from Bitcoin Developers...)

Create a Wallet & sync the balance of a descriptor

Current

const externalDescriptor = await new Descriptor().newBip44(descriptorSecretKey, KeyChainKind.External, Network.Testnet);
const internalDescriptor = await new Descriptor().newBip44(descriptorSecretKey, KeyChainKind.Internal, Network.Testnet);

I think KeyChainKind should be KeychainKind - c in chain is lowercase

and the import from 'bdk-rn/lib/lib/enums' need to include KeychainKind

*Updated - changes show by (star)**

import { DescriptorSecretKey, Mnemonic, Blockchain, Wallet, DatabaseConfig, Descriptor } from 'bdk-rn';
import { WordCount, Network, *KeychainKind* } from 'bdk-rn/lib/lib/enums';

// ....

  const mnemonic = await new Mnemonic().create(WordCount.WORDS12);
  const descriptorSecretKey = await new DescriptorSecretKey().create(Network.Testnet, mnemonic);
  const externalDescriptor = await new Descriptor().newBip44(descriptorSecretKey, *KeychainKind*.External, Network.Testnet);
  const internalDescriptor = await new Descriptor().newBip44(descriptorSecretKey, *KeychainKind*.Internal, Network.Testnet);

A similar typo is in the second example Create a public wallet descriptor

Current

import { WordCount, Network, KeyChainKind } from 'bdk-rn/lib/lib/enums';

*Updated - changes show by (star)* Lower case c in chain on import (case is correct in code) `import { WordCount, Network, KeychainKind* } from 'bdk-rn/lib/lib/enums';`

Thanks

Quick question: for the Descriptor was using the old legacy .newBip44 intentional? I was using Sparrow wallet on Testnet to check the mnemonic works and send some initial funds and took me a while to work out its Bip44 not Bip84. I changed to Bip84 and sent testnet coins and the balance updated on Sparrow Wallet and using wallet.sync! Which is great. (I guess I could have made a legacy wallet with Sparrow and would have worked but...)

BitcoinZavior commented 1 year ago

Thanks @CandidateBlock for the issue. @Czino to the rescue 🚀 Thanks a ton!