Skip to content

Commit

Permalink
Merge pull request #5 from Peach2Peach/update-readme
Browse files Browse the repository at this point in the history
Update readme
  • Loading branch information
Czino authored Nov 14, 2023
2 parents 63b9808 + f34add6 commit a6d21ce
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,16 @@ cd ios && pod install

### Create a Wallet & sync the balance of a descriptor

```js
```ts
import { DescriptorSecretKey, Mnemonic, Blockchain, Wallet, DatabaseConfig, Descriptor } from 'bdk-rn';
import { WordCount, Network } 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);
const externalDescriptor = await new Descriptor().newBip84(descriptorSecretKey, KeychainKind.External, Network.Testnet);
const internalDescriptor = await new Descriptor().newBip84(descriptorSecretKey, KeychainKind.Internal, Network.Testnet);

const config: BlockchainElectrumConfig = {
url: 'ssl://electrum.blockstream.info:60002',
Expand All @@ -82,24 +82,34 @@ await wallet.sync(blockchain);

### Create a `public` wallet descriptor

```js
```ts
import { DescriptorSecretKey, Mnemonic, Descriptor } from 'bdk-rn';
import { WordCount, Network, KeyChainKind } from 'bdk-rn/lib/lib/enums';
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 descriptorPublicKey = await descriptorSecretKey.asPublic();
const fingerprint = 'd1d04177';
const externalPublicDescriptor = await new Descriptor().newBip44Public(
const externalPublicDescriptor = await new Descriptor().newBip84Public(
descriptorPublicKey,
fingerprint,
KeychainKind.External,
Network.Testnet
);
```

### Store wallet data persistently
```ts
import RNFS from 'react-native-fs'
import { DatabaseConfig, ... } from 'bdk-rn';

// create sqlite database config with rn document directory path
const dbConfig = await new DatabaseConfig().sqlite(`${RNFS.DocumentDirectoryPath}/bdk-wallet`)

```

### References:
- Setting up a local Esplora instance for testing:
https://bitcoin.stackexchange.com/questions/116937/how-do-i-setup-an-esplora-instance-for-local-testing/116938#116938
Expand Down

0 comments on commit a6d21ce

Please sign in to comment.