1
0
Fork 0
mirror of https://github.com/ACINQ/eclair.git synced 2025-02-23 14:40:34 +01:00

Proper json serializer for BlockHeight (#2340)

It currently serializes to `{}`.
This commit is contained in:
Pierre-Marie Padiou 2022-07-01 17:46:54 +02:00 committed by GitHub
parent 276340d1b3
commit 31964620bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 134 additions and 1 deletions

View file

@ -36,7 +36,7 @@ import fr.acinq.eclair.transactions.DirectedHtlc
import fr.acinq.eclair.transactions.Transactions._
import fr.acinq.eclair.wire.protocol.MessageOnionCodecs.blindedRouteCodec
import fr.acinq.eclair.wire.protocol._
import fr.acinq.eclair.{CltvExpiry, CltvExpiryDelta, Feature, FeatureSupport, Alias, MilliSatoshi, ShortChannelId, TimestampMilli, TimestampSecond, UInt64, UnknownFeature, channel}
import fr.acinq.eclair.{Alias, BlockHeight, CltvExpiry, CltvExpiryDelta, Feature, FeatureSupport, MilliSatoshi, ShortChannelId, TimestampMilli, TimestampSecond, UInt64, UnknownFeature, channel}
import org.json4s
import org.json4s.JsonAST._
import org.json4s.jackson.Serialization
@ -151,6 +151,10 @@ object CltvExpiryDeltaSerializer extends MinimalSerializer({
case x: CltvExpiryDelta => JInt(x.toInt)
})
object BlockHeightSerializer extends MinimalSerializer({
case x: BlockHeight => JInt(x.toInt)
})
object FeeratePerKwSerializer extends MinimalSerializer({
case x: FeeratePerKw => JLong(x.toLong)
})
@ -539,6 +543,7 @@ object JsonSerializers {
MilliSatoshiSerializer +
CltvExpirySerializer +
CltvExpiryDeltaSerializer +
BlockHeightSerializer +
FeeratePerKwSerializer +
ShortChannelIdSerializer +
ChannelIdentifierSerializer +

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,123 @@
{
"type" : "DATA_WAIT_FOR_FUNDING_CONFIRMED",
"commitments" : {
"channelId" : "e917adc681383fe00f779c6144a1bd91135ba2c9862ad1bc5aa8a14d37bae3f4",
"channelConfig" : [ "funding_pubkey_based_channel_keypath" ],
"channelFeatures" : [ ],
"localParams" : {
"nodeId" : "02aaaa00ce2f18a967dc4f25f414e671ba6585f8ef0b8c5fb812c21064f55a2eaa",
"fundingKeyPath" : {
"path" : [ 4092535092, 4227137620, 3959690417, 2298849496, 2106263857, 1090614243, 1495530077, 1280982866, 2147483649 ]
},
"dustLimit" : 1100,
"maxHtlcValueInFlightMsat" : 500000000,
"requestedChannelReserve_opt" : 10000,
"htlcMinimum" : 0,
"toSelfDelay" : 144,
"maxAcceptedHtlcs" : 100,
"isInitiator" : true,
"defaultFinalScriptPubKey" : "0014fec406ef7a0258cb503fe1f1803787d971eeb4d1",
"initFeatures" : {
"activated" : {
"payment_secret" : "mandatory",
"gossip_queries_ex" : "optional",
"option_data_loss_protect" : "optional",
"var_onion_optin" : "mandatory",
"basic_mpp" : "optional",
"gossip_queries" : "optional"
},
"unknown" : [ 50001 ]
}
},
"remoteParams" : {
"nodeId" : "02bbbb671d15145722fb8c28d732cddb249bcc6652ed2b297ff1f77a18371b1e63",
"dustLimit" : 1000,
"maxHtlcValueInFlightMsat" : 18446744073709551615,
"requestedChannelReserve_opt" : 20000,
"htlcMinimum" : 1000,
"toSelfDelay" : 144,
"maxAcceptedHtlcs" : 30,
"fundingPubKey" : "02e3048a4918587b33fb380e3061b7ac38ef4038551c0f098850d43e45ab1cb283",
"revocationBasepoint" : "02f7c3bf47cdc640304eda4c761a26dfebfee561de15ba106f3d9982d3ef3fbe10",
"paymentBasepoint" : "02be361b7bf1bdfb283cff3f83bf16f6f8fb67d3f480b541e76518939f667ab834",
"delayedPaymentBasepoint" : "03fcaec5443dd423f160c9b77a48b2585b186f2d850147f57210d3f8a8c8d754a7",
"htlcBasepoint" : "021eecb7915d4a3f2b391b9b1fbccbaad2006a1e67a0a03aa041721a817e9a0874",
"initFeatures" : {
"activated" : {
"payment_secret" : "mandatory",
"gossip_queries_ex" : "optional",
"option_data_loss_protect" : "optional",
"var_onion_optin" : "mandatory",
"basic_mpp" : "optional",
"gossip_queries" : "optional"
},
"unknown" : [ ]
}
},
"channelFlags" : {
"announceChannel" : false
},
"localCommit" : {
"index" : 0,
"spec" : {
"htlcs" : [ ],
"commitTxFeerate" : 10000,
"toLocal" : 800000000,
"toRemote" : 200000000
},
"commitTxAndRemoteSig" : {
"commitTx" : {
"txid" : "c6fe6bc0a5a9c149a03a907d2351714aa27fc98a485e981343cea08a1904ee26",
"tx" : "0200000001e917adc681383fe00f779c6144a1bd91135ba2c9862ad1bc5aa8a14d37bae3f40000000000fd11418002400d0300000000001600142276cff9d96f4696d6e504568db62088428706e0b8180c0000000000220020ad1b593fc0780225407ba65c612b974b4b66610e129f21064cb8ada0ffe4c8d2b7262120"
},
"remoteSig" : "1ea9cffd2af82f6c14251bd59ffa3e876178c7b263f16d12790c33fc093eaed053dd9e0d49f79558aeb3c2fe7fe84f95a91eecbea2679fb65916ad9632df07b4"
},
"htlcTxsAndRemoteSigs" : [ ]
},
"remoteCommit" : {
"index" : 0,
"spec" : {
"htlcs" : [ ],
"commitTxFeerate" : 10000,
"toLocal" : 200000000,
"toRemote" : 800000000
},
"txid" : "10e4205393672b61bbde4261441a2cf8d08ae50fdb813df8efaac6c6090ef290",
"remotePerCommitmentPoint" : "032a992c123095216f7937a8b0baf442211eeb57942d586854a61a0dc6b01ca6ee"
},
"localChanges" : {
"proposed" : [ ],
"signed" : [ ],
"acked" : [ ]
},
"remoteChanges" : {
"proposed" : [ ],
"acked" : [ ],
"signed" : [ ]
},
"localNextHtlcId" : 0,
"remoteNextHtlcId" : 0,
"originChannels" : { },
"remoteNextCommitInfo" : "030af74aa1e98668a504d50fe6f664aff3fbdb5c8681f0667c34cdb80024fb950f",
"commitInput" : {
"outPoint" : "f4e3ba374da1a85abcd12a86c9a25b1391bda144619c770fe03f3881c6ad17e9:0",
"amountSatoshis" : 1000000
},
"remotePerCommitmentSecrets" : null
},
"fundingTx" : {
"txid" : "f4e3ba374da1a85abcd12a86c9a25b1391bda144619c770fe03f3881c6ad17e9",
"tx" : "020000000101010101010101010101010101010101010101010101010101010101010101012a00000000ffffffff0140420f0000000000220020a5fb8f636bb73759b4c7e5edd55fd8e9e8e5467c7079709cd22fb519c79ab8b300000000"
},
"waitingSince" : 400000,
"lastSent" : {
"temporaryChannelId" : "0000000000000000000000000000000000000000000000000000000000000000",
"fundingTxid" : "e917adc681383fe00f779c6144a1bd91135ba2c9862ad1bc5aa8a14d37bae3f4",
"fundingOutputIndex" : 0,
"signature" : "bd55d8660f54a1be6e123e2ed9cd6669d90b830d99dc6f9addd9ae65c447ea6b657e2fe39841f66c1d6a2fc80ad59e6f3d9bfaf177f4e95a579f0683bf3e9790",
"tlvStream" : {
"records" : [ ],
"unknown" : [ ]
}
}
}

View file

@ -320,6 +320,10 @@ class JsonSerializersSpec extends AnyFunSuite with Matchers {
}
}
test("serialize block height") {
JsonSerializers.serialization.write(BlockHeight(123456))(JsonSerializers.formats) shouldBe "123456"
}
/** utility method that strips line breaks in the expected json */
def assertJsonEquals(actual: String, expected: String) = {
val cleanedExpected = expected