Skip to content

Commit

Permalink
Fork bip78 by renaming it payjoin
Browse files Browse the repository at this point in the history
  • Loading branch information
DanGould committed Dec 28, 2022
1 parent ecce332 commit e6dae2b
Show file tree
Hide file tree
Showing 19 changed files with 41 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 15 additions & 15 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[workspace]
members = ["bip78", "payjoin-client"]
members = ["payjoin", "payjoin-client"]
2 changes: 1 addition & 1 deletion payjoin-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
16 changes: 8 additions & 8 deletions payjoin-client/src/main.rs
Original file line number Diff line number Diff line change
@@ -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() {
Expand All @@ -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)"));

Expand All @@ -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(
Expand All @@ -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)
Expand All @@ -81,15 +81,15 @@ fn main() {
client.send_raw_transaction(&tx).unwrap();
}

fn load_psbt_from_base64(mut input: impl std::io::Read) -> Result<Psbt, bip78::bitcoin::consensus::encode::Error> {
use bip78::bitcoin::consensus::Decodable;
fn load_psbt_from_base64(mut input: impl std::io::Read) -> Result<Psbt, payjoin::bitcoin::consensus::encode::Error> {
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)
Expand Down
12 changes: 6 additions & 6 deletions bip78/Cargo.toml → payjoin/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[package]
name = "bip78"
version = "0.2.0-preview"
authors = ["Martin Habovstiak <[email protected]>"]
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 <[email protected]>"]
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"]
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions bip78/src/sender/mod.rs → payjoin/src/sender/mod.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
File renamed without changes.
File renamed without changes.
14 changes: 7 additions & 7 deletions bip78/tests/integration.rs → payjoin/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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(
Expand All @@ -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
}
Expand All @@ -96,8 +96,8 @@ mod integration {
}


fn load_psbt_from_base64(mut input: impl std::io::Read) -> Result<Psbt, bip78::bitcoin::consensus::encode::Error> {
use bip78::bitcoin::consensus::Decodable;
fn load_psbt_from_base64(mut input: impl std::io::Read) -> Result<Psbt, payjoin::bitcoin::consensus::encode::Error> {
use payjoin::bitcoin::consensus::Decodable;

let reader = base64::read::DecoderReader::new(&mut input, base64::Config::new(base64::CharacterSet::Standard, true));
Psbt::consensus_decode(reader)
Expand Down

0 comments on commit e6dae2b

Please sign in to comment.