KasarLabs / barknet

https://kasar.io
MIT License
13 stars 0 forks source link

net/bitcoin_config #2

Open antiyro opened 1 year ago

antiyro commented 1 year ago

Description:

Develop a configuration structure for Bitcoin in a manner analogous to Ethereum's configuration in config.rs. This structure will facilitate the connection and interaction with a Bitcoin node.

Tasks:

  1. Define Default Constants:

    • Bitcoin Node RPC Endpoint:

      • Create a constant similar to DEFAULT_ETHEREUM_NODE for Bitcoin. This will be the default RPC endpoint for a Bitcoin node.
      • Example: DEFAULT_BITCOIN_NODE: &str = "127.0.0.1:8332"; (This is a common default for Bitcoin Core's RPC server)
    • Bitcoin Network Type:

      • Define a constant specifying the default Bitcoin network type (mainnet, testnet, regtest).
      • Example: DEFAULT_BITCOIN_NETWORK: &str = "testnet";
    • Other Constants:

      • Depending on the Bitcoin-da functionalities you wish to integrate, you might need additional default constants. These could be related to fee rates, confirmation targets, etc.
  2. Create BitcoinConfig Struct:

    • Fields:

      • rpc_provider: RPC endpoint for the Bitcoin node.
      • network_type: Specifies which Bitcoin network to connect to (mainnet, testnet, regtest).
      • Additional fields can be added based on specific requirements, such as wallet addresses or authentication credentials for the RPC server.
    • Deserialization:

      • Use the serde crate to enable easy deserialization from configuration files, as done in the Ethereum configuration.
    • Example Structure:

      #[derive(Clone, PartialEq, Deserialize, Debug)]
      pub struct BitcoinConfig {
      #[serde(default = "default_rpc")]
      pub rpc_provider: String,
      #[serde(default = "default_network_type")]
      pub network_type: String,
      // Add other fields as required
      }
  3. Implement Default Methods for Configuration:

    • Default RPC Endpoint:

      • Create a method to provide a default RPC endpoint for Bitcoin, referencing the DEFAULT_BITCOIN_NODE constant.
    • Default Network Type:

      • Implement a method to provide a default network type, referencing the DEFAULT_BITCOIN_NETWORK constant.
    • Loading Configuration from File:

      • Adapt the try_from_file method from EthereumConfig to work for BitcoinConfig. This will allow loading of configurations from a specified file.
    • Complete Default Implementation:

      • Implement the Default trait for BitcoinConfig to provide default values for each field.
    • Example Methods:

      
      fn default_rpc() -> String {
      DEFAULT_BITCOIN_NODE.to_string()
      }

    fn default_network_type() -> String { DEFAULT_BITCOIN_NETWORK.to_string() }

axelizsak commented 1 year ago

Can I take this one @antiyro ?

0xEniotna commented 1 year ago

params required are those from bitcoin-da config: host: String, user: String, pass: String,

github-actions[bot] commented 1 year ago

There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale. Please make sure to update to the latest version and check if that solves the issue. Let us know if that works for you by leaving a 👍 Because this issue is marked as stale, it will be closed and locked in 7 days if no further activity occurs. Thank you for your contributions!