Skip to content

Commit 106b045

Browse files
committed
fix(transfer): #2480 transfer limits for classic denomination
1 parent 2092279 commit 106b045

File tree

3 files changed

+7
-61
lines changed

3 files changed

+7
-61
lines changed

src/hooks/transfer.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import { useEffect, useState } from 'react';
22

33
import { blocktankInfoSelector } from '../store/reselect/blocktank';
44
import { blocktankChannelsSizeSelector } from '../store/reselect/lightning';
5+
import { EConversionUnit } from '../store/types/wallet';
56
import { estimateOrderFee } from '../utils/blocktank';
6-
import { fiatToBitcoinUnit } from '../utils/conversion';
7+
import { convertToSats } from '../utils/conversion';
78
import { useAppSelector } from './redux';
89

910
type TTransferValues = {
@@ -17,9 +18,9 @@ const getDefaultLspBalance = (
1718
clientBalance: number,
1819
maxLspBalance: number,
1920
): number => {
20-
const threshold1 = fiatToBitcoinUnit({ amount: 225, currency: 'EUR' });
21-
const threshold2 = fiatToBitcoinUnit({ amount: 495, currency: 'EUR' });
22-
const defaultLspBalance = fiatToBitcoinUnit({ amount: 450, currency: 'EUR' });
21+
const threshold1 = convertToSats(225, EConversionUnit.fiat, 'EUR');
22+
const threshold2 = convertToSats(495, EConversionUnit.fiat, 'EUR');
23+
const defaultLspBalance = convertToSats(450, EConversionUnit.fiat, 'EUR');
2324

2425
let lspBalance = defaultLspBalance - clientBalance;
2526

src/utils/blocktank/index.ts

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -387,59 +387,3 @@ export const logToBlocktank = async (
387387
): Promise<void> => {
388388
return bt.bitkitLog(nodeId, message);
389389
};
390-
391-
/**
392-
* Returns Blocktank spending limits in sats, USD & the user's selectedCurrency.
393-
* CURRENTLY UNUSED
394-
* @param selectedCurrency
395-
*/
396-
// export const getSpendingLimits = ({
397-
// selectedCurrency,
398-
// }: {
399-
// selectedCurrency?: string;
400-
// }): {
401-
// currentBalance: IDisplayValues;
402-
// spendableBalanceSats: number;
403-
// spendableBalanceFiat: number;
404-
// usdSpendingLimitFiat: number;
405-
// spendingLimitSats: number;
406-
// selectedCurrencySpendingLimitFiat: number;
407-
// } => {
408-
// if (!selectedCurrency) {
409-
// selectedCurrency = getSettingsStore().selectedCurrency;
410-
// }
411-
// const usdMax = 1000;
412-
// const denominator = 1.2;
413-
414-
// const currentBalance = getBalance({ onchain: true });
415-
// const spendableBalanceSats = Math.round(
416-
// currentBalance.satoshis / denominator,
417-
// );
418-
// const spendableBalanceFiat = Math.round(
419-
// currentBalance.fiatValue / denominator,
420-
// );
421-
// const usdSpendingLimitFiat =
422-
// spendableBalanceFiat < usdMax ? spendableBalanceFiat : usdMax;
423-
// const spendingLimitSats = fiatToBitcoinUnit({
424-
// fiatValue: usdSpendingLimitFiat,
425-
// bitcoinUnit: EBitcoinUnit.satoshi,
426-
// currency: 'USD',
427-
// });
428-
// const selectedCurrencySpendingLimitFiat = getFiatDisplayValues({
429-
// satoshis:
430-
// spendableBalanceSats < spendingLimitSats
431-
// ? spendableBalanceSats
432-
// : spendingLimitSats,
433-
// bitcoinUnit: EBitcoinUnit.satoshi,
434-
// currency: selectedCurrency,
435-
// });
436-
// return {
437-
// currentBalance,
438-
// spendableBalanceSats,
439-
// spendableBalanceFiat,
440-
// usdSpendingLimitFiat,
441-
// spendingLimitSats,
442-
// selectedCurrencySpendingLimitFiat:
443-
// selectedCurrencySpendingLimitFiat.fiatValue,
444-
// };
445-
// };

src/utils/conversion.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export const satsToBtc = (balance: number): number => {
2828
export const convertToSats = (
2929
value: number | string,
3030
unit: EConversionUnit,
31+
currency?: string,
3132
): number => {
3233
const amount = Number(value);
3334

@@ -37,7 +38,7 @@ export const convertToSats = (
3738

3839
if (unit === EConversionUnit.fiat) {
3940
const denomination = getSettingsStore().denomination;
40-
const btcUnit = fiatToBitcoinUnit({ amount });
41+
const btcUnit = fiatToBitcoinUnit({ amount, currency });
4142
return denomination === EDenomination.modern ? btcUnit : btcToSats(btcUnit);
4243
}
4344

0 commit comments

Comments
 (0)