Skip to content

Commit 17911ce

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

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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@ 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"
148+
146149
```
147150

148151
## 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: 10 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,9 @@ 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
9291

93-
/// Execute an offline wallet sub-command
92+
// Execute an offline wallet sub-command
9493
///
9594
/// Offline wallet sub-commands are described in [`OfflineWalletSubCommand`].
9695
pub fn handle_offline_wallet_subcommand<D>(
@@ -323,7 +322,11 @@ where
323322
B: Blockchain,
324323
D: BatchDatabase,
325324
{
326-
use bdk::{signer::InputSigner, wallet::tx_builder, SyncOptions};
325+
use crate::bitcoin::psbt::Input;
326+
use bdk::SyncOptions;
327+
use payjoin::PjUriExt;
328+
use payjoin::UriExt;
329+
use std::convert::TryFrom;
327330

328331
match online_subcommand {
329332
Sync => {
@@ -396,6 +399,7 @@ where
396399
Ok(json!({ "spendable": spendable }))
397400
}
398401

402+
#[cfg(not(feature = "async-interface"))]
399403
// Payjoin Logic goes here
400404
SendPayjoin { uri } => {
401405
// convert the bip21 uri into a payjoin uri, and handle error if necessary
@@ -406,7 +410,7 @@ where
406410
// ensure uri is payjoin capable
407411
let uri = uri
408412
.check_pj_supported()
409-
.map_err(|e| Error::Generic(format!("Payjoin not supported: {}", e)))?;
413+
.map_err(|e| Error::Generic(format!("Payjoin not supported: {}", e.to_string())))?;
410414

411415
// ensure amount of satoshis is specified in uri, handle error if not
412416
let sats = match uri.amount {
@@ -483,7 +487,7 @@ where
483487
// get original inputs from original psbt clone (ocean_psbt)
484488
let mut original_inputs = input_pairs(&mut ocean_psbt).peekable();
485489

486-
for (proposed_txin, mut proposed_psbtin) in input_pairs(&mut payjoin_psbt) {
490+
for (proposed_txin, proposed_psbtin) in input_pairs(&mut payjoin_psbt) {
487491
if let Some((original_txin, original_psbtin)) = original_inputs.peek() {
488492
if proposed_txin.previous_output == original_txin.previous_output {
489493
proposed_psbtin.witness_utxo = original_psbtin.witness_utxo.clone();

0 commit comments

Comments
 (0)