From f66f8417cf78dbcbfba41b366429eaba8bce895e Mon Sep 17 00:00:00 2001 From: thunderbiscuit Date: Mon, 24 Jun 2024 10:15:30 -0400 Subject: [PATCH] feat: bump rust libraries to alpha 13 --- bdk-ffi/Cargo.lock | 220 +++++++++------ bdk-ffi/Cargo.toml | 15 +- bdk-ffi/src/bdk.udl | 89 +++--- bdk-ffi/src/bitcoin.rs | 40 +-- bdk-ffi/src/electrum.rs | 13 +- bdk-ffi/src/error.rs | 580 ++++++++++------------------------------ bdk-ffi/src/lib.rs | 6 +- bdk-ffi/src/store.rs | 39 +++ bdk-ffi/src/types.rs | 9 + bdk-ffi/src/wallet.rs | 82 +++--- 10 files changed, 438 insertions(+), 655 deletions(-) create mode 100644 bdk-ffi/src/store.rs diff --git a/bdk-ffi/Cargo.lock b/bdk-ffi/Cargo.lock index 490f9a6..936b27d 100644 --- a/bdk-ffi/Cargo.lock +++ b/bdk-ffi/Cargo.lock @@ -128,6 +128,16 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" +[[package]] +name = "base58ck" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c8d66485a3a2ea485c1913c4572ce0256067a5377ac8c75c4960e1cda98605f" +dependencies = [ + "bitcoin-internals 0.3.0", + "bitcoin_hashes 0.14.0", +] + [[package]] name = "base64" version = "0.12.3" @@ -165,37 +175,27 @@ dependencies = [ "bdk_esplora", "bdk_sqlite", "bdk_wallet", - "bitcoin-internals", + "bitcoin-internals 0.2.0", "thiserror", "uniffi", ] [[package]] name = "bdk_bitcoind_rpc" -version = "0.10.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54fe9410002d5c350b59145ed0b18af1bb81521e7d62515defe539a450e20551" +checksum = "ae8b85b7f47af08bb41d6fb9301c9de8ad937a4d506ba0d9920b094fd48d8fbb" dependencies = [ - "bdk_chain 0.14.0", + "bdk_chain", "bitcoin", "bitcoincore-rpc", ] [[package]] name = "bdk_chain" -version = "0.14.0" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "440ec5b1c8911f126b540e05c98493b699b497a3cb90c5e9c5eee21cdd8d1e01" -dependencies = [ - "bitcoin", - "miniscript", -] - -[[package]] -name = "bdk_chain" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c601c4dc7e6c3efa538a0afbb43b964cefab9a9b5e8f352fa0ca38145448a5e7" +checksum = "163b064557cee078e8ee5dd2c88944204506f7b2b1524f78e8fcba38c346da7b" dependencies = [ "bitcoin", "miniscript", @@ -204,43 +204,31 @@ dependencies = [ [[package]] name = "bdk_electrum" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28906275aeb1f71dc32045670f06c8a26fb17cc62151a99f7425d258f4bda589" +version = "0.15.0" +source = "git+https://github.com/thunderbiscuit/bdk/?branch=feature/electrum-client-ring-feature#31ddf1b4b600e9bf10e622cb0dee7ff158439b48" dependencies = [ - "bdk_chain 0.15.0", + "bdk_chain", "electrum-client", ] [[package]] name = "bdk_esplora" -version = "0.14.0" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28b2409ff6b35fc69e864bc6986731e024ccd70bd325183f8ffff1590d9895d1" +checksum = "089babab213bbb32518bad79a7313ebb4c85a52c18c8b558402dfa810c27de3f" dependencies = [ - "bdk_chain 0.15.0", + "bdk_chain", "esplora-client", -] - -[[package]] -name = "bdk_persist" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41528569e8507f078143526c72bdee75f93f17d3b028cb7d88b4889278973e7d" -dependencies = [ - "anyhow", - "bdk_chain 0.15.0", + "miniscript", ] [[package]] name = "bdk_sqlite" -version = "0.1.0" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b665413b2c5d5151dbb9cb6a855ccbbc26fdb6143f22faf2deea4e8c61fc33e6" +checksum = "0926dc5778fb3c5afaf7def9ed9b9c9d9fe9e3ba499e09cb816d3de43211be71" dependencies = [ - "anyhow", - "bdk_chain 0.15.0", - "bdk_persist", + "bdk_chain", "rusqlite", "serde", "serde_json", @@ -248,13 +236,11 @@ dependencies = [ [[package]] name = "bdk_wallet" -version = "1.0.0-alpha.12" +version = "1.0.0-alpha.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f830d1a9a090b5837d3813aff8b90888e04b72bf2704b29796e1bab439c86255" +checksum = "2926afdbfc54ebf7df2caa51af5be4435b90c01c6fbe5578b51b7c2c0a264bd9" dependencies = [ - "anyhow", - "bdk_chain 0.15.0", - "bdk_persist", + "bdk_chain", "bip39", "bitcoin", "getrandom", @@ -267,9 +253,9 @@ dependencies = [ [[package]] name = "bech32" -version = "0.10.0-beta" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98f7eed2b2781a6f0b5c903471d48e15f56fb4e1165df8a9a2337fd1a59d45ea" +checksum = "d965446196e3b7decd44aa7ee49e31d630118f90ef12f97900f262eb915c951d" [[package]] name = "bincode" @@ -293,15 +279,18 @@ dependencies = [ [[package]] name = "bitcoin" -version = "0.31.2" +version = "0.32.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c85783c2fe40083ea54a33aa2f0ba58831d90fcd190f5bdc47e74e84d2a96ae" +checksum = "ea507acc1cd80fc084ace38544bbcf7ced7c2aa65b653b102de0ce718df668f6" dependencies = [ + "base58ck", "base64 0.21.7", "bech32", - "bitcoin-internals", - "bitcoin_hashes 0.13.0", - "hex-conservative 0.1.2", + "bitcoin-internals 0.3.0", + "bitcoin-io", + "bitcoin-units", + "bitcoin_hashes 0.14.0", + "hex-conservative", "hex_lit", "secp256k1", "serde", @@ -312,10 +301,32 @@ name = "bitcoin-internals" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9425c3bf7089c983facbae04de54513cce73b41c7f9ff8c845b54e7bc64ebbfb" + +[[package]] +name = "bitcoin-internals" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30bdbe14aa07b06e6cfeffc529a1f099e5fbe249524f8125358604df99a4bed2" dependencies = [ "serde", ] +[[package]] +name = "bitcoin-io" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "340e09e8399c7bd8912f495af6aa58bea0c9214773417ffaa8f6460f93aaee56" + +[[package]] +name = "bitcoin-units" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb54da0b28892f3c52203a7191534033e051b6f4b52bc15480681b57b7e036f5" +dependencies = [ + "bitcoin-internals 0.3.0", + "serde", +] + [[package]] name = "bitcoin_hashes" version = "0.11.0" @@ -324,20 +335,20 @@ checksum = "90064b8dee6815a6470d60bad07bbbaee885c0e12d04177138fa3291a01b7bc4" [[package]] name = "bitcoin_hashes" -version = "0.13.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1930a4dabfebb8d7d9992db18ebe3ae2876f0a305fab206fd168df931ede293b" +checksum = "bb18c03d0db0247e147a21a6faafd5a7eb851c743db062de72018b6b7e8e4d16" dependencies = [ - "bitcoin-internals", - "hex-conservative 0.1.2", + "bitcoin-io", + "hex-conservative", "serde", ] [[package]] name = "bitcoincore-rpc" -version = "0.18.0" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8eb70725a621848c83b3809913d5314c0d20ca84877d99dd909504b564edab00" +checksum = "aedd23ae0fd321affb4bbbc36126c6f49a32818dc6b979395d24da8c9d4e80ee" dependencies = [ "bitcoincore-rpc-json", "jsonrpc", @@ -348,9 +359,9 @@ dependencies = [ [[package]] name = "bitcoincore-rpc-json" -version = "0.18.0" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "856ffbee2e492c23bca715d72ea34aae80d58400f2bda26a82015d6bc2ec3662" +checksum = "d8909583c5fab98508e80ef73e5592a651c954993dc6b7739963257d19f0e71a" dependencies = [ "bitcoin", "serde", @@ -473,15 +484,14 @@ checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" [[package]] name = "electrum-client" -version = "0.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89008f106be6f303695522f2f4c1f28b40c3e8367ed8b3bb227f1f882cb52cc2" +version = "0.20.0" +source = "git+https://github.com/thunderbiscuit/rust-electrum-client/?branch=feature/ring-feature#7576e1b6d1f298d270526d740b8508923f3fb790" dependencies = [ "bitcoin", "byteorder", "libc", "log", - "rustls", + "rustls 0.23.10", "serde", "serde_json", "webpki-roots", @@ -490,12 +500,12 @@ dependencies = [ [[package]] name = "esplora-client" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a73e879128c5fcb38abaf0ec53e3310947c6e7b61ce0f1b4cd7a0b8ea1ab0389" +checksum = "69c6d27ef4ff21019edd98aa92199757e10a88065bbfcef6bb750ca6ec5e4a45" dependencies = [ "bitcoin", - "hex-conservative 0.2.1", + "hex-conservative", "log", "minreq", "serde", @@ -574,12 +584,6 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" -[[package]] -name = "hex-conservative" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "212ab92002354b4819390025006c897e8140934349e8635c9b077f47b4dcbd20" - [[package]] name = "hex-conservative" version = "0.2.1" @@ -618,11 +622,12 @@ dependencies = [ [[package]] name = "jsonrpc" -version = "0.14.1" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8128f36b47411cd3f044be8c1f5cc0c9e24d1d1bfdc45f0a57897b32513053f2" +checksum = "3662a38d341d77efecb73caf01420cfa5aa63c0253fd7bc05289ef9f6616e1bf" dependencies = [ "base64 0.13.1", + "minreq", "serde", "serde_json", ] @@ -652,9 +657,9 @@ checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] name = "memchr" -version = "2.7.2" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "mime" @@ -680,13 +685,12 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniscript" -version = "11.0.0" +version = "12.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86a23dd3ad145a980e231185d114399f25a0a307d2cd918010ddda6334323df9" +checksum = "b59c67956fd276ceec0cf194fbf80754ef4d88a496d5cf5e4fdf33561466183d" dependencies = [ "bech32", "bitcoin", - "bitcoin-internals", "serde", ] @@ -699,8 +703,8 @@ dependencies = [ "base64 0.12.3", "log", "once_cell", - "rustls", - "rustls-webpki", + "rustls 0.21.12", + "rustls-webpki 0.101.7", "serde", "serde_json", "webpki-roots", @@ -831,10 +835,31 @@ checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e" dependencies = [ "log", "ring", - "rustls-webpki", + "rustls-webpki 0.101.7", "sct", ] +[[package]] +name = "rustls" +version = "0.23.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05cff451f60db80f490f3c182b77c35260baace73209e9cdbbe526bfe3a4d402" +dependencies = [ + "log", + "once_cell", + "ring", + "rustls-pki-types", + "rustls-webpki 0.102.4", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-pki-types" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "976295e77ce332211c0d24d92c0e83e50f5c5f046d11082cea19f3df13a3562d" + [[package]] name = "rustls-webpki" version = "0.101.7" @@ -845,6 +870,17 @@ dependencies = [ "untrusted", ] +[[package]] +name = "rustls-webpki" +version = "0.102.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff448f7e92e913c4b7d4c6d8e4540a1724b319b4152b8aef6d4cf8339712b33e" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", +] + [[package]] name = "ryu" version = "1.0.18" @@ -883,11 +919,11 @@ dependencies = [ [[package]] name = "secp256k1" -version = "0.28.2" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d24b59d129cdadea20aea4fb2352fa053712e5d713eee47d700cd4b2bc002f10" +checksum = "0e0cc0f1cf93f4969faf3ea1c7d8a9faed25918d96affa959720823dfe86d4f3" dependencies = [ - "bitcoin_hashes 0.13.0", + "bitcoin_hashes 0.14.0", "rand", "secp256k1-sys", "serde", @@ -895,9 +931,9 @@ dependencies = [ [[package]] name = "secp256k1-sys" -version = "0.9.2" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5d1746aae42c19d583c3c1a8c646bfad910498e2051c551a7f2e3c0c9fbb7eb" +checksum = "1433bd67156263443f14d603720b082dd3121779323fce20cba2aa07b874bc1b" dependencies = [ "cc", ] @@ -978,6 +1014,12 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" +[[package]] +name = "subtle" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d0208408ba0c3df17ed26eb06992cb1a1268d41b2c0e12e65203fbe3972cee5" + [[package]] name = "syn" version = "2.0.66" @@ -1410,3 +1452,9 @@ dependencies = [ "quote", "syn", ] + +[[package]] +name = "zeroize" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" diff --git a/bdk-ffi/Cargo.toml b/bdk-ffi/Cargo.toml index 4983042..ef06776 100644 --- a/bdk-ffi/Cargo.toml +++ b/bdk-ffi/Cargo.toml @@ -18,14 +18,17 @@ path = "uniffi-bindgen.rs" default = ["uniffi/cli"] [dependencies] -bdk_wallet = { version = "1.0.0-alpha.12", features = ["all-keys", "keys-bip39"] } -bdk_esplora = { version = "0.14.0", default-features = false, features = ["std", "blocking", "blocking-https-rustls"] } -bdk_electrum = { version = "0.14.0" } -bdk_sqlite = { version = "0.1.0" } -bdk_bitcoind_rpc = { version = "0.10.0" } +bdk_wallet = { version = "1.0.0-alpha.13", features = ["all-keys", "keys-bip39"] } +bdk_esplora = { version = "0.15.0", default-features = false, features = ["std", "blocking", "blocking-https-rustls"] } +# NOTE: This is a temporary workaround to use the electrum-client with the use-rustls-ring feature. It points to a fork +# of bdk in which the bdk_electrum library uses the electrum-client with the use-rustls-ring feature. +bdk_electrum = { git = "https://github.com/thunderbiscuit/bdk/", package = "bdk_electrum", branch = "feature/electrum-client-ring-feature" } +# bdk_electrum = { version = "0.15.0" } +bdk_sqlite = { version = "0.2.0" } +bdk_bitcoind_rpc = { version = "0.12.0" } +bitcoin-internals = { version = "0.2.0", features = ["alloc"] } uniffi = { version = "=0.28.0" } -bitcoin-internals = { version = "0.2.0", features = ["alloc"] } thiserror = "1.0.58" [build-dependencies] diff --git a/bdk-ffi/src/bdk.udl b/bdk-ffi/src/bdk.udl index b917428..b336bac 100644 --- a/bdk-ffi/src/bdk.udl +++ b/bdk-ffi/src/bdk.udl @@ -5,16 +5,17 @@ namespace bdk {}; // ------------------------------------------------------------------------ [Error] -interface AddressError { +interface AddressParseError { Base58(); Bech32(); WitnessVersion(string error_message); WitnessProgram(string error_message); - UncompressedPubkey(); - ExcessiveScriptSize(); - UnrecognizedScript(); - NetworkValidation(Network required, Network found, string address); - OtherAddressErr(); + UnknownHrp(); + LegacyAddressTooLong(); + InvalidBase58PayloadLength(); + InvalidLegacyPrefix(); + NetworkValidation(); + OtherAddressParseErr(); }; [Error] @@ -44,7 +45,7 @@ interface Bip39Error { [Error] interface CalculateFeeError { MissingTxOut(sequence out_points); - NegativeFee(i64 fee); + NegativeFee(string amount); }; [Error] @@ -55,7 +56,6 @@ interface CannotConnectError { [Error] interface CreateTxError { Descriptor(string error_message); - Persist(string error_message); Policy(string error_message); SpendingPolicyRequired(string kind); Version0(); @@ -63,7 +63,7 @@ interface CreateTxError { LockTime(string requested, string required); RbfSequence(); RbfSequenceCsv(string rbf, string csv); - FeeTooLow(u64 required); + FeeTooLow(string required); FeeRateTooLow(string required); NoUtxosSelected(); OutputBelowDustLimit(u64 index); @@ -92,6 +92,7 @@ interface DescriptorError { Pk(string error_message); Miniscript(string error_message); Hex(string error_message); + ExternalAndInternalAreTheSame(); }; [Error] @@ -152,16 +153,21 @@ enum FeeRateError { "ArithmeticOverflow" }; +[Error] +interface FromScriptError { + UnrecognizedScript(); + WitnessProgram(string error_message); + WitnessVersion(string error_message); + OtherFromScriptErr(); +}; + [Error] interface ParseAmountError { - Negative(); - TooBig(); + OutOfRange(); TooPrecise(); - InvalidFormat(); + MissingDigits(); InputTooLarge(); InvalidCharacter(string error_message); - UnknownDenomination(string error_message); - PossiblyConfusingDenomination(string error_message); OtherParseAmountErr(); }; @@ -231,7 +237,9 @@ interface SignerError { MissingHdKeypath(); NonStandardSighash(); InvalidSighash(); - SighashError(string error_message); + SighashP2wpkh(string error_message); + SighashTaproot(string error_message); + TxInputsIndexError(string error_message); MiniscriptPsbt(string error_message); External(string error_message); }; @@ -260,19 +268,14 @@ interface TxidParseError { [Error] interface WalletCreationError { - Io(string error_message); - InvalidMagicBytes(sequence got, sequence expected); - Descriptor(); - Persist(string error_message); - NotInitialized(); + Descriptor(string error_message); LoadedGenesisDoesNotMatch(string expected, string got); LoadedNetworkDoesNotMatch(Network expected, Network? got); LoadedDescriptorDoesNotMatch(string got, KeychainKind keychain); - Sqlite(string error_message); }; // ------------------------------------------------------------------------ -// bdk crate - types module +// bdk_wallet crate - types module // ------------------------------------------------------------------------ enum KeychainKind { @@ -343,8 +346,10 @@ interface FullScanScriptInspector { void inspect(KeychainKind keychain, u32 index, Script script); }; +interface ChangeSet {}; + // ------------------------------------------------------------------------ -// bdk crate - wallet module +// bdk_wallet crate - wallet module // ------------------------------------------------------------------------ enum ChangeSpendPolicy { @@ -355,24 +360,20 @@ enum ChangeSpendPolicy { interface Wallet { [Throws=WalletCreationError] - constructor(Descriptor descriptor, Descriptor? change_descriptor, string persistence_backend_path, Network network); + constructor(Descriptor descriptor, Descriptor change_descriptor, Network network); - [Name=new_no_persist, Throws=DescriptorError] - constructor(Descriptor descriptor, Descriptor? change_descriptor, Network network); + // [Name=new_or_load, Throws=WalletCreationError] + // constructor(Descriptor descriptor, Descriptor change_descriptor, Network network); - [Throws=PersistenceError] AddressInfo reveal_next_address(KeychainKind keychain); Network network(); - Balance get_balance(); + Balance balance(); [Throws=CannotConnectError] void apply_update(Update update); - [Throws=PersistenceError] - boolean commit(); - boolean is_mine([ByRef] Script script); [Throws=SignerError] @@ -386,7 +387,7 @@ interface Wallet { CanonicalTx? get_tx(string txid); [Throws=CalculateFeeError] - u64 calculate_fee([ByRef] Transaction tx); + Amount calculate_fee([ByRef] Transaction tx); [Throws=CalculateFeeError] FeeRate calculate_fee_rate([ByRef] Transaction tx); @@ -398,6 +399,8 @@ interface Wallet { FullScanRequest start_full_scan(); SyncRequest start_sync_with_revealed_spks(); + + ChangeSet? take_staged(); }; interface Update {}; @@ -450,6 +453,18 @@ interface BumpFeeTxBuilder { Psbt finish([ByRef] Wallet wallet); }; +// ------------------------------------------------------------------------ +// bdk_sqlite crate +// ------------------------------------------------------------------------ + +interface SqliteStore { + [Throws=SqliteError] + constructor(string path); + + [Throws=SqliteError] + void write([ByRef] ChangeSet change_set); +}; + // ------------------------------------------------------------------------ // bdk crate - descriptor module // ------------------------------------------------------------------------ @@ -584,7 +599,7 @@ dictionary SentAndReceivedValues { }; // ------------------------------------------------------------------------ -// bdk crate - bitcoin re-exports +// bdk_wallet crate - bitcoin re-exports // ------------------------------------------------------------------------ interface Script { @@ -611,14 +626,12 @@ enum WordCount { [Traits=(Display)] interface Address { - [Throws=AddressError] + [Throws=AddressParseError] constructor(string address, Network network); - [Name=from_script, Throws=AddressError] + [Name=from_script, Throws=FromScriptError] constructor(Script script, Network network); - Network network(); - Script script_pubkey(); string to_qr_uri(); @@ -630,7 +643,7 @@ interface Transaction { [Throws=TransactionError] constructor(sequence transaction_bytes); - string txid(); + string compute_txid(); u64 total_size(); diff --git a/bdk-ffi/src/bitcoin.rs b/bdk-ffi/src/bitcoin.rs index 4433163..addf36e 100644 --- a/bdk-ffi/src/bitcoin.rs +++ b/bdk-ffi/src/bitcoin.rs @@ -1,5 +1,6 @@ -use crate::error::{AddressError, FeeRateError, PsbtError, PsbtParseError, TransactionError}; -use std::fmt::Display; +use crate::error::{ + AddressParseError, FeeRateError, FromScriptError, PsbtError, PsbtParseError, TransactionError, +}; use bdk_bitcoind_rpc::bitcoincore_rpc::jsonrpc::serde_json; use bdk_wallet::bitcoin::address::{NetworkChecked, NetworkUnchecked}; @@ -8,6 +9,7 @@ use bdk_wallet::bitcoin::blockdata::script::ScriptBuf as BdkScriptBuf; use bdk_wallet::bitcoin::blockdata::transaction::TxOut as BdkTxOut; use bdk_wallet::bitcoin::consensus::encode::serialize; use bdk_wallet::bitcoin::consensus::Decodable; +use bdk_wallet::bitcoin::io::Cursor; use bdk_wallet::bitcoin::psbt::ExtractTxError; use bdk_wallet::bitcoin::Address as BdkAddress; use bdk_wallet::bitcoin::Amount as BdkAmount; @@ -19,7 +21,7 @@ use bdk_wallet::bitcoin::Transaction as BdkTransaction; use bdk_wallet::bitcoin::TxIn as BdkTxIn; use bdk_wallet::bitcoin::Txid; -use std::io::Cursor; +use std::fmt::Display; use std::ops::Deref; use std::str::FromStr; use std::sync::{Arc, Mutex}; @@ -82,23 +84,19 @@ impl From for Script { pub struct Address(BdkAddress); impl Address { - pub fn new(address: String, network: Network) -> Result { + pub fn new(address: String, network: Network) -> Result { let parsed_address = address.parse::>()?; let network_checked_address = parsed_address.require_network(network)?; Ok(Address(network_checked_address)) } - pub fn from_script(script: Arc