From 95f976fd632c95660b3ef5d876057762b1006ab2 Mon Sep 17 00:00:00 2001 From: Richard Ulrich Date: Fri, 5 Jan 2024 18:41:30 +0100 Subject: [PATCH] adapt to changes in https://github.com/bitcoindevkit/bdk-reserves/pull/34 --- Cargo.lock | 64 ++++++++++++++++++++++++------------------------- Cargo.toml | 7 +++--- src/commands.rs | 16 ++++--------- src/handlers.rs | 24 +++++++++---------- 4 files changed, 51 insertions(+), 60 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ddf5635..2e7d0fe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -147,9 +147,9 @@ checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" [[package]] name = "bdk" -version = "0.27.1" +version = "0.28.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51c878ac60a45c41523ff790df555ccb1fbfd634a667220104dcae3e64d7ed9f" +checksum = "b15adb2017ab6437b6704a779ab8bbefe857612f5af9d84b677a1767f965e099" dependencies = [ "ahash 0.7.6", "async-trait", @@ -176,7 +176,7 @@ dependencies = [ [[package]] name = "bdk-cli" -version = "0.27.1" +version = "0.28.2" dependencies = [ "base64 0.13.1", "bdk", @@ -217,9 +217,8 @@ dependencies = [ [[package]] name = "bdk-reserves" -version = "0.27.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06cb7208a257fce1f716e578a8d9e4c599f0bc5d0bb6535ed0b57c3e940b3bdb" +version = "0.28.1" +source = "git+https://github.com/Ademan/bdk-reserves?branch=wip-bip-0127#097c7a975b7580cd8003294bfd4225fd438ab3e8" dependencies = [ "bdk", "bitcoinconsensus", @@ -234,12 +233,11 @@ checksum = "d86b93f97252c47b41663388e6d155714a9d0c398b99f1005cbc5f978b29f445" [[package]] name = "bip39" -version = "1.2.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29b9e657de8ff1c3488a4ab77cb51d604eab53415ce34f0bc800f2eac9b13c28" +checksum = "93f2635620bf0b9d4576eb7bb9a38a55df78bd1205d26fa994b25911a69f212f" dependencies = [ "bitcoin_hashes", - "rand_core 0.4.2", "serde", "unicode-normalization", ] @@ -667,9 +665,9 @@ dependencies = [ [[package]] name = "esplora-client" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38bbba572d03ca4d628b653f01e60ba6947c67df65ee8910c79daaf252897924" +checksum = "847e59bd6ee1c3f2bdf217118ee3640b97a1b1d8becb55771e67e533b87da66f" dependencies = [ "bitcoin", "log", @@ -1216,12 +1214,6 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2532096657941c2fea9c289d370a250971c689d4f143798ff67113ec042024a5" -[[package]] -name = "maybe-uninit" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" - [[package]] name = "memchr" version = "2.5.0" @@ -1306,7 +1298,7 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77a5d83df9f36fe23f0c3648c6bbb8b0298bb5f1939c8f2704431371f4b84d43" dependencies = [ - "smallvec 1.11.0", + "smallvec", ] [[package]] @@ -1447,7 +1439,7 @@ dependencies = [ "instant", "libc", "redox_syscall 0.2.16", - "smallvec 1.11.0", + "smallvec", "winapi", ] @@ -1903,7 +1895,7 @@ dependencies = [ "fallible-streaming-iterator", "hashlink", "libsqlite3-sys", - "smallvec 1.11.0", + "smallvec", ] [[package]] @@ -1986,7 +1978,7 @@ dependencies = [ "nix 0.22.3", "radix_trie", "scopeguard", - "smallvec 1.11.0", + "smallvec", "unicode-segmentation", "unicode-width", "utf8parse", @@ -2176,15 +2168,6 @@ dependencies = [ "parking_lot", ] -[[package]] -name = "smallvec" -version = "0.6.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97fcaeba89edba30f044a10c6a3cc39df9c3f17d7cd829dd1446cab35f890e0" -dependencies = [ - "maybe-uninit", -] - [[package]] name = "smallvec" version = "1.11.0" @@ -2345,6 +2328,21 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42657b1a6f4d817cda8e7a0ace261fe0cc946cf3a80314390b22cc61ae080792" +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + [[package]] name = "tokio" version = "1.32.0" @@ -2461,11 +2459,11 @@ checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" [[package]] name = "unicode-normalization" -version = "0.1.9" +version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09c8070a9942f5e7cfccd93f490fdebd230ee3c3c9f107cb25bad5351ef671cf" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" dependencies = [ - "smallvec 0.6.14", + "tinyvec", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 48a8603..73bb8c6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bdk-cli" -version = "0.27.1" +version = "0.28.2" edition = "2018" authors = ["Alekos Filini ", "Riccardo Casatta ", "Steve Myers "] homepage = "https://bitcoindevkit.org" @@ -12,7 +12,7 @@ readme = "README.md" license = "MIT" [dependencies] -bdk = { version = "0.27.1", default-features = false, features = ["all-keys"] } +bdk = { version = "0.28.2", default-features = false, features = ["all-keys", "std"] } bdk-macros = "0.6" clap = { version = "3.2.22", features = ["derive"] } serde_json = "1.0" @@ -26,7 +26,8 @@ base64 = "^0.13" rustyline = { version = "~9.0", optional = true } fd-lock = { version = "=3.0.2", optional = true } regex = { version = "1", optional = true } -bdk-reserves = { version = "0.27.1", optional = true } +#bdk-reserves = { version = "0.27.1", optional = true } +bdk-reserves = { git = "https://github.com/Ademan/bdk-reserves", branch="wip-bip-0127", optional = true } electrsd = { version= "0.22", features = ["bitcoind_22_0"], optional = true} # Platform-specific dependencies diff --git a/src/commands.rs b/src/commands.rs index 12d8fe9..a208c1f 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -1554,7 +1554,7 @@ mod test { .unwrap(); let psbt = encode_psbt(psbt); let psbt = str::from_utf8(&psbt).unwrap(); - assert_eq!(format!("{}", psbt), "cHNidP8BAP0YAgEAAAAM0DsC5Uy7AiuQC5e0oOrDcGu6i8rY8fsT3QzMJvJoAyUAAAAAAP////8IgYfaHR37CUDGQCaLj/QMLxAFteVTnYAskOVx6wHQLgEAAAAA/////wxNB645qLQXuZJoemip3ne14b5R5GWHEDL8o20m0oiHAAAAAAD/////UII10YAYjpnNzaXu1mPht5rsUF74nrz4anfwWykHepUAAAAAAP////+yr7v1/En7kXz3nVdxunw3lVhUmh6wbXN3cDFK1wbA9gAAAAAA/////7cV00FjL7mwDKa6bLd6TEoI1EI8OszcFUnlqT8j8a2HAQAAAAD/////u193IvDJvWzXUG6xaO8zqLBJK0wKKcVdgG74x+OYVOkAAAAAAP////+80K0TirJXCaMzD5VTAsfU35C3Xkawe26Ha2/vynAarQEAAAAA/////8BRLif9KQ71JK8i/wwjZd2bfF2fvtK53q5fk/KoKBqcAQAAAAD/////0BqoaKC7isw56cqwgPLMffSpGoSsuaycXuHMBc6W5/8AAAAAAP/////vDoSJCOCXfj+sO/p8S7w6AaPg2dbBaP0bAliB7X+3+wEAAAAA//////nwXYCb9rUnXsOz23U8xLrx6fhHcWbV2U2ItyzyqK4SAQAAAAD/////AWcFIAAAAAAAGXapFJ9/0JbTftLA4/fwz8kkvu9P/OtoiKwAAAAAAAEBCgAAAAAAAAAAAVEBBwAAAQEfio4BAAAAAAAWABTs5SZXEFPahkVMngZne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Z3nq+dFQLmoiBgMrBVgHi+w4aUqEkz1lkwPiV12ufpFoWRFFQRW/1kSH4wTs5SZXAQcAAQhrAkcwRAIgXfk7THAvQuXaD3RX9St/RDBJC1gfwA2ePYXZfWyzZvUCIAtXUmo2km5U+UACzXuhvmfDbMGR/+YRLuUlh1be4KilASEDKwVYB4vsOGlKhJM9ZZMD4lddrn6RaFkRRUEVv9ZEh+MAAQEfnfgYAAAAAAAWABTs5SZXEFPahkVMngZneer50VAuaiIGAysFWAeL7DhpSoSTPWWTA+JXXa5+kWhZEUVBFb/WRIfjBOzlJlcBBwABCGsCRzBEAiBvqAGpqOEGTWWF7N2JEKFWuI+JsQ0jVMNTVw7C8N9zuQIgCV5kPRkGXHsRI5oabseMFfLkzB/ffgn8nt54X8P1eb8BIQMrBVgHi+w4aUqEkz1lkwPiV12ufpFoWRFFQRW/1kSH4wABAR8QJwAAAAAAABYAFOzlJlcQU9qGRUyeBmd56vnRUC5qIgYDKwVYB4vsOGlKhJM9ZZMD4lddrn6RaFkRRUEVv9ZEh+ME7OUmVwEHAAEIawJHMEQCIBU0eMiQ/FfU4OVH19nETqnNuTggoINuzCYO1op789BaAiASnlZtIIA/FB5MsdrqwJrmSmpDwp4LkRUnO/9W9AhdrAEhAysFWAeL7DhpSoSTPWWTA+JXXa5+kWhZEUVBFb/WRIfjAAEBHxAnAAAAAAAAFgAU7OUmVxBT2oZFTJ4GZ3nq+dFQLmoiBgMrBVgHi+w4aUqEkz1lkwPiV12ufpFoWRFFQRW/1kSH4wTs5SZXAQcAAQhrAkcwRAIgQDXc7dRHfxx4f7ZOHFhYIK1tikFek6Z4DE7srzh73iMCIDywccNDMl83yESpXY4S7Jrhm9TiHBMZgAN+ambO3v5VASEDKwVYB4vsOGlKhJM9ZZMD4lddrn6RaFkRRUEVv9ZEh+MAAA=="); let psbt_b64 = &result .as_object() @@ -1602,7 +1602,7 @@ mod test { fn test_proof_of_reserves_veryfy() { let message = "Those coins belong to Satoshi Nakamoto"; let address =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b/WRIfjAAEBHxAnAAAAAAAAFgAU7OUmVxBT2oZFTJ4GZ3nq+dFQLmoiBgMrBVgHi+w4aUqEkz1lkwPiV12ufpFoWRFFQRW/1kSH4wTs5SZXAQcAAQhrAkcwRAIgQDXc7dRHfxx4f7ZOHFhYIK1tikFek6Z4DE7srzh73iMCIDywccNDMl83yESpXY4S7Jrhm9TiHBMZgAN+ambO3v5VASEDKwVYB4vsOGlKhJM9ZZMD4lddrn6RaFkRRUEVv9ZEh+MAAA=="; let cli_args = vec![ "bdk-cli", @@ -1629,15 +1629,9 @@ mod test { } => (message, psbt, confirmations, addresses, electrum_opts), _ => panic!("unexpected subcommand"), }; - let result = handle_ext_reserves_subcommand( - Network::Bitcoin, - message, - psbt, - confirmations, - addresses, - electrum_opts, - ) - .unwrap(); + let result = + handle_ext_reserves_subcommand(message, psbt, confirmations, addresses, electrum_opts) + .unwrap(); let spendable = result .as_object() .unwrap() diff --git a/src/handlers.rs b/src/handlers.rs index c21afc0..a3df9e7 100644 --- a/src/handlers.rs +++ b/src/handlers.rs @@ -26,6 +26,8 @@ use bdk::{database::BatchDatabase, wallet::AddressIndex, Error, FeeRate, Keychai use clap::Parser; +#[cfg(all(feature = "reserves", feature = "electrum"))] +use crate::bitcoin::{OutPoint, TxOut}; use bdk::bitcoin::consensus::encode::{deserialize, serialize, serialize_hex}; #[cfg(any( feature = "electrum", @@ -76,9 +78,7 @@ use bdk_macros::maybe_async; ))] use bdk_macros::maybe_await; #[cfg(feature = "reserves")] -use bdk_reserves::reserves::verify_proof; -#[cfg(feature = "reserves")] -use bdk_reserves::reserves::ProofOfReserves; +use bdk_reserves::reserves::{ProofOfReserves, ReserveProof}; #[cfg(feature = "repl")] use regex::Regex; #[cfg(feature = "repl")] @@ -550,7 +550,6 @@ pub(crate) fn handle_compile_subcommand( /// Proof of reserves options are described in [`CliSubCommand::ExternalReserves`]. #[cfg(all(feature = "reserves", feature = "electrum"))] pub(crate) fn handle_ext_reserves_subcommand( - network: Network, message: String, psbt: String, confirmations: usize, @@ -573,14 +572,14 @@ pub(crate) fn handle_ext_reserves_subcommand( get_outpoints_for_address(address, &client, max_confirmation_height) }) .collect::>, Error>>()?; - let outpoints_combined = outpoints_per_addr - .iter() - .fold(Vec::new(), |mut outpoints, outs| { - outpoints.append(&mut outs.clone()); - outpoints - }); - - let spendable = verify_proof(&psbt, &message, outpoints_combined, network) + let outpoints = outpoints_per_addr + .into_iter() + .flatten() + .map(|(outpoint, outp)| (outpoint, outp)) + .collect::>(); + + let spendable = psbt + .verify_reserve_proof(&message, &outpoints) .map_err(|e| Error::Generic(format!("{:?}", e)))?; Ok(json!({ "spendable": spendable })) @@ -761,7 +760,6 @@ pub(crate) fn handle_command(cli_opts: CliOpts) -> Result { electrum_opts, } => { let result = handle_ext_reserves_subcommand( - cli_opts.network, message, psbt, confirmations,