Skip to content

Commit dfa2704

Browse files
committed
added psbt::input crate
1 parent d2b67e1 commit dfa2704

File tree

5 files changed

+16
-8
lines changed

5 files changed

+16
-8
lines changed

.github/workflows/cont_integration.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ jobs:
6161
cargo update -p flate2 --precise 1.0.26
6262
cargo update -p reqwest --precise "0.11.18"
6363
cargo update -p h2 --precise "0.3.20"
64+
cargo update -p rustls --precise "0.20.8"
6465
6566
- name: Build
6667
run: cargo build --no-default-features --features repl,${{ matrix.features }}

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ readme = "README.md"
1212
license = "MIT"
1313

1414
[dependencies]
15-
# right here set path
1615
bdk = { version = "0.27.1", default-features = false, features = ["all-keys"] }
1716
bdk-macros = "0.6"
1817
clap = { version = "3.2.22", features = ["derive"] }
@@ -25,7 +24,7 @@ base64 = "^0.13"
2524
# payjoin dependencies
2625
payjoin = { version = "=0.8.2", features = ["send"] }
2726
# reqwest
28-
reqwest = { version = "0.11.4", features = ["blocking"] }
27+
reqwest = { version = "0.10.10", features = ["blocking"] }
2928

3029

3130

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ cargo update -p flate2 --precise 1.0.26
143143
cargo update -p reqwest --precise "0.11.18"
144144
# h2 0.3.21 has MSRV 1.63.0+
145145
cargo update -p h2 --precise "0.3.20"
146+
# rustls 0.20.9 has MSRV 1.60.0+
147+
cargo update -p rustls --precise "0.20.8"
146148
```
147149

148150
## Resources

src/commands.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,7 @@ pub enum OnlineWalletSubCommand {
527527
#[clap(name = "CONFIRMATIONS", long = "confirmations", default_value = "6")]
528528
confirmations: u32,
529529
},
530+
#[cfg(not(feature = "async-interface"))]
530531
/// Sends a Payjoin Transaction. Takes a valid payjoin bip21 uri.
531532
SendPayjoin {
532533
/// Sets the bip21 uri to send to.

src/handlers.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ use bdk::{database::BatchDatabase, wallet::AddressIndex, Error, FeeRate, Keychai
2626

2727
use clap::Parser;
2828

29-
3029
use bdk::bitcoin::consensus::encode::{deserialize, serialize, serialize_hex};
3130
#[cfg(any(
3231
feature = "electrum",
@@ -88,9 +87,10 @@ use rustyline::error::ReadlineError;
8887
use rustyline::Editor;
8988
use serde_json::json;
9089
use std::str::FromStr;
91-
// Import some modules for payjoin functionality from payjoin crate
90+
// Import some modules for payjoin functionality
91+
9292

93-
/// Execute an offline wallet sub-command
93+
// Execute an offline wallet sub-command
9494
///
9595
/// Offline wallet sub-commands are described in [`OfflineWalletSubCommand`].
9696
pub fn handle_offline_wallet_subcommand<D>(
@@ -323,7 +323,11 @@ where
323323
B: Blockchain,
324324
D: BatchDatabase,
325325
{
326-
use bdk::{signer::InputSigner, wallet::tx_builder, SyncOptions};
326+
use bdk::SyncOptions;
327+
use payjoin::PjUriExt;
328+
use payjoin::UriExt;
329+
use crate::bitcoin::psbt::Input;
330+
use std::convert::TryFrom;
327331

328332
match online_subcommand {
329333
Sync => {
@@ -396,6 +400,7 @@ where
396400
Ok(json!({ "spendable": spendable }))
397401
}
398402

403+
#[cfg(not(feature = "async-interface"))]
399404
// Payjoin Logic goes here
400405
SendPayjoin { uri } => {
401406
// convert the bip21 uri into a payjoin uri, and handle error if necessary
@@ -406,7 +411,7 @@ where
406411
// ensure uri is payjoin capable
407412
let uri = uri
408413
.check_pj_supported()
409-
.map_err(|e| Error::Generic(format!("Payjoin not supported: {}", e)))?;
414+
.map_err(|e| Error::Generic(format!("Payjoin not supported: {}", e.to_string())))?;
410415

411416
// ensure amount of satoshis is specified in uri, handle error if not
412417
let sats = match uri.amount {
@@ -483,7 +488,7 @@ where
483488
// get original inputs from original psbt clone (ocean_psbt)
484489
let mut original_inputs = input_pairs(&mut ocean_psbt).peekable();
485490

486-
for (proposed_txin, mut proposed_psbtin) in input_pairs(&mut payjoin_psbt) {
491+
for (proposed_txin, proposed_psbtin) in input_pairs(&mut payjoin_psbt) {
487492
if let Some((original_txin, original_psbtin)) = original_inputs.peek() {
488493
if proposed_txin.previous_output == original_txin.previous_output {
489494
proposed_psbtin.witness_utxo = original_psbtin.witness_utxo.clone();

0 commit comments

Comments
 (0)