Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor bp::Network into ChainParams #102

Closed
dr-orlovsky opened this issue Sep 21, 2020 · 0 comments · Fixed by #104
Closed

Refactor bp::Network into ChainParams #102

dr-orlovsky opened this issue Sep 21, 2020 · 0 comments · Fixed by #104
Assignees
Labels
*compatibility* Interoperability and compatibility issues *consensus* Changes breaking existing consensus rules enhancement Improvement to existing functionality or refactoring

Comments

@dr-orlovsky
Copy link
Member

dr-orlovsky commented Sep 21, 2020

We need to support wide range of networks (including Liquid, LN) and create a foundation for generic asset concept (that includes chain-based assets and RGB assets).

Draft concept:

/// P2P network magic number: prefix identifying network on which node operates
pub type P2pMagic = u32;
/// Magic number prefixing Pubkey or Prvkey data according to BIP32 spec
pub type Bip32Magic = u32;

#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[non_exhaustive]
#[repr(u8)]
pub enum ChainFormat {
    Bitcoin = 0,
    Elements = 1,
}

#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(u8)]
pub enum AssetLayer {
    Layer1and2,
    Layer2and3,
}

#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct AssetParams {
    pub ticker: &'static str,
    pub unit_of_accounting: &'static str,
    pub indivisible_unit: &'static str,
    pub divisibility: u64,
    pub asset_id: AssetId,
}

#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct ChainParams {
    pub name: &'static str,
    pub p2p_magic: P2pMagic,
    pub genesis_hash: BlockHash,
    pub bip32_pubkey: Bip32Magic,
    pub bip32_prvkey: Bip32Magic,
    pub bip70_name: &'static str,
    pub bip173_prefix: &'static str,
    pub p2p_port: u16,
    pub rpc_port: u16,
    pub ln_height: u32,
    pub format: ChainFormat,
    pub dust_limit: u64,
    pub native_asset: AssetParams,
    pub testnet: bool,
    pub pow: bool,
}

/// A set of recommended standard networks. Differs from bitcoin::Network in
/// ability to support non-standard and non-predefined networks
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[non_exhaustive]
#[repr(u32)]
pub enum Chains {
    Mainnet,
    Testnet3,
    Regtest(BlockHash),
    Signet,
    SignetPrivate(BlockHash),
    LiquidV1,
    Other(ChainParams),
}
@dr-orlovsky dr-orlovsky added enhancement Improvement to existing functionality or refactoring *consensus* Changes breaking existing consensus rules labels Sep 21, 2020
@dr-orlovsky dr-orlovsky added this to the v0.1.0 Release milestone Sep 21, 2020
@dr-orlovsky dr-orlovsky self-assigned this Sep 21, 2020
@dr-orlovsky dr-orlovsky added this to To do in RGB Core via automation Sep 21, 2020
@dr-orlovsky dr-orlovsky added this to To do in Client-side-validation via automation Sep 21, 2020
@dr-orlovsky dr-orlovsky added *scalability* Issues important for scalability *compatibility* Interoperability and compatibility issues and removed *scalability* Issues important for scalability labels Sep 23, 2020
RGB Core automation moved this from To do to Done Sep 24, 2020
Client-side-validation automation moved this from To do to Done Sep 24, 2020
dr-orlovsky added a commit that referenced this issue Sep 24, 2020
Refactoring bp::Network into Chain and ChainParams: closes #102
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
*compatibility* Interoperability and compatibility issues *consensus* Changes breaking existing consensus rules enhancement Improvement to existing functionality or refactoring
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

1 participant