@@ -10,7 +10,6 @@ import qualified Bitcoin.Address as Btc
10
10
import qualified Data.Aeson as A
11
11
import qualified Data.ByteString.Base16 as B16
12
12
import qualified Data.ByteString.Lazy as BL
13
- import qualified Data.Text.Encoding as T
14
13
import qualified Functora.Bolt11 as B11
15
14
import Functora.Miso.Prelude
16
15
import qualified Functora.Miso.Widgets.FieldPairs as FieldPairs
@@ -123,9 +122,9 @@ makeBolt11Viewer st =
123
122
rawR = st ^. # stDocLnPreimage . # fieldOutput
124
123
ln :: Either MisoString B11. Bolt11
125
124
ln =
126
- first (mappend " Bad invoice - " . from @ Prelude. String @ MisoString )
125
+ first (mappend " Bad invoice - " . toMisoString @ Prelude. String )
127
126
. B11. decodeBolt11
128
- $ from @ MisoString @ Prelude. Text rawLn
127
+ $ fromMisoString @ Prelude. Text rawLn
129
128
rh :: Either MisoString ByteString
130
129
rh = ln >>= parsePreimageHash
131
130
r :: Either MisoString ByteString
@@ -149,12 +148,13 @@ plain =
149
148
150
149
parsePreimage :: MisoString -> Either MisoString ByteString
151
150
parsePreimage rawR =
152
- case B16. decode . T. encodeUtf8 $ from @ MisoString @ Prelude. Text rawR of
151
+ case B16. decode $ fromMisoString @ ByteString rawR of
153
152
(r, " " ) -> Right r
154
153
(_, e) ->
155
154
Left
155
+ . toMisoString @ Prelude. String
156
156
$ " Bad preimage - non hex leftover "
157
- <> from @ Prelude. String @ MisoString ( Prelude. show e)
157
+ <> Prelude. show e
158
158
159
159
parsePreimageHash :: B11. Bolt11 -> Either MisoString ByteString
160
160
parsePreimageHash ln =
@@ -180,7 +180,11 @@ invoiceFields ln =
180
180
B11. BitcoinRegtest -> " Bitcoin Regtest"
181
181
B11. BitcoinSignet -> " Bitcoin Signet" ,
182
182
pair " Amount"
183
- . maybe " 0" B11. inspectBolt11HrpAmt
183
+ . maybe
184
+ " 0"
185
+ ( toMisoString @ Prelude. String
186
+ . B11. inspectBolt11HrpAmt
187
+ )
184
188
. B11. bolt11HrpAmt
185
189
$ B11. bolt11Hrp ln,
186
190
pair " Created At"
@@ -191,6 +195,7 @@ invoiceFields ln =
191
195
>>= invoiceFieldsTag ln
192
196
)
193
197
<> [ pair " Signature"
198
+ . toMisoString @ Prelude. String
194
199
. B11. inspectHex
195
200
$ B11. bolt11SigVal sig,
196
201
pair " Pubkey Recovery Flag"
@@ -212,20 +217,21 @@ invoiceFieldsTag ln = \case
212
217
pure . pair " Expires At" . inspectTimestamp $ x + B11. bolt11Timestamp ln
213
218
B11. MinFinalCltvExpiry x ->
214
219
pure . pair " Min Final CLTV Expiry" $ inspect x <> " Blocks"
215
- B11. OnchainFallback x -> do
216
- --
217
- -- TODO : do not ignore failure?
218
- --
219
- txt <- either (const mempty ) pure . decodeUtf8' $ Btc. renderAddress x
220
- pure $ pair " Onchain Fallback" $ from @ Prelude. Text @ MisoString txt
220
+ B11. OnchainFallback x ->
221
+ pure
222
+ . pair " Onchain Fallback"
223
+ . toMisoString @ ByteString
224
+ $ Btc. renderAddress x
221
225
B11. ExtraRouteInfo x ->
222
226
pure
223
227
. pair " Extra Routing Info"
224
- . either (const mempty ) (from @ Prelude. Text @ MisoString )
225
- . decodeUtf8'
226
- . from @ BL. ByteString @ ByteString
228
+ . toMisoString @ BL. ByteString
227
229
$ A. encode x
228
- B11. Features x -> pure . pair " Feature Bits" $ B11. inspectFeatures x
230
+ B11. Features x ->
231
+ pure
232
+ . pair " Feature Bits"
233
+ . toMisoString @ Prelude. Text
234
+ $ B11. inspectFeatures x
229
235
B11. UnknownTag {} -> mempty
230
236
B11. UnparsedTag {} -> mempty
231
237
where
@@ -239,6 +245,7 @@ invoiceFieldsTag ln = \case
239
245
hex x =
240
246
pure
241
247
. pair x
248
+ . toMisoString @ Prelude. String
242
249
. B11. inspectHex
243
250
244
251
preimageFields :: MisoString -> ByteString -> [FieldPair DynamicField Identity ]
0 commit comments