From 7df79ef17ff37ca7e72208d7117f644f1da6fb06 Mon Sep 17 00:00:00 2001 From: Sandro Simas Date: Mon, 2 Dec 2024 18:26:52 -0300 Subject: [PATCH] Updating configs for XEP networks --- lib/bip/bip/conf/bip44/bip44_coins.dart | 9 +++++ lib/bip/bip/conf/bip44/bip44_conf.dart | 39 +++++++++++++++++- lib/bip/bip/conf/bip49/bip49_coins.dart | 7 +++- lib/bip/bip/conf/bip49/bip49_conf.dart | 53 +++++++++++++++++-------- lib/bip/bip/conf/bip84/bip84_coins.dart | 10 ++++- lib/bip/bip/conf/bip84/bip84_conf.dart | 38 +++++++++++++++++- lib/bip/coin_conf/coins_conf.dart | 19 +++++++-- lib/bip/slip/slip44/slip44.dart | 2 +- 8 files changed, 150 insertions(+), 27 deletions(-) diff --git a/lib/bip/bip/conf/bip44/bip44_coins.dart b/lib/bip/bip/conf/bip44/bip44_coins.dart index 402f226..e5e9a58 100644 --- a/lib/bip/bip/conf/bip44/bip44_coins.dart +++ b/lib/bip/bip/conf/bip44/bip44_coins.dart @@ -314,6 +314,9 @@ class Bip44Coins extends BipCoins { /// Zilliqa static const zilliqa = Bip44Coins._('zilliqa'); + /// Electra Protocol + static const electraProtocol = Bip44Coins._('electraProtocol'); + // Test nets /// Bitcoin Cash Testnet @@ -355,6 +358,9 @@ class Bip44Coins extends BipCoins { /// Ton Testnet static const tonMainnet = Bip44Coins._('tonMainnet'); + /// Electra Protocol Testnet + static const electraProtocolTestnet = Bip44Coins._('electraProtocolTestnet'); + // Fields and methods @override @@ -478,7 +484,10 @@ class Bip44Coins extends BipCoins { Bip44Coins.zilliqa: Bip44Conf.zilliqa, Bip44Coins.tonTestnet: Bip44Conf.tonTestnet, Bip44Coins.tonMainnet: Bip44Conf.tonMainnet, + Bip44Coins.electraProtocol: Bip44Conf.electraProtocolMainNet, + Bip44Coins.electraProtocolTestnet: Bip44Conf.electraProtocolTestNet, }; + @override BipProposal get proposal => BipProposal.bip44; diff --git a/lib/bip/bip/conf/bip44/bip44_conf.dart b/lib/bip/bip/conf/bip44/bip44_conf.dart index b5e1a8f..ce8ef61 100644 --- a/lib/bip/bip/conf/bip44/bip44_conf.dart +++ b/lib/bip/bip/conf/bip44/bip44_conf.dart @@ -3,8 +3,8 @@ import 'package:blockchain_utils/bip/bip/bip32/bip32_const.dart'; import 'package:blockchain_utils/bip/bip/bip32/bip32_key_net_ver.dart'; import 'package:blockchain_utils/bip/bip/conf/config/bip_bitcoin_cash_conf.dart'; import 'package:blockchain_utils/bip/bip/conf/config/bip_coin_conf.dart'; -import 'package:blockchain_utils/bip/bip/conf/const/bip_conf_const.dart'; import 'package:blockchain_utils/bip/bip/conf/config/bip_litecoin_conf.dart'; +import 'package:blockchain_utils/bip/bip/conf/const/bip_conf_const.dart'; import 'package:blockchain_utils/bip/coin_conf/coins_conf.dart'; import 'package:blockchain_utils/bip/ecc/curve/elliptic_curve_types.dart'; import 'package:blockchain_utils/bip/slip/slip44/slip44.dart'; @@ -1408,6 +1408,7 @@ class Bip44Conf { addressEncoder: ([dynamic kwargs]) => TonAddrEncoder(), addrParams: {"workchain": CoinsConf.tonMainnet.params.workchain}, ); + static final BipCoinConfig tonTestnet = BipCoinConfig( coinNames: CoinsConf.tonTestnet.coinName, coinIdx: Slip44.testnet, @@ -1419,4 +1420,40 @@ class Bip44Conf { addressEncoder: ([dynamic kwargs]) => TonAddrEncoder(), addrParams: {"workchain": CoinsConf.tonTestnet.params.workchain}, ); + + /// Configuration for Electra Protocol main net + static final BipCoinConfig electraProtocolMainNet = BipCoinConfig( + coinNames: CoinsConf.electraProtocolMainNet.coinName, + coinIdx: Slip44.electraProtocol, + isTestnet: false, + defPath: derPathNonHardenedFull, + keyNetVer: Bip32KeyNetVersions( + List.from([0x04, 0x88, 0xb2, 0x1e]), + List.from([0x04, 0x88, 0xad, 0xe4]), + ), + wifNetVer: CoinsConf.electraProtocolMainNet.params.wifNetVer, + type: EllipticCurveTypes.secp256k1, + addressEncoder: ([dynamic kwargs]) => P2PKHAddrEncoder(), + addrParams: { + "net_ver": CoinsConf.electraProtocolMainNet.params.p2pkhNetVer!, + }, + ); + + /// Configuration for Electra Protocol test net + static final BipCoinConfig electraProtocolTestNet = BipCoinConfig( + coinNames: CoinsConf.electraProtocolTestNet.coinName, + coinIdx: Slip44.electraProtocol, + isTestnet: true, + defPath: derPathNonHardenedFull, + keyNetVer: Bip32KeyNetVersions( + List.from([0x04, 0x35, 0x87, 0xcf]), + List.from([0x04, 0x35, 0x83, 0x94]), + ), + wifNetVer: CoinsConf.electraProtocolTestNet.params.wifNetVer, + type: EllipticCurveTypes.secp256k1, + addressEncoder: ([dynamic kwargs]) => P2PKHAddrEncoder(), + addrParams: { + "net_ver": CoinsConf.electraProtocolTestNet.params.p2pkhNetVer!, + }, + ); } diff --git a/lib/bip/bip/conf/bip49/bip49_coins.dart b/lib/bip/bip/conf/bip49/bip49_coins.dart index 6268c76..bc3173c 100644 --- a/lib/bip/bip/conf/bip49/bip49_coins.dart +++ b/lib/bip/bip/conf/bip49/bip49_coins.dart @@ -15,7 +15,7 @@ class Bip49Coins extends BipCoins { static const Bip49Coins litecoin = Bip49Coins._('litecoin'); static const Bip49Coins zcash = Bip49Coins._('zcash'); static const Bip49Coins pepecoin = Bip49Coins._('pepecoin'); - static const Bip49Coins omniXep = Bip49Coins._('omniXep'); + static const Bip49Coins electraProtocol = Bip49Coins._('electraProtocol'); // Test nets static const Bip49Coins bitcoinCashTestnet = @@ -30,6 +30,8 @@ class Bip49Coins extends BipCoins { static const Bip49Coins litecoinTestnet = Bip49Coins._('litecoinTestnet'); static const Bip49Coins zcashTestnet = Bip49Coins._('zcashTestnet'); static const Bip49Coins pepecoinTestnet = Bip49Coins._('pepecoinTestnet'); + static const Bip49Coins electraProtocolTestnet = + Bip49Coins._('electraProtocolTestnet'); final String name; @@ -77,7 +79,8 @@ class Bip49Coins extends BipCoins { Bip49Coins.zcashTestnet: Bip49Conf.zcashTestNet, Bip49Coins.pepecoin: Bip49Conf.pepeMainnet, Bip49Coins.pepecoinTestnet: Bip49Conf.pepeTestnet, - Bip49Coins.omniXep: Bip49Conf.omniXepMainNet + Bip49Coins.electraProtocol: Bip49Conf.electraProtocolMainNet, + Bip49Coins.electraProtocolTestnet: Bip49Conf.electraProtocolTestNet, }; @override diff --git a/lib/bip/bip/conf/bip49/bip49_conf.dart b/lib/bip/bip/conf/bip49/bip49_conf.dart index ebd5a70..06801c7 100644 --- a/lib/bip/bip/conf/bip49/bip49_conf.dart +++ b/lib/bip/bip/conf/bip49/bip49_conf.dart @@ -1,9 +1,9 @@ import 'package:blockchain_utils/bip/address/p2sh_addr.dart'; import 'package:blockchain_utils/bip/bip/bip32/bip32_key_net_ver.dart'; -import 'package:blockchain_utils/bip/bip/conf/const/bip_conf_const.dart'; import 'package:blockchain_utils/bip/bip/conf/config/bip_bitcoin_cash_conf.dart'; import 'package:blockchain_utils/bip/bip/conf/config/bip_coin_conf.dart'; import 'package:blockchain_utils/bip/bip/conf/config/bip_litecoin_conf.dart'; +import 'package:blockchain_utils/bip/bip/conf/const/bip_conf_const.dart'; import 'package:blockchain_utils/bip/coin_conf/coins_conf.dart'; import 'package:blockchain_utils/bip/ecc/curve/elliptic_curve_types.dart'; import 'package:blockchain_utils/bip/slip/slip44/slip44.dart'; @@ -411,20 +411,39 @@ class Bip49Conf { "net_ver": CoinsConf.pepeTestnet.params.p2shNetVer!, }); - /// Configuration for Omni XEP main net - static final BipCoinConfig omniXepMainNet = BipCoinConfig( - coinNames: CoinsConf.omniXepMainNet.coinName, - coinIdx: Slip44.omniXep, - isTestnet: false, - defPath: derPathNonHardenedFull, - keyNetVer: Bip32KeyNetVersions( - List.from([0x04, 0x88, 0xb2, 0x1e]), - List.from([0x04, 0x88, 0xad, 0xe4]), - ), - wifNetVer: CoinsConf.omniXepMainNet.params.wifNetVer, - type: EllipticCurveTypes.secp256k1, - addressEncoder: ([dynamic kwargs]) => P2SHAddrEncoder(), - addrParams: { - "net_ver": CoinsConf.omniXepMainNet.params.p2shNetVer!, - }); + /// Configuration for Electra Protocol main net + static final BipCoinConfig electraProtocolMainNet = BipCoinConfig( + coinNames: CoinsConf.electraProtocolMainNet.coinName, + coinIdx: Slip44.electraProtocol, + isTestnet: false, + defPath: derPathNonHardenedFull, + keyNetVer: Bip32KeyNetVersions( + List.from([0x04, 0x88, 0xb2, 0x1e]), + List.from([0x04, 0x88, 0xad, 0xe4]), + ), + wifNetVer: CoinsConf.electraProtocolMainNet.params.wifNetVer, + type: EllipticCurveTypes.secp256k1, + addressEncoder: ([dynamic kwargs]) => P2SHAddrEncoder(), + addrParams: { + "net_ver": CoinsConf.electraProtocolMainNet.params.p2shNetVer!, + }, + ); + + /// Configuration for Electra Protocol test net + static final BipCoinConfig electraProtocolTestNet = BipCoinConfig( + coinNames: CoinsConf.electraProtocolTestNet.coinName, + coinIdx: Slip44.electraProtocol, + isTestnet: true, + defPath: derPathNonHardenedFull, + keyNetVer: Bip32KeyNetVersions( + List.from([0x04, 0x35, 0x87, 0xcf]), + List.from([0x04, 0x35, 0x83, 0x94]), + ), + wifNetVer: CoinsConf.electraProtocolTestNet.params.wifNetVer, + type: EllipticCurveTypes.secp256k1, + addressEncoder: ([dynamic kwargs]) => P2SHAddrEncoder(), + addrParams: { + "net_ver": CoinsConf.electraProtocolTestNet.params.p2shNetVer!, + }, + ); } diff --git a/lib/bip/bip/conf/bip84/bip84_coins.dart b/lib/bip/bip/conf/bip84/bip84_coins.dart index 8425fa4..ba45a2b 100644 --- a/lib/bip/bip/conf/bip84/bip84_coins.dart +++ b/lib/bip/bip/conf/bip84/bip84_coins.dart @@ -62,15 +62,21 @@ class Bip84Coins extends BipCoins { // Main nets static const Bip84Coins bitcoin = Bip84Coins._('bitcoin'); static const Bip84Coins litecoin = Bip84Coins._('litecoin'); + static const Bip84Coins electraProtocol = Bip84Coins._('electraProtocol'); // Test nets static const Bip84Coins bitcoinTestnet = Bip84Coins._('bitcoinTestnet'); static const Bip84Coins litecoinTestnet = Bip84Coins._('litecoinTestnet'); + static const Bip84Coins electraProtocolTestnet = + Bip84Coins._('electraProtocolTestnet'); + static const List values = [ bitcoin, litecoin, + electraProtocol, bitcoinTestnet, - litecoinTestnet + litecoinTestnet, + electraProtocolTestnet, ]; final String name; @@ -100,6 +106,8 @@ class Bip84Coins extends BipCoins { Bip84Coins.bitcoinTestnet: Bip84Conf.bitcoinTestNet, Bip84Coins.litecoin: Bip84Conf.litecoinMainNet, Bip84Coins.litecoinTestnet: Bip84Conf.litecoinTestNet, + Bip84Coins.electraProtocol: Bip84Conf.electraProtocolMainNet, + Bip84Coins.electraProtocolTestnet: Bip84Conf.electraProtocolTestNet, }; @override diff --git a/lib/bip/bip/conf/bip84/bip84_conf.dart b/lib/bip/bip/conf/bip84/bip84_conf.dart index e78755c..31c86c1 100644 --- a/lib/bip/bip/conf/bip84/bip84_conf.dart +++ b/lib/bip/bip/conf/bip84/bip84_conf.dart @@ -1,4 +1,4 @@ -import 'package:blockchain_utils/bip/address/p2wpkh_addr.dart'; +import 'package:blockchain_utils/bip/address/encoders.dart'; import 'package:blockchain_utils/bip/bip/bip32/bip32_key_net_ver.dart'; import 'package:blockchain_utils/bip/bip/conf/config/bip_coin_conf.dart'; import 'package:blockchain_utils/bip/bip/conf/const/bip_conf_const.dart'; @@ -72,4 +72,40 @@ class Bip84Conf { addrParams: {"hrp": CoinsConf.litecoinTestNet.params.p2wpkhHrp!}, addressEncoder: ([dynamic kwargs]) => P2WPKHAddrEncoder(), ); + + /// Configuration for Electra Protocol main net + static final BipCoinConfig electraProtocolMainNet = BipCoinConfig( + coinNames: CoinsConf.electraProtocolMainNet.coinName, + coinIdx: Slip44.electraProtocol, + isTestnet: false, + defPath: derPathNonHardenedFull, + keyNetVer: Bip32KeyNetVersions( + List.from([0x04, 0x88, 0xb2, 0x1e]), + List.from([0x04, 0x88, 0xad, 0xe4]), + ), + wifNetVer: CoinsConf.electraProtocolMainNet.params.wifNetVer, + type: EllipticCurveTypes.secp256k1, + addressEncoder: ([dynamic kwargs]) => P2WPKHAddrEncoder(), + addrParams: { + "hrp": CoinsConf.electraProtocolMainNet.params.p2wpkhHrp!, + }, + ); + + /// Configuration for Electra Protocol test net + static final BipCoinConfig electraProtocolTestNet = BipCoinConfig( + coinNames: CoinsConf.electraProtocolTestNet.coinName, + coinIdx: Slip44.electraProtocol, + isTestnet: true, + defPath: derPathNonHardenedFull, + keyNetVer: Bip32KeyNetVersions( + List.from([0x04, 0x35, 0x87, 0xcf]), + List.from([0x04, 0x35, 0x83, 0x94]), + ), + wifNetVer: CoinsConf.electraProtocolTestNet.params.wifNetVer, + type: EllipticCurveTypes.secp256k1, + addressEncoder: ([dynamic kwargs]) => P2WPKHAddrEncoder(), + addrParams: { + "hrp": CoinsConf.electraProtocolMainNet.params.p2wpkhHrp!, + }, + ); } diff --git a/lib/bip/coin_conf/coins_conf.dart b/lib/bip/coin_conf/coins_conf.dart index ce59b51..58d4d61 100644 --- a/lib/bip/coin_conf/coins_conf.dart +++ b/lib/bip/coin_conf/coins_conf.dart @@ -1,5 +1,5 @@ -import 'package:blockchain_utils/bip/slip/slip173/slip173.dart'; import 'package:blockchain_utils/bip/coin_conf/coins_name.dart'; +import 'package:blockchain_utils/bip/slip/slip173/slip173.dart'; import 'coin_conf.dart'; @@ -707,9 +707,9 @@ class CoinsConf { ), ); - /// Configuration for Omni XEP main net - static const CoinConf omniXepMainNet = CoinConf( - coinName: CoinNames("Omni XEP", "OXEP"), + /// Configuration for Electra Protocol main net + static const CoinConf electraProtocolMainNet = CoinConf( + coinName: CoinNames("Electra Protocol", "XEP"), params: CoinParams( p2pkhNetVer: [0x37], p2shNetVer: [0x89], @@ -717,4 +717,15 @@ class CoinsConf { p2wpkhHrp: "ep", ), ); + + /// Configuration for Electra Protocol test net + static const CoinConf electraProtocolTestNet = CoinConf( + coinName: CoinNames("Electra Protocol TestNet", "XEP"), + params: CoinParams( + p2pkhNetVer: [0x8d], + p2shNetVer: [0x13], + wifNetVer: [0xef], + p2wpkhHrp: "te", + ), + ); } diff --git a/lib/bip/slip/slip44/slip44.dart b/lib/bip/slip/slip44/slip44.dart index 50427b7..eaddafd 100644 --- a/lib/bip/slip/slip44/slip44.dart +++ b/lib/bip/slip/slip44/slip44.dart @@ -103,5 +103,5 @@ class Slip44 { static const int celo = 52752; static const int piNetwork = 314159; static const int pepecoin = 3434; - static const int omniXep = 597; + static const int electraProtocol = 597; }