diff --git a/assets/svg/coin_icons/Namecoin.svg b/assets/svg/coin_icons/Namecoin.svg
new file mode 100644
index 000000000..2cda6aaf0
--- /dev/null
+++ b/assets/svg/coin_icons/Namecoin.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/lib/pages/settings_views/global_settings_view/manage_nodes_views/add_edit_node_view.dart b/lib/pages/settings_views/global_settings_view/manage_nodes_views/add_edit_node_view.dart
index 9bc785547..0cb47b7ff 100644
--- a/lib/pages/settings_views/global_settings_view/manage_nodes_views/add_edit_node_view.dart
+++ b/lib/pages/settings_views/global_settings_view/manage_nodes_views/add_edit_node_view.dart
@@ -116,6 +116,7 @@ class _AddEditNodeViewState extends ConsumerState {
case Coin.bitcoincash:
case Coin.dogecoin:
case Coin.firo:
+ case Coin.namecoin:
case Coin.bitcoinTestNet:
case Coin.firoTestNet:
case Coin.dogecoinTestNet:
@@ -528,6 +529,7 @@ class _NodeFormState extends ConsumerState {
case Coin.bitcoin:
case Coin.dogecoin:
case Coin.firo:
+ case Coin.namecoin:
case Coin.bitcoincash:
case Coin.bitcoinTestNet:
case Coin.firoTestNet:
diff --git a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart
index eb209490f..bb241b494 100644
--- a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart
+++ b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart
@@ -3040,6 +3040,36 @@ class BitcoinCashWallet extends CoinServiceAPI {
return available - estimatedFee;
}
+
+ @override
+ Future generateNewAddress() async {
+ try {
+ await _incrementAddressIndexForChain(
+ 0, DerivePathType.bip44); // First increment the receiving index
+ final newReceivingIndex = DB.instance.get(
+ boxName: walletId,
+ key: 'receivingIndexP2PKH') as int; // Check the new receiving index
+ final newReceivingAddress = await _generateAddressForChain(
+ 0,
+ newReceivingIndex,
+ DerivePathType
+ .bip44); // Use new index to derive a new receiving address
+ await _addToAddressesArrayForChain(
+ newReceivingAddress,
+ 0,
+ DerivePathType
+ .bip44); // Add that new receiving address to the array of receiving addresses
+ _currentReceivingAddressP2PKH = Future(() =>
+ newReceivingAddress); // Set the new receiving address that the service
+
+ return true;
+ } catch (e, s) {
+ Logging.instance.log(
+ "Exception rethrown from generateNewAddress(): $e\n$s",
+ level: LogLevel.Error);
+ return false;
+ }
+ }
}
// Bitcoincash Network
diff --git a/lib/services/coins/coin_service.dart b/lib/services/coins/coin_service.dart
index 629912f00..5db6bd8bc 100644
--- a/lib/services/coins/coin_service.dart
+++ b/lib/services/coins/coin_service.dart
@@ -9,6 +9,7 @@ import 'package:stackwallet/services/coins/epiccash/epiccash_wallet.dart';
import 'package:stackwallet/services/coins/firo/firo_wallet.dart';
import 'package:stackwallet/services/coins/monero/monero_wallet.dart';
import 'package:stackwallet/services/coins/bitcoincash/bitcoincash_wallet.dart';
+import 'package:stackwallet/services/coins/namecoin/namecoin_wallet.dart';
import 'package:stackwallet/services/transaction_notification_tracker.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/prefs.dart';
@@ -134,6 +135,16 @@ abstract class CoinServiceAPI {
// tracker: tracker,
);
+ case Coin.namecoin:
+ return NamecoinWallet(
+ walletId: walletId,
+ walletName: walletName,
+ coin: coin,
+ tracker: tracker,
+ cachedClient: cachedClient,
+ client: client,
+ );
+
case Coin.dogecoinTestNet:
return DogecoinWallet(
walletId: walletId,
diff --git a/lib/services/coins/namecoin/namecoin_wallet.dart b/lib/services/coins/namecoin/namecoin_wallet.dart
index 30394cd62..067b26c0f 100644
--- a/lib/services/coins/namecoin/namecoin_wallet.dart
+++ b/lib/services/coins/namecoin/namecoin_wallet.dart
@@ -46,9 +46,7 @@ const int MINIMUM_CONFIRMATIONS = 3;
const int DUST_LIMIT = 1000000;
const String GENESIS_HASH_MAINNET =
- "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f";
-const String GENESIS_HASH_TESTNET =
- "000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943";
+ "000000000062b72c5e2ceb45fbc8587e807c155b0da735e6483dfba2f0a9c770";
enum DerivePathType { bip44 }
@@ -77,11 +75,11 @@ bip32.BIP32 getBip32NodeFromRoot(
int chain, int index, bip32.BIP32 root, DerivePathType derivePathType) {
String coinType;
switch (root.network.wif) {
- case 0x80: // bch mainnet wif
- coinType = "145"; // bch mainnet
+ case 0x80: // nmc mainnet wif
+ coinType = "7"; // nmc mainnet
break;
default:
- throw Exception("Invalid Bitcoincash network type used!");
+ throw Exception("Invalid Namecoin network type used!");
}
switch (derivePathType) {
case DerivePathType.bip44:
@@ -122,7 +120,7 @@ bip32.BIP32 getBip32RootWrapper(Tuple2 args) {
return getBip32Root(args.item1, args.item2);
}
-class NamecoinCashWallet extends CoinServiceAPI {
+class NamecoinWallet extends CoinServiceAPI {
static const integrationTestFlag =
bool.fromEnvironment("IS_INTEGRATION_TEST");
final _prefs = Prefs.instance;
@@ -134,10 +132,10 @@ class NamecoinCashWallet extends CoinServiceAPI {
NetworkType get _network {
switch (coin) {
- case Coin.bitcoincash:
- return bitcoincash;
+ case Coin.namecoin:
+ return namecoin;
default:
- throw Exception("Bitcoincash network type not set!");
+ throw Exception("Namecoin network type not set!");
}
}
@@ -298,14 +296,14 @@ class NamecoinCashWallet extends CoinServiceAPI {
final features = await electrumXClient.getServerFeatures();
Logging.instance.log("features: $features", level: LogLevel.Info);
switch (coin) {
- case Coin.bitcoincash:
+ case Coin.namecoin:
if (features['genesis_hash'] != GENESIS_HASH_MAINNET) {
throw Exception("genesis hash does not match main net!");
}
break;
default:
throw Exception(
- "Attempted to generate a BitcoinCashWallet using a non bch coin type: ${coin.name}");
+ "Attempted to generate a NamecoinWallet using a non namecoin coin type: ${coin.name}");
}
}
// check to make sure we aren't overwriting a mnemonic
@@ -730,9 +728,6 @@ class NamecoinCashWallet extends CoinServiceAPI {
/// Refreshes display data for the wallet
@override
Future refresh() async {
- final bchaddr = Bitbox.Address.toCashAddress(await currentReceivingAddress);
- print("bchaddr: $bchaddr ${await currentReceivingAddress}");
-
if (refreshMutex) {
Logging.instance.log("$walletId $walletName refreshMutex denied",
level: LogLevel.Info);
@@ -1048,14 +1043,7 @@ class NamecoinCashWallet extends CoinServiceAPI {
@override
bool validateAddress(String address) {
- try {
- // 0 for bitcoincash: address scheme, 1 for legacy address
- final format = Bitbox.Address.detectFormat(address);
- print("format $format");
- return true;
- } catch (e, s) {
- return false;
- }
+ return Address.validateAddress(address, _network);
}
@override
@@ -1082,7 +1070,7 @@ class NamecoinCashWallet extends CoinServiceAPI {
late PriceAPI _priceAPI;
- BitcoinCashWallet({
+ NamecoinWallet({
required String walletId,
required String walletName,
required Coin coin,
@@ -1222,14 +1210,14 @@ class NamecoinCashWallet extends CoinServiceAPI {
final features = await electrumXClient.getServerFeatures();
Logging.instance.log("features: $features", level: LogLevel.Info);
switch (coin) {
- case Coin.bitcoincash:
+ case Coin.namecoin:
if (features['genesis_hash'] != GENESIS_HASH_MAINNET) {
throw Exception("genesis hash does not match main net!");
}
break;
default:
throw Exception(
- "Attempted to generate a BitcoinWallet using a non bitcoin coin type: ${coin.name}");
+ "Attempted to generate a NamecoinWallet using a non namecoin coin type: ${coin.name}");
}
}
@@ -1840,10 +1828,10 @@ class NamecoinCashWallet extends CoinServiceAPI {
/// attempts to convert a string to a valid scripthash
///
- /// Returns the scripthash or throws an exception on invalid bch address
- String _convertToScriptHash(String bchAddress, NetworkType network) {
+ /// Returns the scripthash or throws an exception on invalid namecoin address
+ String _convertToScriptHash(String namecoinAddress, NetworkType network) {
try {
- final output = Address.addressToOutputScript(bchAddress, network);
+ final output = Address.addressToOutputScript(namecoinAddress, network);
final hash = sha256.convert(output.toList(growable: false)).toString();
final chars = hash.split("");
@@ -1937,7 +1925,6 @@ class NamecoinCashWallet extends CoinServiceAPI {
unconfirmedCachedTransactions
.removeWhere((key, value) => value.confirmedStatus);
- print("CACHED_TRANSACTIONS_IS $cachedTransactions");
if (cachedTransactions != null) {
for (final tx in allTxHashes.toList(growable: false)) {
final txHeight = tx["height"] as int;
@@ -1953,7 +1940,6 @@ class NamecoinCashWallet extends CoinServiceAPI {
List