diff --git a/payjoin-cli/src/app/v1.rs b/payjoin-cli/src/app/v1.rs index 5a13479d..8f25667e 100644 --- a/payjoin-cli/src/app/v1.rs +++ b/payjoin-cli/src/app/v1.rs @@ -297,7 +297,7 @@ impl App { })?; log::trace!("check4"); - let mut provisional_payjoin = payjoin.identify_receiver_outputs(|output_script| { + let provisional_payjoin = payjoin.identify_receiver_outputs(|output_script| { if let Ok(address) = bitcoin::Address::from_script(output_script, network) { bitcoind .get_address_info(&address) diff --git a/payjoin-cli/src/app/v2.rs b/payjoin-cli/src/app/v2.rs index 8beb504c..52ca023d 100644 --- a/payjoin-cli/src/app/v2.rs +++ b/payjoin-cli/src/app/v2.rs @@ -334,10 +334,13 @@ impl App { } })?; + let mut provisional_payjoin = provisional_payjoin + .try_substitute_receiver_outputs(None:: Result, Error>>)?; + _ = try_contributing_inputs(&mut provisional_payjoin.inner, &bitcoind) .map_err(|e| log::warn!("Failed to contribute inputs: {}", e)); - let payjoin_proposal = provisional_payjoin.finalize_proposal( + let payjoin_proposal = provisional_payjoin.provisional_proposal().finalize_proposal( |psbt: &Psbt| { bitcoind .wallet_process_psbt(&psbt.to_string(), None, None, Some(false)) diff --git a/payjoin/src/receive/v2/mod.rs b/payjoin/src/receive/v2/mod.rs index 4c790715..e6c1b95f 100644 --- a/payjoin/src/receive/v2/mod.rs +++ b/payjoin/src/receive/v2/mod.rs @@ -405,7 +405,7 @@ impl WantsOutputs { } pub struct WantsInputs { - inner: super::WantsInputs, + pub inner: super::WantsInputs, context: SessionContext, } diff --git a/payjoin/tests/integration.rs b/payjoin/tests/integration.rs index 1a88b753..3885a173 100644 --- a/payjoin/tests/integration.rs +++ b/payjoin/tests/integration.rs @@ -757,13 +757,12 @@ mod integration { .expect("Receiver should have at least one output"); let mut payjoin = payjoin - .try_substitute_receiver_output(|| { - Ok(receiver - .get_new_address(None, None) - .unwrap() - .assume_checked() - .script_pubkey()) - }) + // TODO: + // a- `None` approach is a pita because type inference doesn't work + // b- hard to substitute outputs when output value from payjoin_psbt is not accessible + .try_substitute_receiver_outputs( + None:: Result, payjoin::Error>>, + ) .expect("Could not substitute outputs"); // Select receiver payjoin inputs. TODO Lock them.