diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 3021d6a2..a4ed2b34 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -22,7 +22,7 @@ jobs: uses: actions-rs/cargo@v1 with: command: test - args: --verbose --all-features --lib --manifest-path bip78/Cargo.toml + args: --verbose --all-features --lib --manifest-path payjoin/Cargo.toml build-payjoin-client: runs-on: ubuntu-20.04 diff --git a/Cargo.lock b/Cargo.lock index bea7ffa8..381e7ccf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -71,20 +71,6 @@ dependencies = [ "percent-encoding-rfc3986", ] -[[package]] -name = "bip78" -version = "0.2.0-preview" -dependencies = [ - "base64", - "bip21", - "bitcoin", - "bitcoind", - "env_logger", - "log", - "rand", - "url", -] - [[package]] name = "bitcoin" version = "0.27.1" @@ -734,13 +720,27 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "payjoin" +version = "0.3.0-alpha" +dependencies = [ + "base64", + "bip21", + "bitcoin", + "bitcoind", + "env_logger", + "log", + "rand", + "url", +] + [[package]] name = "payjoin-client" version = "0.1.0" dependencies = [ "base64", - "bip78", "bitcoincore-rpc", + "payjoin", "reqwest", ] diff --git a/Cargo.toml b/Cargo.toml index 22d0a4db..e42c3f24 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,2 +1,2 @@ [workspace] -members = ["bip78", "payjoin-client"] +members = ["payjoin", "payjoin-client"] diff --git a/payjoin-client/Cargo.toml b/payjoin-client/Cargo.toml index a0246a17..d256b8d1 100644 --- a/payjoin-client/Cargo.toml +++ b/payjoin-client/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -bip78 = { path = "../bip78", features = ["sender"] } +payjoin = { path = "../payjoin", features = ["sender"] } bitcoincore-rpc = "0.14.0" reqwest = { version = "0.11.4", features = ["blocking"] } base64 = "0.13.0" diff --git a/payjoin-client/src/main.rs b/payjoin-client/src/main.rs index e43f83a5..8d2742a2 100644 --- a/payjoin-client/src/main.rs +++ b/payjoin-client/src/main.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; -use bip78::bitcoin::util::psbt::PartiallySignedTransaction as Psbt; +use payjoin::bitcoin::util::psbt::PartiallySignedTransaction as Psbt; use bitcoincore_rpc::RpcApi; -use bip78::{UriExt, PjUriExt}; +use payjoin::{UriExt, PjUriExt}; use std::convert::TryFrom; fn main() { @@ -27,7 +27,7 @@ fn main() { .into_string() .expect("bip21 is not UTF-8"); - let link = bip78::Uri::try_from(&*bip21).unwrap(); + let link = payjoin::Uri::try_from(&*bip21).unwrap(); let link = link.check_pj_supported().unwrap_or_else(|_| panic!("The provided URI doesn't support payjoin (BIP78)")); @@ -41,7 +41,7 @@ fn main() { let client = bitcoincore_rpc::Client::new(&format!("http://127.0.0.1:{}", port), bitcoincore_rpc::Auth::CookieFile(cookie_file.into())).unwrap(); let options = bitcoincore_rpc::json::WalletCreateFundedPsbtOptions { lock_unspent: Some(true), - fee_rate: Some(bip78::bitcoin::Amount::from_sat(2000)), + fee_rate: Some(payjoin::bitcoin::Amount::from_sat(2000)), ..Default::default() }; let psbt = client.wallet_create_funded_psbt( @@ -57,7 +57,7 @@ fn main() { .psbt; let psbt = load_psbt_from_base64(psbt.as_bytes()).unwrap(); println!("Original psbt: {:#?}", psbt); - let pj_params = bip78::sender::Params::with_fee_contribution(bip78::bitcoin::Amount::from_sat(10000), None); + let pj_params = payjoin::sender::Params::with_fee_contribution(payjoin::bitcoin::Amount::from_sat(10000), None); let (req, ctx) = link.create_pj_request(psbt, pj_params).unwrap(); let response = reqwest::blocking::Client::new() .post(req.url) @@ -81,15 +81,15 @@ fn main() { client.send_raw_transaction(&tx).unwrap(); } -fn load_psbt_from_base64(mut input: impl std::io::Read) -> Result { - use bip78::bitcoin::consensus::Decodable; +fn load_psbt_from_base64(mut input: impl std::io::Read) -> Result { + use payjoin::bitcoin::consensus::Decodable; let reader = base64::read::DecoderReader::new(&mut input, base64::Config::new(base64::CharacterSet::Standard, true)); Psbt::consensus_decode(reader) } fn serialize_psbt(psbt: &Psbt) -> String { - use bip78::bitcoin::consensus::Encodable; + use payjoin::bitcoin::consensus::Encodable; let mut encoder = base64::write::EncoderWriter::new(Vec::new(), base64::STANDARD); psbt.consensus_encode(&mut encoder) diff --git a/bip78/Cargo.toml b/payjoin/Cargo.toml similarity index 68% rename from bip78/Cargo.toml rename to payjoin/Cargo.toml index 901fd8a2..526b6e49 100644 --- a/bip78/Cargo.toml +++ b/payjoin/Cargo.toml @@ -1,10 +1,10 @@ [package] -name = "bip78" -version = "0.2.0-preview" -authors = ["Martin Habovstiak "] -description = "Library implementing PayJoin (BIP78) protocol." -homepage = "https://github.com/Kixunil/payjoin" -repository = "https://github.com/Kixunil/payjoin" +name = "payjoin" +version = "0.3.0-alpha" +authors = ["Dan Gould "] +description = "PayJoin Library for the BIP78 Pay to Endpoint protocol." +homepage = "https://github.com/chaincase-app/payjoin" +repository = "https://github.com/chaincase-app/payjoin" readme = "README.md" keywords = ["bip78", "payjoin", "bitcoin"] categories = ["api-bindings", "cryptography::cryptocurrencies", "network-programming"] diff --git a/bip78/README.md b/payjoin/README.md similarity index 100% rename from bip78/README.md rename to payjoin/README.md diff --git a/bip78/src/fee_rate.rs b/payjoin/src/fee_rate.rs similarity index 100% rename from bip78/src/fee_rate.rs rename to payjoin/src/fee_rate.rs diff --git a/bip78/src/input_type.rs b/payjoin/src/input_type.rs similarity index 100% rename from bip78/src/input_type.rs rename to payjoin/src/input_type.rs diff --git a/bip78/src/lib.rs b/payjoin/src/lib.rs similarity index 100% rename from bip78/src/lib.rs rename to payjoin/src/lib.rs diff --git a/bip78/src/output_type.rs b/payjoin/src/output_type.rs similarity index 100% rename from bip78/src/output_type.rs rename to payjoin/src/output_type.rs diff --git a/bip78/src/psbt.rs b/payjoin/src/psbt.rs similarity index 100% rename from bip78/src/psbt.rs rename to payjoin/src/psbt.rs diff --git a/bip78/src/receiver/error.rs b/payjoin/src/receiver/error.rs similarity index 100% rename from bip78/src/receiver/error.rs rename to payjoin/src/receiver/error.rs diff --git a/bip78/src/receiver/mod.rs b/payjoin/src/receiver/mod.rs similarity index 100% rename from bip78/src/receiver/mod.rs rename to payjoin/src/receiver/mod.rs diff --git a/bip78/src/sender/error.rs b/payjoin/src/sender/error.rs similarity index 100% rename from bip78/src/sender/error.rs rename to payjoin/src/sender/error.rs diff --git a/bip78/src/sender/mod.rs b/payjoin/src/sender/mod.rs similarity index 99% rename from bip78/src/sender/mod.rs rename to payjoin/src/sender/mod.rs index 0806cbac..3d56c188 100644 --- a/bip78/src/sender/mod.rs +++ b/payjoin/src/sender/mod.rs @@ -1,9 +1,9 @@ -//! Sender side of BIP78 +//! Send a PayJoin //! //! This module contains types and methods used to implement sending via BIP78. //! Usage is prety simple: //! -//! 1. Parse BIP21 as `bip78::Uri` +//! 1. Parse BIP21 as `payjoin::Uri` //! 2. Create a finalized PSBT paying `.amount()` to `.address()` //! 3. Spawn a thread or async task that will broadcast the transaction after one minute unless //! canceled diff --git a/bip78/src/uri.rs b/payjoin/src/uri.rs similarity index 100% rename from bip78/src/uri.rs rename to payjoin/src/uri.rs diff --git a/bip78/src/weight.rs b/payjoin/src/weight.rs similarity index 100% rename from bip78/src/weight.rs rename to payjoin/src/weight.rs diff --git a/bip78/tests/integration.rs b/payjoin/tests/integration.rs similarity index 89% rename from bip78/tests/integration.rs rename to payjoin/tests/integration.rs index fd827db4..19da0de5 100644 --- a/bip78/tests/integration.rs +++ b/payjoin/tests/integration.rs @@ -4,12 +4,12 @@ mod integration { use bitcoind::bitcoincore_rpc::RpcApi; use bitcoind::bitcoincore_rpc; use bitcoin::Amount; - use bip78::Uri; + use payjoin::Uri; use std::str::FromStr; use bitcoin::util::psbt::PartiallySignedTransaction as Psbt; use log::{debug, log_enabled, Level}; use std::collections::HashMap; - use bip78::receiver::Headers; + use payjoin::receiver::Headers; #[test] fn integration_test() { @@ -52,7 +52,7 @@ mod integration { debug!("outputs: {:?}", outputs); let options = bitcoincore_rpc::json::WalletCreateFundedPsbtOptions { lock_unspent: Some(true), - fee_rate: Some(bip78::bitcoin::Amount::from_sat(2000)), + fee_rate: Some(payjoin::bitcoin::Amount::from_sat(2000)), ..Default::default() }; let psbt = sender.wallet_create_funded_psbt( @@ -68,12 +68,12 @@ mod integration { .psbt; let psbt = load_psbt_from_base64(psbt.as_bytes()).unwrap(); debug!("Original psbt: {:#?}", psbt); - let pj_params = bip78::sender::Params::with_fee_contribution(bip78::bitcoin::Amount::from_sat(10000), None); + let pj_params = payjoin::sender::Params::with_fee_contribution(payjoin::bitcoin::Amount::from_sat(10000), None); let (req, ctx) = pj_uri.create_request(psbt, pj_params).unwrap(); let headers = HeaderMock::from_vec(&req.body); // Receiver receive payjoin proposal, IRL it will be an HTTP request (over ssl or onion) - let proposal = bip78::receiver::UncheckedProposal::from_request(req.body.as_slice(), "", headers).unwrap(); + let proposal = payjoin::receiver::UncheckedProposal::from_request(req.body.as_slice(), "", headers).unwrap(); // TODO } @@ -96,8 +96,8 @@ mod integration { } - fn load_psbt_from_base64(mut input: impl std::io::Read) -> Result { - use bip78::bitcoin::consensus::Decodable; + fn load_psbt_from_base64(mut input: impl std::io::Read) -> Result { + use payjoin::bitcoin::consensus::Decodable; let reader = base64::read::DecoderReader::new(&mut input, base64::Config::new(base64::CharacterSet::Standard, true)); Psbt::consensus_decode(reader)