did-btcr2-js

ADR 131: The Network of the Active Profile Wins over defaults.network

Context

A command with no identifier gets its network from resolveDefaultNetwork. These commands are create, genesis build, config effective, config doctor, and keystore unlock. The order was: -n, then defaults.network, then the network of the active profile, then regtest. ADR 074 (decision 7) added the network key of a profile, and a warning in create for a mismatch. It did not change the order.

The active profile also gives the endpoints, the keystore, and the default key. The old order caused two problems:

  1. btcr2 --profile production create with defaults.network: "mutinynet" made a mutinynet identifier. The profile production holds the mainnet endpoints, so the command printed a warning. The explicit --profile flag lost to a value in the config file.
  2. resolve, update, and deactivate read the network from the identifier. But they use the endpoints of the active profile, also if the profile declares another network. A mutinynet identifier under defaults.profile: "production" went to the mainnet endpoints with no warning.

The test networks share the tb1 address prefix. So an Esplora server of one test network can accept the beacon address of another test network. It then finds no transaction, and the resolution shows no update, with no error.

Decision

The network of the active profile wins over defaults.network. The order for a command with no identifier:

Layer Source
Flag -n, --network
Active profile The network key of the profile that --profile or defaults.profile names. Else the profile name, if it is a network name.
Config default defaults.network
Built-in regtest

resolve, update, and deactivate print a warning if the network of the identifier is not the network of the active profile.

Alternatives

Consequences

Positive. An explicit --profile sets the network of a new identifier. A new identifier and the endpoints of its profile have one network, unless -n names another. A read or a write through the endpoints of another network always prints a warning.

Negative. A config file with defaults.profile and a different defaults.network now makes identifiers on the network of the profile. This is a breaking change of the cli (MINOR at 0.x, with ADRs 129 and 130). keystore unlock now uses the network of the active profile for its mainnet gate. The text of the create warning changes.

Tests. The cli tests cover: