Skip to content

Commit

Permalink
V4.5.0
Browse files Browse the repository at this point in the history
Added support for Pepecoin network
  • Loading branch information
mrtnetwork committed Jun 24, 2024
1 parent 45029e1 commit 4368730
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 717 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 4.5.0

* Added support for Pepecoin network
* Update dependencies

## 4.4.0

* Update dependencies
Expand Down
4 changes: 2 additions & 2 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ packages:
path: ".."
relative: true
source: path
version: "4.3.0"
version: "4.4.0"
blockchain_utils:
dependency: "direct main"
description:
path: "../../blockchain_utils"
relative: true
source: path
version: "3.0.0"
version: "3.1.0"
boolean_selector:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion example/test/widget_test.dart
Original file line number Diff line number Diff line change
@@ -1 +1 @@
void main() {}
void main() async {}
20 changes: 20 additions & 0 deletions lib/src/bitcoin/address/network_address.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,26 @@ class DogeAddress extends BitcoinNetworkAddress<DogecoinNetwork> {
final String address;
}

/// A concrete implementation of [BitcoinNetworkAddress] for Pepecoin network.
class PepeAddress extends BitcoinNetworkAddress<PepeNetwork> {
const PepeAddress._(this.baseAddress, this.address);
factory PepeAddress(String address,
{PepeNetwork network = PepeNetwork.mainnet}) {
return PepeAddress._(
_BitcoinAddressUtils.decodeAddress(address, network), address);
}
factory PepeAddress.fromBaseAddress(BitcoinBaseAddress address,
{PepeNetwork network = PepeNetwork.mainnet}) {
final baseAddress = _BitcoinAddressUtils.validateAddress(address, network);
return PepeAddress._(baseAddress, baseAddress.toAddress(network));
}
@override
final BitcoinBaseAddress baseAddress;

@override
final String address;
}

/// A concrete implementation of [BitcoinNetworkAddress] for Litecoin network.
class LitecoinAddress extends BitcoinNetworkAddress<LitecoinNetwork> {
LitecoinAddress._(this.baseAddress, this.address);
Expand Down
62 changes: 57 additions & 5 deletions lib/src/models/network.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import 'package:bitcoin_base/bitcoin_base.dart';
import 'package:bitcoin_base/src/utils/enumerate.dart';
import 'package:blockchain_utils/bip/bip/conf/bip44/bip44_coins.dart';
import 'package:blockchain_utils/bip/bip/conf/bip49/bip49_coins.dart';
import 'package:blockchain_utils/bip/bip/conf/bip84/bip84_coins.dart';
import 'package:blockchain_utils/bip/bip/conf/bip86/bip86_coins.dart';
import 'package:blockchain_utils/bip/bip/bip.dart';
import 'package:blockchain_utils/bip/bip/conf/bip_coins.dart';
import 'package:blockchain_utils/bip/coin_conf/coin_conf.dart';
import 'package:blockchain_utils/bip/coin_conf/coins_conf.dart';
Expand Down Expand Up @@ -50,7 +47,8 @@ abstract class BasedUtxoNetwork implements Enumerate {
BitcoinCashNetwork.mainnet,
BitcoinCashNetwork.testnet,
BitcoinSVNetwork.mainnet,
BitcoinSVNetwork.testnet
BitcoinSVNetwork.testnet,
PepeNetwork.mainnet
];

static BasedUtxoNetwork fromName(String name) {
Expand Down Expand Up @@ -441,3 +439,57 @@ class BitcoinCashNetwork implements BasedUtxoNetwork {
return [Bip44Coins.bitcoinCashTestnet, Bip49Coins.bitcoinCashTestnet];
}
}

/// Class representing a Dogecoin network, implementing the `BasedUtxoNetwork` abstract class.
class PepeNetwork implements BasedUtxoNetwork {
/// Mainnet configuration with associated `CoinConf`.
static const PepeNetwork mainnet =
PepeNetwork._("pepecoinMainnet", CoinsConf.pepeMainnet);

/// 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 PepeNetwork._(this.value, this.conf);

@override
final String value;

/// Retrieves the Wallet Import Format (WIF) version bytes from the associated `CoinConf`.
@override
List<int> get wifNetVer => conf.params.wifNetVer!;

/// Retrieves the Pay-to-Public-Key-Hash (P2PKH) version bytes from the associated `CoinConf`.
@override
List<int> get p2pkhNetVer => conf.params.p2pkhNetVer!;

/// Retrieves the Pay-to-Script-Hash (P2SH) version bytes from the associated `CoinConf`.
@override
List<int> 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 UnimplementedError(
"DogecoinNetwork network does not support P2WPKH/P2WSH");

/// Checks if the current network is the mainnet.
@override
bool get isMainnet => true;

@override
final List<BitcoinAddressType> supportedAddress = const [
PubKeyAddressType.p2pk,
P2pkhAddressType.p2pkh,
P2shAddressType.p2pkhInP2sh,
P2shAddressType.p2pkInP2sh
];

@override
List<CryptoCoins> get coins {
if (isMainnet) {
return [Bip44Coins.pepecoin, Bip49Coins.pepecoin];
}
return [Bip44Coins.pepecoinTestnet, Bip49Coins.pepecoinTestnet];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ class ElectrumEstimateFee extends ElectrumRequest<BigInt, dynamic> {
/// The estimated transaction fee in Bigint(satoshi)
@override
BigInt onResonse(result) {
return BtcUtils.toSatoshi(result.toString());
return BtcUtils.toSatoshi(result.toString()).abs();
}
}
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: bitcoin_base
description: A versatile library for Bitcoin, Dogecoin, Litecoin, Dash, BSV, and BCH. Supports P2PKH, P2SH, P2WPKH, P2WSH, P2TR, with advanced creation, signing, and spending capabilities.
version: 4.4.0
version: 4.5.0
homepage: "https://github.com/mrtnetwork/bitcoin_base"
repository: "https://github.com/mrtnetwork/bitcoin_base"
Author: mrhaydari.t@gmail.com
Expand All @@ -16,7 +16,7 @@ environment:


dependencies:
blockchain_utils: ^3.1.0
blockchain_utils: ^3.2.0

# blockchain_utils:
# path: ../blockchain_utils
Expand Down
Loading

0 comments on commit 4368730

Please sign in to comment.