Skip to content

Commit

Permalink
add new support dogecoin, litecoin, dash
Browse files Browse the repository at this point in the history
  • Loading branch information
mrtnetwork committed Dec 6, 2023
1 parent 687052c commit fa95d0d
Show file tree
Hide file tree
Showing 44 changed files with 513 additions and 311 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## Changelog 1.1.0+1

* Add support for Dogecoin, Litecoin and dash network

## Changelog 1.0.0+1

* Initial Release
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# About MRT Wallet

Welcome to MRT Wallet, the open-source wallet designed for the decentralized future of finance. Our mission is to empower users with a secure and versatile solution that supports both Bitcoin mainnet and testnet, with a roadmap set to embrace a broad spectrum of cryptocurrencies.
Welcome to MRT Wallet, the open-source wallet designed for the decentralized future of finance. Our mission is to empower users with a secure and versatile solution that supports both Bitcoin mainnet and testnet, as well as networks such as Dogecoin, Litecoin, and Dash, with a roadmap set to embrace a broad spectrum of cryptocurrencies.

**Decentralized, Secure, and Open Source**

At MRT Wallet, we believe in the power of decentralization. Our commitment to decentralization is at the core of our design philosophy, providing you with full control over your assets. Your private keys remain in your hands, ensuring the highest level of security.

We take pride in being fully open source. You can explore and audit our code on [GitHub](https://github.com/mrtnetwork/mrtwallet) under the Apache License 2.0. This commitment to transparency means that every line of code is accessible, empowering the community to verify the security and integrity of our wallet.

**Bitcoin Support — Mainnet and Testnet**
**Bitcoin, Dogecoin, Litecoin, Dash Support — Mainnet and Testnet**

Whether you're navigating the Bitcoin mainnet for your financial transactions or experimenting on the testnet, MRT Wallet is your reliable companion. Seamlessly switch between mainnet and testnet environments to explore, test, and transact with confidence.

Expand Down
Binary file modified mrt_wallet/assets/image/btc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mrt_wallet/assets/image/dash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mrt_wallet/assets/image/doge.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mrt_wallet/assets/image/ltc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion mrt_wallet/lib/app/extention/context.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ extension QuickContextAccsess on BuildContext {
T? getNullArgruments<T>() {
final args = ModalRoute.of(this)?.settings.arguments;
if (args == null) return null;
print("arags ${args.runtimeType} ${T}");
if (args.runtimeType != T) {
throw ArgumentError(
"value of type ${args.runtimeType} is not subtype ${T.runtimeType}");
Expand Down
28 changes: 15 additions & 13 deletions mrt_wallet/lib/app/localization/localization.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class Localization {
"Welcome to the secure login portal for your cryptocurrency wallet. Please enter your credentials below to access your digital assets",
"password": "Password",
"unlock": "Unlock",
"derive_bitcoin_address": "Deriving Bitcoin Addresses",
"derive_network_address": "Deriving ___1__ Addresses",
"generate_from_hd_wallet":
"Generating an address based on your HD wallet seed.",
"generate_from_imported_keys":
Expand All @@ -97,13 +97,13 @@ class Localization {
"BIP84: Introduces native SegWit (bech32) for more efficient fund storage, reducing fees and improving processing.",
"bip86_desc":
"BIP86: Proposes SegWit Version 1 P2TR, advancing Bitcoin's features, security, and scalability in line with community efforts.",
"setup_bitcoin_address": "Setup bitcoin address",
"setup_bitcoin_address_desc":
"You have not set up any Bitcoin account. To begin setup, please click on the 'Setup Address' button.",
"setup_network_address": "Setup ___1__ address",
"setup_network_address_desc":
"You have not set up any ___1__ account. To begin setup, please click on the 'Setup Address' button.",
"setup_address": "Setup Address",
"choose_bitcoin_address_type": "Choose Address Type",
"choose_bitcoin_address_type_desc":
"Please select a Bitcoin address type to create an address.",
"Please select the address type to create an address.",
"bitcoin_type_recomended":
"We recommend creating a P2TR or P2WPKH address due to their enhanced security features and lower cost fees.",
"standard_derivation": "Standard Derivation",
Expand Down Expand Up @@ -143,18 +143,20 @@ class Localization {
"invalid_bip_key_index": "invalid bip proposal derivation index",
"address_already_exist": "Address already exist",
"generating_new_addr": "Generating new address",
"copied_to_clipboard": "Copied to clipboard.",
"copied_to_clipboard": "Copied to cliqwe qwe qwe qwe qwe qwe pboard.",
"selected": "Selected",
"switch_account": "Switch account",
"new_address": "New Address",
"request_error": "The request encountered an error",
"invalid_request_type":
"Invalid type, request result can be string, list, or map",
"build_transacation": "Build transaction",
"create_and_send_bitcoin_transaction":
"Create and send Bitcoin transactions",
"create_and_send_network_transaction":
"Create and send ___1__ transactions",
"please_selected_acc_spend":
"Please select the Bitcoin accounts you want to spend.",
"Please select the ___1__ accounts you want to spend.",
"spend_multiple_account_desc":
"In a single transaction, you can spend from multiple addresses.",
"export_mnemonic": "Export mnemonic",
"export_mnemonic_desc":
"Export your mnemonic for secure backup and recovery",
Expand Down Expand Up @@ -277,9 +279,9 @@ class Localization {
"Insufficient balance to finalize the transaction. Prior to proceeding, please review the transaction outputs for accuracy.",
"create_send_transaction":
"Creating and sending Bitcoin transaction. Kindly await completion.",
"bitcoin_multi_sig_addr": "Bitcoin multi-signature address",
"establishing_bitcoin_multi_sig_addr":
"Establishing a Bitcoin multi-signature address.",
"multi_sig_addr": "Multi-signature address",
"establishing_multi_sig_addr":
"Establishing a multi-signature address.",
"multi_sig_desc":
"This feature is specifically crafted to enhance the security of your funds. It involves creating an account with the public keys of multiple chosen accounts. This address serves as an added layer of security, ensuring that even if one of your private keys is compromised, your funds remain both accessible and secure.",
"mutli_sig_desc2":
Expand Down Expand Up @@ -466,7 +468,7 @@ class Localization {
"last_request_error": "The most recent request encountered an error",
"reached_limit_error":
"You have reached the limit for free requests. Please wait.",
"bitcoin_api_provider_service": "Bitcoin service provider",
"service_provider": "Service provider",
"what_is_api_provider":
"A Blockchain API provider service, offers developers a comprehensive interface for interacting with the blockchain. It facilitates functions such as reading UTXOs, checking balances, and sending transactions, providing seamless integration for applications requiring real-time access to blockchain network data and transaction management.",
"what_is_service_provider": "What is a blockchain service provider?",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import 'package:bitcoin_base/bitcoin_base.dart';
import 'package:blockchain_utils/bip/bip/conf/bip_coins.dart';
import 'package:mrt_wallet/app/error/exception/wallet_ex.dart';

class BlockchainAddressUtils {
static BitcoinAddress toBitcoinAddress(
String address, BasedUtxoNetwork network) {
final length = address.length;
try {
switch (length) {
case 34:
try {
return P2pkhAddress.fromAddress(address: address, network: network);
} catch (e) {
return P2shAddress.fromAddress(address: address, network: network);
}
case 35:
return P2shAddress.fromAddress(address: address, network: network);
case 42:
case 43:
return P2wpkhAddress.fromAddress(address: address, network: network);
case 64:
case 63:
case 62:
try {
return P2wshAddress.fromAddress(address: address, network: network);
} catch (e) {
return P2trAddress.fromAddress(address: address, network: network);
}

default:
throw ArgumentError("invalid bitcoin address length");
}
} on ArgumentError {
rethrow;
} catch (e) {
throw ArgumentError("invalid bitcoin address");
}
}

static BitcoinAddress publicKeyToBitcoinAddress(
List<int> publicKey, CryptoCoins coin, BitcoinAddressType addressType) {
final bitcoinPublicKey = ECPublic.fromBytes(publicKey);
BitcoinAddress address;

switch (coin.proposal) {
case BipProposal.bip44:
address = bitcoinPublicKey.toAddress();
break;
case BipProposal.bip49:
switch (addressType) {
case BitcoinAddressType.p2wshInP2sh:
address = bitcoinPublicKey.toP2wshInP2sh();
break;
case BitcoinAddressType.p2wpkhInP2sh:
address = bitcoinPublicKey.toP2wpkhInP2sh();
break;
case BitcoinAddressType.p2pkhInP2sh:
address = bitcoinPublicKey.toP2pkhInP2sh();
break;
default:
address = bitcoinPublicKey.toP2pkInP2sh();
break;
}
break;
case BipProposal.bip84:
if (addressType == BitcoinAddressType.p2wsh) {
address = bitcoinPublicKey.toP2wshAddress();
} else {
address = bitcoinPublicKey.toSegwitAddress();
}

break;
default:
address = bitcoinPublicKey.toTaprootAddress();
break;
}
if (address.type != addressType) {
throw WalletExceptionConst.invalidBitcoinAddressType;
}

return address;
}
}
5 changes: 1 addition & 4 deletions mrt_wallet/lib/app/utility/method_caller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ class MethodCaller {
}

class MethodResult<T> {
MethodResult.error(this.exception, this.trace) : _result = null {
WalletLogging.print("request error: $error");
}
MethodResult.error(this.exception, this.trace) : _result = null;
MethodResult.succsess(this._result)
: exception = null,
trace = null;
Expand All @@ -61,7 +59,6 @@ class MethodResult<T> {
exception is ApiProviderException) {
return exception!.toString();
}

return "somthing_wrong";
}

Expand Down
1 change: 0 additions & 1 deletion mrt_wallet/lib/app/utility/secure_flag_state.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'package:flutter/material.dart';
import 'package:mrt_native_support/models/models.dart';
import 'package:mrt_native_support/platform_interface.dart';
import 'package:mrt_wallet/app/core.dart';

mixin SecureState<T extends StatefulWidget> on State<T> {
bool _enabled = false;
Expand Down
6 changes: 3 additions & 3 deletions mrt_wallet/lib/future/pages/start_page/about.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class AbountWalletView extends StatelessWidget {
),
WidgetConstant.height8,
const Text(
"Welcome to MRT Wallet, the open-source wallet designed for the decentralized future of finance. Our mission is to empower users with a secure and versatile solution that supports both Bitcoin mainnet and testnet, with a roadmap set to embrace a broad spectrum of cryptocurrencies."),
"Welcome to MRT Wallet, the open-source wallet designed for the decentralized future of finance. Our mission is to empower users with a secure and versatile solution that supports both Bitcoin mainnet and testnet, as well as networks such as Dogecoin, Litecoin, and Dash, with a roadmap set to embrace a broad spectrum of cryptocurrencies."),
WidgetConstant.height20,
Text(
"Decentralized, Secure, and Open Source",
Expand All @@ -52,7 +52,7 @@ class AbountWalletView extends StatelessWidget {
])),
WidgetConstant.height20,
Text(
"Bitcoin Support — Mainnet and Testnet",
"Bitcoin, Dogecoin, Litecoin, Dash Support — Mainnet and Testnet",
style: context.textTheme.titleLarge,
),
WidgetConstant.height8,
Expand Down Expand Up @@ -100,7 +100,7 @@ class AbountWalletView extends StatelessWidget {
),
WidgetConstant.height8,
const Text(
"Our journey doesn't end with Bitcoin. The MRT Wallet roadmap is a dynamic chart that outlines our commitment to support a wide range of cryptocurrencies. We're dedicated to staying at the forefront of innovation, adapting to new technologies, and expanding our capabilities to serve the evolving needs of the crypto community."),
"Our journey doesn't end with four networks. The MRT Wallet roadmap is a dynamic chart that outlines our commitment to support a wide range of cryptocurrencies. We're dedicated to staying at the forefront of innovation, adapting to new technologies, and expanding our capabilities to serve the evolving needs of the crypto community."),
WidgetConstant.height20,
Text(
"Community-Driven Development",
Expand Down
6 changes: 4 additions & 2 deletions mrt_wallet/lib/future/pages/start_page/account_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ class NetworkAccountPageView extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
PageTitleSubtitle(
title: "setup_bitcoin_address".tr,
body: Text("setup_bitcoin_address_desc".tr),
title: "setup_network_address"
.tr
.replaceOne(wallet.network.coinParam.coinName),
body: Text("setup_network_address_desc".tr.replaceOne(wallet.network.coinParam.coinName)),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@ class SwitchOrSelectAccountView extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
PageTitleSubtitle(
title: "setup_bitcoin_address".tr,
body: Text("setup_bitcoin_address_desc".tr),
title: "setup_network_address"
.tr
.replaceOne(wallet.network.coinParam.coinName),
body: Text("setup_network_address_desc"
.tr
.replaceOne(wallet.network.coinParam.coinName)),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:bitcoin_base/bitcoin_base.dart';
import 'package:flutter/material.dart';

import 'package:mrt_wallet/app/core.dart';
import 'package:mrt_wallet/app/utility/blockchin_utils/blockchain_addr_utils.dart';
import 'package:mrt_wallet/future/pages/wallet_pages/wallet_pages.dart';
import 'package:mrt_wallet/future/widgets/custom_widgets.dart';
import 'package:mrt_wallet/models/wallet_models/wallet_models.dart';
Expand All @@ -25,7 +26,7 @@ class _SelectAddressState extends State<SelectAddress> with SafeState {

BitcoinAddress? validateBitcoinNetwork(String address) {
try {
return BitcoinAddress.fromAddress(
return BlockchainAddressUtils.toBitcoinAddress(
address, widget.network.coinParam.transacationNetwork);
} on ArgumentError {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class SelectProviderView extends StatelessWidget {
],
);
},
itemCount: AppBitcoinNetwork.values.length,
itemCount: network.coinParam.providers.length,
),
],
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class BitcoinAccountPageView extends StatelessWidget {
children: [
AppListTile(
title: Text("multi_signature".tr),
subtitle: Text("establishing_bitcoin_multi_sig_addr".tr),
subtitle: Text("establishing_multi_sig_addr".tr),
trailing: const Icon(Icons.arrow_forward),
onTap: () {
context.to(PagePathConst.setupBitcoinMultsig);
Expand Down Expand Up @@ -46,7 +46,7 @@ class BitcoinAccountPageView extends StatelessWidget {
network: wallet.network,
selectedProvider: apiProvider.provider,
),
"bitcoin_api_provider_service".tr)
"service_provider".tr)
.then(wallet.changeProvider);
},
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ enum BitcoinTransactionPages { account, utxo, receiver, send }
class BitcoinStateController extends StateController {
BitcoinStateController(this._walletProvider);

Future<bool> onBackButtom() async {
bool onBackButtom() {
if (progressKey.status == StreamWidgetStatus.success) {
return true;
}
Expand Down Expand Up @@ -70,6 +70,9 @@ class BitcoinStateController extends StateController {
int _utxosCount = 0;

BitcoinTransactionPages _page = BitcoinTransactionPages.account;
bool get canPopPage =>
progressKey.status == StreamWidgetStatus.success ||
_page == BitcoinTransactionPages.account;
bool get inAccountPage => _page == BitcoinTransactionPages.account;
bool get inUtxoPage => _page == BitcoinTransactionPages.utxo;
bool get inReceiverPage => _page == BitcoinTransactionPages.receiver;
Expand Down Expand Up @@ -113,6 +116,7 @@ class BitcoinStateController extends StateController {
}
}

bool get haveUtxos => _utxosCount > 0;
bool get allUtxosSelected => _selectedUtxo.length == _utxosCount;
void selectAll() {
if (allUtxosSelected) {
Expand Down Expand Up @@ -148,14 +152,16 @@ class BitcoinStateController extends StateController {
void addAccount(IBitcoinAddress account) {
final address = account.address.toAddress;
final blanace = account.address.balance.value.balance;
final bool canSpend = blanace > BigInt.zero;

if (_addresses.containsKey(address)) {
_addresses.remove(address);
} else {
if (blanace > BigInt.zero) {
if (canSpend) {
if (account.isMultiSigAccounts) {
account as IBitcoinMultiSigAddress;
_addresses.addAll({
address: UtxoAddressDetails(
address: UtxoAddressDetails.multiSigAddress(
address: account.bitcoinAddress,
multiSigAddress: account.multiSignatureAddress)
});
Expand Down Expand Up @@ -393,6 +399,7 @@ class BitcoinStateController extends StateController {
),
backToIdle: false);
}
notify();
}

void changeAccount(CryptoAddress? change) {
Expand Down
Loading

0 comments on commit fa95d0d

Please sign in to comment.