From 711b453641d98bc12188c2951d5fef635bdf5951 Mon Sep 17 00:00:00 2001 From: DanGould Date: Wed, 16 Oct 2024 14:37:06 -0400 Subject: [PATCH 1/4] Fix type visibility Add compilation flags so tests don't cause build problems. Simplify lib.rs with `pub use ...::*` wildcards. --- src/lib.rs | 31 ++++++------------------------- src/receive/v1.rs | 1 + src/uri.rs | 1 + tests/bdk_integration_test.rs | 2 ++ tests/bitcoin_core_integration.rs | 2 ++ 5 files changed, 12 insertions(+), 25 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 84b6331..5fdb9dd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,31 +8,12 @@ pub mod types; pub mod uri; use crate::error::PayjoinError; -#[cfg(feature = "uniffi")] -use crate::receive::v1::{ - CanBroadcast, GenerateScript, IsOutputKnown, IsScriptOwned, ProcessPartiallySignedTransaction, -}; -#[allow(unused_imports)] -use crate::receive::v1::{ - Headers, MaybeInputsOwned, MaybeInputsSeen, MaybeMixedInputScripts, OutputsUnknown, - PayjoinProposal, ProvisionalProposal, UncheckedProposal, -}; -#[allow(unused_imports)] -use crate::receive::v2::{ - ActiveSession, ClientResponse, RequestResponse, SessionInitializer, V2MaybeInputsOwned, - V2MaybeInputsSeen, V2MaybeMixedInputScripts, V2OutputsUnknown, V2PayjoinProposal, - V2ProvisionalProposal, V2UncheckedProposal, -}; -#[allow(unused_imports)] -use crate::send::v1::{ - ContextV1, RequestBuilder, RequestContext, RequestContextV1, RequestContextV2, -}; -#[allow(unused_imports)] -use crate::send::v2::ContextV2; -#[allow(unused_imports)] -use crate::types::{Network, OhttpKeys, OutPoint, Request, TxOut}; -#[allow(unused_imports)] -use crate::uri::{PjUri, PjUriBuilder, Uri, Url}; +pub use crate::receive::v1::*; +pub use crate::receive::v2::*; +pub use crate::send::v1::*; +pub use crate::send::v2::*; +pub use crate::types::*; +pub use crate::uri::{PjUri, PjUriBuilder, Uri, Url}; #[cfg(feature = "uniffi")] uniffi::include_scaffolding!("payjoin_ffi"); diff --git a/src/receive/v1.rs b/src/receive/v1.rs index 7602ad3..9fbbc22 100644 --- a/src/receive/v1.rs +++ b/src/receive/v1.rs @@ -441,6 +441,7 @@ impl PayjoinProposal { } #[cfg(test)] +#[cfg(not(feature = "uniffi"))] mod test { use std::sync::Arc; diff --git a/src/uri.rs b/src/uri.rs index e53118d..0b83ba9 100644 --- a/src/uri.rs +++ b/src/uri.rs @@ -220,6 +220,7 @@ impl PjUriBuilder { } #[cfg(test)] +#[cfg(not(feature = "uniffi"))] mod tests { use bdk::bitcoin; diff --git a/tests/bdk_integration_test.rs b/tests/bdk_integration_test.rs index d56edf4..aff290a 100644 --- a/tests/bdk_integration_test.rs +++ b/tests/bdk_integration_test.rs @@ -1,3 +1,5 @@ +#![cfg(all(feature = "enable-danger-local-https", not(feature = "uniffi")))] + use std::collections::HashMap; use std::str::FromStr; use std::sync::{Arc, Mutex, MutexGuard}; diff --git a/tests/bitcoin_core_integration.rs b/tests/bitcoin_core_integration.rs index f2caef4..3345c8a 100644 --- a/tests/bitcoin_core_integration.rs +++ b/tests/bitcoin_core_integration.rs @@ -1,3 +1,5 @@ +#![cfg(all(feature = "enable-danger-local-https", not(feature = "uniffi")))] + extern crate core; use std::collections::HashMap; From 98b5e130266e83f5dd530e73dc91a55f37eec2fb Mon Sep 17 00:00:00 2001 From: DanGould Date: Wed, 16 Oct 2024 14:41:34 -0400 Subject: [PATCH 2/4] Name danger-local-https --- .github/workflows/build.yml | 2 +- Cargo.toml | 2 +- README.md | 2 +- src/io.rs | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8d7628a..419ed02 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,7 +18,7 @@ jobs: override: true profile: minimal - name: Build on Rust ${{ matrix.toolchain }} - run: cargo build --color always --all-targets --features enable-danger-local-https + run: cargo build --color always --all-targets --features danger-local-https - name: Check formatting (nightly only) if: matrix.rust == 'nightly' run: rustup component add rustfmt && cargo fmt --all -- --check diff --git a/Cargo.toml b/Cargo.toml index 15c6fcf..6b568da 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -51,4 +51,4 @@ strip = true [features] default = ["uniffi/cli"] uniffi = [] -enable-danger-local-https = ["payjoin/danger-local-https"] +danger-local-https = ["payjoin/danger-local-https"] diff --git a/README.md b/README.md index d3c062e..3d83ca1 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ The integration tests illustrates and verify integration using bitcoin core and # Run the integration test cargo test --package payjoin_ffi --test bitcoin_core_integration_test v1_to_v1_full_cycle cargo test --package payjoin_ffi --test bdk_integration_test v1_to_v1_full_cycle -cargo test --package payjoin_ffi --test bdk_integration_test v2_to_v2_full_cycle --features enable-danger-local-https +cargo test --package payjoin_ffi --test bdk_integration_test v2_to_v2_full_cycle --features danger-local-https ``` diff --git a/src/io.rs b/src/io.rs index a78844b..4dce7de 100644 --- a/src/io.rs +++ b/src/io.rs @@ -16,11 +16,11 @@ use crate::uri::Url; pub async fn fetch_ohttp_keys( ohttp_relay: Url, payjoin_directory: Url, - #[cfg(feature = "enable-danger-local-https")] cert_der: Vec, + #[cfg(feature = "danger-local-https")] cert_der: Vec, ) -> Result { - #[cfg(not(feature = "enable-danger-local-https"))] + #[cfg(not(feature = "danger-local-https"))] let res = payjoin::io::fetch_ohttp_keys(ohttp_relay.into(), payjoin_directory.into()); - #[cfg(feature = "enable-danger-local-https")] + #[cfg(feature = "danger-local-https")] let res = payjoin::io::fetch_ohttp_keys(ohttp_relay.into(), payjoin_directory.into(), cert_der); res.await.map(|e| e.into()).map_err(|e| e.into()) } From 7586ec6c6229147aed024e82b0b8291de36f99e0 Mon Sep 17 00:00:00 2001 From: DanGould Date: Wed, 16 Oct 2024 14:47:31 -0400 Subject: [PATCH 3/4] Replicate rust-payjoin directory structure Add bitcoin, ohttp, request modules. Remove types module. --- src/bitcoin.rs | 74 +++++++++++++++++++ src/io.rs | 2 +- src/lib.rs | 27 ++++++- src/ohttp.rs | 20 ++++++ src/receive/v1.rs | 2 +- src/receive/v2.rs | 5 +- src/request.rs | 0 src/send/v1.rs | 2 +- src/types.rs | 114 ------------------------------ src/uri.rs | 2 +- tests/bitcoin_core_integration.rs | 3 +- 11 files changed, 128 insertions(+), 123 deletions(-) create mode 100644 src/bitcoin.rs create mode 100644 src/ohttp.rs create mode 100644 src/request.rs delete mode 100644 src/types.rs diff --git a/src/bitcoin.rs b/src/bitcoin.rs new file mode 100644 index 0000000..a8d46c0 --- /dev/null +++ b/src/bitcoin.rs @@ -0,0 +1,74 @@ +use std::str::FromStr; + +use payjoin::bitcoin; + +/// A reference to a transaction output. +#[derive(Clone, Debug, PartialEq, Eq, Hash)] +pub struct OutPoint { + /// The referenced transaction's txid. + pub txid: String, + /// The index of the referenced output in its transaction's vout. + pub vout: u32, +} + +impl From for bitcoin::OutPoint { + fn from(outpoint: OutPoint) -> Self { + bitcoin::OutPoint { + txid: bitcoin::Txid::from_str(&outpoint.txid).expect("Invalid txid"), + vout: outpoint.vout, + } + } +} + +impl From for OutPoint { + fn from(outpoint: bitcoin::OutPoint) -> Self { + OutPoint { txid: outpoint.txid.to_string(), vout: outpoint.vout } + } +} + +#[derive(Debug, Clone)] +pub struct TxOut { + /// The value of the output, in satoshis. + pub value: u64, + /// The address of the output. + pub script_pubkey: Vec, +} + +impl From for bitcoin::TxOut { + fn from(tx_out: TxOut) -> Self { + bitcoin::TxOut { + value: bitcoin::amount::Amount::from_sat(tx_out.value), + script_pubkey: bitcoin::ScriptBuf::from_bytes(tx_out.script_pubkey), + } + } +} + +impl From for TxOut { + fn from(tx_out: bitcoin::TxOut) -> Self { + TxOut { value: tx_out.value.to_sat(), script_pubkey: tx_out.script_pubkey.to_bytes() } + } +} + +#[derive(Clone, Default)] +pub enum Network { + ///Bitcoin’s testnet + Testnet, + ///Bitcoin’s regtest + Regtest, + #[default] + ///Classic Bitcoin + Bitcoin, + ///Bitcoin’s signet + Signet, +} + +impl From for bitcoin::Network { + fn from(network: Network) -> Self { + match network { + Network::Signet => bitcoin::Network::Signet, + Network::Testnet => bitcoin::Network::Testnet, + Network::Regtest => bitcoin::Network::Regtest, + Network::Bitcoin => bitcoin::Network::Bitcoin, + } + } +} diff --git a/src/io.rs b/src/io.rs index 4dce7de..690160f 100644 --- a/src/io.rs +++ b/src/io.rs @@ -1,5 +1,5 @@ use crate::error::PayjoinError; -use crate::types::OhttpKeys; +use crate::ohttp::OhttpKeys; use crate::uri::Url; /// Fetch the ohttp keys from the specified payjoin directory via proxy. diff --git a/src/lib.rs b/src/lib.rs index 5fdb9dd..7c4580c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,19 +1,42 @@ #![crate_name = "payjoin_ffi"] +pub mod bitcoin; pub mod error; pub mod io; +pub mod ohttp; pub mod receive; pub mod send; -pub mod types; pub mod uri; +pub use crate::bitcoin::*; use crate::error::PayjoinError; +pub use crate::ohttp::*; pub use crate::receive::v1::*; pub use crate::receive::v2::*; pub use crate::send::v1::*; pub use crate::send::v2::*; -pub use crate::types::*; pub use crate::uri::{PjUri, PjUriBuilder, Uri, Url}; #[cfg(feature = "uniffi")] uniffi::include_scaffolding!("payjoin_ffi"); + +use std::sync::Arc; +///Represents data that needs to be transmitted to the receiver. +///You need to send this request over HTTP(S) to the receiver. +#[derive(Clone, Debug)] +pub struct Request { + ///URL to send the request to. + /// + ///This is full URL with scheme etc - you can pass it right to reqwest or a similar library. + pub url: Arc, + ///Bytes to be sent to the receiver. + /// + ///This is properly encoded PSBT, already in base64. You only need to make sure Content-Type is text/plain and Content-Length is body.len() (most libraries do the latter automatically). + pub body: Vec, +} + +impl From for Request { + fn from(value: payjoin::Request) -> Self { + Self { url: Arc::new(value.url.into()), body: value.body } + } +} diff --git a/src/ohttp.rs b/src/ohttp.rs new file mode 100644 index 0000000..cdc2d15 --- /dev/null +++ b/src/ohttp.rs @@ -0,0 +1,20 @@ +use crate::error::PayjoinError; + +impl From for OhttpKeys { + fn from(value: payjoin::OhttpKeys) -> Self { + Self(value) + } +} +impl From for payjoin::OhttpKeys { + fn from(value: OhttpKeys) -> Self { + value.0 + } +} +#[derive(Debug, Clone)] +pub struct OhttpKeys(pub payjoin::OhttpKeys); +impl OhttpKeys { + /// Decode an OHTTP KeyConfig + pub fn decode(bytes: Vec) -> Result { + payjoin::OhttpKeys::decode(bytes.as_slice()).map(|e| e.into()).map_err(|e| e.into()) + } +} diff --git a/src/receive/v1.rs b/src/receive/v1.rs index 9fbbc22..0ea19d4 100644 --- a/src/receive/v1.rs +++ b/src/receive/v1.rs @@ -6,8 +6,8 @@ use payjoin::bitcoin::psbt::Psbt; use payjoin::bitcoin::FeeRate; use payjoin::receive as pdk; +use crate::bitcoin::{OutPoint, TxOut}; use crate::error::PayjoinError; -use crate::types::{OutPoint, TxOut}; pub trait CanBroadcast { fn callback(&self, tx: Vec) -> Result; diff --git a/src/receive/v2.rs b/src/receive/v2.rs index de8ee22..156299f 100644 --- a/src/receive/v2.rs +++ b/src/receive/v2.rs @@ -8,13 +8,14 @@ use payjoin::bitcoin::psbt::Psbt; use payjoin::bitcoin::FeeRate; use payjoin::receive as pdk; +use crate::bitcoin::Network; +use crate::ohttp::OhttpKeys; #[cfg(feature = "uniffi")] use crate::receive::v1::{ CanBroadcast, GenerateScript, IsOutputKnown, IsScriptOwned, ProcessPartiallySignedTransaction, }; -use crate::types::Network; use crate::uri::PjUriBuilder; -use crate::{OhttpKeys, OutPoint, PayjoinError, Request, TxOut, Url}; +use crate::{OutPoint, PayjoinError, Request, TxOut, Url}; pub struct ClientResponse(Mutex>); diff --git a/src/request.rs b/src/request.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/send/v1.rs b/src/send/v1.rs index cc5b392..e625e77 100644 --- a/src/send/v1.rs +++ b/src/send/v1.rs @@ -6,8 +6,8 @@ pub use payjoin::send as pdk; use crate::error::PayjoinError; use crate::send::v2::ContextV2; -use crate::types::Request; use crate::uri::{PjUri, Url}; +use crate::Request; ///Builder for sender-side payjoin parameters /// diff --git a/src/types.rs b/src/types.rs deleted file mode 100644 index 54425a2..0000000 --- a/src/types.rs +++ /dev/null @@ -1,114 +0,0 @@ -use std::str::FromStr; -use std::sync::Arc; - -use crate::error::PayjoinError; -use crate::uri::Url; -///Represents data that needs to be transmitted to the receiver. -///You need to send this request over HTTP(S) to the receiver. -#[derive(Clone, Debug)] -pub struct Request { - ///URL to send the request to. - /// - ///This is full URL with scheme etc - you can pass it right to reqwest or a similar library. - pub url: Arc, - ///Bytes to be sent to the receiver. - /// - ///This is properly encoded PSBT, already in base64. You only need to make sure Content-Type is text/plain and Content-Length is body.len() (most libraries do the latter automatically). - pub body: Vec, -} - -impl From for Request { - fn from(value: payjoin::Request) -> Self { - Self { url: Arc::new(value.url.into()), body: value.body } - } -} - -/// A reference to a transaction output. -#[derive(Clone, Debug, PartialEq, Eq, Hash)] -pub struct OutPoint { - /// The referenced transaction's txid. - pub txid: String, - /// The index of the referenced output in its transaction's vout. - pub vout: u32, -} - -impl From for payjoin::bitcoin::OutPoint { - fn from(outpoint: OutPoint) -> Self { - payjoin::bitcoin::OutPoint { - txid: payjoin::bitcoin::Txid::from_str(&outpoint.txid).expect("Invalid txid"), - vout: outpoint.vout, - } - } -} - -impl From for OutPoint { - fn from(outpoint: payjoin::bitcoin::OutPoint) -> Self { - OutPoint { txid: outpoint.txid.to_string(), vout: outpoint.vout } - } -} - -#[derive(Debug, Clone)] -pub struct TxOut { - /// The value of the output, in satoshis. - pub value: u64, - /// The address of the output. - pub script_pubkey: Vec, -} - -impl From for payjoin::bitcoin::TxOut { - fn from(tx_out: TxOut) -> Self { - payjoin::bitcoin::TxOut { - value: payjoin::bitcoin::amount::Amount::from_sat(tx_out.value), - script_pubkey: payjoin::bitcoin::ScriptBuf::from_bytes(tx_out.script_pubkey), - } - } -} - -impl From for TxOut { - fn from(tx_out: payjoin::bitcoin::TxOut) -> Self { - TxOut { value: tx_out.value.to_sat(), script_pubkey: tx_out.script_pubkey.to_bytes() } - } -} - -#[derive(Clone, Default)] -pub enum Network { - ///Bitcoin’s testnet - Testnet, - ///Bitcoin’s regtest - Regtest, - #[default] - ///Classic Bitcoin - Bitcoin, - ///Bitcoin’s signet - Signet, -} - -impl From for payjoin::bitcoin::Network { - fn from(network: Network) -> Self { - match network { - Network::Signet => payjoin::bitcoin::Network::Signet, - Network::Testnet => payjoin::bitcoin::Network::Testnet, - Network::Regtest => payjoin::bitcoin::Network::Regtest, - Network::Bitcoin => payjoin::bitcoin::Network::Bitcoin, - } - } -} - -impl From for OhttpKeys { - fn from(value: payjoin::OhttpKeys) -> Self { - Self(value) - } -} -impl From for payjoin::OhttpKeys { - fn from(value: OhttpKeys) -> Self { - value.0 - } -} -#[derive(Debug, Clone)] -pub struct OhttpKeys(pub payjoin::OhttpKeys); -impl OhttpKeys { - /// Decode an OHTTP KeyConfig - pub fn decode(bytes: Vec) -> Result { - payjoin::OhttpKeys::decode(bytes.as_slice()).map(|e| e.into()).map_err(|e| e.into()) - } -} diff --git a/src/uri.rs b/src/uri.rs index 0b83ba9..be93cd5 100644 --- a/src/uri.rs +++ b/src/uri.rs @@ -7,7 +7,7 @@ use payjoin::bitcoin::address::NetworkChecked; use payjoin::UriExt; use crate::error::PayjoinError; -use crate::types::OhttpKeys; +use crate::ohttp::OhttpKeys; #[derive(Clone)] pub struct Uri(payjoin::Uri<'static, NetworkChecked>); impl From for payjoin::Uri<'static, NetworkChecked> { diff --git a/tests/bitcoin_core_integration.rs b/tests/bitcoin_core_integration.rs index 3345c8a..7e09c36 100644 --- a/tests/bitcoin_core_integration.rs +++ b/tests/bitcoin_core_integration.rs @@ -8,10 +8,11 @@ use std::sync::Arc; use bitcoincore_rpc::bitcoincore_rpc_json::WalletProcessPsbtResult; use bitcoincore_rpc::{Auth, Client, RpcApi}; +use payjoin_ffi::bitcoin::{OutPoint, Request, TxOut}; use payjoin_ffi::receive::v1::{Headers, PayjoinProposal, UncheckedProposal}; use payjoin_ffi::send::v1::RequestBuilder; -use payjoin_ffi::types::{OutPoint, Request, TxOut}; use payjoin_ffi::uri::{PjUriBuilder, Uri, Url}; +use payjoin_ffi::Request; type BoxError = Box; From c96d28cc30d99271207b7226b71a6b5402adb9ac Mon Sep 17 00:00:00 2001 From: DanGould Date: Wed, 16 Oct 2024 14:59:37 -0400 Subject: [PATCH 4/4] Upgrade to unreleased payjoin-0.21 Remove support for v1 send,receive code. Separate uniffi exports where wrappers are required in order to support payjoin-flutter and other non-uniffi bindings. Use procedural macros to define uniffi bindings. Irrelevant v1-to-v1 tests were removed. --- Cargo.lock | 684 ++++++++++++++++------------- Cargo.toml | 15 +- README.md | 27 +- build.rs | 1 + src/bitcoin.rs | 89 ++++ src/error.rs | 34 +- src/io.rs | 34 +- src/lib.rs | 36 +- src/ohttp.rs | 22 + src/payjoin_ffi.udl | 252 ----------- src/receive/mod.rs | 526 +++++++++++++++++++++- src/receive/uni.rs | 420 ++++++++++++++++++ src/receive/v1.rs | 495 --------------------- src/receive/v2.rs | 694 ------------------------------ src/request.rs | 34 ++ src/send/mod.rs | 218 +++++++++- src/send/uni.rs | 216 ++++++++++ src/send/v1.rs | 177 -------- src/send/v2.rs | 29 -- src/uri.rs | 14 +- tests/bdk_integration_test.rs | 531 ++++++++--------------- tests/bitcoin_core_integration.rs | 229 ---------- uniffi-bindgen.rs | 1 + 23 files changed, 2184 insertions(+), 2594 deletions(-) create mode 100644 src/receive/uni.rs delete mode 100644 src/receive/v1.rs delete mode 100644 src/receive/v2.rs create mode 100644 src/send/uni.rs delete mode 100644 src/send/v1.rs delete mode 100644 src/send/v2.rs delete mode 100644 tests/bitcoin_core_integration.rs diff --git a/Cargo.lock b/Cargo.lock index 3226e48..a0e384b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -24,7 +24,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b613b8e1e3cf911a086f53f03bf286f52fd7a7258e4fa606f0ef220d39d8877" dependencies = [ "generic-array", - "rand_core 0.6.4", + "rand_core", ] [[package]] @@ -51,9 +51,9 @@ dependencies = [ [[package]] name = "aes" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac1f845298e95f983ff1944b728ae08b8cebab80d684f0a832ed0fc74dfa27e2" +checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" dependencies = [ "cfg-if", "cipher 0.4.4", @@ -69,22 +69,8 @@ dependencies = [ "aead 0.4.3", "aes 0.7.5", "cipher 0.3.0", - "ctr 0.7.0", - "ghash 0.4.4", - "subtle", -] - -[[package]] -name = "aes-gcm" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "831010a0f742e1209b3bcea8fab6a8e149051ba6099432c8cb2cc117dec3ead1" -dependencies = [ - "aead 0.5.2", - "aes 0.8.3", - "cipher 0.4.4", - "ctr 0.9.2", - "ghash 0.5.0", + "ctr", + "ghash", "subtle", ] @@ -249,6 +235,12 @@ version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" +[[package]] +name = "base64ct" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" + [[package]] name = "basic-toml" version = "0.1.4" @@ -268,6 +260,7 @@ dependencies = [ "bdk-macros", "bip39", "bitcoin 0.30.1", + "core-rpc", "electrum-client", "esplora-client", "getrandom", @@ -378,6 +371,25 @@ dependencies = [ "serde", ] +[[package]] +name = "bitcoin-hpke" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d37a54c486727c1d1ae9cc28dcf78b6e6ba20dcb88e8c892f1437d9ce215dc8c" +dependencies = [ + "aead 0.5.2", + "chacha20poly1305 0.10.1", + "digest 0.10.7", + "generic-array", + "hkdf 0.12.4", + "hmac 0.12.1", + "rand_core", + "secp256k1 0.29.0", + "sha2 0.10.8", + "subtle", + "zeroize", +] + [[package]] name = "bitcoin-internals" version = "0.1.0" @@ -399,6 +411,29 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "340e09e8399c7bd8912f495af6aa58bea0c9214773417ffaa8f6460f93aaee56" +[[package]] +name = "bitcoin-ohttp" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87a803a4b54e44635206b53329c78c0029d0c70926288ac2f07f4bb1267546cb" +dependencies = [ + "aead 0.4.3", + "aes-gcm", + "bitcoin-hpke", + "byteorder", + "chacha20poly1305 0.8.0", + "hex", + "hkdf 0.11.0", + "lazy_static", + "log", + "rand", + "serde", + "serde_derive", + "sha2 0.9.9", + "thiserror", + "toml", +] + [[package]] name = "bitcoin-private" version = "0.1.0" @@ -449,7 +484,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aedd23ae0fd321affb4bbbc36126c6f49a32818dc6b979395d24da8c9d4e80ee" dependencies = [ "bitcoincore-rpc-json", - "jsonrpc", + "jsonrpc 0.18.0", "log", "serde", "serde_json", @@ -466,6 +501,24 @@ dependencies = [ "serde_json", ] +[[package]] +name = "bitcoind" +version = "0.36.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ee5cf6a9903ff9cc808494c1232b0e9f6eef6600913d0d69fe1cb5c428f25b9" +dependencies = [ + "anyhow", + "bitcoin_hashes 0.14.0", + "bitcoincore-rpc", + "flate2", + "log", + "minreq", + "tar", + "tempfile", + "which", + "zip", +] + [[package]] name = "bitflags" version = "1.3.2" @@ -524,6 +577,27 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" +[[package]] +name = "bzip2" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdb116a6ef3f6c3698828873ad02c3014b3c85cadb88496095628e3ef1e347f8" +dependencies = [ + "bzip2-sys", + "libc", +] + +[[package]] +name = "bzip2-sys" +version = "0.1.11+1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "736a955f3fa7875102d57c82b8cac37ec45224a07fd32d58f9f7a186b6cd4cdc" +dependencies = [ + "cc", + "libc", + "pkg-config", +] + [[package]] name = "camino" version = "1.1.6" @@ -562,6 +636,7 @@ version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" dependencies = [ + "jobserver", "libc", ] @@ -702,6 +777,12 @@ dependencies = [ "tokio-util", ] +[[package]] +name = "constant_time_eq" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" + [[package]] name = "core-foundation" version = "0.9.4" @@ -718,6 +799,32 @@ version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" +[[package]] +name = "core-rpc" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26d77079e1b71c2778d6e1daf191adadcd4ff5ec3ccad8298a79061d865b235b" +dependencies = [ + "bitcoin-private", + "core-rpc-json", + "jsonrpc 0.13.0", + "log", + "serde", + "serde_json", +] + +[[package]] +name = "core-rpc-json" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "581898ed9a83f31c64731b1d8ca2dfffcfec14edf1635afacd5234cddbde3a41" +dependencies = [ + "bitcoin 0.30.1", + "bitcoin-private", + "serde", + "serde_json", +] + [[package]] name = "cpufeatures" version = "0.1.5" @@ -767,7 +874,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ "generic-array", - "rand_core 0.6.4", + "rand_core", "typenum", ] @@ -790,28 +897,6 @@ dependencies = [ "cipher 0.3.0", ] -[[package]] -name = "ctr" -version = "0.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835" -dependencies = [ - "cipher 0.4.4", -] - -[[package]] -name = "curve25519-dalek" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b9fdf9972b2bd6af2d913799d9ebc165ea4d2e65878e329d9c6b372c4491b61" -dependencies = [ - "byteorder", - "digest 0.9.0", - "rand_core 0.5.1", - "subtle", - "zeroize", -] - [[package]] name = "darling" version = "0.13.4" @@ -882,6 +967,12 @@ dependencies = [ "subtle", ] +[[package]] +name = "either" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" + [[package]] name = "electrum-client" version = "0.18.0" @@ -902,10 +993,14 @@ dependencies = [ ] [[package]] -name = "equivalent" -version = "1.0.1" +name = "errno" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] [[package]] name = "esplora-client" @@ -920,6 +1015,24 @@ dependencies = [ "ureq", ] +[[package]] +name = "fastrand" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" + +[[package]] +name = "filetime" +version = "0.2.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35c0522e981e68cbfa8c3f978441a5f34b30b96e146b33cd3359176b50fe8586" +dependencies = [ + "cfg-if", + "libc", + "libredox", + "windows-sys 0.59.0", +] + [[package]] name = "flate2" version = "1.0.27" @@ -1087,17 +1200,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1583cc1656d7839fd3732b80cf4f38850336cdb9b8ded1cd399ca62958de3c99" dependencies = [ "opaque-debug", - "polyval 0.5.3", -] - -[[package]] -name = "ghash" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d930750de5717d2dd0b8c0d42c076c0e884c81a73e6cab859bbd2339c71e3e40" -dependencies = [ - "opaque-debug", - "polyval 0.6.1", + "polyval", ] [[package]] @@ -1123,31 +1226,6 @@ dependencies = [ "scroll", ] -[[package]] -name = "h2" -version = "0.3.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" -dependencies = [ - "bytes", - "fnv", - "futures-core", - "futures-sink", - "futures-util", - "http 0.2.12", - "indexmap", - "slab", - "tokio", - "tokio-util", - "tracing", -] - -[[package]] -name = "hashbrown" -version = "0.14.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" - [[package]] name = "heck" version = "0.4.1" @@ -1226,35 +1304,12 @@ dependencies = [ ] [[package]] -name = "hpke" -version = "0.10.0" +name = "home" +version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf39e5461bfdc6ad0fbc97067519fcaf96a7a2e67f24cc0eb8a1e7c0c45af792" +checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" dependencies = [ - "aead 0.5.2", - "aes-gcm 0.10.3", - "byteorder", - "chacha20poly1305 0.10.1", - "digest 0.10.7", - "generic-array", - "hkdf 0.12.4", - "hmac 0.12.1", - "rand_core 0.6.4", - "sha2 0.10.8", - "subtle", - "x25519-dalek", - "zeroize", -] - -[[package]] -name = "http" -version = "0.2.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" -dependencies = [ - "bytes", - "fnv", - "itoa", + "windows-sys 0.52.0", ] [[package]] @@ -1268,17 +1323,6 @@ dependencies = [ "itoa", ] -[[package]] -name = "http-body" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" -dependencies = [ - "bytes", - "http 0.2.12", - "pin-project-lite", -] - [[package]] name = "http-body" version = "1.0.1" @@ -1286,7 +1330,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" dependencies = [ "bytes", - "http 1.1.0", + "http", ] [[package]] @@ -1297,8 +1341,8 @@ checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" dependencies = [ "bytes", "futures-util", - "http 1.1.0", - "http-body 1.0.1", + "http", + "http-body", "pin-project-lite", ] @@ -1314,30 +1358,6 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" -[[package]] -name = "hyper" -version = "0.14.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a152ddd61dfaec7273fe8419ab357f33aee0d914c5f4efbf0d96fa749eea5ec9" -dependencies = [ - "bytes", - "futures-channel", - "futures-core", - "futures-util", - "h2", - "http 0.2.12", - "http-body 0.4.6", - "httparse", - "httpdate", - "itoa", - "pin-project-lite", - "socket2 0.5.7", - "tokio", - "tower-service", - "tracing", - "want", -] - [[package]] name = "hyper" version = "1.4.1" @@ -1347,8 +1367,8 @@ dependencies = [ "bytes", "futures-channel", "futures-util", - "http 1.1.0", - "http-body 1.0.1", + "http", + "http-body", "httparse", "httpdate", "itoa", @@ -1358,22 +1378,6 @@ dependencies = [ "want", ] -[[package]] -name = "hyper-rustls" -version = "0.24.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" -dependencies = [ - "futures-util", - "http 0.2.12", - "hyper 0.14.30", - "log", - "rustls 0.21.7", - "rustls-native-certs 0.6.3", - "tokio", - "tokio-rustls 0.24.1", -] - [[package]] name = "hyper-rustls" version = "0.26.0" @@ -1381,15 +1385,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a0bea761b46ae2b24eb4aef630d8d1c398157b6fc29e6350ecf090a0b70c952c" dependencies = [ "futures-util", - "http 1.1.0", - "hyper 1.4.1", + "http", + "hyper", "hyper-util", "log", "rustls 0.22.4", - "rustls-native-certs 0.7.1", + "rustls-native-certs", "rustls-pki-types", "tokio", - "tokio-rustls 0.25.0", + "tokio-rustls", "tower-service", "webpki-roots 0.26.3", ] @@ -1401,7 +1405,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a343d17fe7885302ed7252767dc7bb83609a874b6ff581142241ec4b73957ad" dependencies = [ "http-body-util", - "hyper 1.4.1", + "hyper", "hyper-util", "pin-project-lite", "tokio", @@ -1418,9 +1422,9 @@ dependencies = [ "bytes", "futures-channel", "futures-util", - "http 1.1.0", - "http-body 1.0.1", - "hyper 1.4.1", + "http", + "http-body", + "hyper", "pin-project-lite", "socket2 0.5.7", "tokio", @@ -1445,16 +1449,6 @@ dependencies = [ "unicode-normalization", ] -[[package]] -name = "indexmap" -version = "2.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" -dependencies = [ - "equivalent", - "hashbrown", -] - [[package]] name = "inout" version = "0.1.3" @@ -1485,6 +1479,15 @@ version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" +[[package]] +name = "jobserver" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48d1dbcbbeb6a7fec7e059840aa538bd62aaccf972c7346c4d9d2059312853d0" +dependencies = [ + "libc", +] + [[package]] name = "js-sys" version = "0.3.64" @@ -1494,6 +1497,17 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "jsonrpc" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd8d6b3f301ba426b30feca834a2a18d48d5b54e5065496b5c1b05537bee3639" +dependencies = [ + "base64 0.13.1", + "serde", + "serde_json", +] + [[package]] name = "jsonrpc" version = "0.18.0" @@ -1518,6 +1532,23 @@ version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +[[package]] +name = "libredox" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" +dependencies = [ + "bitflags 2.6.0", + "libc", + "redox_syscall 0.5.3", +] + +[[package]] +name = "linux-raw-sys" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" + [[package]] name = "lock_api" version = "0.4.11" @@ -1598,8 +1629,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fdef521c74c2884a4f3570bcdb6d2a77b3c533feb6b27ac2ae72673cc221c64" dependencies = [ "log", + "once_cell", + "rustls 0.21.7", + "rustls-webpki 0.101.6", "serde", "serde_json", + "webpki-roots 0.25.2", ] [[package]] @@ -1658,29 +1693,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "ohttp" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578cb11a3fb5c85697ed8bb850d5ad1cbf819d3eea05c2b253cf1d240fbb10c5" -dependencies = [ - "aead 0.4.3", - "aes-gcm 0.9.2", - "byteorder", - "chacha20poly1305 0.8.0", - "hex", - "hkdf 0.11.0", - "hpke", - "lazy_static", - "log", - "rand", - "serde", - "serde_derive", - "sha2 0.9.9", - "thiserror", - "toml", -] - [[package]] name = "ohttp-relay" version = "0.0.8" @@ -1688,10 +1700,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7850c40a0aebcba289d3252c0a45f93cba6ad4b0c46b88a5fc51dba6ddce8632" dependencies = [ "futures", - "http 1.1.0", + "http", "http-body-util", - "hyper 1.4.1", - "hyper-rustls 0.26.0", + "hyper", + "hyper-rustls", "hyper-tungstenite", "hyper-util", "once_cell", @@ -1775,6 +1787,17 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "password-hash" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7676374caaee8a325c9e7a2ae557f216c5563a171d6997b0ef8a65af35147700" +dependencies = [ + "base64ct", + "rand_core", + "subtle", +] + [[package]] name = "paste" version = "1.0.14" @@ -1784,16 +1807,15 @@ checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" [[package]] name = "payjoin" version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf485245549b366884e295426755ce649d924762f676c1cc00e12e21501884a3" +source = "git+https://github.com/payjoin/rust-payjoin?rev=ef2ce55a57fe5270bc761bfcda58024ae45a93aa#ef2ce55a57fe5270bc761bfcda58024ae45a93aa" dependencies = [ "bhttp", "bip21", "bitcoin 0.32.2", - "chacha20poly1305 0.10.1", - "http 1.1.0", + "bitcoin-hpke", + "bitcoin-ohttp", + "http", "log", - "ohttp", "reqwest", "rustls 0.22.4", "serde", @@ -1804,18 +1826,21 @@ dependencies = [ [[package]] name = "payjoin-directory" version = "0.0.1" -source = "git+https://github.com/payjoin/rust-payjoin#12e08ce3476562e5d22512e17c13281e156bc4b2" +source = "git+https://github.com/payjoin/rust-payjoin?rev=ef2ce55a57fe5270bc761bfcda58024ae45a93aa#ef2ce55a57fe5270bc761bfcda58024ae45a93aa" dependencies = [ "anyhow", "bhttp", - "bitcoin 0.30.1", + "bitcoin 0.32.2", + "bitcoin-ohttp", "futures", - "hyper 0.14.30", - "hyper-rustls 0.24.2", - "ohttp", + "http-body-util", + "hyper", + "hyper-rustls", + "hyper-util", "redis", - "rustls 0.21.7", + "rustls 0.22.4", "tokio", + "tokio-rustls", "tracing", "tracing-subscriber", ] @@ -1826,10 +1851,11 @@ version = "0.20.0" dependencies = [ "base64 0.22.1", "bdk", + "bitcoin-ohttp", "bitcoincore-rpc", + "bitcoind", "hex", - "http 1.1.0", - "ohttp", + "http", "ohttp-relay", "payjoin", "payjoin-directory", @@ -1844,6 +1870,18 @@ dependencies = [ "url", ] +[[package]] +name = "pbkdf2" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" +dependencies = [ + "digest 0.10.7", + "hmac 0.12.1", + "password-hash", + "sha2 0.10.8", +] + [[package]] name = "pem" version = "3.0.4" @@ -1898,6 +1936,12 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "pkg-config" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" + [[package]] name = "plain" version = "0.2.3" @@ -1938,18 +1982,6 @@ dependencies = [ "universal-hash 0.4.0", ] -[[package]] -name = "polyval" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d52cff9d1d4dee5fe6d03729099f4a310a41179e0a10dbf542039873f2e826fb" -dependencies = [ - "cfg-if", - "cpufeatures 0.2.9", - "opaque-debug", - "universal-hash 0.5.1", -] - [[package]] name = "powerfmt" version = "0.2.0" @@ -1988,7 +2020,7 @@ checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", "rand_chacha", - "rand_core 0.6.4", + "rand_core", ] [[package]] @@ -1998,15 +2030,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core 0.6.4", + "rand_core", ] -[[package]] -name = "rand_core" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" - [[package]] name = "rand_core" version = "0.6.4" @@ -2121,11 +2147,11 @@ dependencies = [ "bytes", "futures-core", "futures-util", - "http 1.1.0", - "http-body 1.0.1", + "http", + "http-body", "http-body-util", - "hyper 1.4.1", - "hyper-rustls 0.26.0", + "hyper", + "hyper-rustls", "hyper-util", "ipnet", "js-sys", @@ -2135,14 +2161,14 @@ dependencies = [ "percent-encoding", "pin-project-lite", "rustls 0.22.4", - "rustls-pemfile 2.1.2", + "rustls-pemfile", "rustls-pki-types", "serde", "serde_json", "serde_urlencoded", "sync_wrapper", "tokio", - "tokio-rustls 0.25.0", + "tokio-rustls", "tower-service", "url", "wasm-bindgen", @@ -2187,6 +2213,19 @@ version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" +[[package]] +name = "rustix" +version = "0.38.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" +dependencies = [ + "bitflags 2.6.0", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.52.0", +] + [[package]] name = "rustls" version = "0.21.7" @@ -2213,18 +2252,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "rustls-native-certs" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00" -dependencies = [ - "openssl-probe", - "rustls-pemfile 1.0.4", - "schannel", - "security-framework", -] - [[package]] name = "rustls-native-certs" version = "0.7.1" @@ -2232,21 +2259,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a88d6d420651b496bdd98684116959239430022a115c1240e6c3993be0b15fba" dependencies = [ "openssl-probe", - "rustls-pemfile 2.1.2", + "rustls-pemfile", "rustls-pki-types", "schannel", "security-framework", ] -[[package]] -name = "rustls-pemfile" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" -dependencies = [ - "base64 0.21.7", -] - [[package]] name = "rustls-pemfile" version = "2.1.2" @@ -2431,11 +2449,12 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.113" +version = "1.0.132" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69801b70b1c3dac963ecb03a364ba0ceda9cf60c71cfe475e99864759c8b8a79" +checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" dependencies = [ "itoa", + "memchr", "ryu", "serde", ] @@ -2633,9 +2652,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "subtle" -version = "2.5.0" +version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "syn" @@ -2665,6 +2684,29 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" +[[package]] +name = "tar" +version = "0.4.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ff6c40d3aedb5e06b57c6f669ad17ab063dd1e63d977c6a88e7f4dfa4f04020" +dependencies = [ + "filetime", + "libc", + "xattr", +] + +[[package]] +name = "tempfile" +version = "3.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" +dependencies = [ + "cfg-if", + "fastrand", + "rustix", + "windows-sys 0.52.0", +] + [[package]] name = "testcontainers" version = "0.15.0" @@ -2794,16 +2836,6 @@ dependencies = [ "syn 2.0.48", ] -[[package]] -name = "tokio-rustls" -version = "0.24.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" -dependencies = [ - "rustls 0.21.7", - "tokio", -] - [[package]] name = "tokio-rustls" version = "0.25.0" @@ -2952,7 +2984,7 @@ dependencies = [ "byteorder", "bytes", "data-encoding", - "http 1.1.0", + "http", "httparse", "log", "rand", @@ -3350,6 +3382,18 @@ dependencies = [ "nom", ] +[[package]] +name = "which" +version = "4.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" +dependencies = [ + "either", + "home", + "once_cell", + "rustix", +] + [[package]] name = "winapi" version = "0.3.9" @@ -3390,6 +3434,15 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", +] + [[package]] name = "windows-targets" version = "0.48.5" @@ -3522,14 +3575,14 @@ dependencies = [ ] [[package]] -name = "x25519-dalek" -version = "2.0.0-pre.1" +name = "xattr" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5da623d8af10a62342bcbbb230e33e58a63255a58012f8653c578e54bab48df" +checksum = "8da84f1a25939b27f6820d92aed108f83ff920fdf11a7b19366c27c4cda81d4f" dependencies = [ - "curve25519-dalek", - "rand_core 0.6.4", - "zeroize", + "libc", + "linux-raw-sys", + "rustix", ] [[package]] @@ -3560,3 +3613,52 @@ dependencies = [ "quote", "syn 2.0.48", ] + +[[package]] +name = "zip" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "760394e246e4c28189f19d488c058bf16f564016aefac5d32bb1f3b51d5e9261" +dependencies = [ + "aes 0.8.4", + "byteorder", + "bzip2", + "constant_time_eq", + "crc32fast", + "crossbeam-utils", + "flate2", + "hmac 0.12.1", + "pbkdf2", + "sha1", + "time", + "zstd", +] + +[[package]] +name = "zstd" +version = "0.11.2+zstd.1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4" +dependencies = [ + "zstd-safe", +] + +[[package]] +name = "zstd-safe" +version = "5.0.2+zstd.1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d2a5585e04f9eea4b2a3d1eca508c4dee9592a89ef6f450c11719da0726f4db" +dependencies = [ + "libc", + "zstd-sys", +] + +[[package]] +name = "zstd-sys" +version = "2.0.13+zstd.1.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38ff0f21cfee8f97d94cef41359e0c89aa6113028ab0291aa8ca0038995a95aa" +dependencies = [ + "cc", + "pkg-config", +] diff --git a/Cargo.toml b/Cargo.toml index 6b568da..cd3651c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,10 +14,12 @@ uniffi = { version = "0.28.0", features = ["build"] } [dev-dependencies] uniffi = { version = "0.28.0", features = ["bindgen-tests"] } -bdk = { version = "0.29.0", features = ["all-keys", "use-esplora-ureq", "keys-bip39"] } +bdk = { version = "0.29.0", features = ["all-keys", "use-esplora-ureq", "keys-bip39", "rpc"] } +#bitcoin-ffi = { git = "https://github.com/bitcoindevkit/bitcoin-ffi" } +bitcoind = { version = "0.36.0", features = ["0_21_2"] } bitcoincore-rpc = "0.19.0" http = "1" -payjoin-directory = { git = "https://github.com/payjoin/rust-payjoin", features = ["danger-local-https"] } +payjoin-directory = { git = "https://github.com/payjoin/rust-payjoin", rev = "ef2ce55a57fe5270bc761bfcda58024ae45a93aa", features = ["danger-local-https"] } ohttp-relay = "0.0.8" rcgen = { version = "0.11" } reqwest = { version = "0.12", default-features = false, features = ["rustls-tls"] } @@ -27,10 +29,10 @@ testcontainers-modules = { version = "0.1.3", features = ["redis"] } tokio = { version = "1.12.0", features = ["full"] } [dependencies] -payjoin = {version = "=0.20.0", features = ["send", "receive", "base64", "v2", "io"] } -uniffi = { version = "0.28.0" } +payjoin = { git = "https://github.com/payjoin/rust-payjoin", rev = "ef2ce55a57fe5270bc761bfcda58024ae45a93aa", features = ["send", "receive", "base64", "v2", "io"] } +uniffi = { version = "0.28.0", optional = true } thiserror = "1.0.47" -ohttp = { version = "0.5.1" } +ohttp = { package = "bitcoin-ohttp", version = "0.6.0" } url = "2.5.0" base64 = "0.22.1" hex = "0.4.3" @@ -49,6 +51,5 @@ strip = true [features] -default = ["uniffi/cli"] -uniffi = [] +uniffi = ["uniffi/cli"] danger-local-https = ["payjoin/danger-local-https"] diff --git a/README.md b/README.md index 3d83ca1..cada60d 100644 --- a/README.md +++ b/README.md @@ -33,37 +33,12 @@ pip install payjoin ``` ## Running the Integration Test -First, we need to set up bitcoin core and esplora locally in the regtest network. If you don't have these, please refer to this [page](https://learn.saylor.org/mod/page/view.php?id=36347). Alternatively, you can install `Nigiri Bitcoin`, a tool designed to simplify the process of running local instances of Bitcoin and Liquid networks for development and testing purposes. Follow the instructions [here](https://github.com/vulpemventures/nigiri) to install it on your machine. -Once Nigiri Bitcoin is up and running, you need to mine a few blocks. Refer to this [link](https://developer.bitcoin.org/reference/rpc/generatetoaddress.html?highlight=generate) on how to mine blocks. - -Before running the integration tests, replace the following snippet in `tests/bdk_integration_test.rs` and `tests/bitcoin_core_integration_test.rs` with your Nigiri Bitcoin Core credentials: - -```rust -static RPC_USER: &str = "admin1"; -static RPC_PASSWORD: &str = "123"; -static RPC_HOST: &str = "localhost"; -static RPC_PORT: &str = "18443"; - -``` - -NB: The default nigiri credentials would be the following - -``` -rpc_user = "admin1" -rpc_password = "123" -rpc_host = "localhost" -rpc_port = "18443" -``` - -Now, run the integration tests: - -The integration tests illustrates and verify integration using bitcoin core and with bitcoin dev kit(bdk). +The integration tests illustrates and verify integration using bitcoin core and bdk. ```shell # Run the integration test -cargo test --package payjoin_ffi --test bitcoin_core_integration_test v1_to_v1_full_cycle cargo test --package payjoin_ffi --test bdk_integration_test v1_to_v1_full_cycle cargo test --package payjoin_ffi --test bdk_integration_test v2_to_v2_full_cycle --features danger-local-https diff --git a/build.rs b/build.rs index a6b0a23..c1e2e4f 100644 --- a/build.rs +++ b/build.rs @@ -1,3 +1,4 @@ fn main() { + #[cfg(feature = "uniffi")] uniffi::generate_scaffolding("src/payjoin_ffi.udl").unwrap(); } diff --git a/src/bitcoin.rs b/src/bitcoin.rs index a8d46c0..2b51a19 100644 --- a/src/bitcoin.rs +++ b/src/bitcoin.rs @@ -1,9 +1,11 @@ use std::str::FromStr; +use std::sync::Arc; use payjoin::bitcoin; /// A reference to a transaction output. #[derive(Clone, Debug, PartialEq, Eq, Hash)] +#[cfg_attr(feature = "uniffi", derive(uniffi::Record))] pub struct OutPoint { /// The referenced transaction's txid. pub txid: String, @@ -27,6 +29,64 @@ impl From for OutPoint { } #[derive(Debug, Clone)] +#[cfg_attr(feature = "uniffi", derive(uniffi::Record))] +pub struct PsbtInput { + pub witness_utxo: Option, + pub redeem_script: Option>, + pub witness_script: Option>, +} + +impl PsbtInput { + pub fn new( + witness_utxo: Option, + redeem_script: Option>, + witness_script: Option>, + ) -> Self { + Self { witness_utxo, redeem_script, witness_script } + } +} + +impl From for PsbtInput { + fn from(psbt_input: bitcoin::psbt::Input) -> Self { + Self { + witness_utxo: psbt_input.witness_utxo.map(|s| s.into()), + redeem_script: psbt_input.redeem_script.clone().map(|s| Arc::new(s.into())), + witness_script: psbt_input.witness_script.clone().map(|s| Arc::new(s.into())), + } + } +} + +impl From for bitcoin::psbt::Input { + fn from(psbt_input: PsbtInput) -> Self { + Self { + witness_utxo: psbt_input.witness_utxo.map(|s| s.into()), + redeem_script: psbt_input.redeem_script.map(|s| Arc::unwrap_or_clone(s).into()), + witness_script: psbt_input.witness_script.map(|s| Arc::unwrap_or_clone(s).into()), + ..Default::default() + } + } +} + +#[derive(Debug, Clone)] +#[cfg_attr(feature = "uniffi", derive(uniffi::Record))] +pub struct TxIn { + pub previous_output: OutPoint, +} + +impl From for bitcoin::TxIn { + fn from(tx_in: TxIn) -> Self { + bitcoin::TxIn { previous_output: tx_in.previous_output.into(), ..Default::default() } + } +} + +impl From for TxIn { + fn from(tx_in: bitcoin::TxIn) -> Self { + TxIn { previous_output: tx_in.previous_output.into() } + } +} + +#[derive(Debug, Clone)] +#[cfg_attr(feature = "uniffi", derive(uniffi::Record))] pub struct TxOut { /// The value of the output, in satoshis. pub value: u64, @@ -50,6 +110,7 @@ impl From for TxOut { } #[derive(Clone, Default)] +#[cfg_attr(feature = "uniffi", derive(uniffi::Enum))] pub enum Network { ///Bitcoin’s testnet Testnet, @@ -72,3 +133,31 @@ impl From for bitcoin::Network { } } } + +#[derive(Clone, Debug)] +#[cfg_attr(feature = "uniffi", derive(uniffi::Object))] +pub struct Script(pub payjoin::bitcoin::ScriptBuf); + +#[cfg_attr(feature = "uniffi", uniffi::export)] +impl Script { + #[cfg_attr(feature = "uniffi", uniffi::constructor)] + pub fn new(script: Vec) -> Self { + Self(payjoin::bitcoin::ScriptBuf::from_bytes(script)) + } + + pub fn to_bytes(&self) -> Vec { + self.0.to_bytes() + } +} + +impl From for Script { + fn from(value: payjoin::bitcoin::ScriptBuf) -> Self { + Self(value) + } +} + +impl From