Skip to content

Commit

Permalink
tmp: debug duplicated outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Mar 26, 2024
1 parent 9726835 commit b9f4c51
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions src/pay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,13 @@ impl Runtime {
.iter()
// TODO: Support liquid
.map(|o| o.as_reduced_unsafe())
.map(|o| Outpoint::new(o.txid, o.vout));
.map(|o| Outpoint::new(o.txid, o.vout)).collect::<BTreeSet<_>>();
params.tx.change_keychain = RgbKeychain::for_method(method).into();
let (mut psbt, mut meta) =
self.wallet_mut()
.construct_psbt(prev_outpoints, &beneficiaries, params.tx)?;
let (mut psbt, mut meta) = self.wallet_mut().construct_psbt(
prev_outpoints.iter().copied(),
&beneficiaries,
params.tx,
)?;

let beneficiary_script =
if let Beneficiary::WitnessVout(addr) = invoice.beneficiary.into_inner() {
Expand Down Expand Up @@ -293,8 +295,13 @@ impl Runtime {
}
Beneficiary::BlindedSeal(_) => None,
};
let batch = self
.compose(invoice, prev_outputs, method, beneficiary_vout, |_, _, _| meta.change_vout)?;
let batch = self.compose(
invoice,
prev_outputs.iter().copied(),
method,
beneficiary_vout,
|_, _, _| meta.change_vout,
)?;

let methods = batch.close_method_set();
if methods.has_opret_first() {
Expand All @@ -303,7 +310,12 @@ impl Runtime {
}

psbt.complete_construction();
psbt.rgb_embed(batch)?;
eprintln!("{}", &serde_yaml::to_string(&batch).unwrap());
psbt.rgb_embed(batch).inspect_err(|_| {
eprintln!("{}", &serde_yaml::to_string(&psbt).unwrap());
eprintln!("{prev_outputs:#?}");
eprintln!("{prev_outpoints:#?}");
})?;
Ok((psbt, meta))
}

Expand Down

0 comments on commit b9f4c51

Please sign in to comment.