Skip to content

Commit ee03a4d

Browse files
committed
wip
1 parent 03f4fe3 commit ee03a4d

File tree

15 files changed

+77
-64
lines changed

15 files changed

+77
-64
lines changed
-5.31 KB
Loading
-16.7 KB
Loading
-4.92 KB
Loading
-285 Bytes
Loading
-723 Bytes
Loading
0 Bytes
Binary file not shown.

ghcjs/lightning-verifier/default.nix

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,17 +195,17 @@ in rec {
195195
text = ''
196196
(
197197
${app-release-stable}/bin/app-release-stable
198-
if [ -d "${repo}/../../pub/functora-hakyll/apps/currency-converter/${vsn}" ]
198+
if [ -d "${repo}/../../pub/functora-hakyll/apps/${label}/${vsn}" ]
199199
then
200200
echo "Version ${vsn} does already exist!"
201201
exit 1
202202
else
203-
mkdir -p ${repo}/../../pub/functora-hakyll/apps/currency-converter/${vsn}
203+
mkdir -p ${repo}/../../pub/functora-hakyll/apps/${label}/${vsn}
204204
fi
205205
${safeCopy} ${repo}/dist/${vsn}/* \
206-
${repo}/../../pub/functora-hakyll/apps/currency-converter/${vsn}
206+
${repo}/../../pub/functora-hakyll/apps/${label}/${vsn}
207207
${forceCopy} ${repo}/dist/index.html \
208-
${repo}/../../pub/functora-hakyll/apps/currency-converter
208+
${repo}/../../pub/functora-hakyll/apps/${label}
209209
)
210210
'';
211211
};

ghcjs/lightning-verifier/src/App/Types.hs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ baseUri =
233233
"http://localhost:8080"
234234
#else
235235
baseUri =
236-
"https://functora.github.io/apps/currency-converter/" <> vsn <> "/index.html"
236+
"https://functora.github.io/apps/lightning-verifier/" <> vsn <> "/index.html"
237237
#endif
238238

239239
setScreenPure :: Screen -> Model -> JSM Model
@@ -266,7 +266,7 @@ btc :: CurrencyInfo
266266
btc = CurrencyInfo (CurrencyCode "btc") mempty
267267

268268
googlePlayLink :: Prelude.Text
269-
googlePlayLink = "https://play.google.com/apps/testing/com.functora.currency_converter"
269+
googlePlayLink = "https://play.google.com/apps/testing/com.functora.lightning_verifier"
270270

271271
testGroupLink :: Prelude.Text
272272
testGroupLink = "https://groups.google.com/g/currency-converter"
@@ -276,12 +276,12 @@ functoraLink = "https://functora.github.io/"
276276

277277
sourceLink :: Prelude.Text
278278
sourceLink =
279-
"https://github.com/functora/functora.github.io/tree/master/ghcjs/currency-converter"
279+
"https://github.com/functora/functora.github.io/tree/master/ghcjs/lightning-verifier"
280280

281281
apkLink :: Prelude.Text
282282
apkLink =
283-
"https://github.com/functora/functora.github.io/releases/download/currency-converter-v"
283+
"https://github.com/functora/functora.github.io/releases/download/lightning-verifier-v"
284284
<> fromMisoString vsn
285-
<> "/currency-converter-v"
285+
<> "/lightning-verifier-v"
286286
<> fromMisoString vsn
287287
<> ".apk"

ghcjs/lightning-verifier/src/App/Widgets/Bolt11.hs

Lines changed: 56 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,18 @@ bolt11 st =
2525
(\bsR -> if bsR == mempty then mempty else preimageWidget rawR bsR)
2626
r
2727
where
28+
rawLn :: MisoString
2829
rawLn = st ^. #modelState . #stDoc . #stDocLnInvoice . #fieldOutput
30+
rawR :: MisoString
2931
rawR = st ^. #modelState . #stDoc . #stDocLnPreimage . #fieldOutput
30-
ln = first (mappend "Bad invoice - " . inspect) $ B11.decodeBolt11 rawLn
32+
ln :: Either MisoString B11.Bolt11
33+
ln =
34+
first (mappend "Bad invoice - " . from @Prelude.String @MisoString)
35+
. B11.decodeBolt11
36+
$ from @MisoString @Prelude.Text rawLn
37+
rh :: Either MisoString ByteString
3138
rh = ln >>= parsePreimageHash
39+
r :: Either MisoString ByteString
3240
r = parsePreimage rawR
3341

3442
parserWidget :: MisoString -> Either MisoString a -> [View Action]
@@ -49,34 +57,54 @@ invoiceWidget :: B11.Bolt11 -> [View Action]
4957
invoiceWidget ln =
5058
Header.headerViewer "Invoice Details"
5159
<> pairs
52-
( [ simple "Network" . B11.bolt11Currency $ B11.bolt11HRP ln,
53-
simple "Amount" . B11.bolt11Amount $ B11.bolt11HRP ln,
54-
simple "Timestamp" $ B11.bolt11Timestamp ln
60+
( [ pair "Network"
61+
$ case B11.bolt11Currency $ B11.bolt11HRP ln of
62+
B11.Bitcoin -> "Bitcoin Mainnet"
63+
B11.BitcoinTestnet -> "Bitcoin Testnet"
64+
B11.BitcoinRegtest -> "Bitcoin Regtest",
65+
pair "Amount"
66+
. maybe "0" defShow
67+
. B11.bolt11Amount
68+
$ B11.bolt11HRP ln,
69+
pair "Timestamp"
70+
. inspect
71+
$ B11.bolt11Timestamp ln
5572
]
56-
<> fmap (simple "Tag") (B11.bolt11Tags ln)
57-
<> [ simple "Signature" $ B11.bolt11Signature ln
73+
<> ( B11.bolt11Tags ln
74+
>>= invoiceTagWidget
75+
)
76+
<> [ pair "Signature"
77+
. defShow
78+
$ B11.bolt11Signature ln
5879
]
5980
)
81+
82+
invoiceTagWidget :: B11.Tag -> [FieldPair DynamicField Identity]
83+
invoiceTagWidget = \case
84+
B11.PaymentHash x -> simple "Preimage Hash" x
85+
B11.PaymentSecret x -> simple "Payment Secret" x
86+
B11.Description x -> pure . pair "Description" $ inspect x
87+
B11.PayeePubkey x -> simple "Payee Pubkey" x
88+
B11.DescriptionHash x -> simple "Description Hash" x
89+
B11.Expiry x -> simple "Expiry" x
90+
B11.MinFinalCltvExpiry x -> simple "Min Final CLTV Expiry" x
91+
B11.OnchainFallback x -> simple "Onchain Fallback" x
92+
B11.ExtraRouteInfo -> mempty
93+
B11.FeatureBits x -> simple "Feature Bits" x
6094
where
61-
simple :: (Show a) => MisoString -> a -> FieldPair DynamicField Identity
95+
simple :: (Show a) => MisoString -> a -> [FieldPair DynamicField Identity]
6296
simple x =
63-
newFieldPairId x
64-
. DynamicFieldText
65-
. from @Prelude.String @MisoString
66-
. Prelude.show
97+
pure
98+
. pair x
99+
. defShow
67100

68101
preimageWidget :: MisoString -> ByteString -> [View Action]
69102
preimageWidget rawR r =
70103
Header.headerViewer "Preimage Details"
71104
<> pairs
72-
[ simple "Preimage" rawR,
73-
simple "Preimage Hash" . inspect @ByteString $ sha256Hash r
105+
[ pair "Preimage" rawR,
106+
pair "Preimage Hash" . inspect @ByteString $ sha256Hash r
74107
]
75-
where
76-
simple :: MisoString -> MisoString -> FieldPair DynamicField Identity
77-
simple x =
78-
newFieldPairId x
79-
. DynamicFieldText
80108

81109
parsePreimage :: MisoString -> Either MisoString ByteString
82110
parsePreimage rawR =
@@ -93,6 +121,11 @@ parsePreimageHash ln =
93121
Just (B11.PaymentHash (B11.Hex rh)) -> Right rh
94122
_ -> Left "Bad invoice - no preimage hash"
95123

124+
pair :: MisoString -> MisoString -> FieldPair DynamicField Identity
125+
pair x =
126+
newFieldPairId x
127+
. DynamicFieldText
128+
96129
pairs :: [FieldPair DynamicField f] -> [View Action]
97130
pairs xs =
98131
FieldPairs.fieldPairsViewer
@@ -105,6 +138,11 @@ pairs xs =
105138
pure next
106139
}
107140

141+
defShow :: (Show a) => a -> MisoString
142+
defShow =
143+
from @Prelude.String @MisoString
144+
. Prelude.show
145+
108146
success :: MisoString -> [View Action]
109147
success msg =
110148
css "app-success"

ghcjs/lightning-verifier/src/App/Widgets/Menu.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ menu st =
5858
. #stScreen
5959
.~ Converter
6060
]
61-
[ text "Converter"
61+
[ text "LN Verifier"
6262
]
6363
],
6464
TopAppBar.section
@@ -93,7 +93,7 @@ menu st =
9393
$ JS.global
9494
^. JS.js1
9595
("printCurrentPage" :: MisoString)
96-
("currency-converter" :: MisoString)
96+
("lightning-verifier" :: MisoString)
9797
pure next
9898
)
9999
& IconButton.setAttributes
@@ -133,7 +133,7 @@ menu st =
133133
Nothing
134134
[ Grid.grid
135135
mempty
136-
$ [ Grid.smallCell
136+
$ [ Grid.mediumCell
137137
$ Button.raised
138138
( Button.config
139139
& Button.setOnClick
@@ -145,7 +145,7 @@ menu st =
145145
& Button.setIcon
146146
( Just
147147
$ if isQrCode sc
148-
then "currency_exchange"
148+
then "bolt"
149149
else "qr_code_2"
150150
)
151151
& Button.setAttributes
@@ -154,9 +154,9 @@ menu st =
154154
]
155155
)
156156
$ if isQrCode sc
157-
then "Rates"
157+
then "LN Verifier"
158158
else "QR",
159-
Grid.smallCell
159+
Grid.mediumCell
160160
$ Button.raised
161161
( Button.config
162162
& Button.setDisabled disabled

0 commit comments

Comments
 (0)