From 5c844aee9ab3b3f53cbe45b19655928892b59d7f Mon Sep 17 00:00:00 2001 From: Sandro Simas Date: Mon, 14 Oct 2024 20:02:00 -0300 Subject: [PATCH 1/7] Adding Omni XEP support --- lib/src/models/network.dart | 54 ++++++++++++++++++++++++++++++++++++- pubspec.yaml | 10 ++++--- 2 files changed, 59 insertions(+), 5 deletions(-) diff --git a/lib/src/models/network.dart b/lib/src/models/network.dart index 67c1277..ac324ea 100644 --- a/lib/src/models/network.dart +++ b/lib/src/models/network.dart @@ -48,7 +48,8 @@ abstract class BasedUtxoNetwork implements Enumerate { BitcoinCashNetwork.testnet, BitcoinSVNetwork.mainnet, BitcoinSVNetwork.testnet, - PepeNetwork.mainnet + PepeNetwork.mainnet, + OmniXepNetwork.mainnet, ]; static BasedUtxoNetwork fromName(String name) { @@ -493,3 +494,54 @@ class PepeNetwork implements BasedUtxoNetwork { return [Bip44Coins.pepecoinTestnet, Bip49Coins.pepecoinTestnet]; } } + +/// Class representing a Dogecoin network, implementing the `BasedUtxoNetwork` abstract class. +class OmniXepNetwork implements BasedUtxoNetwork { + /// Mainnet configuration with associated `CoinConf`. + static const OmniXepNetwork mainnet = + OmniXepNetwork._("omniXepMainnet", CoinsConf.omniXepMainNet); + + /// Overrides the `conf` property from `BasedUtxoNetwork` with the associated `CoinConf`. + @override + final CoinConf conf; + + /// Constructor for creating a Dogecoin network with a specific configuration. + const OmniXepNetwork._(this.value, this.conf); + + @override + final String value; + + /// Retrieves the Wallet Import Format (WIF) version bytes from the associated `CoinConf`. + @override + List get wifNetVer => conf.params.wifNetVer!; + + /// Retrieves the Pay-to-Public-Key-Hash (P2PKH) version bytes from the associated `CoinConf`. + @override + List get p2pkhNetVer => conf.params.p2pkhNetVer!; + + /// Retrieves the Pay-to-Script-Hash (P2SH) version bytes from the associated `CoinConf`. + @override + List get p2shNetVer => conf.params.p2shNetVer!; + + /// Retrieves the Human-Readable Part (HRP) for Pay-to-Witness-Public-Key-Hash (P2WPKH) addresses. + @override + String get p2wpkhHrp => throw const DartBitcoinPluginException( + "Omni XEP network does not support P2WPKH/P2WSH"); + + /// Checks if the current network is the mainnet. + @override + bool get isMainnet => true; + + @override + final List supportedAddress = const [ + P2shAddressType.p2wpkhInP2sh, + ]; + + @override + List get coins { + if (isMainnet) { + return [Bip49Coins.omniXep]; + } + return []; + } +} \ No newline at end of file diff --git a/pubspec.yaml b/pubspec.yaml index 359c7ef..0538952 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -11,15 +11,17 @@ topics: - bitcoincash - dash +publish_to: 'none' + environment: sdk: '>=2.15.0 <4.0.0' dependencies: - blockchain_utils: ^3.4.0 - - # blockchain_utils: - # path: ../blockchain_utils + # blockchain_utils: ^3.4.0 + + blockchain_utils: + path: ../blockchain_utils dev_dependencies: From 81082e26c668a8e1561e3f8da2d214dc15306448 Mon Sep 17 00:00:00 2001 From: Sandro Simas Date: Fri, 18 Oct 2024 16:11:24 -0300 Subject: [PATCH 2/7] Small improvement --- lib/src/models/network.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/models/network.dart b/lib/src/models/network.dart index ac324ea..3280519 100644 --- a/lib/src/models/network.dart +++ b/lib/src/models/network.dart @@ -525,8 +525,7 @@ class OmniXepNetwork implements BasedUtxoNetwork { /// Retrieves the Human-Readable Part (HRP) for Pay-to-Witness-Public-Key-Hash (P2WPKH) addresses. @override - String get p2wpkhHrp => throw const DartBitcoinPluginException( - "Omni XEP network does not support P2WPKH/P2WSH"); + String get p2wpkhHrp => conf.params.p2wpkhHrp!; /// Checks if the current network is the mainnet. @override @@ -534,6 +533,7 @@ class OmniXepNetwork implements BasedUtxoNetwork { @override final List supportedAddress = const [ + SegwitAddresType.p2wpkh, P2shAddressType.p2wpkhInP2sh, ]; From 997762fa354e3ac70dfd7061f900232434eb43a1 Mon Sep 17 00:00:00 2001 From: Sandro Simas Date: Fri, 29 Nov 2024 18:11:40 -0300 Subject: [PATCH 3/7] Small fix in omnixep network description --- lib/src/models/network.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/models/network.dart b/lib/src/models/network.dart index 3280519..fd293a4 100644 --- a/lib/src/models/network.dart +++ b/lib/src/models/network.dart @@ -495,7 +495,7 @@ class PepeNetwork implements BasedUtxoNetwork { } } -/// Class representing a Dogecoin network, implementing the `BasedUtxoNetwork` abstract class. +/// Class representing a OmniXEP network, implementing the `BasedUtxoNetwork` abstract class. class OmniXepNetwork implements BasedUtxoNetwork { /// Mainnet configuration with associated `CoinConf`. static const OmniXepNetwork mainnet = @@ -505,7 +505,7 @@ class OmniXepNetwork implements BasedUtxoNetwork { @override final CoinConf conf; - /// Constructor for creating a Dogecoin network with a specific configuration. + /// Constructor for creating a OmniXEP network with a specific configuration. const OmniXepNetwork._(this.value, this.conf); @override From b1c3ebf0dbb783dde4ab067bd0922b2cfd243701 Mon Sep 17 00:00:00 2001 From: Sandro Simas Date: Fri, 29 Nov 2024 18:12:35 -0300 Subject: [PATCH 4/7] Small fix in omnixep network description --- lib/src/models/network.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/models/network.dart b/lib/src/models/network.dart index fd293a4..d8194c6 100644 --- a/lib/src/models/network.dart +++ b/lib/src/models/network.dart @@ -544,4 +544,4 @@ class OmniXepNetwork implements BasedUtxoNetwork { } return []; } -} \ No newline at end of file +} From 1e1b0d46eb70bbb3c7b047942481c735cfe620d4 Mon Sep 17 00:00:00 2001 From: Sandro Simas Date: Fri, 29 Nov 2024 18:13:01 -0300 Subject: [PATCH 5/7] Updating pubspec --- pubspec.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/pubspec.yaml b/pubspec.yaml index 66b442c..73f4adf 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -11,8 +11,6 @@ topics: - bitcoincash - dash -publish_to: 'none' - environment: sdk: '>=2.15.0 <4.0.0' From 0cbdfa06a2945b87cc751246274a1a61cbdd730b Mon Sep 17 00:00:00 2001 From: Sandro Simas Date: Mon, 2 Dec 2024 19:54:04 -0300 Subject: [PATCH 6/7] Support electra protocol main and test net --- lib/src/models/network.dart | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/lib/src/models/network.dart b/lib/src/models/network.dart index d8194c6..5ffbbb7 100644 --- a/lib/src/models/network.dart +++ b/lib/src/models/network.dart @@ -49,7 +49,8 @@ abstract class BasedUtxoNetwork implements Enumerate { BitcoinSVNetwork.mainnet, BitcoinSVNetwork.testnet, PepeNetwork.mainnet, - OmniXepNetwork.mainnet, + ElectraProtocolNetwork.mainnet, + ElectraProtocolNetwork.testnet, ]; static BasedUtxoNetwork fromName(String name) { @@ -380,6 +381,7 @@ class BitcoinCashNetwork implements BasedUtxoNetwork { /// Constructor for creating a Bitcoin Cash network with a specific configuration. const BitcoinCashNetwork._(this.value, this.conf); + @override final String value; @@ -495,18 +497,26 @@ class PepeNetwork implements BasedUtxoNetwork { } } -/// Class representing a OmniXEP network, implementing the `BasedUtxoNetwork` abstract class. -class OmniXepNetwork implements BasedUtxoNetwork { +/// Class representing a Electra Protocol network, implementing the `BasedUtxoNetwork` abstract class. +class ElectraProtocolNetwork implements BasedUtxoNetwork { /// Mainnet configuration with associated `CoinConf`. - static const OmniXepNetwork mainnet = - OmniXepNetwork._("omniXepMainnet", CoinsConf.omniXepMainNet); + static const ElectraProtocolNetwork mainnet = ElectraProtocolNetwork._( + "electraProtocolMainnet", + CoinsConf.electraProtocolMainNet, + ); + + /// Testnet configuration with associated `CoinConf`. + static const ElectraProtocolNetwork testnet = ElectraProtocolNetwork._( + "electraProtocolTestnet", + CoinsConf.electraProtocolTestNet, + ); /// Overrides the `conf` property from `BasedUtxoNetwork` with the associated `CoinConf`. @override final CoinConf conf; /// Constructor for creating a OmniXEP network with a specific configuration. - const OmniXepNetwork._(this.value, this.conf); + const ElectraProtocolNetwork._(this.value, this.conf); @override final String value; @@ -529,19 +539,26 @@ class OmniXepNetwork implements BasedUtxoNetwork { /// Checks if the current network is the mainnet. @override - bool get isMainnet => true; + bool get isMainnet => this == ElectraProtocolNetwork.mainnet; @override final List supportedAddress = const [ - SegwitAddresType.p2wpkh, + P2pkhAddressType.p2pkh, P2shAddressType.p2wpkhInP2sh, + SegwitAddresType.p2wpkh, ]; @override List get coins { if (isMainnet) { - return [Bip49Coins.omniXep]; + return [ + Bip44Coins.electraProtocol, + Bip49Coins.electraProtocol, + ]; } - return []; + return [ + Bip44Coins.electraProtocolTestnet, + Bip49Coins.electraProtocolTestnet, + ]; } } From 147ed34f4bba8e76b2e485aa7c121805955601a7 Mon Sep 17 00:00:00 2001 From: Sandro Simas Date: Tue, 3 Dec 2024 09:43:14 -0300 Subject: [PATCH 7/7] Adding more supported addresses to XEP network --- lib/src/models/network.dart | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/src/models/network.dart b/lib/src/models/network.dart index 5ffbbb7..4250794 100644 --- a/lib/src/models/network.dart +++ b/lib/src/models/network.dart @@ -543,9 +543,14 @@ class ElectraProtocolNetwork implements BasedUtxoNetwork { @override final List supportedAddress = const [ + PubKeyAddressType.p2pk, P2pkhAddressType.p2pkh, - P2shAddressType.p2wpkhInP2sh, SegwitAddresType.p2wpkh, + SegwitAddresType.p2wsh, + P2shAddressType.p2pkInP2sh, + P2shAddressType.p2pkhInP2sh, + P2shAddressType.p2wpkhInP2sh, + P2shAddressType.p2wshInP2sh, ]; @override @@ -554,11 +559,13 @@ class ElectraProtocolNetwork implements BasedUtxoNetwork { return [ Bip44Coins.electraProtocol, Bip49Coins.electraProtocol, + Bip84Coins.electraProtocol, ]; } return [ Bip44Coins.electraProtocolTestnet, Bip49Coins.electraProtocolTestnet, + Bip84Coins.electraProtocolTestnet, ]; } }