mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-26 06:08:40 +01:00
feat: show Bitcoin master fingerprint in wallet keys (#3489)
* feat: show Bitcoin master fingerprint in wallet keys Add the BIP-32 master fingerprint (XFP) to the Bitcoin wallet keys shown under Settings > Seed & Keys > Keys, labeled "Master fingerprint". * fix: keep xPub in Keys tab by splitting silent payment keys into a dedicated list The Keys tab / Silent Payments tab split relied on a hardcoded item index (`items.sublist(0, 4)` / `sublist(4)`) that assumed the first four items were always WIF/private key/public key/xPub. Adding the master fingerprint as the first item pushed xPub into the Silent Payments tab. Route Bitcoin silent payment keys into their own `silentPaymentItems` list instead, and render each tab from its list.
This commit is contained in:
@@ -1,12 +1,23 @@
|
||||
class BitcoinWalletKeys {
|
||||
const BitcoinWalletKeys(
|
||||
{required this.wif, required this.privateKey, required this.publicKey, required this.xpub});
|
||||
const BitcoinWalletKeys({
|
||||
required this.wif,
|
||||
required this.privateKey,
|
||||
required this.publicKey,
|
||||
required this.xpub,
|
||||
this.masterFingerprint = '',
|
||||
});
|
||||
|
||||
final String wif;
|
||||
final String privateKey;
|
||||
final String publicKey;
|
||||
final String xpub;
|
||||
final String masterFingerprint;
|
||||
|
||||
Map<String, String> toJson() =>
|
||||
{'wif': wif, 'privateKey': privateKey, 'publicKey': publicKey, 'xpub': xpub};
|
||||
Map<String, String> toJson() => {
|
||||
'wif': wif,
|
||||
'privateKey': privateKey,
|
||||
'publicKey': publicKey,
|
||||
'xpub': xpub,
|
||||
'masterFingerprint': masterFingerprint,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -471,6 +471,7 @@ abstract class ElectrumWalletBase
|
||||
privateKey: privateKey ?? '',
|
||||
publicKey: publicKey ?? '',
|
||||
xpub: xpub,
|
||||
masterFingerprint: _masterHD?.fingerPrint.toHex() ?? '',
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ class _WalletKeysPageBodyState extends State<WalletKeysPageBody>
|
||||
|
||||
showKeyTab = widget.walletKeysViewModel.items.isNotEmpty;
|
||||
showSilentPaymentsTab =
|
||||
widget.walletKeysViewModel.isBitcoin && widget.walletKeysViewModel.items.length > 4;
|
||||
widget.walletKeysViewModel.isBitcoin && widget.walletKeysViewModel.silentPaymentItems.isNotEmpty;
|
||||
showLegacySeedTab = widget.walletKeysViewModel.legacySeedSplit.isNotEmpty;
|
||||
isLegacySeedOnly = widget.walletKeysViewModel.isLegacySeedOnly;
|
||||
|
||||
@@ -157,16 +157,12 @@ class _WalletKeysPageBodyState extends State<WalletKeysPageBody>
|
||||
if (showKeyTab)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 22, right: 22),
|
||||
child: _buildKeysTab(
|
||||
context,
|
||||
showSilentPaymentsTab
|
||||
? widget.walletKeysViewModel.items.sublist(0, 4)
|
||||
: widget.walletKeysViewModel.items),
|
||||
child: _buildKeysTab(context, widget.walletKeysViewModel.items),
|
||||
),
|
||||
if (showSilentPaymentsTab)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 22, right: 22),
|
||||
child: _buildKeysTab(context, widget.walletKeysViewModel.items.sublist(4)),
|
||||
child: _buildKeysTab(context, widget.walletKeysViewModel.silentPaymentItems),
|
||||
),
|
||||
if (showLegacySeedTab)
|
||||
Padding(
|
||||
|
||||
@@ -30,6 +30,7 @@ abstract class WalletKeysViewModelBase with Store {
|
||||
_restoreHeight = _appStore.wallet!.walletInfo.restoreHeight,
|
||||
_restoreHeightByTransactions = 0,
|
||||
items = ObservableList<StandartListItem>(),
|
||||
silentPaymentItems = ObservableList<StandartListItem>(),
|
||||
_title = _getInitialTitle(_appStore.wallet!) {
|
||||
_populateKeysItems();
|
||||
|
||||
@@ -87,6 +88,7 @@ abstract class WalletKeysViewModelBase with Store {
|
||||
// this is incomplete, needs legacy seed toggle for XMR
|
||||
bool get shouldShowHeightBox => [WalletType.bitcoin, WalletType.zcash].contains(_wallet.type);
|
||||
final ObservableList<StandartListItem> items;
|
||||
final ObservableList<StandartListItem> silentPaymentItems;
|
||||
|
||||
@observable
|
||||
String _title;
|
||||
@@ -150,6 +152,7 @@ abstract class WalletKeysViewModelBase with Store {
|
||||
|
||||
void _populateKeysItems() {
|
||||
items.clear();
|
||||
silentPaymentItems.clear();
|
||||
|
||||
Map<String, String>? keys;
|
||||
|
||||
@@ -217,6 +220,11 @@ abstract class WalletKeysViewModelBase with Store {
|
||||
final electrumKeys = bitcoin!.getWalletKeys(_appStore.wallet!);
|
||||
|
||||
items.addAll([
|
||||
if ((electrumKeys['masterFingerprint'] ?? '').isNotEmpty)
|
||||
StandartListItem(
|
||||
title: "Master fingerprint",
|
||||
value: electrumKeys['masterFingerprint']!,
|
||||
),
|
||||
if ((electrumKeys['wif'] ?? '').isNotEmpty)
|
||||
StandartListItem(title: "WIF", value: electrumKeys['wif']!),
|
||||
if ((electrumKeys['privateKey'] ?? '').isNotEmpty)
|
||||
@@ -233,7 +241,8 @@ abstract class WalletKeysViewModelBase with Store {
|
||||
}
|
||||
|
||||
if (keys != null) {
|
||||
items.addAll([
|
||||
final keysList = _wallet.type == WalletType.bitcoin ? silentPaymentItems : items;
|
||||
keysList.addAll([
|
||||
if ((keys['primaryAddress'] ?? '').isNotEmpty)
|
||||
StandartListItem(
|
||||
key: ValueKey('${_walletName}_wallet_primary_address_item_key'),
|
||||
|
||||
Reference in New Issue
Block a user