Skip to content

Commit

Permalink
prepare for the great msat purge.
Browse files Browse the repository at this point in the history
  • Loading branch information
fiatjaf committed Jun 8, 2022
1 parent 179776b commit 299b77c
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/main/scala/CLN.scala
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ class CLN extends NodeInterface {
.Obj(
"first_hop" -> ujson.Obj(
"id" -> targetPeerId.toHex,
"amount_msat" -> s"${amount.toLong}msat",
"amount_msat" -> amount.toLong,
"delay" -> cltvExpiryDelta.toInt
),
"onion" -> onion.toHex,
Expand All @@ -254,7 +254,7 @@ class CLN extends NodeInterface {
ujson.Obj(
"first_hop" -> ujson.Obj(
"id" -> targetPeerId.toHex,
"amount_msat" -> s"${amount.toLong}msat",
"amount_msat" -> amount.toLong,
"delay" -> cltvExpiryDelta.toInt
),
"onion" -> onion.toHex,
Expand Down Expand Up @@ -382,12 +382,18 @@ class CLN extends NodeInterface {
val hash = ByteVector32.fromValidHex(htlc("payment_hash").str)
val sourceChannel = ShortChannelId(htlc("short_channel_id").str)
val sourceAmount = MilliSatoshi(
Integer.getInteger(htlc("amount").str.takeWhile(_.isDigit)).toLong
if htlc.obj.contains("amount_msat") then
htlc("amount_msat").num.toLong
else htlc("amount").str.takeWhile(_.isDigit).toLong
)
val sourceId = htlc("id").num.toInt.toULong
val targetChannel = ShortChannelId(onion("short_channel_id").str)
val targetAmount =
MilliSatoshi(onion("forward_amount").str.dropRight(4).toInt)
MilliSatoshi(
if onion.obj.contains("forward_msat") then
onion("forward_msat").num.toLong
else onion("forward_amount").str.takeWhile(_.isDigit).toLong
)
val cltvExpiry = CltvExpiry(
BlockHeight(onion("outgoing_cltv_value").num.toLong)
)
Expand Down

0 comments on commit 299b77c

Please sign in to comment.