Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions payjoin-ffi/src/receive/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1114,6 +1114,9 @@ impl InputPair {
.map(Self)
.map_err(|err| InputPairError::InvalidPsbtInput(Arc::new(err.into())))
}

/// Returns the outpoint spent by this input pair.
pub fn outpoint(&self) -> OutPoint { self.0.outpoint().into() }
}

impl From<InputPair> for payjoin::receive::InputPair {
Expand Down
15 changes: 15 additions & 0 deletions payjoin/src/core/receive/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@ impl InputPair {
Self::new_segwit_input_pair(txout, outpoint, Some(expected_weight))
}

/// Returns the outpoint spent by this input pair.
pub fn outpoint(&self) -> OutPoint { self.txin.previous_output }

pub(crate) fn previous_txout(&self) -> TxOut {
InternalInputPair::from(self)
.previous_txout()
Expand Down Expand Up @@ -541,6 +544,18 @@ pub(crate) mod tests {
assert_eq!(input_pair.expected_weight, expected_satifiability_weight);
}

#[test]
fn input_pair_outpoint_preserves_txid_and_vout() {
let txout = TxOut {
value: Amount::from_sat(123),
script_pubkey: ScriptBuf::new_p2wpkh(&WPubkeyHash::from_byte_array(DUMMY20)),
};
let outpoint = OutPoint { txid: Txid::from_byte_array(DUMMY32), vout: 31 };
let input_pair = InputPair::new_p2wpkh(txout, outpoint).unwrap();

assert_eq!(input_pair.outpoint(), outpoint);
}

#[test]
fn create_p2pkh_input_pair() {
let p2sh_txout = TxOut {
Expand Down
Loading