@@ -96,8 +96,12 @@ class AmountInputViewModel: ObservableObject {
9696 amountSats = newAmountSats
9797 displayText = formatDisplayTextFromAmount ( newAmountSats, currency: currency)
9898 // Update raw input text based on the formatted display
99+ // Remove formatting separators (spaces for modern Bitcoin, commas for fiat)
99100 if currency. primaryDisplay == . fiat {
100101 rawInputText = displayText. replacingOccurrences ( of: " , " , with: " " )
102+ } else if currency. displayUnit == . modern {
103+ // Modern Bitcoin uses spaces as grouping separators
104+ rawInputText = displayText. replacingOccurrences ( of: " " , with: " " )
101105 } else {
102106 rawInputText = displayText
103107 }
@@ -115,8 +119,12 @@ class AmountInputViewModel: ObservableObject {
115119 if amountSats > 0 {
116120 displayText = formatDisplayTextFromAmount ( amountSats, currency: currency)
117121 // Update raw input text based on the formatted display
122+ // Remove formatting separators (spaces for modern Bitcoin, commas for fiat)
118123 if currency. primaryDisplay == . fiat {
119124 rawInputText = displayText. replacingOccurrences ( of: " , " , with: " " )
125+ } else if currency. displayUnit == . modern {
126+ // Modern Bitcoin uses spaces as grouping separators
127+ rawInputText = displayText. replacingOccurrences ( of: " " , with: " " )
120128 } else {
121129 rawInputText = displayText
122130 }
@@ -135,8 +143,14 @@ class AmountInputViewModel: ObservableObject {
135143 // First convert fiat to sats, then format for Bitcoin display
136144 let cleanFiat = currentRawInput. replacingOccurrences ( of: " , " , with: " " )
137145 if let fiatValue = Double ( cleanFiat) , let sats = currency. convert ( fiatAmount: fiatValue) {
138- rawInputText = formatBitcoinFromSats ( sats, isModern: currency. displayUnit == . modern)
139- displayText = rawInputText
146+ let formatted = formatBitcoinFromSats ( sats, isModern: currency. displayUnit == . modern)
147+ displayText = formatted
148+ // Remove spaces from rawInputText for modern Bitcoin
149+ if currency. displayUnit == . modern {
150+ rawInputText = formatted. replacingOccurrences ( of: " " , with: " " )
151+ } else {
152+ rawInputText = formatted
153+ }
140154 }
141155 }
142156 }
0 commit comments