From aaf4320c9e4f942c1b7f5ae24950447069197001 Mon Sep 17 00:00:00 2001 From: macgyver13 <4712150+macgyver13@users.noreply.github.com> Date: Wed, 1 Apr 2026 14:25:44 -0400 Subject: [PATCH 1/3] docs: fix typo in PSBT_OUT_PROPRIETARY comment --- src/consts.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/consts.rs b/src/consts.rs index 84e7b91..ff1201c 100644 --- a/src/consts.rs +++ b/src/consts.rs @@ -114,7 +114,7 @@ pub(crate) const PSBT_OUT_SP_V0_INFO: u64 = 0x09; #[cfg(feature = "silent-payments")] /// Type: Silent Payment v0 Label PSBT_OUT_SP_V0_LABEL = 0x0A pub(crate) const PSBT_OUT_SP_V0_LABEL: u64 = 0x0A; -/// Type: Proprietary Use Type PSBT_IN_PROPRIETARY = 0xFC +/// Type: Proprietary Use Type PSBT_OUT_PROPRIETARY = 0xFC pub(crate) const PSBT_OUT_PROPRIETARY: u64 = 0xFC; /// Converts a global key type value consts to a string, useful for debugging. From 695c8c4bcac8d8da61df1f28e6ae2f0b3946658f Mon Sep 17 00:00:00 2001 From: macgyver13 <4712150+macgyver13@users.noreply.github.com> Date: Thu, 26 Feb 2026 15:39:00 -0500 Subject: [PATCH 2/3] feat: expose raw key-value pairs on v2 map types Downstream code needs a method to iterate all fields of a PSBT map as raw (type, key, value) tuples. Allows an extension trait to expose pairs without duplicating field knowledge. --- src/v2/map/global.rs | 3 +++ src/v2/map/input.rs | 3 +++ src/v2/map/output.rs | 3 +++ 3 files changed, 9 insertions(+) diff --git a/src/v2/map/global.rs b/src/v2/map/global.rs index cd4ad41..416f544 100644 --- a/src/v2/map/global.rs +++ b/src/v2/map/global.rs @@ -100,6 +100,9 @@ impl Global { } } + /// Returns all key-value pairs for this global map in serialization order. + pub fn pairs(&self) -> Vec { Map::get_pairs(self) } + pub(crate) fn set_inputs_modifiable_flag(&mut self) { self.tx_modifiable_flags |= INPUTS_MODIFIABLE; } diff --git a/src/v2/map/input.rs b/src/v2/map/input.rs index 7302bfd..e8b0e7e 100644 --- a/src/v2/map/input.rs +++ b/src/v2/map/input.rs @@ -175,6 +175,9 @@ impl Input { } } + /// Returns all key-value pairs for this input map in serialization order. + pub fn pairs(&self) -> Vec { Map::get_pairs(self) } + // /// Converts this `Input` to a `v0::Input`. // pub(crate) fn into_v0(self) -> v0::Input { // v0::Input { diff --git a/src/v2/map/output.rs b/src/v2/map/output.rs index b3fb910..6ae78b8 100644 --- a/src/v2/map/output.rs +++ b/src/v2/map/output.rs @@ -86,6 +86,9 @@ impl Output { } } + /// Returns all key-value pairs for this output map in serialization order. + pub fn pairs(&self) -> Vec { Map::get_pairs(self) } + // /// Converts this `Output` to a `v0::Output`. // pub(crate) fn into_v0(self) -> v0::Output { // v0::Output { From 11f50e2c54ba9e4e27a18bfedddc0e192a85afc7 Mon Sep 17 00:00:00 2001 From: macgyver13 <4712150+macgyver13@users.noreply.github.com> Date: Thu, 2 Apr 2026 14:41:43 -0400 Subject: [PATCH 3/3] test: add failing tests for pairs() --- src/v2/map/global.rs | 18 ++++++++++++++++++ src/v2/map/input.rs | 13 +++++++++++++ src/v2/map/output.rs | 13 +++++++++++++ 3 files changed, 44 insertions(+) diff --git a/src/v2/map/global.rs b/src/v2/map/global.rs index 416f544..6df04e0 100644 --- a/src/v2/map/global.rs +++ b/src/v2/map/global.rs @@ -784,3 +784,21 @@ impl std::error::Error for CombineError { impl From for CombineError { fn from(e: InconsistentKeySourcesError) -> Self { Self::InconsistentKeySources(e) } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn pairs_matches_serialize_map() { + let global = Global::default(); + + let mut from_pairs = Vec::new(); + for pair in global.pairs() { + from_pairs.extend(pair.serialize()); + } + from_pairs.push(0x00); + + assert_eq!(from_pairs, global.serialize_map()); + } +} diff --git a/src/v2/map/input.rs b/src/v2/map/input.rs index e8b0e7e..987ad7a 100644 --- a/src/v2/map/input.rs +++ b/src/v2/map/input.rs @@ -1120,4 +1120,17 @@ mod test { assert_eq!(decoded, input); } + + #[test] + fn pairs_matches_serialize_map() { + let input = Input::new(&out_point()); + + let mut from_pairs = Vec::new(); + for pair in input.pairs() { + from_pairs.extend(pair.serialize()); + } + from_pairs.push(0x00); + + assert_eq!(from_pairs, input.serialize_map()); + } } diff --git a/src/v2/map/output.rs b/src/v2/map/output.rs index 6ae78b8..6911377 100644 --- a/src/v2/map/output.rs +++ b/src/v2/map/output.rs @@ -520,4 +520,17 @@ mod tests { assert_eq!(decoded, output); } + + #[test] + fn pairs_matches_serialize_map() { + let output = Output::new(tx_out()); + + let mut from_pairs = Vec::new(); + for pair in output.pairs() { + from_pairs.extend(pair.serialize()); + } + from_pairs.push(0x00); + + assert_eq!(from_pairs, output.serialize_map()); + } }