currency updates

This commit is contained in:
Matthew Fosse 2024-02-29 12:39:49 -08:00
parent 2af749a155
commit bc6073692a
9 changed files with 33 additions and 9 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

View file

@ -0,0 +1,10 @@
<?xml version="1.0" standalone="no"?>
<!-- Generator: Adobe Fireworks 10, Export SVG Extension by Aaron Beall (http://fireworks.abeall.com) . Version: 0.6.1 -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg id="bitcoin_lightning_icon.fw-Page%201" viewBox="0 0 280 280" style="background-color:#ffffff00" version="1.1"
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve"
x="0px" y="0px" width="280px" height="280px"
>
<path id="Ellipse" d="M 7 140.5 C 7 66.769 66.769 7 140.5 7 C 214.231 7 274 66.769 274 140.5 C 274 214.231 214.231 274 140.5 274 C 66.769 274 7 214.231 7 140.5 Z" fill="#f7931a"/>
<path d="M 161.1943 51.5 C 153.2349 72.1607 145.2756 94.4107 135.7244 116.6607 C 135.7244 116.6607 135.7244 119.8393 138.9081 119.8393 L 204.1747 119.8393 C 204.1747 119.8393 204.1747 121.4286 205.7667 123.0179 L 110.2545 229.5 C 108.6626 227.9107 108.6626 226.3214 108.6626 224.7321 L 142.0919 153.2143 L 142.0919 146.8571 L 75.2333 146.8571 L 75.2333 140.5 L 156.4187 51.5 L 161.1943 51.5 Z" fill="#ffffff"/>
</svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

View file

@ -42,7 +42,7 @@ class ElectrumWalletSnapshot {
.whereType<String>()
.map((addr) => BitcoinAddressRecord.fromJSON(addr, network))
.toList();
final balance = ElectrumBalance.fromJSON(data['balance'] as String) ??
final balance = ElectrumBalance.fromJSON(data['balance'] as String?) ??
ElectrumBalance(confirmed: 0, unconfirmed: 0, frozen: 0);
var regularAddressIndexByType = {SegwitAddresType.p2wpkh.toString(): 0};
var changeAddressIndexByType = {SegwitAddresType.p2wpkh.toString(): 0};

View file

@ -23,6 +23,8 @@ class AmountConverter {
return _moneroAmountToDouble(amount);
case CryptoCurrency.btc:
return _bitcoinAmountToDouble(amount);
case CryptoCurrency.btcln:
return _lightningAmountToDouble(amount);
case CryptoCurrency.bch:
return _bitcoinCashAmountToDouble(amount);
case CryptoCurrency.dash:
@ -83,6 +85,8 @@ class AmountConverter {
case CryptoCurrency.bch:
case CryptoCurrency.ltc:
return _bitcoinAmountToString(amount);
case CryptoCurrency.btcln:
return _lightningAmountToString(amount);
case CryptoCurrency.xhv:
case CryptoCurrency.xag:
case CryptoCurrency.xau:
@ -119,9 +123,17 @@ class AmountConverter {
_bitcoinAmountFormat.format(
cryptoAmountToDouble(amount: amount, divider: _bitcoinAmountDivider));
static String _lightningAmountToString(int amount) {
String formattedAmount = _bitcoinAmountFormat.format(amount);
return formattedAmount.substring(0, formattedAmount.length - 2);
}
static double _bitcoinAmountToDouble(int amount) =>
cryptoAmountToDouble(amount: amount, divider: _bitcoinAmountDivider);
static double _lightningAmountToDouble(int amount) =>
cryptoAmountToDouble(amount: amount, divider: 1);
static int _doubleToBitcoinAmount(double amount) =>
(amount * _bitcoinAmountDivider).toInt();

View file

@ -186,7 +186,7 @@ class CryptoCurrency extends EnumerableItem<int> with Serializable<int> implemen
static const scrt = CryptoCurrency(title: 'SCRT', fullName: 'Secret Network', raw: 59, name: 'scrt', iconPath: 'assets/images/scrt_icon.png', decimals: 6);
static const uni = CryptoCurrency(title: 'UNI', tag: 'ETH', fullName: 'Uniswap', raw: 60, name: 'uni', iconPath: 'assets/images/uni_icon.png', decimals: 18);
static const stx = CryptoCurrency(title: 'STX', fullName: 'Stacks', raw: 61, name: 'stx', iconPath: 'assets/images/stx_icon.png', decimals: 8);
static const btcln = CryptoCurrency(title: 'BTC', tag: 'LN', fullName: 'Bitcoin Lightning Network', raw: 62, name: 'btcln', iconPath: 'assets/images/btc.png', decimals: 8);
static const btcln = CryptoCurrency(title: 'Sats', tag: 'LN', fullName: 'Bitcoin Lightning Network', raw: 62, name: 'btcln', iconPath: 'assets/images/lightning_logo.png', decimals: 8);
static const shib = CryptoCurrency(title: 'SHIB', tag: 'ETH', fullName: 'Shiba Inu', raw: 63, name: 'shib', iconPath: 'assets/images/shib_icon.png', decimals: 18);
static const aave = CryptoCurrency(title: 'AAVE', tag: 'ETH', fullName: 'Aave', raw: 64, name: 'aave', iconPath: 'assets/images/aave_icon.png', decimals: 18);
static const arb = CryptoCurrency(title: 'ARB', fullName: 'Arbitrum', raw: 65, name: 'arb', iconPath: 'assets/images/arb_icon.png', decimals: 18);
@ -216,7 +216,7 @@ class CryptoCurrency extends EnumerableItem<int> with Serializable<int> implemen
static const kaspa = CryptoCurrency(title: 'KAS', fullName: 'Kaspa', raw: 89, name: 'kas', iconPath: 'assets/images/kaspa_icon.png', decimals: 8);
static const digibyte = CryptoCurrency(title: 'DGB', fullName: 'DigiByte', raw: 90, name: 'dgb', iconPath: 'assets/images/digibyte.png', decimals: 8);
static const usdtSol = CryptoCurrency(title: 'USDT', tag: 'SOL', fullName: 'USDT Tether', raw: 90, name: 'usdtsol', iconPath: 'assets/images/usdt_icon.png', decimals: 6);
static const satoshis = CryptoCurrency(title: 'Sats', fullName: 'Satoshis', raw: 91, name: 'sats', iconPath: 'assets/images/btc.png', decimals: 0);
static const satoshis = CryptoCurrency(title: 'Sats', fullName: 'Satoshis', raw: 91, name: 'sats', iconPath: 'assets/images/lightning_logo.png', decimals: 0);

View file

@ -194,7 +194,7 @@ CryptoCurrency walletTypeToCryptoCurrency(WalletType type) {
case WalletType.polygon:
return CryptoCurrency.maticpoly;
case WalletType.lightning:
return CryptoCurrency.btc;
return CryptoCurrency.btcln;
case WalletType.solana:
return CryptoCurrency.sol;
default:

View file

@ -84,7 +84,7 @@ abstract class LightningWalletBase
_password = password,
_isTransactionUpdating = false,
balance = ObservableMap<CryptoCurrency, LightningBalance>.of({
CryptoCurrency.btc:
CryptoCurrency.btcln:
initialBalance ?? const LightningBalance(confirmed: 0, unconfirmed: 0, frozen: 0)
}),
super(walletInfo) {
@ -207,7 +207,7 @@ abstract class LightningWalletBase
sdk.nodeStateStream.listen((event) {
if (event == null) return;
balance[CryptoCurrency.btc] = LightningBalance(
balance[CryptoCurrency.btcln] = LightningBalance(
confirmed: event.maxPayableMsat ~/ 1000,
unconfirmed: event.maxReceivableMsat ~/ 1000,
frozen: 0,

View file

@ -270,6 +270,7 @@ class AddressValidator extends TextValidator {
'|([^0-9a-zA-Z]|^)8[0-9a-zA-Z]{94}([^0-9a-zA-Z]|\$)'
'|([^0-9a-zA-Z]|^)[0-9a-zA-Z]{106}([^0-9a-zA-Z]|\$)';
case CryptoCurrency.btc:
case CryptoCurrency.btcln:
return '([^0-9a-zA-Z]|^)${P2pkhAddress.regex.pattern}|\$)'
'([^0-9a-zA-Z]|^)${P2shAddress.regex.pattern}|\$)'
'([^0-9a-zA-Z]|^)${P2wpkhAddress.regex.pattern}|\$)'

View file

@ -39,13 +39,14 @@ abstract class LightningViewModelBase with Store {
Future<List<String>> invoiceLimitsSats() async {
final sdk = await BreezSDK();
final req = ReceivePaymentRequest(
amountMsat: 3000 * 1000,// 3000 sats
ReceivePaymentRequest? req = null;
req = ReceivePaymentRequest(
amountMsat: 10000 * 1000, // 10000 sats
description: "limits",
);
final res = await sdk.receivePayment(req: req);
int min = (res.openingFeeMsat ?? (2500 * 1000)) ~/ 1000;
int max = 1000000000 * 1000 * 10;// 10 BTC
int max = 1000000000 * 1000 * 10; // 10 BTC
return [min.toString(), max.toString()];
}
}