Skip to content

Commit

Permalink
Fix currency formatting throughout app
Browse files Browse the repository at this point in the history
  • Loading branch information
getsnoopy committed May 10, 2024
1 parent 647c380 commit 5166923
Show file tree
Hide file tree
Showing 24 changed files with 54 additions and 54 deletions.
4 changes: 2 additions & 2 deletions WalletWasabi.Documentation/WasabiSetupRegtest.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,10 @@ Todo:
`dotnet run --no-build`
5. Generate a wallet in Wasabi named: R1.
6. Generate a receive address in Wasabi, now go to Bitcoin Knots to the Send tab.
7. Send 1 BTC to that address.
7. Send BTC 1 to that address.
8. Generate a wallet in Wasabi named: R2.
9. Generate a receive address in Wasabi, now go to Bitcoin Knots to the Send tab.
10. Send 1 BTC to that address.
10. Send BTC 1 to that address.
11. Now let the coinjoin happen automatically in both wallets.
12. If you see `Waiting for confirmed funds` in the music box you can generate a block in Bitcoin Knots to continue coinjoining.
- You can do it with the console command `generatetoaddress 1 <replace_with_your_address_here>`
Expand Down
8 changes: 4 additions & 4 deletions WalletWasabi.Fluent/Controls/DualCurrencyEntryBox.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -347,17 +347,17 @@ private decimal FiatToBitcoin(decimal fiatValue)

private static string FullFormatBtc(decimal value)
{
return $"{value.FormattedBtc()} BTC";
return $"BTC {value.FormattedBtc()}";
}

private static string FullFormatFiat(decimal value, string currencyCode, bool approximate)
{
var part1 = approximate ? "" : "";
var part2 = value.FormattedFiat();
var part3 =
var part2 =
!string.IsNullOrWhiteSpace(currencyCode)
? $" {currencyCode}"
? $"{currencyCode} "
: "";
var part3 = value.FormattedFiat();
return part1 + part2 + part3;
}

Expand Down
6 changes: 3 additions & 3 deletions WalletWasabi.Fluent/Extensions/CurrencyExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public static decimal BtcToUsd(this Money money, decimal exchangeRate)

public static string ToUsdFormatted(this decimal n)
{
return ToUsdAmountFormatted(n) + " USD";
return "USD " + ToUsdAmountFormatted(n);
}

public static string ToUsdAmountFormatted(this decimal n)
Expand All @@ -98,7 +98,7 @@ public static string ToUsdAmountFormatted(this decimal n)

public static string ToUsd(this decimal n)
{
return n.WithFriendlyDecimals() + " USD";
return "USD " + n.WithFriendlyDecimals();
}

public static decimal WithFriendlyDecimals(this double n)
Expand Down Expand Up @@ -149,7 +149,7 @@ public static string ToFeeDisplayUnitFormattedString(this Money? fee)
_ => fee.ToString()
};

var feeText = $"{feePartText} {displayUnit.FriendlyName()}";
var feeText = $"{displayUnit.FriendlyName()} {feePartText}";

return feeText;
}
Expand Down
2 changes: 1 addition & 1 deletion WalletWasabi.Fluent/Helpers/TextHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static string TimeSpanToFriendlyString(TimeSpan time)

public static string ToBtcWithUnit(this Money money, bool fplus = false)
{
return money.ToFormattedString(fplus) + " BTC";
return "BTC " + money.ToFormattedString(fplus);
}

public static string ToFormattedString(this Money money, bool fplus = false)
Expand Down
4 changes: 2 additions & 2 deletions WalletWasabi.Fluent/Models/TransactionBroadcasterModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public TransactionBroadcastInfo GetBroadcastInfo(SmartTransaction transaction)
var inputAmountString =
totalInputValue is null
? "Unknown"
: $"{totalInputValue.ToFormattedString()} BTC";
: $"BTC {totalInputValue.ToFormattedString()}";

var outputCount = outputAddressAmount.Length;

Expand All @@ -87,7 +87,7 @@ public TransactionBroadcastInfo GetBroadcastInfo(SmartTransaction transaction)
var outputAmountString =
totalOutputValue is null
? "Unknown"
: $"{totalOutputValue.ToFormattedString()} BTC";
: $"BTC {totalOutputValue.ToFormattedString()}";

var networkFee = totalInputValue is null || totalOutputValue is null
? null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ private string GetDifferenceText(decimal btcDifference)

private string GetDifferenceAmountText(decimal btcDifference, decimal fiatDifference)
{
return $"{Math.Abs(btcDifference).FormattedBtc()} BTC {Math.Abs(fiatDifference).ToUsdAproxBetweenParens()}";
return $"BTC {Math.Abs(btcDifference).FormattedBtc()} {Math.Abs(fiatDifference).ToUsdAproxBetweenParens()}";
}

private record Parameters(TransactionInfo TransactionInfo, BuildTransactionResult Transaction, bool IncludeSuggestions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public OfferMessageViewModel(ChatMessage message) : base(message)

var total = Items.Sum(x => x.TotalPrice);

TotalMessage = $"For a total price of {total} USD.";
TotalMessage = $"For a total price of USD {total}.";
UiMessage = "Our offer includes:";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public CountryStep(Conversation conversation, IReadOnlyList<Country> countries,
protected override IEnumerable<string> BotMessages(Conversation conversation)
{
// Assistant greeting, min order limit
yield return $"Hello, I am your {GetAssistantName(conversation)}.\nFor now, the MINIMUM ORDER VALUE is $1,000 USD and we only accept requests for LEGAL goods or services.";
yield return $"Hello, I am your {GetAssistantName(conversation)}.\nFor now, the MINIMUM ORDER VALUE is USD 1,000 and we only accept requests for LEGAL goods or services.";

// Ask for Location
yield return "If your order involves shipping, provide the destination country. For non-shipping orders, specify your nationality.";
Expand Down
2 changes: 1 addition & 1 deletion WalletWasabi.Fluent/Views/AddWallet/WelcomePageView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@

<StackPanel Grid.Column="0" Grid.Row="2">
<TextBlock Name="PlebsTextBlock" Text="Plebs Don't Pay" Classes="title2" />
<TextBlock Text="You won't pay the coordination fee for coins that are less than or equal to 0.01 BTC." Classes="text" />
<TextBlock Text="You won't pay the coordination fee for coins that are less than or equal to BTC 0.01." Classes="text" />
</StackPanel>

<StackPanel Grid.Column="1" Grid.Row="2">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
<Separator />
<PreviewItem Icon="{StaticResource btc_logo}"
Label="Input amount"
Content="{Binding InputAmountString, FallbackValue=0.0001 1234 BTC}" />
Content="{Binding InputAmountString, FallbackValue=BTC 0.0001 1234}" />
<Separator />
<PreviewItem Icon="{StaticResource btc_logo}"
Label="Output amount"
Content="{Binding OutputAmountString, FallbackValue=0.0001 1234 BTC}" />
Content="{Binding OutputAmountString, FallbackValue=BTC 0.0001 1234}" />
<Separator />
<PreviewItem Icon="{StaticResource arrow_down_right_circle_regular}"
Label="Input count"
Expand All @@ -32,7 +32,7 @@
<Separator />
<PreviewItem Icon="{StaticResource paper_cash_regular}"
Label="Fee"
Content="{Binding FeeString, FallbackValue=0.0001 1234 BTC}" />
Content="{Binding FeeString, FallbackValue=BTC 0.0001 1234}" />
</StackPanel>
</ContentArea>
</UserControl>
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
<Grid ColumnDefinitions="Auto,*,Auto" Margin="0 1 0 1">
<TextBlock Classes="monoSpaced" Grid.Column="0" Text="{Binding Quantity, StringFormat={}{0}x}" />
<TextBlock Classes="monoSpaced" Grid.Column="1" Margin="15 0 15 0" Text="{Binding Description}" />
<TextBlock Classes="monoSpaced" Grid.Column="2" TextWrapping="Wrap" Text="{Binding TotalPrice, StringFormat={}{0} USD}" />
<TextBlock Classes="monoSpaced" Grid.Column="2" TextWrapping="Wrap" Text="{Binding TotalPrice, StringFormat=USD {}{0}}" />
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
<StackPanel DataContext="{Binding Path=Amount, RelativeSource={RelativeSource TemplatedParent}}" Orientation="Horizontal" Spacing="4" HorizontalAlignment="Center">
<TextBlock TextAlignment="Center"
FontWeight="Bold"
Text="{Binding Btc, Converter={x:Static converters:MoneyConverters.ToFeeWithUnit}, FallbackValue='0.0000 0232 BTC'}"
Text="{Binding Btc, Converter={x:Static converters:MoneyConverters.ToFeeWithUnit}, FallbackValue='BTC 0.0000 0232'}"
Classes="h5" VerticalAlignment="Bottom" />
<TextBlock
FontWeight="Bold"
Text="{Binding Usd^, Converter={x:Static converters:MoneyConverters.ToUsdApprox}, FallbackValue='≈3.5 USD'}"
Text="{Binding Usd^, Converter={x:Static converters:MoneyConverters.ToUsdApprox}, FallbackValue='≈USD 3.5'}"
Opacity="0.6" VerticalAlignment="Bottom" Margin="0 0 0 3" Classes="h8" />
</StackPanel>
</ControlTemplate>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
<StackPanel DataContext="{Binding Path=Amount, RelativeSource={RelativeSource TemplatedParent}}" Orientation="Horizontal" Spacing="4" HorizontalAlignment="Center">
<TextBlock TextAlignment="Center"
FontWeight="Bold"
Text="{Binding Btc, Converter={x:Static converters:MoneyConverters.ToFeeWithUnit}, FallbackValue='0.0000 0232 BTC'}"
Text="{Binding Btc, Converter={x:Static converters:MoneyConverters.ToFeeWithUnit}, FallbackValue='BTC 0.0000 0232'}"
Classes="h5" VerticalAlignment="Bottom" />
<TextBlock
FontWeight="Bold"
Text="{Binding Usd^, Converter={x:Static converters:MoneyConverters.ToUsdApprox}, FallbackValue='≈3.5 USD'}"
Text="{Binding Usd^, Converter={x:Static converters:MoneyConverters.ToUsdApprox}, FallbackValue='≈USD 3.5'}"
Opacity="0.6" VerticalAlignment="Bottom" Margin="0 0 0 3" Classes="h8" />
</StackPanel>
</ControlTemplate>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,9 +283,9 @@ public void UndoTransaction_TransactionAmounts()
SmartTransaction tx3; // The transaction has 1 input and 1 output.

Money tx0CreditingAmount = Money.Coins(1.0m);
Money expectedTx1Amount = Money.Coins(-0.05m); // 0.05 BTC was spent (on fees).
Money expectedTx2Amount = Money.Coins(-0.15m); // 0.15 BTC was spent (on fees).
Money expectedTx3Amount = Money.Coins(-0.10m); // 0.10 BTC was spent (on fees).
Money expectedTx1Amount = Money.Coins(-0.05m); // BTC 0.05 was spent (on fees).
Money expectedTx2Amount = Money.Coins(-0.15m); // BTC 0.15 was spent (on fees).
Money expectedTx3Amount = Money.Coins(-0.10m); // BTC 0.10 was spent (on fees).

// Create and process transaction tx0.
{
Expand Down
4 changes: 2 additions & 2 deletions WalletWasabi/Blockchain/TransactionOutputs/SmartCoin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace WalletWasabi.Blockchain.TransactionOutputs;
/// <summary>
/// An UTXO that knows more.
/// </summary>
[DebuggerDisplay("{Amount}BTC {Confirmed} {HdPubKey.Label} OutPoint={Coin.Outpoint}")]
[DebuggerDisplay("BTC{Amount} {Confirmed} {HdPubKey.Label} OutPoint={Coin.Outpoint}")]
public class SmartCoin : NotifyPropertyChangedBase, IEquatable<SmartCoin>, IDestination, ISmartCoin
{
private Height _height;
Expand Down Expand Up @@ -158,7 +158,7 @@ public bool RefreshAndGetIsBanned()
/// </summary>
public bool IsAvailable() => SpenderTransaction is null && !SpentAccordingToBackend && !CoinJoinInProgress;

public override string ToString() => $"{TransactionId.ToString()[..7]}.. - {Index}, {ScriptPubKey.ToString()[..7]}.. - {Amount} BTC";
public override string ToString() => $"{TransactionId.ToString()[..7]}.. - {Index}, {ScriptPubKey.ToString()[..7]}.. - BTC {Amount}";

#region EqualityAndComparison

Expand Down
2 changes: 1 addition & 1 deletion WalletWasabi/Blockchain/Transactions/TransactionFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ public TransactionFactory(Network network, KeyManager keyManager, ICoinsView coi

var sign = !KeyManager.IsWatchOnly;

Logger.LogDebug($"Built tx: {totalOutgoingAmountNoFee.ToString(fplus: false, trimExcessZero: true)} BTC. Fee: {fee.Satoshi} sats. Vsize: {vSize} vBytes. Fee/Total ratio: {feePercentage:0.#}%. Tx hash: {tx.GetHash()}.");
Logger.LogDebug($"Built tx: BTC {totalOutgoingAmountNoFee.ToString(fplus: false, trimExcessZero: true)}. Fee: {fee.Satoshi} sats. Vsize: {vSize} vBytes. Fee/Total ratio: {feePercentage:0.#}%. Tx hash: {tx.GetHash()}.");
return new BuildTransactionResult(smartTransaction, psbt, sign, fee, feePercentage, hdPubKeysWithNewLabels);
}

Expand Down
2 changes: 1 addition & 1 deletion WalletWasabi/BuyAnything/BuyAnythingManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ private async Task CheckUpdateInOrderStatusAsync(ConversationUpdateTrack track,
// Remove sending this chat once the UI can handle the track.Invoice and save the track.
await SendSystemChatLinesAsync(track,
// $"Pay to: {orderCustomFields.Btcpay_PaymentLink}. The invoice expires in 30 minutes",
$"To finalize your order, please pay {invoice.Amount} BTC in 30 minutes, the latest by {(DateTimeOffset.Now + TimeSpan.FromMinutes(30)).ToLocalTime():HH:mm}.",
$"To finalize your order, please pay BTC {invoice.Amount} in 30 minutes, the latest by {(DateTimeOffset.Now + TimeSpan.FromMinutes(30)).ToLocalTime():HH:mm}.",
invoice,
order.UpdatedAt, ConversationStatus.InvoiceReceived,
cancel).ConfigureAwait(false);
Expand Down
2 changes: 1 addition & 1 deletion WalletWasabi/Exceptions/InsufficientBalanceException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace WalletWasabi.Exceptions;

public class InsufficientBalanceException : Exception
{
public InsufficientBalanceException(Money minimum, Money actual) : base($"Needed: {minimum.ToString(false, true)} BTC, got only: {actual.ToString(false, true)} BTC.")
public InsufficientBalanceException(Money minimum, Money actual) : base($"Needed: BTC {minimum.ToString(false, true)}, got only: BTC {actual.ToString(false, true)}.")
{
Minimum = minimum ?? Money.Zero;
Actual = actual ?? Money.Zero;
Expand Down
2 changes: 1 addition & 1 deletion WalletWasabi/Exceptions/TransactionSizeException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace WalletWasabi.Exceptions;
public class TransactionSizeException : Exception
{
public TransactionSizeException(Money target, Money maximumPossible)
: base($"Transaction size is over the limit, {target.ToString(false, true)} BTC was needed. Currently, the maximum amount you can spend is {maximumPossible.ToString(false, true)} BTC.")
: base($"Transaction size is over the limit, BTC {target.ToString(false, true)} was needed. Currently, the maximum amount you can spend is {maximumPossible.ToString(false, true)} BTC.")
{
Target = target ?? Money.Zero;
MaximumPossible = maximumPossible ?? Money.Zero;
Expand Down
2 changes: 1 addition & 1 deletion WalletWasabi/Helpers/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static class Constants
public const int P2shOutputVirtualSize = 32;

// https://en.bitcoin.it/wiki/Bitcoin
// There are a maximum of 2,099,999,997,690,000 Bitcoin elements (called satoshis), which are currently most commonly measured in units of 100,000,000 known as BTC. Stated another way, no more than 21 million BTC can ever be created.
// There are a maximum of 2,099,999,997,690,000 Bitcoin elements (called satoshis), which are currently most commonly measured in units of 100,000,000 known as BTC. Stated another way, no more than BTC 21 million can ever be created.
public const long MaximumNumberOfSatoshis = 2099999997690000;

public const decimal MaximumNumberOfBitcoins = 20999999.9769m;
Expand Down
8 changes: 4 additions & 4 deletions WalletWasabi/WabiSabi/Backend/Rounds/Arena.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ await foreach (var offendingAlices in CheckTxoSpendStatusAsync(round, cancel).Co

MaxSuggestedAmountProvider.StepMaxSuggested(round, false);
EndRound(round, EndRoundState.AbortedNotEnoughAlices);
round.LogInfo($"Not enough inputs ({round.InputCount}) in {nameof(Phase.InputRegistration)} phase. The minimum is ({round.Parameters.MinInputCountByRound}). {nameof(round.Parameters.MaxSuggestedAmount)} was '{round.Parameters.MaxSuggestedAmount}' BTC.");
round.LogInfo($"Not enough inputs ({round.InputCount}) in {nameof(Phase.InputRegistration)} phase. The minimum is ({round.Parameters.MinInputCountByRound}). {nameof(round.Parameters.MaxSuggestedAmount)} was BTC '{round.Parameters.MaxSuggestedAmount}'.");
}
else if (round.IsInputRegistrationEnded(round.Parameters.MaxInputCountByRound))
{
Expand Down Expand Up @@ -327,7 +327,7 @@ private async Task StepTransactionSigningPhaseAsync(CancellationToken cancellati
round.LogInfo("Trying to broadcast coinjoin.");
Coin[] spentCoins = round.CoinjoinState.Inputs.ToArray();
Money networkFee = coinjoin.GetFee(spentCoins);
round.LogInfo($"Network Fee: {networkFee.ToString(false, false)} BTC.");
round.LogInfo($"Network Fee: BTC {networkFee.ToString(false, false)}.");
uint256 roundId = round.Id;
FeeRate feeRate = coinjoin.GetFeeRate(spentCoins);
round.LogInfo($"Network Fee Rate: {feeRate.SatoshiPerByte} sat/vByte.");
Expand Down Expand Up @@ -571,9 +571,9 @@ private async Task CreateRoundsAsync(CancellationToken cancellationToken)

if (foundLargeRound is null)
{
largeRound.LogInfo($"Mined round with parameters: {nameof(largeRound.Parameters.MaxSuggestedAmount)}:'{largeRound.Parameters.MaxSuggestedAmount}' BTC.");
largeRound.LogInfo($"Mined round with parameters: BTC {nameof(largeRound.Parameters.MaxSuggestedAmount)}:'{largeRound.Parameters.MaxSuggestedAmount}'.");
}
smallRound.LogInfo($"Mined round with parameters: {nameof(smallRound.Parameters.MaxSuggestedAmount)}:'{smallRound.Parameters.MaxSuggestedAmount}' BTC.");
smallRound.LogInfo($"Mined round with parameters: BTC {nameof(smallRound.Parameters.MaxSuggestedAmount)}:'{smallRound.Parameters.MaxSuggestedAmount}'.");

// If it can't create the large round, then don't abort.
EndRound(round, EndRoundState.AbortedLoadBalancing);
Expand Down
4 changes: 2 additions & 2 deletions WalletWasabi/WabiSabi/Client/Batching/PaymentBatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public Guid AddPayment(IDestination destination, Money amount)
{
_payments.Add(payment);
}
Logger.LogInfo($"Payment {payment.Id} for {payment.Amount} BTC to {payment.Destination.ScriptPubKey}.");
Logger.LogInfo($"Payment {payment.Id} for BTC {payment.Amount} to {payment.Destination.ScriptPubKey}.");
return payment.Id;
}

Expand Down Expand Up @@ -130,7 +130,7 @@ private static void LogPaymentSetDetails(PaymentSet paymentSet)
Logger.LogInfo($"Best payment set contains {paymentSet.PaymentCount} payments.");
foreach (var payment in paymentSet.Payments)
{
Logger.LogInfo($"Id {payment.Id} to {payment.Destination.ScriptPubKey} {payment.Amount.ToDecimal(MoneyUnit.BTC)} BTC.");
Logger.LogInfo($"Id {payment.Id} to {payment.Destination.ScriptPubKey} BTC {payment.Amount.ToDecimal(MoneyUnit.BTC)}.");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public async Task<CoinJoinResult> StartCoinJoinAsync(Func<Task<IEnumerable<Smart

if (coins.IsEmpty)
{
throw new CoinJoinClientException(CoinjoinError.NoCoinsEligibleToMix, $"No coin was selected from '{coinCandidates.Count()}' number of coins. Probably it was not economical, total amount of coins were: {Money.Satoshis(coinCandidates.Sum(c => c.Amount))} BTC.");
throw new CoinJoinClientException(CoinjoinError.NoCoinsEligibleToMix, $"No coin was selected from '{coinCandidates.Count()}' number of coins. Probably it was not economical, total amount of coins were: BTC {Money.Satoshis(coinCandidates.Sum(c => c.Amount))}.");
}

// Keep going to blame round until there's none, so CJs won't be DDoS-ed.
Expand Down
Loading

0 comments on commit 5166923

Please sign in to comment.