Merge remote-tracking branch 'agent/benma-agent/bitcoin-coin-enabled'
What changed, and why it matters
This commit adds a new check called coin_enabled() at the start of several Bitcoin-related operations in the BitBox02 firmware, including registering script configurations, signing messages, and signing transactions. The change appears to enforce whether a particular Bitcoin coin type (such as mainnet, testnet, or regtest) is currently enabled before allowing those operations to proceed. Without seeing the implementation of coin_enabled(), it is unclear whether this is a hardening improvement or a fix for a security-relevant bypass, but the pattern suggests it closes a gap where disabled coins could previously be used.
Review the implementation of coin_enabled() and the surrounding coin policy configuration to confirm the gate behaves as intended for all BtcCoin variants. Verify that no other Bitcoin API entry points (for example, address generation, xpub export, or policy parsing helpers) bypass the new check. Consider regression tests that attempt operations with disabled coins to ensure they are rejected.
Security signals we found
New runtime authorization gate (coin_enabled) added to Bitcoin API entry points
Gates script-config registration/query, message signing, and transaction signing
May close a path where disabled or unsupported coin types were processed
Insufficient diff context to determine whether coin_enabled existed before or is newly introduced
Evidence from the diff
The diff inserts calls to super::coin_enabled(coin)? in three Rust source files: registration.rs (four insertion points covering multisig and policy script-config registration and query paths), signmsg.rs (before the existing coin whitelist check), and signtx.rs (after BtcCoin::try_from). The function is not defined in the visible diff, so its exact behavior is unknown, but its placement indicates it gates Bitcoin-family coin operations by an enabled-coin policy. The existing signmsg.rs code already restricts allowed coins to BtcCoin::Btc, Tbtc, and Rbtc; adding coin_enabled() before that check may be redundant for those coins but could reject additional coin enum values or enforce runtime configuration. The change is small and additive, suggesting a defense-in-depth or policy-enforcement fix rather than a large feature.
Changed components
src/rust/bitbox02-rust/src/hww/api/bitcoin/registration.rssrc/rust/bitbox02-rust/src/hww/api/bitcoin/signmsg.rssrc/rust/bitbox02-rust/src/hww/api/bitcoin/signtx.rsBitBox02 Bitcoin hardware-wallet APIInspect captured patch +6 / −0
### src/rust/bitbox02-rust/src/hww/api/bitcoin/registration.rs
@@ -32,6 +32,7 @@ pub fn process_is_script_config_registered(
keypath,
}) => {
let coin = BtcCoin::try_from(*coin)?;
+ super::coin_enabled(coin)?;
Ok(Response::IsScriptConfigRegistered(
pb::BtcIsScriptConfigRegisteredResponse {
is_registered: super::multisig::get_name(hal, coin, multisig, keypath)?
@@ -48,6 +49,7 @@ pub fn process_is_script_config_registered(
..
}) => {
let coin = BtcCoin::try_from(*coin)?;
+ super::coin_enabled(coin)?;
Ok(Response::IsScriptConfigRegistered(
pb::BtcIsScriptConfigRegisteredResponse {
is_registered: super::policies::get_name(hal, coin, policy)
@@ -122,6 +124,7 @@ pub async fn process_register_script_config(
keypath,
}) => {
let coin = BtcCoin::try_from(*coin)?;
+ super::coin_enabled(coin)?;
let coin_params = params::get(coin);
let name = get_name(hal, request).await?;
super::multisig::validate(hal, multisig, keypath).await?;
@@ -151,6 +154,7 @@ pub async fn process_register_script_config(
..
}) => {
let coin = BtcCoin::try_from(*coin)?;
+ super::coin_enabled(coin)?;
let coin_params = params::get(coin);
let name = get_name(hal, request).await?;
let parsed = super::policies::parse(hal, policy, coin).await?;
### src/rust/bitbox02-rust/src/hww/api/bitcoin/signmsg.rs
@@ -49,6 +49,7 @@ pub async fn process(
request: &pb::BtcSignMessageRequest,
) -> Result<Response, Error> {
let coin = BtcCoin::try_from(request.coin)?;
+ super::coin_enabled(coin)?;
if !matches!(coin, BtcCoin::Btc | BtcCoin::Tbtc | BtcCoin::Rbtc) {
return Err(Error::InvalidInput);
}
### src/rust/bitbox02-rust/src/hww/api/bitcoin/signtx.rs
@@ -735,6 +735,7 @@ async fn _process(
}
// Validate the coin.
let coin = pb::BtcCoin::try_from(request.coin)?;
+ super::coin_enabled(coin)?;
let coin_params = super::params::get(coin);
// Validate the format_unit.
let format_unit = FormatUnit::try_from(request.format_unit)?;Why this scored 49/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.