Compare commits

..

266 Commits

Author SHA1 Message Date
thunderbiscuit
485f4f72ce Bump version to 0.9.0 2022-09-08 15:18:48 -04:00
thunderbiscuit
37dddd05f6 Update changelog for 0.9.0 release 2022-09-08 15:17:35 -04:00
Steve Myers
dfb350e206 Merge bitcoindevkit/bdk-ffi#193: Update bdk dependency to 0.22
3c6075ad96 Add Balance struct and conversion from BdkBalance (thunderbiscuit)
4e15badb14 Update BDK to version 0.22 (thunderbiscuit)

Pull request description:

  The bindings do not build when attempting this upgrade because `get_balance()` now returns a `Balance` struct (this was merged in bitcoindevkit/bdk#640)

  ```sh
  error[E0308]: mismatched types
     --> src/lib.rs:433:9
      |
  432 |     fn get_balance(&self) -> Result<u64, Error> {
      |                              ------------------ expected `Result<u64, bdk::Error>` because of return type
  433 |         self.get_wallet().get_balance()
      |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `u64`, found struct `Balance`
      |
      = note: expected enum `Result<u64, _>`
                 found enum `Result<Balance, _>`

  For more information about this error, try `rustc --explain E0308`.
  error: could not compile `bdk-ffi` due to previous error
  ```

  When we upgrade to `0.22.0` we could decide to add the `Balance` struct to the bindings, or simply return the total by calling `get_total()`, which returns a `u64` (same as we have now).

ACKs for top commit:
  notmandatory:
    ACK 3c6075ad96

Tree-SHA512: 13d2f83f992735f4f9619ae339d7834df08385129edf06bac830c298b433571af3f211e92a6da1f4f9646dec27dbd2c6133a035f26eac8757b7a1c94b54b463d
2022-09-08 13:58:27 -05:00
thunderbiscuit
3c6075ad96 Add Balance struct and conversion from BdkBalance 2022-09-08 08:35:10 -05:00
thunderbiscuit
4e15badb14 Update BDK to version 0.22 2022-09-08 08:34:56 -05:00
Steve Myers
f05a6648a7 Refactor TransactionDetails to include confirmation_time (#190) 2022-09-05 14:02:29 -04:00
thunderbiscuit
297680b7c2 Merge pull request #194 from thunderbiscuit/update/uniffi-bindgen
Update uniffi-bindgen to 0.19.5
2022-09-05 13:36:07 -04:00
Steve Myers
8166f820b4 Add README info badges for MSRV and other links 2022-09-05 12:04:08 -05:00
Steve Myers
4f20966ddd Update CI test rust versions to 1.61 and 1.63 2022-09-05 11:46:26 -05:00
thunderbiscuit
d447aac9ae Update uniffi-bindgen to 0.19.5 2022-09-02 13:11:31 -04:00
thunderbiscuit
159e7ab4af Pin version of uniffi-bindgen in bdk-ffi-bindgen tool (#189) 2022-08-29 22:08:38 -04:00
thunderbiscuit
bfe03b91b2 Add inline documentation (#171)
* Add docs for AddressInfo and AddressIndex structs

* Add docs for DatabaseConfig and ElectrumConfig

* Add docs for EsploraConfig struct

* Add docs for TransactionDetails struct

* Add docs for OutPoint struct

* Add docs for TxOut struct

* Add docs for TxBuilder
2022-08-29 15:47:37 -04:00
Pedro
3b028ecab1 Expose set_recipients API from TxBuiler (#186) 2022-08-29 09:58:46 -04:00
thunderbiscuit
aa004201b2 Fix method names to mirror Rust bdk API (#185)
* Fix method names to mirror Rust bdk API

* Fix method names to mirror Rust bdk API
2022-08-18 14:35:17 -04:00
thunderbiscuit
eed5554551 Merge pull request #184 from thunderbiscuit/block-height-hash
Add `get_height` and `get_block_hash` methods on blockchain
2022-08-18 14:14:03 -04:00
thunderbiscuit
88427e4a05 Update CHANGELOG.md
Co-authored-by: Steve Myers <github@notmandatory.org>
2022-08-18 14:04:31 -04:00
thunderbiscuit
8248660c52 Merge branch 'master' into block-height-hash 2022-08-18 13:43:18 -04:00
thunderbiscuit
25963ec982 Add get_height and get_block_hash methods on blockchain 2022-08-18 13:39:00 -04:00
Steve Myers
7da28658a5 Merge bitcoindevkit/bdk-ffi#154: Add child key pair generation api
5944756b78 Added tests for DescriptorSecretKey and DescriptorPublicKey (dhruvbaliyan)
58fea6b205 Added interfaces DescriptorSecretKey and DescriptorPublicKey (dhruvbaliyan)
4977cb6d68 Added interface DerivationPath (dhruvbaliyan)
930a1f1eb4 Added generate_mnemonic method (dhruvbaliyan)
973013cbdf Removed ExtendedKeyInfo & related methods (dhruvbaliyan)

Pull request description:

  Would like to know if anything can be improved. Completes #87

Top commit has no ACKs.

Tree-SHA512: a480535c8965015d860336c717ec3c394778ac08194b0336eeba4209f3e3eff2072873a190dd8c9e4fac1e2f712c7040c838dc1c1a757d53c28866f118c99c17
2022-08-18 12:14:35 -05:00
dhruvbaliyan
5944756b78 Added tests for DescriptorSecretKey and DescriptorPublicKey 2022-08-18 04:24:03 +05:30
dhruvbaliyan
58fea6b205 Added interfaces DescriptorSecretKey and DescriptorPublicKey 2022-08-18 04:24:02 +05:30
dhruvbaliyan
4977cb6d68 Added interface DerivationPath 2022-08-18 04:24:02 +05:30
dhruvbaliyan
930a1f1eb4 Added generate_mnemonic method 2022-08-18 04:24:02 +05:30
dhruvbaliyan
973013cbdf Removed ExtendedKeyInfo & related methods 2022-08-18 04:24:01 +05:30
thunderbiscuit
d38737669d Fix bdk-python link in readme (#182) 2022-08-17 17:20:20 -04:00
thunderbiscuit
6896097eb7 Release/0.8 (#177)
* Update changelog to reflect 0.8.0 additions

* Bump version to 0.8.0
2022-07-29 14:08:23 -04:00
Steve Myers
7d95433c28 Merge bitcoindevkit/bdk-ffi#175: Set project MSRV to 1.57.0
6d53cbeb25 Fix fmt error (Steve Myers)
1a12f37a2f Set MSRV to 1.57.0 (Steve Myers)

Pull request description:

  ### Description

  The `master` branch is currently not passing the new github checks.

  A required dependency of `bdk-ffi-bindgen` is `uniffi_bindgen` and it depends on `os_str_bytes` v6.2.0 which has a MSRV of 1.57.0. I therefore had to make the MSRV of `bdk-ffi` also 1.57.0 and update the github actions. This PR also fixes a small `cargo fmt` warning.

  ### Notes to the reviewers

  ```shell
  % cargo +1.56.1 build
  error: package `os_str_bytes v6.2.0` cannot be built because it requires rustc 1.57.0 or newer, while the currently active rustc version is 1.56.1
  ```

  ```shell
  % cargo tree -i os_str_bytes
  os_str_bytes v6.2.0
  └── clap_lex v0.2.4
      └── clap v3.1.18
          └── uniffi_bindgen v0.19.3
              └── bdk-ffi-bindgen v0.2.0 (/Users/steve/git/notmandatory/bdk-ffi/bdk-ffi-bindgen)
  ```

  ### Checklists

  #### All Submissions:

  * [x] I've signed all my commits
  * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md)
  * [x] I ran `cargo fmt` and `cargo clippy` before committing

Top commit has no ACKs.

Tree-SHA512: 87ad4a02d91184b421871354b1f5c31d906bf7460fe992db15666da32a65f13d8fbaf4ae53928f410a7206b195c8dff76af07210c144a4d02854ceb6af265f7e
2022-07-29 09:43:16 -07:00
Steve Myers
6d53cbeb25 Fix fmt error 2022-07-26 12:36:07 -07:00
Steve Myers
1a12f37a2f Set MSRV to 1.57.0 2022-07-26 12:35:41 -07:00
Steve Myers
04022787c4 Merge bitcoindevkit/bdk-ffi#174: Add github workflows for audit, test and fmt
46850ed471 Add github issue templates and PR template (Steve Myers)
49da6fcbae Fix clippy warnings (Steve Myers)
075510d6e4 Add github workflows for audit, test and fmt (Steve Myers)

Pull request description:

  1. Copied and updated github workflows from BDK project.
  2. Fixed clippy warnings.
  3. Added github issue templates and PR templates from BDK project.

  Fixes #88

Top commit has no ACKs.

Tree-SHA512: 7aaca6be0f05d12f4561e165ebc45b52e40200b231b55326732756d45116f371f2da4c5d7cc590cd0af9450c344530f815a357fa979a34d0181efc2149ffccb3
2022-07-26 12:25:25 -07:00
Steve Myers
46850ed471 Add github issue templates and PR template 2022-07-25 13:17:52 -07:00
Steve Myers
49da6fcbae Fix clippy warnings 2022-07-25 13:17:52 -07:00
Steve Myers
075510d6e4 Add github workflows for audit, test and fmt 2022-07-25 13:17:38 -07:00
thunderbiscuit
fa5c67cd05 Bump uniffi-rs to 0.19.3 (#173) 2022-07-25 15:15:23 -04:00
thunderbiscuit
1a20d0a6c2 Merge pull request #164 from zoedberg/coin_selection
Add coin selection methods
2022-07-21 15:39:55 -04:00
Zoe Faltibà
a3ae4635eb Post review fixes 2022-07-21 21:04:57 +02:00
Zoe Faltibà
5f12900c6d Add TxBuilder coin selection methods 2022-07-21 16:59:16 +02:00
thunderbiscuit
1a5a628a5d Merge pull request #170 from thunderbiscuit/bump/bdk-0.20.0
Update BDK to version 0.20.0
2022-07-20 11:49:21 -04:00
thunderbiscuit
d8c8261e44 Update BDK to version 0.20.0 2022-07-15 12:03:19 -04:00
thunderbiscuit
692904df1e Merge pull request #158 from zoedberg/list_unspent
Add Wallet list_unspent method
2022-07-12 12:07:52 -04:00
thunderbiscuit
2ac42b3ae0 Add list_unspent and add_data methods to changelog 2022-07-12 12:05:31 -04:00
Pedro
6be22daf84 Add add_data method for txbuilder op_return (#163) 2022-06-23 07:20:02 -04:00
thunderbiscuit
fad5e3cefd Fix comment for NetworkLocalUtxo trait 2022-06-22 14:48:56 -03:00
Zoe Faltibà
28a9b302d5 Post review changes 2022-06-18 15:38:39 +02:00
Zoe Faltibà
8f5ca7f0fc Add Wallet list_unspent method 2022-06-18 15:37:40 +02:00
Steve Myers
80ed21e4c9 Bump version to 0.7.0 2022-06-14 10:46:44 -07:00
Steve Myers
f2efcb6196 Update CHANGELOG for v0.7.0 2022-06-14 10:45:35 -07:00
Steve Myers
cc8a17ef86 Merge bitcoindevkit/bdk-ffi#148: Add Wallet and TxBuilder tests using test funded wallet
e469dcd32c Add test with funded wallet (Steve Myers)

Pull request description:

  This PR adds an example test using the `bdk` test funded wallet.  The example test makes sure the `bdk-ffi` `TxBuilder` is able to drain a single wallet UTXO to a single address.  More tests can be added as we need them in future PRs.

  Required to complete #141

Top commit has no ACKs.

Tree-SHA512: 780e8cf5b3d3091f3322113f017c5b5524b30a3ac9e18910539c51042740d2809535a947b8d56012076ac5e9ad1abcf707ceaf17651457ea327a0b522fcc1002
2022-06-14 10:27:43 -07:00
Steve Myers
5ffe9ff331 Merge bitcoindevkit/bdk-ffi#161: Match bdk API and return a boolean when signing a PSBT
9a3d609826 Match bdk API and return a boolean when signing a PSBT (thunderbiscuit)

Pull request description:

  This is a fix for #160.

  I was looking at the `get_transactions()` method just below and I'm not sure which syntax is best (let me know if you have opinions on this) between

  What I have:
  ```rust
  fn sign(&self, psbt: &PartiallySignedBitcoinTransaction) -> Result<bool, Error> {
      let mut psbt = psbt.internal.lock().unwrap();
      self.get_wallet().sign(&mut psbt, SignOptions::default())
  }
  ```

  If I mirrored `get_transactions()`:
  ```rust
  fn sign(&self, psbt: &PartiallySignedBitcoinTransaction) -> Result<bool, Error> {
      let mut psbt = psbt.internal.lock().unwrap();
      let finalized = self.get_wallet().sign(&mut psbt, SignOptions::default())?;
      Ok(finalized)
  }
  ```

ACKs for top commit:
  notmandatory:
    reACK 9a3d609826

Tree-SHA512: c220929ea9bf7f670c850aebef1c2ebefcbf354f3887e692be36dced30e0e180816426bd58c5a58f61a9759e2f9f451b56e9448f42c23e26f96cf857fd6aa37c
2022-06-13 12:09:03 -07:00
thunderbiscuit
9a3d609826 Match bdk API and return a boolean when signing a PSBT 2022-06-13 15:58:44 -03:00
Steve Myers
bf8fef807d Merge bitcoindevkit/bdk-ffi#162: Update BDK to version 0.19.0
0a3347b85a Update BDK to version 0.19.0 (Steve Myers)

Pull request description:

  Update BDK to version 0.19.0
    - fixes #155, sqlite-db issue causing wrong balance
    - adds experimental taproot descriptor and PSBT support

ACKs for top commit:
  thunderbiscuit:
    Tested ACK [0a3347b](0a3347b85a).

Tree-SHA512: c94ee13f948996350f1079a5fb9be73225e40a930b982dcd7d6826bc19ae3d5ed76d4d3b78ebebf1ce78092570a26a53c93bcc6edf3eeca731142921cf297f83
2022-06-13 11:07:21 -07:00
Steve Myers
e469dcd32c Add test with funded wallet 2022-06-10 15:59:33 -07:00
Steve Myers
0a3347b85a Update BDK to version 0.19.0 2022-06-10 11:25:37 -07:00
Steve Myers
f40ab551b6 Merge bitcoindevkit/bdk-ffi#147: Clean up UDL file
efc475e33f Clean up UDL file (thunderbiscuit)

Pull request description:

  This PR groups related constructs together, fixes indentation inconsistencies (2 spaces is the standard), and adds space between methods in interfaces.

ACKs for top commit:
  notmandatory:
    ACK efc475e33f

Tree-SHA512: 8b37afd1d05f23cb51e04664459b88f3cf415f8616ee0a080294bc27c71c16ed8049ea605b4b41091e4c8276b107da21aff0c1712f2ebfb0dd059f68a4240745
2022-05-17 10:08:55 -07:00
thunderbiscuit
efc475e33f Clean up UDL file 2022-05-17 08:16:17 -04:00
thunderbiscuit
cdea6dc0bf Merge pull request #137 from thunderbiscuit/feat/address-index
Add address index to return type of get_address
2022-05-17 07:31:03 -04:00
thunderbiscuit
6beb98ca4c Incorporate PR review fixes 2022-05-16 15:06:01 -04:00
thunderbiscuit
04d538ad45 Add get_address method on the wallet 2022-05-16 14:50:12 -04:00
thunderbiscuit
c074a92e0c Add address index to return type of get_last_unused_address 2022-05-16 14:45:21 -04:00
Steve Myers
ff260edb3c Merge bitcoindevkit/bdk-ffi#153: Simplify using struct update syntax and clone
e5cd7cb3a2 Simplify using struct update syntax and clone (Sudarsan Balaji)

Pull request description:

ACKs for top commit:
  notmandatory:
    ACK e5cd7cb3a2

Tree-SHA512: 643013f6b0e131a56d9819598c99e7ac4ed008e121bd22d0e3d7dcff61bcb0826c8f1295bf2317580865e2b014f12b56bf4b538f0461a120ad3222b35b7cb933
2022-05-13 10:14:13 -07:00
Steve Myers
15a0795626 Merge bitcoindevkit/bdk-ffi#152: Release version 0.6.0
30e54ac067 Bump version to 0.6.0 (Steve Myers)

Pull request description:

ACKs for top commit:
  thunderbiscuit:
    ACK 30e54ac067.

Tree-SHA512: 235e1f894ba5bfac2fa60330d6e38c6179aaa27b4c6cb8cede17974207c9e04674d4cbbbaaa1705578e0552f09cc78db3ee1015e14cad91281a9d06764495cdd
2022-05-12 19:32:12 -07:00
Sudarsan Balaji
e5cd7cb3a2 Simplify using struct update syntax and clone 2022-05-12 22:50:03 +01:00
Steve Myers
30e54ac067 Bump version to 0.6.0 2022-05-10 22:41:48 -07:00
Steve Myers
71583eca7f Merge bitcoindevkit/bdk-ffi#150: Add new BumpFeeTxBuilder interface
0787d9c446 Fix order of BumpFeeTxBuilder parameters (Steve Myers)
390d12703e Change TxBuilder and BumpFeeTxBuilder build() to finish() (Steve Myers)
9f903932dc Add BumpFeeTxBuilder (Steve Myers)

Pull request description:

  Add BumpFeeTxBuilder to bump the fee on an unconfirmed tx created by the Wallet. The structure of the new interface is:

  ```udl
  interface BumpFeeTxBuilder {
    constructor(string txid, float new_fee_rate);
    BumpFeeTxBuilder allow_shrinking(string address);
    BumpFeeTxBuilder enable_rbf();
    BumpFeeTxBuilder enable_rbf_with_sequence(u32 nsequence);
    [Throws=BdkError]
    PartiallySignedBitcoinTransaction build([ByRef] Wallet wallet);
  };
  ```
  Fixes #150

Top commit has no ACKs.

Tree-SHA512: a24ed41f7b897a0e091ef55d4c1347b3973cbe628b7d1bd69c95e663bc6f049de8f7e3b019115d763cff3fa6d5cb4d31ed474022c3087e8404a2af37f380d56d
2022-05-10 22:35:32 -07:00
Steve Myers
0787d9c446 Fix order of BumpFeeTxBuilder parameters 2022-05-06 09:59:07 -07:00
Steve Myers
390d12703e Change TxBuilder and BumpFeeTxBuilder build() to finish() 2022-05-06 09:52:20 -07:00
Steve Myers
9f903932dc Add BumpFeeTxBuilder 2022-05-05 20:22:55 -07:00
Steve Myers
3b243efefd Merge bitcoindevkit/bdk-ffi#149: Update to bdk 0.18.0
f38f4c6197 Update CHANGELOG (Steve Myers)
11ba16ec1b Move txid getter to PartiallySignedBitcoinTransaction (Steve Myers)
4665c551dd Update EsploraConfig, Blockchain broadcast, Wallet sync (Steve Myers)
907540d214 Update bdk to 0.18.0 with sqlite-bundled feature (Steve Myers)

Pull request description:

  Changes that were needed to match updated bdk APIs:
  * new bdk-ffi `Blockchain`  interface with `constructo(BlockchainConfig)` and `broadcast()` functions
  * `Blockchain.broadcast()` function is now void (doesn't return txid)
  * added `PartiallySignedBitcoinTransaction.txid()` getter function
  * `Wallet.sync()` function now takes a `Blockchain` and optional `Progress` callback interface

  Tests performed:
  * from `bdk-kotlin/bdk-ffi` added local remote to this branch, ran build.sh script
  * fixed broken `bdk-kotlin` jvm and android tests and confirmed tests all pass

Top commit has no ACKs.

Tree-SHA512: d50633bbc8fd8a0d141597b30122c72957d2a0d64fc1537b649eeb8a5df1b1fb9a78ee1f03b9c606f47dee3952c9a91ae09eb47eb7a66d5f0fcb5545c86d906b
2022-05-05 09:29:37 -07:00
Steve Myers
f38f4c6197 Update CHANGELOG 2022-05-02 16:17:27 -07:00
Steve Myers
11ba16ec1b Move txid getter to PartiallySignedBitcoinTransaction 2022-04-25 21:31:40 -07:00
Steve Myers
4665c551dd Update EsploraConfig, Blockchain broadcast, Wallet sync 2022-04-25 21:31:38 -07:00
Steve Myers
907540d214 Update bdk to 0.18.0 with sqlite-bundled feature 2022-04-25 21:31:36 -07:00
Steve Myers
e6a6be5b60 Merge bitcoindevkit/bdk-ffi#145: Fix fee parameter typo in TransactionDetails
c722223b49 Fix fee parameter typo in TransactionDetails (dhruvbaliyan)

Pull request description:

  Solves issue #136
  Generated Kotlin file now have "fee" in TransactionDetails as parameter instead of "fees"
  ```
  data class TransactionDetails (
      var fee: ULong?,
      var received: ULong,
      var sent: ULong,
      var txid: String
  ) {
      // ...
  }
  ```

ACKs for top commit:
  thunderbiscuit:
    Tested ACK c722223. Works as expected in my apps. Thanks for the quick fix!

Tree-SHA512: c55a6e77ca5a0cd19758fc628fc48ed997b3c86247a1eadf5be77771818e3aa5f4db10025e7aa30d05be573e94d7439b15c7fc1f3d6dad752487f7f1ad455367
2022-04-25 21:30:17 -07:00
dhruvbaliyan
c722223b49 Fix fee parameter typo in TransactionDetails 2022-04-20 06:13:49 +05:30
Steve Myers
236360e8c4 Merge bitcoindevkit/bdk-ffi#140: Add RBF methods to TxBuilder
220835cffd Add RBF to TxBuilder (Sudarsan Balaji)
b3c93b0435 Expose functions (Sudarsan Balaji)

Pull request description:

  Fix #133

  We need to create another `RbfValue` enum because the actual type is only visible within the crate in `bdk`.

ACKs for top commit:
  notmandatory:
    tACK 220835cffd

Tree-SHA512: 648ea26a9742c8a395876f38c7299ff0dabb4ccad64e2f6a47d29ceecf44d9e54d845410fa68665e4d4d03d8eda1e51f680d0b89df307b003de49cf7b98e8701
2022-04-16 22:36:34 -07:00
Sudarsan Balaji
220835cffd Add RBF to TxBuilder 2022-04-15 21:04:21 +01:00
Sudarsan Balaji
b3c93b0435 Expose functions 2022-04-15 21:04:04 +01:00
Sudarsan Balaji
a12e5ed396 Use Path instead of PathBuf 2022-04-04 11:07:51 +01:00
Sudarsan Balaji
fc00d0d38c Use unwrap_or_else panic instead of expect 2022-04-04 11:01:50 +01:00
Sudarsan Balaji
7ea5e75bc4 Use write_all when not writing partially 2022-04-04 10:59:19 +01:00
Sudarsan Balaji
a5bd16db4d Enforce rust naming conventions 2022-04-04 10:58:01 +01:00
Steve Myers
d72905168b Merge bitcoindevkit/bdk-ffi#128: Release/0.5
8a556d0ba0 Bump bdk-ffi version to 0.5.0 (Steve Myers)
d7c5f24fe8 Bump bdk-ffi-bindgen version to 0.2.0 (Steve Myers)
f1431c3073 Update CHANGELOG.md (Steve Myers)

Pull request description:

Top commit has no ACKs.

Tree-SHA512: 2d612936740b93148c90acf512005c82e1fe38b4708710952abeac03d361e7dca6c6bdea4e82981a87dbba1cb6d37c0bd48b4ab252467798aa60aca463af5e5e
2022-04-01 19:24:48 -07:00
Steve Myers
8a556d0ba0 Bump bdk-ffi version to 0.5.0 2022-04-01 19:16:53 -07:00
Steve Myers
d7c5f24fe8 Bump bdk-ffi-bindgen version to 0.2.0 2022-04-01 19:16:29 -07:00
Steve Myers
f1431c3073 Update CHANGELOG.md 2022-04-01 19:15:58 -07:00
Steve Myers
e797efea57 Merge bitcoindevkit/bdk-ffi#126: Add workspace and bdk-ffi-bindgen binary cli tool
b207464fe6 Update README.md with bdk-ffi-bindgen info (Steve Myers)
fca5d1602b Add workspace and move bin to bdk-ffi-bindgen package (Steve Myers)
f4e097c4ac Only print python fix up lib path if used (Steve Myers)
c66dfdd52a Use structopt to capture generate options (Steve Myers)
ce848725b4 Add binary to remove the need for uniffi-bindgen cli tool (thunderbiscuit)

Pull request description:

  This PR is based on the mozilla/application-services [embedded-uniffi-bindgen](https://github.com/mozilla/application-services/tree/main/tools/embedded-uniffi-bindgen) tool. The purpose is to keep the bdk-ffi and bdk-ffi-bindgen tool in sync with the same version of uniffi-rs.

  Fixes #124, this PR replaces #122.

  The `bdkffi` library code remains unchanged but the `bin/generate` and `bin/generate-bindings` bins are combined and put in a new workspace binary package called `bdk-ffi-bindgen`.  The `bdk-ffi-bindgen` binary uses the following options, defaults, and environment variables:

  ```shell
  % cargo run -p bdk-ffi-bindgen -- --help

  bdk-ffi-bindgen 0.1.0
  A tool to generate bdk-ffi language bindings

  USAGE:
      bdk-ffi-bindgen [OPTIONS] --language <language> --out-dir <out-dir>

  FLAGS:
      -h, --help       Prints help information
      -V, --version    Prints version information

  OPTIONS:
      -l, --language <language>
              Language to generate bindings for [env: BDKFFI_BINDGEN_LANGUAGE=]  [possible values: kotlin, swift, python]

      -o, --out-dir <out-dir>
              Output directory to put generated language bindings [env: BDKFFI_BINDGEN_OUTPUT_DIR=]

      -p, --python-fixup-path <python-fixup-path>    Python fix up lib path [env: BDKFFI_BINDGEN_PYTHON_FIXUP_PATH=]
      -u, --udl-file <udl-file>                      UDL file [env: BDKFFI_BINDGEN_UDL=]  [default: src/bdk.udl]

  ```

Top commit has no ACKs.

Tree-SHA512: fa1a1c097fe5d0e704d76078c10f82c466dad5d045c8c93d579c2d13c448c52fb6a4f99dfd3dbc46be30471477ae2d1f9264201e14bae7948b408c8e0b3c9b81
2022-04-01 18:58:18 -07:00
Sudarsan Balaji
a41d628b14 Fix typo 2022-04-01 13:56:43 +05:30
Steve Myers
b207464fe6 Update README.md with bdk-ffi-bindgen info 2022-03-31 20:18:31 -07:00
Steve Myers
fca5d1602b Add workspace and move bin to bdk-ffi-bindgen package 2022-03-31 19:29:05 -07:00
Steve Myers
f4e097c4ac Only print python fix up lib path if used 2022-03-31 19:29:03 -07:00
Steve Myers
c66dfdd52a Use structopt to capture generate options 2022-03-31 19:29:01 -07:00
thunderbiscuit
ce848725b4 Add binary to remove the need for uniffi-bindgen cli tool 2022-03-31 19:28:59 -07:00
Sudarsan Balaji
5512b31969 Simplify 2022-03-31 17:26:32 +01:00
Sudarsan Balaji
a48f9b4387 Simplify 2022-03-31 17:22:52 +01:00
Sudarsan Balaji
87a0a15ea7 Fix formatting
cargo fmt
2022-03-31 17:18:03 +01:00
Sudarsan Balaji
ee91ad5b31 Add TxBuilder::drain_to 2022-03-31 17:17:43 +01:00
Sudarsan Balaji
ba68103be1 Add TxBuilder::drain_wallet 2022-03-31 17:17:24 +01:00
Steve Myers
bc43d2eb1a Map TxBuilder address error to BdkError::Generic 2022-03-28 17:30:40 -07:00
Sudarsan Balaji
adc3f68e31 Remove unnecessary map_err 2022-03-28 20:04:22 +01:00
Sudarsan Balaji
dd5622f724 Remove PSBT constructor 2022-03-25 17:39:25 +00:00
Sudarsan Balaji
e5aa51c3f8 Use TxBuilder in PSBT constructor 2022-03-25 17:37:25 +00:00
Sudarsan Balaji
a39fc787d5 Add initial version of TxBuilder 2022-03-25 17:24:21 +00:00
Sudarsan Balaji
51603e06d9 Remove to_owned() 2022-03-25 15:18:25 +00:00
Steve Myers
a1b89adf84 Remove unneeded WalletHolder and WalletOperations traits 2022-03-20 19:59:20 -05:00
Steve Myers
b1d483463f Merge bitcoindevkit/bdk-ffi#120: Fix Wallet.broadcast function, now returns a tx id as a hex string
851f61296a Fix Wallet.broadcast function, now returns a tx id as a hex string (Steve Myers)

Pull request description:

ACKs for top commit:
  thunderbiscuit:
    Tested ACK 851f612.

Tree-SHA512: 86e1d39029924e4fa3a0c21e9f45c1ba0694f4db9d1cfd8dee25a5675d5a8b7851a7c712ce57fb74382a7428fcecbe8ecee4b7b87b9245672bbd6ccea63dfc13
2022-03-16 16:53:20 -05:00
Steve Myers
851f61296a Fix Wallet.broadcast function, now returns a tx id as a hex string 2022-03-15 20:50:12 -05:00
Steve Myers
5128ce8d5b Bump version to 0.4.1 2022-03-14 14:46:31 -05:00
Steve Myers
c6e9a62628 Bump version to 0.4.0 2022-03-14 14:40:55 -05:00
Steve Myers
f76f3234b4 Merge bitcoindevkit/bdk-ffi#109: Refactor memory database config enum
cc3736809a Fix memory database configuration enum (thunderbiscuit)

Pull request description:

  The `DatabaseConfig.Memory` enum currently requires a "junk" string argument which is not used when creating the wallet:

  ```rust
  // lib.rs line 24
  pub enum DatabaseConfig {
      Memory { junk: String },
      Sled { config: SledDbConfiguration },
  }

  // lib.rs line 209
  impl Wallet {
      fn new(
          descriptor: String,
          change_descriptor: Option<String>,
          network: Network,
          database_config: DatabaseConfig,
          blockchain_config: BlockchainConfig,
      ) -> Result<Self, BdkError> {
          let any_database_config = match database_config {
              DatabaseConfig::Memory { .. } => AnyDatabaseConfig::Memory(()),
              DatabaseConfig::Sled { config } => AnyDatabaseConfig::Sled(config),
          };
  ```

  Which translates to the udl file like this:
  ```txt
  [Enum]
  interface DatabaseConfig {
    Memory(string junk);
    Sled(SledDbConfiguration config);
  };
  ```

  According to the [docs from uniffi-rs](https://mozilla.github.io/uniffi-rs/udl/enumerations.html) the `interface` here is required because the enums have named fields. But after testing I found that we can declare the udl file like so, and remove the requirement for the `junk` argument:
  ```txt
  [Enum]
  interface DatabaseConfig {
    Memory();
    Sled(SledDbConfiguration config);
  };
  ```

  On the Rust side we then have
  ```rust
  pub enum DatabaseConfig {
      Memory,
      Sled { config: SledDbConfiguration },
  }
  ```

  And the resulting bindings go from (note that the bindings transform the enum into a sealed class rather than a Kotlin enum)
  ```kotlin
  sealed class DatabaseConfig  {

      data class Memory(
          val junk: String
          ) : DatabaseConfig()

      data class Sled(
          val config: SledDbConfiguration
          ) : DatabaseConfig()
  ```
  to
  ```kotlin
  sealed class DatabaseConfig  {
      object Memory : DatabaseConfig()

      data class Sled(
          val config: SledDbConfiguration
          ) : DatabaseConfig()
  ```

  Which makes the API simpler to use, and removes the confusion created by having to provide an empty string (or not know what we're supposed to provide) to the `Memory()` enum.

  The final call-site looks like this:
  ```kotlin
      fun onlineWalletSyncGetBalance() {
          // val db = DatabaseConfig.Memory("")
          val db = DatabaseConfig.Memory
          val client = BlockchainConfig.Electrum(
              ElectrumConfig(
                  "ssl://electrum.blockstream.info:60002",
                  null,
                  5u,
                  null,
                  100u
              )
          )
          val wallet = Wallet(descriptor, null, Network.REGTEST, databaseConfig, blockchainConfig)
          wallet.sync(LogProgress(), null)
          val balance = wallet.getBalance()
          assertTrue(balance > 0u)
      }
  ```

  All tests run well on my side of things, but I'm opening this more as a discussion piece because I wasn't sure if there were other reasons for the choice of providing the argument to the `Memory` enum, or other design choices I'm not aware of. Any thoughts on this @artfuldev? I think you were the one who wrote the initial enum.

Top commit has no ACKs.

Tree-SHA512: 135e5943039a08522773f721a7cf6bbb93bd5bb9394bf42a30bab5f3e16fd35ce078056756e020a666d4f574d74080bc3404cc81809c0d7e0afe5c9471878425
2022-03-14 10:02:04 -05:00
thunderbiscuit
cc3736809a Fix memory database configuration enum 2022-03-14 10:01:45 -04:00
Steve Myers
4fc9fb916b Merge bitcoindevkit/bdk-ffi#116: Add sqlite database support
12f4784b85 Add sqlite database option (Steve Myers)

Pull request description:

  ### Description

  Add sqlite db database option.

  ### Notes to the reviewers

  When https://github.com/bitcoindevkit/bdk/pull/566 is released we need to updated this project to use the `sqlite-packaged` feature, see TODO in Cargo.toml.

ACKs for top commit:
  thunderbiscuit:
    Tested ACK [12f4784](12f4784b85).

Tree-SHA512: c39472507596e036dd81c22a05d424c6d363545b1a8bd622bf9647967b1b86ab44764da1a15169ac542c80a62a79331b5abcda7b657cc28d93ffdda51a62bd6e
2022-03-13 19:09:28 -05:00
Steve Myers
12f4784b85 Add sqlite database option 2022-03-11 22:45:37 -06:00
Steve Myers
58e75d1a1d Merge commit 'refs/pull/112/head' of github.com:bitcoindevkit/bdk-ffi 2022-03-02 14:49:41 -08:00
Steve Myers
89d58db02a Bump version to 0.3.1 2022-03-02 14:46:06 -08:00
Steve Myers
cda682b634 Remove hard coded sync progress value 2022-03-02 14:45:26 -08:00
Steve Myers
939a88214a Remove hard coded sync progress value 2022-03-02 14:06:40 -08:00
Steve Myers
1bbd85378a Merge bitcoindevkit/bdk-ffi#107: Add license files
f3c6d97d81 Add license files (Steve Myers)
d17ea4b90c Bump version to 0.3.0 (Steve Myers)
76fa9b9521 Add CHANGELOG.md (Steve Myers)

Pull request description:

  This issue is based on https://github.com/bitcoindevkit/bdk/issues/301, to be clear we should add license files to all our repositories.

  If you're on the below list and agree with this change please add a comment with "I hereby license my previous contributions to BDK under [Apache 2.0](https://choosealicense.com/licenses/apache-2.0/) and [MIT](https://choosealicense.com/licenses/mit/) licenses."

  - [x] @artfuldev
  - [x] @notmandatory
  - [x] @afilini
  - [x] @thunderbiscuit

Top commit has no ACKs.

Tree-SHA512: 7e0f2c7bf93d1cdb28cec979330790e00c1efd3ce80986e9084bc371fa73eda6413014e3ad8e598ca6ce1f797622dbfbe8339453de8d7ebefbb27fd5204bc4c6
2022-02-28 09:19:41 -08:00
Steve Myers
f3c6d97d81 Add license files 2022-02-27 21:26:23 -08:00
Steve Myers
d17ea4b90c Bump version to 0.3.0 2022-02-27 21:18:05 -08:00
Steve Myers
76fa9b9521 Add CHANGELOG.md 2022-02-27 21:17:37 -08:00
Steve Myers
cafa8dacab Merge bitcoindevkit/bdk-ffi#104: Add PSBT deserialize and serialize functions, remove details
c039281ffc Add PSBT deserialize and serialize functions, remove details (Steve Myers)
1f0b053872 Fix bin/generate with no features (Steve Myers)

Pull request description:

  1. Fix bin/generate with no features
  2. Add `PartiallySignedBitcoinTransaction::deserialize` function as named constructor to decode from a string per [BIP 0174]
  3. Add `PartiallySignedBitcoinTransaction::serialize` function to encode to a string per [BIP 0174]
  4. Remove `PartiallySignedBitcoinTransaction.details` struct field

  [BIP 0174]:https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki#encoding

  Fixes #103

Top commit has no ACKs.

Tree-SHA512: 0ba34d96625d71434d41573089a150d09fcfb6439648a7eed6e36dcdddd2682c969525b7c6efda898b2f979a7ca6ce51dc2158acf65da7f1f4c554d98b60f4ff
2022-02-25 14:47:47 -08:00
Steve Myers
c039281ffc Add PSBT deserialize and serialize functions, remove details 2022-02-24 20:49:59 -08:00
Steve Myers
1f0b053872 Fix bin/generate with no features 2022-02-24 17:17:05 -08:00
Alekos Filini
97f1011748 Add a binary to generate bindings 2022-02-08 22:15:10 +01:00
Alekos Filini
edfcde1cc6 Generate bindings for Python in build.rs 2022-02-08 21:04:12 +01:00
Sudarsan Balaji
15c0dac622 Rename field to wallet_mutex 2022-01-30 21:22:40 +00:00
Sudarsan Balaji
a99e022756 Rename OnlineWallet to Wallet
and remove OfflineWallet
2022-01-24 20:32:49 +00:00
Steve Myers
672131ca0f Fix uniffi_macros and uniffi_build versions 2022-01-24 10:58:48 -08:00
Steve Myers
72f90f1d63 Upgrade bdk to 0.14.0 2021-12-21 22:16:29 -08:00
Steve Myers
5240cd895e Update uniffi-rs to 0.16.0 2021-12-21 22:16:27 -08:00
Steve Myers
55462fb426 Remove bindings and examples, update README.md 2021-12-21 22:16:25 -08:00
Steve Myers
9188dec2f2 Remove swift related files and -s option in build.sh
Build script and files to create a bdkFFI binary xcframework and BitcoinDevKit swift package
have been moved to the bdk-swift repo.
2021-11-24 12:23:19 -08:00
Steve Myers
a9a01950ee Fix IOSBdkAppSample to work with git hosted BitcoinDevKit swift package 2021-11-23 10:05:19 -08:00
Steve Myers
39cc3b3bfa Update build.sh to create swift xcframework 2021-11-23 10:05:19 -08:00
Steve Myers
c08fe99ad6 Pin anyhow version to "=1.0.45"
This change can be removed after upgrading to the next version of uniffi.
See: https://github.com/mozilla/uniffi-rs/issues/1109
2021-11-22 15:59:12 -08:00
thunderbiscuit
d53eb793ea Refactor transaction 'id' property to 'txid' 2021-11-12 12:50:40 -05:00
Sudarsan Balaji
a68a8bee7d Merge pull request #75 from bitcoindevkit/update-readme-with-deployed-package-versions
Update README with latest published package information
2021-11-06 05:48:53 +05:30
Sudarsan Balaji
e250d4ae1f Update README with latest published package information 2021-11-06 05:48:27 +05:30
Sudarsan Balaji
3e0ae31890 Merge pull request #73 from bitcoindevkit/publish-a-package
Publish android and kotlin packages
2021-11-06 01:31:42 +05:30
Sudarsan Balaji
d197e17eaa Add some notes on consuming published packages 2021-11-06 01:30:36 +05:30
Sudarsan Balaji
63cbcb1aa3 Remove armv7 ABI target instead of i686 2021-11-06 00:45:03 +05:30
Sudarsan Balaji
be8b31684f Stop publishing on build 2021-11-06 00:23:06 +05:30
Sudarsan Balaji
862658ce96 Stop copying over i686 2021-11-06 00:22:58 +05:30
Sudarsan Balaji
6257911095 Ignore unnecessary files 2021-11-05 23:52:08 +05:30
Steve Myers
01da0137ef Merge pull request #70 from notmandatory/fix_build
Fix build.sh kotlin copy for android, also a rust fmt fix
2021-11-04 17:47:52 -07:00
Steve Myers
f86a9df594 Fix build.sh kotlin copy for android 2021-11-04 17:44:02 -07:00
Sudarsan Balaji
379cbe0b59 Merge pull request #69 from bitcoindevkit/return-transaction-details-on-broadcast
Return transaction details on broadcast
2021-11-05 01:19:04 +05:30
Sudarsan Balaji
4fd4a7ee6f Use From trait for conversion 2021-11-05 01:13:45 +05:30
Sudarsan Balaji
c6c4446092 Use From trait for conversion 2021-11-05 01:08:50 +05:30
Sudarsan Balaji
358cc35b60 Update Wallet::broadcast API 2021-11-05 00:45:40 +05:30
Sudarsan Balaji
c58a31f711 Return transaction on broadcast 2021-11-05 00:45:27 +05:30
Sudarsan Balaji
8a9e025e2f Simplify 2021-11-05 00:45:16 +05:30
Sudarsan Balaji
2ac26fa060 Add details to PSBT 2021-11-05 00:45:02 +05:30
Sudarsan Balaji
7e61659cb7 Add a way to convert TransactionDetails to Transaction 2021-11-05 00:44:40 +05:30
Sudarsan Balaji
947a5cb8e0 Allow cloning transaction 2021-11-05 00:43:26 +05:30
Sudarsan Balaji
f6b099aa76 Merge pull request #67 from bitcoindevkit/allow-passing-a-fee-rate-when-creating-a-transaction
Add optional fee rate to a transaction
2021-11-04 23:30:11 +05:30
Sudarsan Balaji
0467e12aae Add optional fee rate to a transaction 2021-11-04 23:29:22 +05:30
Sudarsan Balaji
94b07b9fb9 Merge pull request #65 from bitcoindevkit/allow-getting-last-unused-wallet-address
Allow getting last unused wallet address
2021-11-04 22:48:55 +05:30
Sudarsan Balaji
9ee31d97c7 Expose Wallet::getLastUnusedAddress 2021-11-04 22:45:00 +05:30
Sudarsan Balaji
2c30bdff56 Add a way to get last unused address 2021-11-04 22:44:38 +05:30
Sudarsan Balaji
97c59b4cad Merge pull request #52 from notmandatory/add-more-features-to-ios-example
Add more features to iOS example
2021-11-02 21:59:59 +05:30
Sudarsan Balaji
c5f18ca998 Ignore xc user data 2021-11-02 21:48:29 +05:30
Sudarsan Balaji
c79f1b6326 Ignore unnecessary files 2021-11-02 18:43:05 +05:30
Steve Myers
334bafcc7c Delete generated swift files, update lib name 2021-11-01 19:36:52 -07:00
Steve Myers
1148a2e6d7 Rename kotlin package to org.bitcoindevkit, rust lib to bdkffi 2021-11-01 19:07:27 -07:00
Sudarsan Balaji
80510381de Merge pull request #40 from notmandatory/add-documentation-for-swift-bindings
Add sections and more info to README
2021-10-30 00:29:24 +05:30
Sudarsan Balaji
a4370332df Fix heading levels 2021-10-30 00:28:26 +05:30
Sudarsan Balaji
693a75e6d1 Add sections and more info 2021-10-30 00:27:02 +05:30
Steve Myers
b6fa3539e4 Update README android setup 2021-10-28 15:34:17 -07:00
Steve Myers
5e7a42df07 Fix build.sh and test.sh help 2021-10-28 14:22:45 -07:00
Steve Myers
3b05c57794 Update bdk dependency to 0.13.0 2021-10-28 14:21:57 -07:00
Sudarsan Balaji
aabb09ccb8 Merge pull request #35 from notmandatory/add-swift-language-bindings
Add swift language bindings
2021-10-28 23:01:11 +05:30
Sudarsan Balaji
ab301f075b Update uniffi to 0.14.1
which supports callback interface in Swift
2021-10-28 23:00:23 +05:30
Sudarsan Balaji
9681f30e19 Revert "Remove callback interface"
This reverts commit 4ad9b89e25.
2021-10-28 01:51:16 +05:30
Sudarsan Balaji
ef73e38154 Add swiftmodule 2021-10-28 00:37:42 +05:30
Sudarsan Balaji
e98298090d Generate bindings for swift 2021-10-28 00:35:22 +05:30
Sudarsan Balaji
d1b24026e6 Copy kotlin libs only when building kotlin 2021-10-28 00:35:09 +05:30
Sudarsan Balaji
4ad9b89e25 Remove callback interface 2021-10-28 00:33:10 +05:30
Sudarsan Balaji
a8d9864825 Merge pull request #32 from notmandatory/fix-identifier-case-in-udl
Use snake_case for identifier
2021-10-21 23:43:28 +05:30
Sudarsan Balaji
71531b7abb Use snake_case for identifier 2021-10-21 23:42:38 +05:30
Sudarsan Balaji
a7a45a036c Merge pull request #31 from notmandatory/change-aar-outputs
Export source files with aar
2021-10-21 23:27:04 +05:30
Sudarsan Balaji
7e02dbc97a Export source files with aar 2021-10-21 23:26:34 +05:30
Sudarsan Balaji
1b30ce14a3 Merge pull request #30 from notmandatory/allow-creating-a-wallet-with-a-change-descriptor
Allow creating a wallet with a change descriptor
2021-10-21 14:54:21 +05:30
Sudarsan Balaji
e0937b73db Add change descriptor to Wallet 2021-10-21 14:50:52 +05:30
Sudarsan Balaji
a8b161569c Merge pull request #29 from notmandatory/allow-restoring-extended-key-from-mnemonic
Allow restoring extended key from mnemonic
2021-10-21 14:45:11 +05:30
Sudarsan Balaji
04eec7bf56 Allow restoring extended keys from mnemonic 2021-10-21 14:40:26 +05:30
Sudarsan Balaji
f2bbe668b1 Merge pull request #28 from notmandatory/allow-generating-key
Allow creating extended keys
2021-10-21 14:37:18 +05:30
Sudarsan Balaji
f1c2118b02 Allow generating extended keys 2021-10-21 14:35:40 +05:30
Sudarsan Balaji
f34e59e289 Merge pull request #21 from notmandatory/list-incomplete-transactions
List both confirmed and unconfirmed transactions
2021-10-18 17:35:14 +05:30
Sudarsan Balaji
892bfe868f List both confirmed and unconfirmed transactions 2021-10-18 15:48:30 +05:30
Steve Myers
fe251c12f3 Add android aar build and connected device test 2021-10-17 14:51:05 -07:00
Steve Myers
ee59dbe543 Remove and ignore generated code and binary libs 2021-10-17 14:51:02 -07:00
Sudarsan Balaji
2f83a9ed05 Merge pull request #18 from notmandatory/allow-listing-transactions
Allow listing confirmed transactions
2021-10-17 03:19:42 +05:30
Sudarsan Balaji
4a7d665f7c Return only confirmed transactions in Wallet::getTransactions 2021-10-17 02:36:43 +05:30
Sudarsan Balaji
25b8a8841d Allow listing confirmed transactions 2021-10-17 02:28:26 +05:30
Sudarsan Balaji
38b8589526 Merge pull request #14 from notmandatory/allow-signing-partially-signed-transactions
Allow signing partially signed transactions
2021-10-16 20:28:03 +05:30
Sudarsan Balaji
3693e99372 Share Wallet::getBalance and Wallet::sign 2021-10-16 20:25:58 +05:30
Sudarsan Balaji
d97a13d186 Fix formatting 2021-10-16 20:19:56 +05:30
Sudarsan Balaji
4e1c6bd62b Add sign and broadcast to wallet 2021-10-16 20:19:34 +05:30
Sudarsan Balaji
04eee046cb Merge pull request #13 from notmandatory/allow-creating-a-wallet-transaction
Allow creating partially signed bitcoin transactions
2021-10-16 16:44:49 +05:30
Sudarsan Balaji
69a676ba36 Allow creating partially signed bitcoin transactions 2021-10-16 16:42:35 +05:30
Sudarsan Balaji
a528a76c5d Merge pull request #12 from notmandatory/add-demo-application
Add demo application
2021-10-16 14:46:50 +05:30
Sudarsan Balaji
653773a638 Add demo application in kotlin 2021-10-16 14:45:32 +05:30
Sudarsan Balaji
857d99030b Merge pull request #11 from notmandatory/unify-offline-operations
Share OfflineWalletOperations
2021-10-16 14:22:37 +05:30
Sudarsan Balaji
2db59de659 Share OfflineWalletOperations 2021-10-16 14:19:29 +05:30
Steve Myers
c15993310d Reorganize bdk-kotlin into jvm sub-module 2021-10-14 22:05:21 -07:00
artfuldev
b2f2f9135d Add OnlineWallet::getBalance() 2021-10-15 03:40:33 +05:30
artfuldev
3a7e7baf51 Remove testdb before every test 2021-10-15 03:05:46 +05:30
artfuldev
d307b281d7 Remove unnecessary Mutex wrapper 2021-10-15 03:00:49 +05:30
artfuldev
41afeafcd3 Test a callback 2021-10-15 01:54:32 +05:30
artfuldev
47651f3681 Add OnlineWallet::getNetwork 2021-10-15 00:48:53 +05:30
artfuldev
9b7a9ded56 Add online wallet 2021-10-15 00:43:17 +05:30
Steve Myers
178fd6f010 Change order of Network param 2021-10-14 11:17:52 -07:00
Steve Myers
31710ac77b Add Network enum as wallet constructor param 2021-10-14 10:58:16 -07:00
Sudarsan Balaji
6d7939c88f Allow using configs for database 2021-10-14 04:23:17 +05:30
Sudarsan Balaji
598d08b3bc Use a thread-safe MemoryDatabase 2021-10-14 03:53:22 +05:30
Sudarsan Balaji
b6d6a0d092 Add name to authors 2021-10-14 00:15:25 +05:30
Sudarsan Balaji
6093a8750b Add JNA debug_load to gradle script 2021-10-14 00:06:05 +05:30
Sudarsan Balaji
279f304d5d Add a little bit of error handling 2021-10-14 00:05:50 +05:30
Sudarsan Balaji
64fbf60a6a Stop running gradle build
which also runs tests
2021-10-14 00:05:29 +05:30
Sudarsan Balaji
ce93e4e954 Ignore more files
mac-specific
local sled database
2021-10-14 00:05:04 +05:30
Sudarsan Balaji
cf56619157 Use settings from rust-fmt 2021-10-14 00:04:44 +05:30
Sudarsan Balaji
caff93c945 Add editorconfig 2021-10-13 13:42:55 +05:30
Steve Myers
01bfe5d10e Update README, build.sh and test.sh, rust fmt 2021-10-12 18:22:02 -07:00
Steve Myers
091c9994fa [WIP] reorganize and remove old stuff 2021-10-12 15:24:11 -07:00
Sudarsan Balaji
f30558d55c Ignore testdb 2021-10-13 03:06:49 +05:30
Sudarsan Balaji
4efbfc1e9c Add some more steps to run 2021-10-13 03:05:55 +05:30
Sudarsan Balaji
3491a4548d [WIP] kotlin tests work! 2021-10-13 03:02:49 +05:30
Sudarsan Balaji
0cc2f0a5be [WIP] Add generated and test files 2021-10-13 02:05:46 +05:30
Sudarsan Balaji
784f754cd9 [WIP] Add get new address API to Wallet 2021-10-13 01:45:22 +05:30
Steve Myers
8faba58cd4 wip compiles now 2021-10-12 11:53:11 -07:00
Steve Myers
0b265a7c26 WIP -- NOT WORKING 2021-10-12 10:27:33 -07:00
Steve Myers
f9e3bdfdb2 [wip] swift 2021-10-02 18:22:30 -07:00
Steve Myers
39e5efe5c0 Upgrade bdk dependency to 0.11 2021-09-28 17:03:25 -07:00
Steve Myers
342c4c4aa8 Remove local.properties and add to .gitignore 2021-07-07 10:42:42 -07:00
Steve Myers
bb9fdd35cf Update build.sh to install jvm darwin-x86-64 dylib 2021-07-05 14:25:09 -07:00
Steve Myers
a1aea54c53 Add Wallet.listTransactions() 2021-07-04 22:10:32 -07:00
Steve Myers
a33a09f2a3 Add Wallet.balance() 2021-07-04 15:54:23 -07:00
Steve Myers
6361b41f33 Return FfiResult errors as FfiError enum short values 2021-07-03 20:40:17 -07:00
Steve Myers
2abe7205cb Add FfiResultVoid type 2021-07-03 19:24:29 -07:00
Steve Myers
3e31e9aca3 Remove unneeded pointers from FfiResult types 2021-07-03 19:07:49 -07:00
Steve Myers
a056c0dd59 Reorganized code into wallet mod/package 2021-07-03 10:16:02 -07:00
Steve Myers
060e54a718 Refactor to return results by value, add wallet list_unspent and related types 2021-07-02 21:28:26 -07:00
Steve Myers
59fe24818a Add LibTest getTestDataDir to fix sled test on android 2021-06-26 18:55:49 -07:00
Steve Myers
91ae8dd537 Add kotlin BlockchainConfig and DatabaseConfig 2021-06-25 23:40:38 -07:00
Steve Myers
13e7217ffd Simplify Kotlin Wallet api 2021-06-24 15:00:00 -07:00
Steve Myers
af828efa93 Update build.sh to publish to local maven repo 2021-06-23 14:20:04 -07:00
Steve Myers
0f7a4aebf8 Fix Kotlin jar: native library path 2021-06-23 14:13:33 -07:00
Steve Myers
9f29eb0e86 Add classes to wrap LibJna native types 2021-06-22 11:53:09 -07:00
Steve Myers
3a5d4816ac Add jna lib to jvm jar resources 2021-06-21 15:08:39 -07:00
Steve Myers
2b40718875 Add kotlin test-fixtures module used by jvm and android 2021-06-20 20:26:13 -07:00
Steve Myers
36333b9fb7 Rename gradle modules to jvm and android 2021-06-20 18:48:48 -07:00
Steve Myers
f6c10da805 Return results as opaque structs from ffi calls 2021-06-20 15:48:06 -07:00
Steve Myers
76087b9aec Add kotlin/aar android device tests 2021-06-14 22:38:29 -07:00
Steve Myers
43ddf0a3b1 Execute bdk_ffi_test via valgrind 2021-06-14 14:18:16 -07:00
Steve Myers
5303de9593 Rename bdk-kotlin companion project, fix gradle warnings 2021-06-14 13:59:56 -07:00
Steve Myers
333f694d55 Remove unneeded test structs and functions, cleanup tests 2021-06-10 17:22:33 -07:00
Steve Myers
308d4af4f1 Fix kotlin wallet struct access via JNA opaque pointer 2021-06-10 13:41:46 -07:00
Steve Myers
2aad5d4428 Add missing kotlin files 2021-06-09 16:00:40 -07:00
Steve Myers
f31ebaa1e6 Test new, print, and free Config works 2021-06-08 18:15:20 -07:00
Steve Myers
43425c8875 Pass wallet by ref 2021-06-04 23:04:19 -07:00
Steve Myers
cb54405aed Fix bdk features 2021-06-04 23:01:28 -07:00
Steve Myers
49126a8943 Add strings example 2021-06-04 18:03:34 -07:00
Steve Myers
ec9d2ea284 Set safer-ffi version 2021-06-04 18:01:47 -07:00
Steve Myers
f07f0248ef Add build.sh 2021-06-04 18:00:55 -07:00
Steve Myers
d14ea9a059 Add WalletPtr 2021-06-04 11:07:51 -07:00
20 changed files with 2258 additions and 60 deletions

29
.editorconfig Normal file
View File

@@ -0,0 +1,29 @@
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
trim_trailing_whitespace = false
[*.rs]
indent_size = 4
[*.kt]
indent_size = 4
[*.gradle]
indent_size = 4
[tests/**/*.rs]
charset = utf-8
end_of_line = unset
indent_size = unset
indent_style = unset
trim_trailing_whitespace = unset
insert_final_newline = unset

26
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@@ -0,0 +1,26 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: 'bug'
assignees: ''
---
**Describe the bug**
<!-- A clear and concise description of what the bug is. -->
**To Reproduce**
<!-- Steps or code to reproduce the behavior. -->
**Expected behavior**
<!-- A clear and concise description of what you expected to happen. -->
**Build environment**
- BDK tag/commit: <!-- e.g. v0.13.0, 3a07614 -->
- OS+version: <!-- e.g. ubuntu 20.04.01, macOS 12.0.1, windows -->
- Rust/Cargo version: <!-- e.g. 1.56.0 -->
- Rust/Cargo target: <!-- e.g. x86_64-apple-darwin, x86_64-unknown-linux-gnu, etc. -->
**Additional context**
<!-- Add any other context about the problem here. -->

View File

@@ -0,0 +1,77 @@
---
name: Summer of Bitcoin Project
about: Template to suggest a new https://www.summerofbitcoin.org/ project.
title: ''
labels: 'summer-of-bitcoin'
assignees: ''
---
<!--
## Overview
Project ideas are scoped for a university-level student with a basic background in CS and bitcoin
fundamentals - achievable over 12-weeks. Below are just a few types of ideas:
- Low-hanging fruit: Relatively short projects with clear goals; requires basic technical knowledge
and minimal familiarity with the codebase.
- Core development: These projects derive from the ongoing work from the core of your development
team. The list of features and bugs is never-ending, and help is always welcome.
- Risky/Exploratory: These projects push the scope boundaries of your development effort. They
might require expertise in an area not covered by your current development team. They might take
advantage of a new technology. There is a reasonable chance that the project might be less
successful, but the potential rewards make it worth the attempt.
- Infrastructure/Automation: These projects are the code that your organization uses to get its
development work done; for example, projects that improve the automation of releases, regression
tests and automated builds. This is a category where a Summer of Bitcoin student can be really
helpful, doing work that the development team has been putting off while they focus on core
development.
- Quality Assurance/Testing: Projects that work on and test your project's software development
process. Additionally, projects that involve a thorough test and review of individual PRs.
- Fun/Peripheral: These projects might not be related to the current core development focus, but
create new innovations and new perspectives for your project.
-->
**Description**
<!-- Description: 3-7 sentences describing the project background and tasks to be done. -->
**Expected Outcomes**
<!-- Short bullet list describing what is to be accomplished -->
**Resources**
<!-- 2-3 reading materials for candidate to learn about the repo, project, scope etc -->
<!-- Recommended reading such as a developer/contributor guide -->
<!-- [Another example a paper citation](https://arxiv.org/pdf/1802.08091.pdf) -->
<!-- [Another example an existing issue](https://github.com/opencv/opencv/issues/11013) -->
<!-- [An existing related module](https://github.com/opencv/opencv_contrib/tree/master/modules/optflow) -->
**Skills Required**
<!-- 3-4 technical skills that the candidate should know -->
<!-- hands on experience with git -->
<!-- mastery plus experience coding in C++ -->
<!-- basic knowledge in matrix and tensor computations, college course work in cryptography -->
<!-- strong mathematical background -->
<!-- Bonus - has experience with React Native. Best if you have also worked with OSSFuzz -->
**Mentor(s)**
<!-- names of mentor(s) for this project go here -->
**Difficulty**
<!-- Easy, Medium, Hard -->
**Competency Test (optional)**
<!-- 2-3 technical tasks related to the project idea or repository youd like a candidate to
perform in order to demonstrate competency, good first bugs, warm-up exercises -->
<!-- ex. Read the instructions here to get Bitcoin core running on your machine -->
<!-- ex. pick an issue labeled as “newcomer” in the repository, and send a merge request to the
repository. You can also suggest some other improvement that we did not think of yet, or
something that you find interesting or useful -->
<!-- ex. fixes for coding style are usually easy to do, and are good issues for first time
contributions for those learning how to interact with the project. After you are done with the
coding style issue, try making a different contribution. -->
<!-- ex. setup a full Debian packaging development environment and learn the basics of Debian
packaging. Then identify and package the missing dependencies to package Specter Desktop -->
<!-- ex. write a pull parser for CSV files. You'll be judged by the decisions to store the parser
state and how flexible it is to wrap this parser in other scenarios. -->
<!-- ex. Stretch Goal: Implement some basic metaprogram/app to prove you're very familiar with BDK.
Be prepared to make adjustments as we judge your solution. -->

30
.github/pull_request_template.md vendored Normal file
View File

@@ -0,0 +1,30 @@
<!-- You can erase any parts of this template not applicable to your Pull Request. -->
### Description
<!-- Describe the purpose of this PR, what's being adding and/or fixed -->
### Notes to the reviewers
<!-- In this section you can include notes directed to the reviewers, like explaining why some parts
of the PR were done in a specific way -->
### Checklists
#### All Submissions:
* [ ] I've signed all my commits
* [ ] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md)
* [ ] I ran `cargo fmt` and `cargo clippy` before committing
#### New Features:
* [ ] I've added tests for the new feature
* [ ] I've added docs for the new feature
* [ ] I've updated `CHANGELOG.md`
#### Bugfixes:
* [ ] This pull request breaks the existing API
* [ ] I've added tests to reproduce the issue which are now passing
* [ ] I'm linking the issue being fixed by this PR

19
.github/workflows/audit.yml vendored Normal file
View File

@@ -0,0 +1,19 @@
name: Audit
on:
push:
paths:
- '**/Cargo.toml'
- '**/Cargo.lock'
schedule:
- cron: '0 0 * * 0' # Once per week
jobs:
security_audit:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions-rs/audit-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}

61
.github/workflows/cont_integration.yml vendored Normal file
View File

@@ -0,0 +1,61 @@
on: [push, pull_request]
name: CI
jobs:
build-test:
name: Build and test
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- version: 1.63.0 # STABLE
clippy: true
- version: 1.61.0 # MSRV
steps:
- name: checkout
uses: actions/checkout@v2
- name: Generate cache key
run: echo "${{ matrix.rust.version }} ${{ matrix.features }}" | tee .cache_key
- name: cache
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('.cache_key') }}-${{ hashFiles('**/Cargo.toml','**/Cargo.lock') }}
- name: Set default toolchain
run: rustup default ${{ matrix.rust.version }}
- name: Set profile
run: rustup set profile minimal
- name: Add clippy
if: ${{ matrix.rust.clippy }}
run: rustup component add clippy
- name: Update toolchain
run: rustup update
- name: Build
run: cargo build
- name: Clippy
if: ${{ matrix.rust.clippy }}
run: cargo clippy --all-targets -- -D warnings
- name: Test
run: cargo test
fmt:
name: Rust fmt
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set default toolchain
run: rustup default nightly
- name: Set profile
run: rustup set profile minimal
- name: Add rustfmt
run: rustup component add rustfmt
- name: Update toolchain
run: rustup update
- name: Check fmt
run: cargo fmt --all -- --config format_code_in_doc_comments=true --check

21
.gitignore vendored
View File

@@ -1,4 +1,17 @@
/target
*.h
/main
/Cargo.lock
target
build
Cargo.lock
/bindings/bdk-kotlin/local.properties
.gradle
wallet_db
bdk_ffi_test
local.properties
*.log
*.dylib
*.so
.DS_Store
testdb
xcuserdata
.lsp
.clj-kondo
.idea/

113
CHANGELOG.md Normal file
View File

@@ -0,0 +1,113 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
## [v0.9.0]
- Breaking Changes
- Rename `get_network()` method on `Wallet` interface to `network()` [#185]
- Rename `get_transactions()` method on `Wallet` interface to `list_transactions()` [#185]
- Remove `generate_extended_key`, returned ExtendedKeyInfo [#154]
- Remove `restore_extended_key`, returned ExtendedKeyInfo [#154]
- Remove dictionary `ExtendedKeyInfo {mnenonic, xprv, fingerprint}` [#154]
- Remove interface `Transaction` [#190]
- Changed `Wallet` interface `list_transaction()` to return array of `TransactionDetails` [#190]
- Update `bdk` dependency version to 0.22 [#193]
- APIs Added [#154]
- `generate_mnemonic()`, returns string mnemonic
- `interface DescriptorSecretKey`
- `new(Network, string_mnenoinc, password)`, contructs DescriptorSecretKey
- `derive(DerivationPath)`, derives and returns child DescriptorSecretKey
- `extend(DerivationPath)`, extends and returns DescriptorSecretKey
- `as_public()`, returns DescriptorSecretKey as DescriptorPublicKey
- `as_string()`, returns DescriptorSecretKey as String
- `interface DescriptorPublicKey`
- `derive(DerivationPath)` derives and returns child DescriptorPublicKey
- `extend(DerivationPath)` extends and returns DescriptorPublicKey
- `as_string()` returns DescriptorPublicKey as String
- Add to `interface Blockchain` the `get_height()` and `get_block_hash()` methods [#184]
- Add to `interface TxBuilder` the `set_recipients(recipient: Vec<AddressAmount>)` method [#186]
- Add to `dictionary TransactionDetails` the `confirmation_time` field [#190]
- Interfaces Added [#154]
- `DescriptorSecretKey`
- `DescriptorPublicKey`
- `DerivationPath`
[#154]: https://github.com/bitcoindevkit/bdk-ffi/pull/154
[#184]: https://github.com/bitcoindevkit/bdk-ffi/pull/184
[#185]: https://github.com/bitcoindevkit/bdk-ffi/pull/185
[#193]: https://github.com/bitcoindevkit/bdk-ffi/pull/193
## [v0.8.0]
- Update BDK to version 0.20.0 [#169]
- APIs Added
- `TxBuilder.add_data(data: Vec<u8>)` [#163]
- `Wallet.list_unspent()` returns `Vec<LocalUtxo>` [#158]
- Add coin control methods on TxBuilder [#164]
[#163]: https://github.com/bitcoindevkit/bdk-ffi/pull/163
[#158]: https://github.com/bitcoindevkit/bdk-ffi/pull/158
[#164]: https://github.com/bitcoindevkit/bdk-ffi/pull/164
[#169]: https://github.com/bitcoindevkit/bdk-ffi/pull/169
[#190]: https://github.com/bitcoindevkit/bdk-ffi/pull/190
## [v0.7.0]
- Update BDK to version 0.19.0
- fixes sqlite-db issue causing wrong balance
- adds experimental taproot descriptor and PSBT support
- APIs Removed
- `Wallet.get_new_address()`, returned String, [#137]
- `Wallet.get_last_unused_address()`, returned String [#137]
- APIs Added
- `Wallet.get_address(AddressIndex)`, returns `AddressInfo` [#137]
- APIs Changed
- `Wallet.sign(PartiallySignedBitcoinTransaction)` now returns a bool, true if finalized [#161]
[#137]: https://github.com/bitcoindevkit/bdk-ffi/pull/137
[#161]: https://github.com/bitcoindevkit/bdk-ffi/pull/161
## [v0.6.0]
- Update BDK to version 0.18.0
- Add BumpFeeTxBuilder to bump the fee on an unconfirmed tx created by the Wallet
- Change TxBuilder.build() to TxBuilder.finish() to align with bdk function name
## [v0.5.0]
- Fix Wallet.broadcast function, now returns a tx id as a hex string
- Remove creating a new spending Transaction via the PartiallySignedBitcoinTransaction constructor
- Add TxBuilder for creating new spending PartiallySignedBitcoinTransaction
- Add TxBuilder .add_recipient, .fee_rate, and .build functions
- Add TxBuilder .drain_wallet and .drain_to functions
- Update generate cli tool to generate all binding languages and rename to bdk-ffi-bindgen
## [v0.4.0]
- Add dual license MIT and Apache 2.0
- Add sqlite database support
- Fix memory database configuration enum, remove junk field
## [v0.3.1]
- Remove hard coded sync progress value (was always returning 21.0)
## [v0.3.0]
- Move bdk-kotlin bindings and ios example to separate repos
- Add bin to generate Python bindings
- Add `PartiallySignedBitcoinTransaction::deserialize` function as named constructor to decode from a string per [BIP 0174]
- Add `PartiallySignedBitcoinTransaction::serialize` function to encode to a string per [BIP 0174]
- Remove `PartiallySignedBitcoinTransaction.details` struct field
[BIP 0174]:https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki#encoding
## [v0.2.0]
[unreleased]: https://github.com/bitcoindevkit/bdk-ffi/compare/v0.9.0...HEAD
[v0.9.0]: https://github.com/bitcoindevkit/bdk-ffi/compare/v0.8.0...v0.9.0
[v0.8.0]: https://github.com/bitcoindevkit/bdk-ffi/compare/v0.7.0...v0.8.0
[v0.7.0]: https://github.com/bitcoindevkit/bdk-ffi/compare/v0.6.0...v0.7.0
[v0.6.0]: https://github.com/bitcoindevkit/bdk-ffi/compare/v0.5.0...v0.6.0
[v0.5.0]: https://github.com/bitcoindevkit/bdk-ffi/compare/v0.4.0...v0.5.0
[v0.4.0]: https://github.com/bitcoindevkit/bdk-ffi/compare/v0.3.1...v0.4.0
[v0.3.1]: https://github.com/bitcoindevkit/bdk-ffi/compare/v0.3.0...v0.3.1
[v0.3.0]: https://github.com/bitcoindevkit/bdk-ffi/compare/v0.2.0...v0.3.0
[v0.2.0]: https://github.com/bitcoindevkit/bdk-ffi/compare/v0.0.0...v0.2.0

View File

@@ -1,16 +1,23 @@
[package]
name = "bdk_ffi"
version = "0.1.0"
authors = ["Steve Myers <steve@notmandatory.org>"]
name = "bdk-ffi"
version = "0.9.0"
authors = ["Steve Myers <steve@notmandatory.org>", "Sudarsan Balaji <sudarsan.balaji@artfuldev.com>"]
edition = "2018"
[workspace]
members = [".","bdk-ffi-bindgen"]
default-members = [".", "bdk-ffi-bindgen"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
crate-type = ["staticlib"]
crate-type = ["staticlib", "cdylib"]
name = "bdkffi"
[dependencies]
bdk = { version = "^0.7", feature = ["all-keys"] }
safer-ffi = { version = "*", features = ["proc_macros"]}
bdk = { version = "0.22", features = ["all-keys", "use-esplora-ureq", "sqlite-bundled"] }
[features]
c-headers = ["safer-ffi/headers"]
uniffi_macros = { version = "0.19.3", features = ["builtin-bindgen"] }
uniffi = { version = "0.19.3", features = ["builtin-bindgen"] }
[build-dependencies]
uniffi_build = { version = "0.19.3", features = ["builtin-bindgen"] }

14
LICENSE Normal file
View File

@@ -0,0 +1,14 @@
This software is licensed under [Apache 2.0](LICENSE-APACHE) or
[MIT](LICENSE-MIT), at your option.
Some files retain their own copyright notice, however, for full authorship
information, see version control history.
Except as otherwise noted in individual files, all files in this repository are
licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
http://www.apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
http://opensource.org/licenses/MIT>, at your option.
You may not use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of this software or any files in this repository except in
accordance with one or both of these licenses.

201
LICENSE-APACHE Normal file
View File

@@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

16
LICENSE-MIT Normal file
View File

@@ -0,0 +1,16 @@
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

75
README.md Normal file
View File

@@ -0,0 +1,75 @@
# Native language bindings for BDK
<p>
<a href="https://github.com/bitcoindevkit/bdk-ffi/blob/master/LICENSE"><img alt="MIT or Apache-2.0 Licensed" src="https://img.shields.io/badge/license-MIT%2FApache--2.0-blue.svg"/></a>
<a href="https://github.com/bitcoindevkit/bdk-ffi/actions?query=workflow%3ACI"><img alt="CI Status" src="https://github.com/bitcoindevkit/bdk-ffi/workflows/CI/badge.svg"></a>
<a href="https://blog.rust-lang.org/2022/05/19/Rust-1.61.0.html"><img alt="Rustc Version 1.61.0+" src="https://img.shields.io/badge/rustc-1.61.0%2B-lightgrey.svg"/></a>
<a href="https://discord.gg/d7NkDKm"><img alt="Chat on Discord" src="https://img.shields.io/discord/753336465005608961?logo=discord"></a>
</p>
The workspace in this repository creates the `libbdkffi` multi-language library for the rust based
[bdk] library from the [Bitcoin Dev Kit] project. The `bdk-ffi-bindgen` package builds a tool for
generating the actual language binding code used to access the `libbdkffi` library.
Each supported language has its own repository that includes this project as a [git submodule].
The rust code in this project is a wrapper around the [bdk] library to expose it's APIs in a
uniform way using the [mozilla/uniffi-rs] bindings generator for each supported target language.
## Supported target languages and platforms
The below repositories include instructions for using, building, and publishing the native
language binding for [bdk] supported by this project.
| Language | Platform | Repository |
| -------- | ------------ | ------------ |
| Kotlin | jvm | [bdk-kotlin] |
| Kotlin | android | [bdk-kotlin] |
| Swift | iOS, macOS | [bdk-swift] |
| Python | linux, macOS | [bdk-python] |
## Language bindings generator tool
Use the `bdk-ffi-bindgen` tool to generate language binding code for the above supported languages.
To run `bdk-ffi-bindgen` and see the available options use the command:
```shell
cargo run -p bdk-ffi-bindgen -- --help
```
[bdk]: https://github.com/bitcoindevkit/bdk
[Bitcoin Dev Kit]: https://github.com/bitcoindevkit
[git submodule]: https://git-scm.com/book/en/v2/Git-Tools-Submodules
[uniffi-rs]: https://github.com/mozilla/uniffi-rs
[bdk-kotlin]: https://github.com/bitcoindevkit/bdk-kotlin
[bdk-swift]: https://github.com/bitcoindevkit/bdk-swift
[bdk-python]: https://github.com/bitcoindevkit/bdk-python
## Contributing
### Adding new structs and functions
See the [UniFFI User Guide](https://mozilla.github.io/uniffi-rs/)
#### For pass by value objects
1. create new rust struct with only fields that are supported UniFFI types
1. update mapping `bdk.udl` file with new `dictionary`
#### For pass by reference values
1. create wrapper rust struct/impl with only fields that are `Sync + Send`
1. update mapping `bdk.udl` file with new `interface`
## Goals
1. Language bindings should feel idiomatic in target languages/platforms
1. Adding new targets should be easy
1. Getting up and running should be easy
1. Contributing should be easy
1. Get it right, then automate
## Thanks
This project is made possible thanks to the wonderful work by the [mozilla/uniffi-rs] team.
[mozilla/uniffi-rs]: https://github.com/mozilla/uniffi-rs

View File

@@ -0,0 +1,10 @@
[package]
name = "bdk-ffi-bindgen"
version = "0.2.0"
edition = "2021"
[dependencies]
anyhow = "=1.0.45" # remove after upgrading to next version of uniffi
structopt = "0.3"
uniffi_bindgen = "0.19.5"
camino = "1.0.9"

138
bdk-ffi-bindgen/src/main.rs Normal file
View File

@@ -0,0 +1,138 @@
use camino::Utf8Path;
use std::fmt;
use std::path::{Path, PathBuf};
use std::str::FromStr;
use structopt::StructOpt;
#[derive(Debug, Eq, PartialEq)]
pub enum Language {
Kotlin,
Python,
Swift,
}
impl fmt::Display for Language {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
Language::Kotlin => write!(f, "kotlin"),
Language::Swift => write!(f, "swift"),
Language::Python => write!(f, "python"),
}
}
}
#[derive(Debug)]
pub enum Error {
UnsupportedLanguage,
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{:?}", self)
}
}
impl FromStr for Language {
type Err = Error;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"kotlin" => Ok(Language::Kotlin),
"python" => Ok(Language::Python),
"swift" => Ok(Language::Swift),
_ => Err(Error::UnsupportedLanguage),
}
}
}
fn generate_bindings(opt: &Opt) -> anyhow::Result<(), anyhow::Error> {
let path: &Utf8Path = Utf8Path::from_path(&opt.udl_file).unwrap();
let out_dir: &Utf8Path = Utf8Path::from_path(&opt.out_dir).unwrap();
uniffi_bindgen::generate_bindings(
path,
None,
vec![opt.language.to_string().as_str()],
Some(out_dir),
None,
false,
)?;
Ok(())
}
fn fixup_python_lib_path(
out_dir: &Path,
lib_name: &Path,
) -> Result<(), Box<dyn std::error::Error>> {
use std::fs;
use std::io::Write;
const LOAD_INDIRECT_DEF: &str = "def loadIndirect():";
let bindings_file = out_dir.join("bdk.py");
let mut data = fs::read_to_string(&bindings_file)?;
let pos = data
.find(LOAD_INDIRECT_DEF)
.unwrap_or_else(|| panic!("loadIndirect not found in `{}`", bindings_file.display()));
let range = pos..pos + LOAD_INDIRECT_DEF.len();
let replacement = format!(
r#"
def loadIndirect():
import glob
return getattr(ctypes.cdll, glob.glob(os.path.join(os.path.dirname(os.path.abspath(__file__)), '{}.*'))[0])
def _loadIndirectOld():"#,
&lib_name.to_str().expect("lib name")
);
data.replace_range(range, &replacement);
let mut file = fs::OpenOptions::new()
.write(true)
.truncate(true)
.open(&bindings_file)?;
file.write_all(data.as_bytes())?;
Ok(())
}
#[derive(Debug, StructOpt)]
#[structopt(
name = "bdk-ffi-bindgen",
about = "A tool to generate bdk-ffi language bindings"
)]
struct Opt {
/// UDL file
#[structopt(env = "BDKFFI_BINDGEN_UDL", short, long, default_value("src/bdk.udl"), parse(try_from_str = PathBuf::from_str))]
udl_file: PathBuf,
/// Language to generate bindings for
#[structopt(env = "BDKFFI_BINDGEN_LANGUAGE", short, long, possible_values(&["kotlin","swift","python"]), parse(try_from_str = Language::from_str))]
language: Language,
/// Output directory to put generated language bindings
#[structopt(env = "BDKFFI_BINDGEN_OUTPUT_DIR", short, long, parse(try_from_str = PathBuf::from_str))]
out_dir: PathBuf,
/// Python fix up lib path
#[structopt(env = "BDKFFI_BINDGEN_PYTHON_FIXUP_PATH", short, long, parse(try_from_str = PathBuf::from_str))]
python_fixup_path: Option<PathBuf>,
}
fn main() -> Result<(), Box<dyn std::error::Error>> {
let opt = Opt::from_args();
println!("Input UDL file is {:?}", opt.udl_file);
println!("Chosen language is {}", opt.language);
println!("Output directory is {:?}", opt.out_dir);
generate_bindings(&opt)?;
if opt.language == Language::Python {
if let Some(path) = opt.python_fixup_path {
println!("Fixing up python lib path, {:?}", &path);
fixup_python_lib_path(&opt.out_dir, &path)?;
}
}
Ok(())
}

3
build.rs Normal file
View File

@@ -0,0 +1,3 @@
fn main() {
uniffi_build::generate_scaffolding("src/bdk.udl").unwrap();
}

13
main.c
View File

@@ -1,13 +0,0 @@
#include <stdlib.h>
#include "bdk_ffi.h"
int main (int argc, char const * const argv[])
{
Point_t * a = new_point(84,45);
Point_t * b = new_point(0.0,39.0);
Point_t * m = mid_point(a, b);
print_point(m);
print_point(NULL);
return EXIT_SUCCESS;
}

293
src/bdk.udl Normal file
View File

@@ -0,0 +1,293 @@
namespace bdk {
[Throws=BdkError]
string generate_mnemonic(WordCount word_count);
};
[Error]
enum BdkError {
"InvalidU32Bytes",
"Generic",
"MissingCachedScripts",
"ScriptDoesntHaveAddressForm",
"NoRecipients",
"NoUtxosSelected",
"OutputBelowDustLimit",
"InsufficientFunds",
"BnBTotalTriesExceeded",
"BnBNoExactMatch",
"UnknownUtxo",
"TransactionNotFound",
"TransactionConfirmed",
"IrreplaceableTransaction",
"FeeRateTooLow",
"FeeTooLow",
"FeeRateUnavailable",
"MissingKeyOrigin",
"Key",
"ChecksumMismatch",
"SpendingPolicyRequired",
"InvalidPolicyPathError",
"Signer",
"InvalidNetwork",
"InvalidProgressValue",
"ProgressUpdateError",
"InvalidOutpoint",
"Descriptor",
"AddressValidator",
"Encode",
"Miniscript",
"Bip32",
"Secp256k1",
"Json",
"Hex",
"Psbt",
"PsbtParse",
"Electrum",
"Esplora",
"Sled",
"Rusqlite",
};
dictionary AddressInfo {
u32 index;
string address;
};
enum AddressIndex {
"New",
"LastUnused",
};
enum Network {
"Bitcoin",
"Testnet",
"Signet",
"Regtest",
};
dictionary SledDbConfiguration {
string path;
string tree_name;
};
dictionary SqliteDbConfiguration {
string path;
};
dictionary Balance {
u64 immature;
u64 trusted_pending;
u64 untrusted_pending;
u64 confirmed;
u64 spendable;
u64 total;
};
[Enum]
interface DatabaseConfig {
Memory();
Sled(SledDbConfiguration config);
Sqlite(SqliteDbConfiguration config);
};
dictionary TransactionDetails {
u64? fee;
u64 received;
u64 sent;
string txid;
BlockTime? confirmation_time;
};
dictionary BlockTime {
u32 height;
u64 timestamp;
};
enum WordCount {
"Words12",
"Words15",
"Words18",
"Words21",
"Words24",
};
dictionary ElectrumConfig {
string url;
string? socks5;
u8 retry;
u8? timeout;
u64 stop_gap;
};
dictionary EsploraConfig {
string base_url;
string? proxy;
u8? concurrency;
u64 stop_gap;
u64? timeout;
};
[Enum]
interface BlockchainConfig {
Electrum(ElectrumConfig config);
Esplora(EsploraConfig config);
};
interface Blockchain {
[Throws=BdkError]
constructor(BlockchainConfig config);
[Throws=BdkError]
void broadcast([ByRef] PartiallySignedBitcoinTransaction psbt);
[Throws=BdkError]
u32 get_height();
[Throws=BdkError]
string get_block_hash(u32 height);
};
callback interface Progress {
void update(f32 progress, string? message);
};
dictionary OutPoint {
string txid;
u32 vout;
};
dictionary TxOut {
u64 value;
string address;
};
enum KeychainKind {
"External",
"Internal",
};
dictionary LocalUtxo {
OutPoint outpoint;
TxOut txout;
KeychainKind keychain;
boolean is_spent;
};
dictionary AddressAmount {
string address;
u64 amount;
};
interface Wallet {
[Throws=BdkError]
constructor(string descriptor, string? change_descriptor, Network network, DatabaseConfig database_config);
[Throws=BdkError]
AddressInfo get_address(AddressIndex address_index);
[Throws=BdkError]
Balance get_balance();
[Throws=BdkError]
boolean sign([ByRef] PartiallySignedBitcoinTransaction psbt);
[Throws=BdkError]
sequence<TransactionDetails> list_transactions();
Network network();
[Throws=BdkError]
void sync([ByRef] Blockchain blockchain, Progress? progress);
[Throws=BdkError]
sequence<LocalUtxo> list_unspent();
};
interface PartiallySignedBitcoinTransaction {
[Throws=BdkError]
constructor(string psbt_base64);
string serialize();
string txid();
};
interface TxBuilder {
constructor();
TxBuilder add_recipient(string address, u64 amount);
TxBuilder add_unspendable(OutPoint unspendable);
TxBuilder add_utxo(OutPoint outpoint);
TxBuilder add_utxos(sequence<OutPoint> outpoints);
TxBuilder do_not_spend_change();
TxBuilder manually_selected_only();
TxBuilder only_spend_change();
TxBuilder unspendable(sequence<OutPoint> unspendable);
TxBuilder fee_rate(float sat_per_vbyte);
TxBuilder fee_absolute(u64 fee_amount);
TxBuilder drain_wallet();
TxBuilder drain_to(string address);
TxBuilder enable_rbf();
TxBuilder enable_rbf_with_sequence(u32 nsequence);
TxBuilder add_data(sequence<u8> data);
TxBuilder set_recipients(sequence<AddressAmount> recipients);
[Throws=BdkError]
PartiallySignedBitcoinTransaction finish([ByRef] Wallet wallet);
};
interface BumpFeeTxBuilder {
constructor(string txid, float new_fee_rate);
BumpFeeTxBuilder allow_shrinking(string address);
BumpFeeTxBuilder enable_rbf();
BumpFeeTxBuilder enable_rbf_with_sequence(u32 nsequence);
[Throws=BdkError]
PartiallySignedBitcoinTransaction finish([ByRef] Wallet wallet);
};
interface DerivationPath {
[Throws=BdkError]
constructor(string path);
};
interface DescriptorSecretKey {
[Throws=BdkError]
constructor(Network network, string mnemonic, string? password);
[Throws=BdkError]
DescriptorSecretKey derive(DerivationPath path);
DescriptorSecretKey extend(DerivationPath path);
DescriptorPublicKey as_public();
string as_string();
};
interface DescriptorPublicKey {
[Throws=BdkError]
DescriptorPublicKey derive(DerivationPath path);
DescriptorPublicKey extend(DerivationPath path);
string as_string();
};

1144
src/lib.rs

File diff suppressed because it is too large Load Diff

12
uniffi.toml Normal file
View File

@@ -0,0 +1,12 @@
[bindings.kotlin]
package_name = "org.bitcoindevkit"
cdylib_name = "bdkffi"
[bindings.python]
cdylib_name = "bdkffi"
[bindings.ruby]
cdylib_name = "bdkffi"
[bindings.swift]
cdylib_name = "bdkffi"