rust-bitcoin / rust-bitcoin/rust-bitcoin

Global `Network`

Open
#1,840 25 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

brainstorm minor API Change
Dominant language
Rust
Stars
2.7k
Forks
1k
Avg merge
4d 39m
Merged PRs (30d)
86

Description

I just realized that many applications allow the user to configure them for a single network which is then used in the whole program. One would normally parse the network from configuration and then pass it around in arguments. This can be a bit annoying.

Maybe we could also provide a global (internally AtomicU8) that user could set in main and then use alternative functions that don't require Network. The functions would obviously need to panic if the network is not set. To avoid accidental use by libraries (and also target_has_atomic issues) this should be behind a feature flag. When the flag is activated we could also provide an implementation of FromStr/Deserialize for Address<NetworkChecked>. (NetworkUnchecked should keep its behavior regardless of the flag.)

Note that this is intended for applications only, libraries should continue to support arguments. Also our library should support both interfaces.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the existing Network and Address/NetworkUnchecked APIs and how applications currently pass Network values. Review the feature-flag and target_has_atomic constraints described in the issue before proposing the global setter and alternative functions. Done means both interfaces remain supported, unset global access panics, NetworkUnchecked is unchanged, and the requested parsing conversions work only under the flag.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
networking
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.