primitives: Fix holes in API surface test
What changed, and why it matters
This commit only updates an internal test file that checks the public API surface of the `bitcoin_primitives` crate. It adds missing types (like `Ntxid`, `BlockChecked`, script buffer types) to compile-time API tests and enables a previously commented-out iterator field. There is no change to production code, no bug fix, and no security relevance.
No security action needed; this is a routine test-maintenance commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff modifies primitives/tests/api.rs, a test-only file that verifies public types are reachable, implement expected traits, and have expected methods. The changes add transaction::Ntxid/Ntxid, BlockChecked, BlockUnchecked, BlockValidation, RedeemScript, RedeemScriptBuf, ScriptPubKey, ScriptPubKeyBuf, ScriptSig, ScriptSigBuf, TapScript, TapScriptBuf, WitnessScript, WitnessScriptBuf to struct fields and import lists, and uncomment/add witness::Iter and compute_ntxid() coverage. No library source code is altered.
Changed components
primitives/tests/api.rsInspect captured patch +22 / −15
diff --git a/primitives/tests/api.rs b/primitives/tests/api.rs
index b996b615..6b91844d 100644
--- a/primitives/tests/api.rs
+++ b/primitives/tests/api.rs
@@ -63,9 +63,10 @@ struct Structs<'a> {
r: OutPoint,
s: Txid,
t: Wtxid,
- u: transaction::Version,
- v: Witness,
- // w: witness::Iter<'a>,
+ u: transaction::Ntxid,
+ v: transaction::Version,
+ w: Witness,
+ // x: witness::Iter<'a>,
}
static REDEEM_SCRIPT: RedeemScriptBuf = RedeemScriptBuf::new();
@@ -103,9 +104,10 @@ struct CommonTraits {
r: OutPoint,
s: Txid,
t: Wtxid,
- u: transaction::Version,
- v: Witness,
- // w: witness::Iter<'a>,
+ u: transaction::Ntxid,
+ v: transaction::Version,
+ w: Witness,
+ // x: witness::Iter<'a>,
}
/// A struct that includes all types that implement `Clone`.
@@ -135,9 +137,10 @@ struct Clone<'a> {
r: OutPoint,
s: Txid,
t: Wtxid,
- u: transaction::Version,
- v: Witness,
- w: witness::Iter<'a>,
+ u: transaction::Ntxid,
+ v: transaction::Version,
+ w: Witness,
+ x: witness::Iter<'a>,
}
/// Public structs that derive common traits.
@@ -168,9 +171,10 @@ struct Ord {
r: OutPoint,
s: Txid,
t: Wtxid,
- u: transaction::Version,
- v: Witness,
- // w: witness::Iter<'a>,
+ u: transaction::Ntxid,
+ v: transaction::Version,
+ w: Witness,
+ // x: witness::Iter<'a>,
}
/// A struct that includes all types that implement `Default`.
@@ -244,9 +248,11 @@ fn api_can_use_modules_from_crate_root() {
#[test]
fn api_can_use_types_from_crate_root() {
use bitcoin_primitives::{
- Block, BlockHash, BlockHeader, BlockVersion, CompactTarget, OutPoint, ScriptPubKey,
- ScriptPubKeyBuf, ScriptSig, ScriptSigBuf, Sequence, Transaction, TransactionVersion, TxIn,
- TxMerkleNode, TxOut, Txid, Witness, WitnessCommitment, WitnessMerkleNode, Wtxid,
+ Block, BlockChecked, BlockHash, BlockHeader, BlockUnchecked, BlockValidation, BlockVersion,
+ CompactTarget, Ntxid, OutPoint, RedeemScript, RedeemScriptBuf, ScriptPubKey,
+ ScriptPubKeyBuf, ScriptSig, ScriptSigBuf, Sequence, TapScript, TapScriptBuf, Transaction,
+ TransactionVersion, TxIn, TxMerkleNode, TxOut, Txid, Witness, WitnessCommitment,
+ WitnessMerkleNode, WitnessScript, WitnessScriptBuf, Wtxid,
};
}
@@ -320,6 +326,7 @@ fn api_all_non_error_types_have_non_empty_debug() {
OutPoint::arbitrary(&mut u).unwrap();
transaction.compute_txid();
transaction.compute_wtxid();
+ transaction.compute_ntxid();
transaction.version;
Witness::arbitrary(&mut u).unwrap();
// ad: witness::Iter<'a>,
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.