Skip to content

introduce output.UniqueId - #77

Merged
arminsabouri merged 1 commit into
struct-macrofrom
output-unique-id
Nov 12, 2026
Merged

arminsabouri merged 1 commit into
struct-macrofrom
output-unique-id

Conversation

@yuval-block

Copy link
Copy Markdown
Collaborator

Introduce the PSBT_OUT_UNIQUE_ID field (currently proprietary field) which serves as a stable key for outputs in unordered PSBTS.

@yuval-block
yuval-block added this pull request to stack #80 November 11, 2026 23:19
@github-code-quality

github-code-quality Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Code coverage overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

struct-macro 5346f2b output-unique-id 0df3dfe +/-
100% 100% 0%
View coverage of the 2 most impacted files.
File struct-macro 5346f2b output-unique-id 0df3dfe +/-
crates/concurre...struct_macro.rs 0% 100% +100%
crates/concurre.../psbt/output.rs 0% 100% +100%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.


Updated November 12, 2026 16:02 UTC

Base automatically changed from output-type to struct-macro November 12, 2026 14:39
@github-actions

Copy link
Copy Markdown
range-diff for force push 47cabf5f9c → a910227698 November 12, 2026 14:40 UTC: 1 unchanged; 1 commit; base e99ad1e9f9 → c5e4c44c6e (descendant, 1 commit ahead)

reproduce: git range-diff e99ad1e..47cabf5 c5e4c44..a910227

1:  47cabf5f9c +142 -1 4f = 1:  a910227698 +142 -1 4f introduce output.UniqueId

Introduce the PSBT_OUT_UNIQUE_ID field (currently proprietary field)
which serves as a stable key for outputs in unordered PSBTS.
@github-actions

Copy link
Copy Markdown
range-diff for force push a910227698 → 0df3dfe4bc November 12, 2026 15:54 UTC: 1 modified; 1 commit; same base c5e4c44c6e

reproduce: git range-diff c5e4c44..a910227 c5e4c44..0df3dfe

1:  a910227698 +142 -1 4f ! 1:  0df3dfe4bc +152 -1 4f introduce output.UniqueId
1: a910227698 ! 1: 0df3dfe4bc introduce output.UniqueId
@@ crates/concurrent-psbt/src/psbt/output.rs: joinable_struct! {
 +
 +    /// Generate a fresh random 16-byte unique identifier.
 +    ///
-+    /// Each call yields a distinct identity, so copies of an otherwise
-+    /// identical txout can coexist as separate outputs.
++    /// The bytes come straight from the operating system's RNG rather than a
++    /// userspace generator such as `ThreadRng`, whose state a forked child
++    /// would share with its parent. Two calls therefore collide only with
++    /// negligible probability, so copies of an otherwise identical txout can
++    /// coexist as separate outputs.
++    ///
++    /// # Panics
++    /// Panics if the operating system's RNG is unavailable.
 +    pub fn generate() -> Self {
-+        Self(rand::random::<[u8; 16]>().to_vec())
++        use rand::{RngCore, TryRngCore, rngs::OsRng};
++
++        let mut bytes = [0u8; 16];
++        OsRng.unwrap_err().fill_bytes(&mut bytes);
++        Self(bytes.to_vec())
 +    }
 +}
 +

@arminsabouri arminsabouri left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re-ACK

@arminsabouri
arminsabouri merged commit c5e82a0 into struct-macro Nov 12, 2026
6 checks passed
@arminsabouri
arminsabouri deleted the output-unique-id branch November 12, 2026 17:04
@yuval-block

Copy link
Copy Markdown
Collaborator Author

same with this PR, i think it shouldn't be merged until #68 is, and then it should target main as a separate stack

Mshehu5 pushed a commit to Mshehu5/concurrent-psbt that referenced this pull request Nov 14, 2026
Introduce the PSBT_OUT_UNIQUE_ID field (currently proprietary field)
which serves as a stable key for outputs in unordered PSBTS.

Reopens fungi-protocol#77, which was merged into \`struct-macro\` before fungi-protocol#68 landed.
Same commit, now stacked on fungi-protocol#90.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants