Skip to content
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

Upgrade to bdk ffi v0.31.0 #72

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
## [0.31.0]

#### APIs Changed:

- `BumpFeeTxBuilder.allowShrinking()` now takes a `Script` as its argument.
- The `Address` constructor now takes a `Network` argument.
- The `Payload::PubkeyHash` and `Payload::ScriptHash` now have string arguments instead of byte arrays.

#### APIs Added:

- The `Address` type now has the `isValidForNetwork()` method.

## [0.30.0]

#### APIs added

- Added `BIP-86` descriptor templates

## [0.29.0]

#### APIs added
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ cd ios && pod install

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

// ....

Expand All @@ -69,7 +69,7 @@ const config: BlockchainElectrumConfig = {
sock5: null,
retry: 5,
timeout: 5,
stopGap: 100,
stopGap: 500,
validateDomain: false,
};

Expand Down Expand Up @@ -111,8 +111,10 @@ const dbConfig = await new DatabaseConfig().sqlite(`${RNFS.DocumentDirectoryPath
```

### 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
https://bitcoin.stackexchange.com/questions/116937/how-do-i-setup-an-esplora-instance-for-local-testing/116938#116938

---

_Note: Caution this is an Alpha at this stage
Expand Down
9 changes: 8 additions & 1 deletion __tests__/classes/Address.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('Address', () => {
const addressString = 'tb1qccmtnhczmv3a6k4mtq8twm7ltj3e32qsntmamv';

beforeAll(async () => {
address = await new Address().create('address');
address = await new Address().create('address', Network.Testnet);
});
afterEach(() => {
jest.clearAllMocks();
Expand Down Expand Up @@ -69,4 +69,11 @@ describe('Address', () => {
expect(res).toBe(addressString);
expect(mockBdkRnModule.addressAsString).toHaveBeenCalledWith(address.id);
});

it('verify addressIsValidForNetwork()', async () => {
mockBdkRnModule.addressIsValidForNetwork.mockResolvedValueOnce(true);
let res = await address.isValidForNetwork(Network.Testnet);
expect(res).toBe(true);
expect(mockBdkRnModule.addressIsValidForNetwork).toHaveBeenCalledWith(address.id, Network.Testnet);
});
});
7 changes: 3 additions & 4 deletions __tests__/classes/BumpFeeTxBuilder.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BumpFeeTxBuilder, DatabaseConfig, Descriptor, PartiallySignedTransaction, Wallet } from '../../src';
import { Network } from '../../src/lib/enums';
import { mockWallet } from '../mockData';
import { mockScript, mockWallet } from '../mockData';
import { mockBdkRnModule } from '../setup';

const id = 'instanceId';
Expand All @@ -27,9 +27,8 @@ describe('BumpFeeTxBuilder', () => {
expect(bumpFeeTxBuilder).toBeInstanceOf(BumpFeeTxBuilder);
});
it('should allow shrinking', async () => {
const address = 'address';
await bumpFeeTxBuilder.allowShrinking(address);
expect(mockBdkRnModule.bumpFeeTxBuilderAllowShrinking).toHaveBeenCalledWith(id, address);
await bumpFeeTxBuilder.allowShrinking(mockScript);
expect(mockBdkRnModule.bumpFeeTxBuilderAllowShrinking).toHaveBeenCalledWith(id, mockScript.id);
});
it('should enable rbf', async () => {
await bumpFeeTxBuilder.enableRbf();
Expand Down
1 change: 1 addition & 0 deletions __tests__/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export const mockBdkRnModule = {
addressNetwork: jest.fn(),
addressToQrUri: jest.fn(),
addressAsString: jest.fn(),
addressIsValidForNetwork: jest.fn(),

addRecipient: jest.fn(),
finish: jest.fn(),
Expand Down
6 changes: 6 additions & 0 deletions android/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-16/"/>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
<classpathentry kind="output" path="bin/default"/>
</classpath>
34 changes: 34 additions & 0 deletions android/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>bdk-rn</name>
<comment>Project bdk-rn created by Buildship.</comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
<filteredResources>
<filter>
<id>1706000397923</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
13 changes: 13 additions & 0 deletions android/.settings/org.eclipse.buildship.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
arguments=--init-script /var/folders/77/pwdxzmrn7p53dyts2cw8s2ch0000gn/T/d146c9752a26f79b52047fb6dc6ed385d064e120494f96f08ca63a317c41f94c.gradle --init-script /var/folders/77/pwdxzmrn7p53dyts2cw8s2ch0000gn/T/52cde0cfcf3e28b8b7510e992210d9614505e0911af0c190bd590d7158574963.gradle
auto.sync=false
build.scans.enabled=false
connection.gradle.distribution=GRADLE_DISTRIBUTION(VERSION(8.1.1))
connection.project.dir=
eclipse.preferences.version=1
gradle.user.home=
java.home=/Library/Java/JavaVirtualMachines/jdk-18.0.2.jdk/Contents/Home
jvm.arguments=
offline.mode=false
override.workspace.settings=true
show.console.view=true
show.executions.view=true
4 changes: 4 additions & 0 deletions android/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=16
org.eclipse.jdt.core.compiler.compliance=16
org.eclipse.jdt.core.compiler.source=16
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@ dependencies {
implementation 'com.facebook.react:react-native:+'

// bitcoindevkit
implementation 'org.bitcoindevkit:bdk-android:0.29.0'
implementation 'org.bitcoindevkit:bdk-android:0.31.0'
}
Loading
Loading