Add PaymentSecret, ShortChannelId, and MilliSatoshis Db Mappers (#4396)

This commit is contained in:
benthecarman 2022-06-15 07:32:53 -05:00 committed by GitHub
parent c2f0762028
commit 24a9e6a5e6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -16,7 +16,9 @@ import org.bitcoins.core.protocol.dlc.models.{
DLCState,
SingleOracleInfo
}
import org.bitcoins.core.protocol.ln.LnInvoice
import org.bitcoins.core.protocol.ln.channel.ShortChannelId
import org.bitcoins.core.protocol.ln.currency.MilliSatoshis
import org.bitcoins.core.protocol.ln._
import org.bitcoins.core.protocol.ln.node.NodeId
import org.bitcoins.core.protocol.script.{ScriptPubKey, ScriptWitness}
import org.bitcoins.core.protocol.tlv._
@ -519,4 +521,13 @@ class DbCommonsColumnMappers(val profile: JdbcProfile) {
MappedColumnType.base[InetSocketAddress, String](toString, fromString)
}
implicit val PaymentSecretMapper: BaseColumnType[PaymentSecret] =
MappedColumnType.base[PaymentSecret, String](_.hex, PaymentSecret.fromHex)
implicit val ShortChannelIdMapper: BaseColumnType[ShortChannelId] =
MappedColumnType.base[ShortChannelId, Long](_.u64.toLong,
l => ShortChannelId(UInt64(l)))
implicit val MilliSatoshisMapper: BaseColumnType[MilliSatoshis] =
MappedColumnType.base[MilliSatoshis, Long](_.toLong, MilliSatoshis.apply(_))
}