mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-17 05:41:29 +02:00
v6.0.2 Release candidate (#3080)
* v6.0.2 Release candidate * v6.0.2 Release candidate * move btc ln up in the currency picker * disable bsc for swapsxyz * minor [skip ci] * hide dex/rate selection on swap screen * temp fix for evm tokens swaps icons until hive migration is done * minor [skip ci] * disable force dex providers for existing users and let them pick it from settings preference * Show bitcoin address types in swap picker (#3096) * Show bitcoin address types in swap picker * remove wrong conversion to bolt11 [skip ci] * feat: add Lightning invoice resolution and address normalization * automatically select contact wallet address based on the selected swap currency (whether it's bitcoin or lightning) * minor [skip ci] * default to bolt11 invoice for lightning swaps --------- Co-authored-by: Konstantin Ullrich <konstantinullrich12@gmail.com> --------- Co-authored-by: Konstantin Ullrich <konstantinullrich12@gmail.com>
This commit is contained in:
co-authored by
Konstantin Ullrich
parent
82982ae5af
commit
db00a0214a
@@ -151,6 +151,7 @@ abstract class BitcoinWalletBase extends ElectrumWallet with Store {
|
||||
seedBytes: seedBytes,
|
||||
apiKey: secrets.breezApiKey,
|
||||
lnurlDomain: "cake.cash",
|
||||
cachedAddress: cachedLightningAddress,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -81,6 +81,7 @@ abstract class ElectrumWalletAddressesBase extends WalletAddresses with Store {
|
||||
mwebAddresses =
|
||||
ObservableList<BitcoinAddressRecord>.of((initialMwebAddresses ?? []).toSet()),
|
||||
lockedReceiveAddressByType = ObservableMap<BitcoinAddressType, String>(),
|
||||
lightningAddress = lightningWallet?.cachedAddress,
|
||||
super(walletInfo) {
|
||||
if (masterHd != null) {
|
||||
silentAddress = SilentPaymentOwner.fromPrivateKeys(
|
||||
@@ -490,6 +491,14 @@ abstract class ElectrumWalletAddressesBase extends WalletAddresses with Store {
|
||||
addressesMap[address] = 'Active - Silent Payments';
|
||||
}
|
||||
}
|
||||
|
||||
if (lightningAddress != null) {
|
||||
if (lightningAddress != address) {
|
||||
addressesMap[lightningAddress!] = 'LN';
|
||||
} else {
|
||||
addressesMap[address] = 'Active - LN';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void addLitecoinAddressTypes() {
|
||||
@@ -767,34 +776,40 @@ abstract class ElectrumWalletAddressesBase extends WalletAddresses with Store {
|
||||
Future<void> setLightningAddress(String walletName, {String newAddress = ""}) async {
|
||||
if (lightningWallet == null) return;
|
||||
|
||||
final path = await pathForWalletDir(name: walletName, type: WalletType.bitcoin);
|
||||
final initialized = await lightningWallet!.init(path);
|
||||
try {
|
||||
final path = await pathForWalletDir(name: walletName, type: WalletType.bitcoin);
|
||||
final initialized = await lightningWallet!.init(path);
|
||||
|
||||
if (!initialized) {
|
||||
printV("Failed to initialize the lightning wallet");
|
||||
return;
|
||||
}
|
||||
if (!initialized) {
|
||||
printV("Failed to initialize the lightning wallet");
|
||||
return;
|
||||
}
|
||||
|
||||
lightningAddress = await lightningWallet!.getAddress();
|
||||
lightningAddress = await lightningWallet!.getAddress();
|
||||
|
||||
late final String username;
|
||||
late final String username;
|
||||
|
||||
if (newAddress.isEmpty) {
|
||||
if (lightningAddress != null) return;
|
||||
if (newAddress.isEmpty) {
|
||||
if (lightningAddress != null) return;
|
||||
|
||||
final randomNumber = Random.secure().nextInt(9999);
|
||||
final randomName = await generateName();
|
||||
username = "${randomName.replaceAll(" ", "")}$randomNumber".toLowerCase();
|
||||
} else {
|
||||
username = newAddress;
|
||||
}
|
||||
} else {
|
||||
username = newAddress;
|
||||
}
|
||||
|
||||
try {
|
||||
printV(username);
|
||||
lightningAddress = await lightningWallet!.registerAddress(username);
|
||||
try {
|
||||
printV(username);
|
||||
lightningAddress = await lightningWallet!.registerAddress(username);
|
||||
} catch (e) {
|
||||
printV(e);
|
||||
printV(username);
|
||||
rethrow;
|
||||
}
|
||||
} catch (e) {
|
||||
printV(e);
|
||||
printV(username);
|
||||
// make sure lightningAddress gets initialized anyway
|
||||
lightningAddress ??= lightningWallet!.cachedAddress;
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,8 +77,6 @@ class LightningWallet {
|
||||
_eventStream ??= sdk.addEventListener().asBroadcastStream();
|
||||
_logStream ??= initLogging().asBroadcastStream();
|
||||
|
||||
await sdk.syncWallet(request: SyncWalletRequest());
|
||||
|
||||
try {
|
||||
final logFile = File("$appPath/lightning.log")
|
||||
..createSync();
|
||||
@@ -87,6 +85,8 @@ class LightningWallet {
|
||||
printV(e);
|
||||
}
|
||||
|
||||
await sdk.syncWallet(request: SyncWalletRequest());
|
||||
|
||||
return true;
|
||||
} catch (e) {
|
||||
printV(e);
|
||||
|
||||
Reference in New Issue
Block a user