mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-03-26 21:42:48 +01:00
Make all uint64 types from lnd a UInt64 (#4332)
* Make all uint64 types from lnd a UInt64 * Make all uint32 types from lnd a UInt32
This commit is contained in:
parent
b980c432fd
commit
6845caf778
16 changed files with 192 additions and 63 deletions
|
@ -1,6 +1,7 @@
|
|||
package org.bitcoins.commons.jsonmodels.lnd
|
||||
|
||||
import org.bitcoins.core.currency.CurrencyUnit
|
||||
import org.bitcoins.core.number.UInt64
|
||||
import org.bitcoins.core.protocol.BitcoinAddress
|
||||
import org.bitcoins.core.protocol.ln.LnInvoice
|
||||
import org.bitcoins.core.protocol.ln.LnTag.PaymentHashTag
|
||||
|
@ -14,7 +15,7 @@ sealed abstract class LndModel
|
|||
case class AddInvoiceResult(
|
||||
rHash: PaymentHashTag,
|
||||
invoice: LnInvoice,
|
||||
addIndex: Long,
|
||||
addIndex: UInt64,
|
||||
paymentAddr: ByteVector)
|
||||
extends LndModel
|
||||
|
||||
|
|
|
@ -393,6 +393,10 @@ object UInt32
|
|||
UInt32(bytes.toLong(signed = false, ordering = ByteOrdering.BigEndian))
|
||||
}
|
||||
|
||||
def apply(int: Int): UInt32 = {
|
||||
apply(int.toLong)
|
||||
}
|
||||
|
||||
def apply(long: Long): UInt32 = {
|
||||
checkCached(long)
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.bitcoins.lnd.rpc
|
|||
|
||||
import lnrpc.Invoice.InvoiceState
|
||||
import org.bitcoins.core.currency.Satoshis
|
||||
import org.bitcoins.core.number.UInt32
|
||||
import org.bitcoins.core.protocol.ln.LnInvoice
|
||||
import org.bitcoins.core.protocol.ln.currency._
|
||||
import org.bitcoins.core.protocol.script.P2WPKHWitnessSPKV0
|
||||
|
@ -14,7 +15,7 @@ class LndRemoteClientTest extends RemoteLndFixture {
|
|||
it must "get info from lnd" in { lnd =>
|
||||
for {
|
||||
info <- lnd.getInfo
|
||||
} yield assert(info.blockHeight >= 0)
|
||||
} yield assert(info.blockHeight >= UInt32.zero)
|
||||
}
|
||||
|
||||
it must "create an invoice using sats" in { lnd =>
|
||||
|
|
|
@ -31,8 +31,8 @@ class LndRpcClientPairTest extends DualLndFixture {
|
|||
infoB <- lndB.getInfo
|
||||
} yield {
|
||||
assert(infoA.identityPubkey != infoB.identityPubkey)
|
||||
assert(infoA.blockHeight >= 0)
|
||||
assert(infoB.blockHeight >= 0)
|
||||
assert(infoA.blockHeight >= UInt32.zero)
|
||||
assert(infoB.blockHeight >= UInt32.zero)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.bitcoins.lnd.rpc
|
|||
|
||||
import lnrpc.Invoice.InvoiceState
|
||||
import org.bitcoins.core.currency.Satoshis
|
||||
import org.bitcoins.core.number.UInt32
|
||||
import org.bitcoins.core.protocol.ln.LnInvoice
|
||||
import org.bitcoins.core.protocol.ln.currency._
|
||||
import org.bitcoins.core.protocol.script.P2WPKHWitnessSPKV0
|
||||
|
@ -15,7 +16,7 @@ class LndRpcClientTest extends LndFixture {
|
|||
it must "get info from lnd" in { lnd =>
|
||||
for {
|
||||
info <- lnd.getInfo
|
||||
} yield assert(info.blockHeight >= 0)
|
||||
} yield assert(info.blockHeight >= UInt32.zero)
|
||||
}
|
||||
|
||||
it must "create an invoice using sats" in { lnd =>
|
||||
|
|
|
@ -10,10 +10,19 @@ CommonSettings.prodSettings
|
|||
|
||||
enablePlugins(AkkaGrpcPlugin)
|
||||
|
||||
// Disable deprecation warning otherwise protobuf deprecation warnings will cause errors
|
||||
Compile / scalacOptions += {
|
||||
"-Wconf:cat=deprecation:site=lnrpc\\..*:silent,cat=deprecation:site=signrpc\\..*:silent,cat=deprecation:site=walletrpc\\..*:silent,cat=deprecation:site=routerrpc\\..*:silent,cat=deprecation:site=invoicesrpc\\..*:silent"
|
||||
}
|
||||
// Disable deprecation and unused imports warning otherwise generated files will cause errors
|
||||
Compile / scalacOptions ++= Seq(
|
||||
"-Wconf:cat=deprecation:site=lnrpc\\..*:silent",
|
||||
"-Wconf:cat=deprecation:site=signrpc\\..*:silent",
|
||||
"-Wconf:cat=deprecation:site=walletrpc\\..*:silent",
|
||||
"-Wconf:cat=deprecation:site=routerrpc\\..*:silent",
|
||||
"-Wconf:cat=deprecation:site=invoicesrpc\\..*:silent",
|
||||
"-Wconf:cat=unused-imports:site=lnrpc:silent",
|
||||
"-Wconf:cat=unused-imports:site=signrpc:silent",
|
||||
"-Wconf:cat=unused-imports:site=walletrpc:silent",
|
||||
"-Wconf:cat=unused-imports:site=routerrpc:silent",
|
||||
"-Wconf:cat=unused-imports:site=invoicesrpc:silent"
|
||||
)
|
||||
|
||||
TaskKeys.downloadLnd := {
|
||||
val logger = streams.value.log
|
||||
|
|
|
@ -6,6 +6,27 @@ package invoicesrpc;
|
|||
|
||||
option go_package = "github.com/lightningnetwork/lnd/lnrpc/invoicesrpc";
|
||||
|
||||
import "scalapb/scalapb.proto";
|
||||
|
||||
option (scalapb.options) = {
|
||||
import: "org.bitcoins.lnd.rpc.LndUtils._"
|
||||
scope: PACKAGE
|
||||
field_transformations : [
|
||||
{
|
||||
when : {
|
||||
type: TYPE_UINT64
|
||||
}
|
||||
set : {[scalapb.field] {type : 'org.bitcoins.core.number.UInt64' }}
|
||||
},
|
||||
{
|
||||
when : {
|
||||
type: TYPE_UINT32
|
||||
}
|
||||
set : {[scalapb.field] {type : 'org.bitcoins.core.number.UInt32' }}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
// Invoices is a service that can be used to create, accept, settle and cancel
|
||||
// invoices.
|
||||
service Invoices {
|
||||
|
|
|
@ -4,6 +4,27 @@ package lnrpc;
|
|||
|
||||
option go_package = "github.com/lightningnetwork/lnd/lnrpc";
|
||||
|
||||
import "scalapb/scalapb.proto";
|
||||
|
||||
option (scalapb.options) = {
|
||||
import: "org.bitcoins.lnd.rpc.LndUtils._"
|
||||
scope: PACKAGE
|
||||
field_transformations : [
|
||||
{
|
||||
when : {
|
||||
type: TYPE_UINT64
|
||||
}
|
||||
set : {[scalapb.field] {type : 'org.bitcoins.core.number.UInt64' }}
|
||||
},
|
||||
{
|
||||
when : {
|
||||
type: TYPE_UINT32
|
||||
}
|
||||
set : {[scalapb.field] {type : 'org.bitcoins.core.number.UInt32' }}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
/*
|
||||
* Comments in this file will be directly parsed into the API
|
||||
* Documentation as descriptions of the associated method, message, or field.
|
||||
|
|
|
@ -6,6 +6,27 @@ package routerrpc;
|
|||
|
||||
option go_package = "github.com/lightningnetwork/lnd/lnrpc/routerrpc";
|
||||
|
||||
import "scalapb/scalapb.proto";
|
||||
|
||||
option (scalapb.options) = {
|
||||
import: "org.bitcoins.lnd.rpc.LndUtils._"
|
||||
scope: PACKAGE
|
||||
field_transformations : [
|
||||
{
|
||||
when : {
|
||||
type: TYPE_UINT64
|
||||
}
|
||||
set : {[scalapb.field] {type : 'org.bitcoins.core.number.UInt64' }}
|
||||
},
|
||||
{
|
||||
when : {
|
||||
type: TYPE_UINT32
|
||||
}
|
||||
set : {[scalapb.field] {type : 'org.bitcoins.core.number.UInt32' }}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
// Router is a service that offers advanced interaction with the router
|
||||
// subsystem of the daemon.
|
||||
service Router {
|
||||
|
|
|
@ -4,6 +4,27 @@ package signrpc;
|
|||
|
||||
option go_package = "github.com/lightningnetwork/lnd/lnrpc/signrpc";
|
||||
|
||||
import "scalapb/scalapb.proto";
|
||||
|
||||
option (scalapb.options) = {
|
||||
import: "org.bitcoins.lnd.rpc.LndUtils._"
|
||||
scope: PACKAGE
|
||||
field_transformations : [
|
||||
{
|
||||
when : {
|
||||
type: TYPE_UINT64
|
||||
}
|
||||
set : {[scalapb.field] {type : 'org.bitcoins.core.number.UInt64' }}
|
||||
},
|
||||
{
|
||||
when : {
|
||||
type: TYPE_UINT32
|
||||
}
|
||||
set : {[scalapb.field] {type : 'org.bitcoins.core.number.UInt32' }}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
// Signer is a service that gives access to the signing functionality of the
|
||||
// daemon's wallet.
|
||||
service Signer {
|
||||
|
|
|
@ -7,6 +7,21 @@ package walletrpc;
|
|||
|
||||
option go_package = "github.com/lightningnetwork/lnd/lnrpc/walletrpc";
|
||||
|
||||
import "scalapb/scalapb.proto";
|
||||
|
||||
option (scalapb.options) = {
|
||||
import: "org.bitcoins.lnd.rpc.LndUtils._"
|
||||
scope: PACKAGE
|
||||
field_transformations : [
|
||||
{
|
||||
when : {
|
||||
type: TYPE_UINT64
|
||||
}
|
||||
set : {[scalapb.field] {type : 'org.bitcoins.core.number.UInt64' }}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
// WalletKit is a service that gives access to the core functionalities of the
|
||||
// daemon's wallet.
|
||||
service WalletKit {
|
||||
|
|
|
@ -15,10 +15,11 @@ import lnrpc._
|
|||
import org.bitcoins.commons.jsonmodels.lnd._
|
||||
import org.bitcoins.commons.util.NativeProcessFactory
|
||||
import org.bitcoins.core.currency._
|
||||
import org.bitcoins.core.number.UInt32
|
||||
import org.bitcoins.core.number._
|
||||
import org.bitcoins.core.protocol._
|
||||
import org.bitcoins.core.protocol.ln.LnInvoice
|
||||
import org.bitcoins.core.protocol.ln.LnTag.PaymentHashTag
|
||||
import org.bitcoins.core.protocol.ln.channel.ShortChannelId
|
||||
import org.bitcoins.core.protocol.ln.currency.MilliSatoshis
|
||||
import org.bitcoins.core.protocol.ln.node.NodeId
|
||||
import org.bitcoins.core.protocol.script._
|
||||
|
@ -319,8 +320,7 @@ class LndRpcClient(val instance: LndInstance, binaryOpt: Option[File] = None)(
|
|||
.map(_.utxos.toVector.map { utxo =>
|
||||
val outPointOpt = utxo.outpoint.map { out =>
|
||||
val txId = DoubleSha256DigestBE(out.txidStr)
|
||||
val vout = UInt32(out.outputIndex)
|
||||
TransactionOutPoint(txId, vout)
|
||||
TransactionOutPoint(txId, out.outputIndex)
|
||||
}
|
||||
|
||||
val spkBytes = ByteVector.fromValidHex(utxo.pkScript)
|
||||
|
@ -388,7 +388,7 @@ class LndRpcClient(val instance: LndInstance, binaryOpt: Option[File] = None)(
|
|||
val request = OpenChannelRequest(
|
||||
nodePubkey = nodeId.bytes,
|
||||
localFundingAmount = fundingAmount.satoshis.toLong,
|
||||
satPerVbyte = satPerVByte.toLong,
|
||||
satPerVbyte = UInt64(satPerVByte.toLong),
|
||||
`private` = privateChannel
|
||||
)
|
||||
|
||||
|
@ -405,7 +405,7 @@ class LndRpcClient(val instance: LndInstance, binaryOpt: Option[File] = None)(
|
|||
nodePubkey = nodeId.bytes,
|
||||
localFundingAmount = fundingAmount.satoshis.toLong,
|
||||
pushSat = pushAmt.satoshis.toLong,
|
||||
satPerVbyte = satPerVByte.toLong,
|
||||
satPerVbyte = UInt64(satPerVByte.toLong),
|
||||
`private` = privateChannel
|
||||
)
|
||||
|
||||
|
@ -422,7 +422,7 @@ class LndRpcClient(val instance: LndInstance, binaryOpt: Option[File] = None)(
|
|||
point.fundingTxid.fundingTxidBytes match {
|
||||
case Some(bytes) =>
|
||||
val txId = DoubleSha256DigestBE(bytes)
|
||||
Some(TransactionOutPoint(txId, UInt32(point.outputIndex)))
|
||||
Some(TransactionOutPoint(txId, point.outputIndex))
|
||||
case None => None
|
||||
}
|
||||
}
|
||||
|
@ -433,18 +433,18 @@ class LndRpcClient(val instance: LndInstance, binaryOpt: Option[File] = None)(
|
|||
force: Boolean,
|
||||
feeRate: SatoshisPerVirtualByte): Future[TransactionOutPoint] = {
|
||||
val channelPoint =
|
||||
ChannelPoint(FundingTxidBytes(outPoint.txId.bytes), outPoint.vout.toInt)
|
||||
ChannelPoint(FundingTxidBytes(outPoint.txId.bytes), outPoint.vout)
|
||||
|
||||
closeChannel(
|
||||
CloseChannelRequest(channelPoint = Some(channelPoint),
|
||||
force = force,
|
||||
satPerVbyte = feeRate.toLong))
|
||||
satPerVbyte = UInt64(feeRate.toLong)))
|
||||
}
|
||||
|
||||
def closeChannel(
|
||||
outPoint: TransactionOutPoint): Future[TransactionOutPoint] = {
|
||||
val channelPoint =
|
||||
ChannelPoint(FundingTxidBytes(outPoint.txId.bytes), outPoint.vout.toInt)
|
||||
ChannelPoint(FundingTxidBytes(outPoint.txId.bytes), outPoint.vout)
|
||||
closeChannel(CloseChannelRequest(Some(channelPoint)))
|
||||
}
|
||||
|
||||
|
@ -459,8 +459,7 @@ class LndRpcClient(val instance: LndInstance, binaryOpt: Option[File] = None)(
|
|||
.runWith(Sink.head)
|
||||
.collect { case ClosePending(closeUpdate) =>
|
||||
val txId = DoubleSha256Digest(closeUpdate.txid)
|
||||
val vout = UInt32(closeUpdate.outputIndex)
|
||||
TransactionOutPoint(txId, vout)
|
||||
TransactionOutPoint(txId, closeUpdate.outputIndex)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -499,9 +498,9 @@ class LndRpcClient(val instance: LndInstance, binaryOpt: Option[File] = None)(
|
|||
}
|
||||
}
|
||||
|
||||
def findChannel(chanId: Long): Future[Option[Channel]] = {
|
||||
def findChannel(chanId: ShortChannelId): Future[Option[Channel]] = {
|
||||
listChannels().map { channels =>
|
||||
channels.find(_.chanId == chanId)
|
||||
channels.find(_.chanId == chanId.u64)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -524,16 +523,18 @@ class LndRpcClient(val instance: LndInstance, binaryOpt: Option[File] = None)(
|
|||
.channelBalance(ChannelBalanceRequest())
|
||||
.map { bals =>
|
||||
ChannelBalances(
|
||||
localBalance = Satoshis(bals.localBalance.map(_.sat).getOrElse(0L)),
|
||||
remoteBalance = Satoshis(bals.remoteBalance.map(_.sat).getOrElse(0L)),
|
||||
unsettledLocalBalance =
|
||||
Satoshis(bals.unsettledLocalBalance.map(_.sat).getOrElse(0L)),
|
||||
unsettledRemoteBalance =
|
||||
Satoshis(bals.unsettledRemoteBalance.map(_.sat).getOrElse(0L)),
|
||||
pendingOpenLocalBalance =
|
||||
Satoshis(bals.pendingOpenLocalBalance.map(_.sat).getOrElse(0L)),
|
||||
pendingOpenRemoteBalance =
|
||||
Satoshis(bals.pendingOpenRemoteBalance.map(_.sat).getOrElse(0L))
|
||||
localBalance =
|
||||
Satoshis(bals.localBalance.map(_.sat).getOrElse(UInt64.zero)),
|
||||
remoteBalance =
|
||||
Satoshis(bals.remoteBalance.map(_.sat).getOrElse(UInt64.zero)),
|
||||
unsettledLocalBalance = Satoshis(
|
||||
bals.unsettledLocalBalance.map(_.sat).getOrElse(UInt64.zero)),
|
||||
unsettledRemoteBalance = Satoshis(
|
||||
bals.unsettledRemoteBalance.map(_.sat).getOrElse(UInt64.zero)),
|
||||
pendingOpenLocalBalance = Satoshis(
|
||||
bals.pendingOpenLocalBalance.map(_.sat).getOrElse(UInt64.zero)),
|
||||
pendingOpenRemoteBalance = Satoshis(
|
||||
bals.pendingOpenRemoteBalance.map(_.sat).getOrElse(UInt64.zero))
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -616,11 +617,11 @@ class LndRpcClient(val instance: LndInstance, binaryOpt: Option[File] = None)(
|
|||
feeRate: SatoshisPerVirtualByte,
|
||||
spendUnconfirmed: Boolean): Future[PSBT] = {
|
||||
val outputMap = outputs.map { case (addr, amt) =>
|
||||
addr.toString -> amt.satoshis.toLong
|
||||
addr.toString -> amt.satoshis.toUInt64
|
||||
}
|
||||
val template = TxTemplate(inputs, outputMap)
|
||||
val rawTemplate = FundPsbtRequest.Template.Raw(template)
|
||||
val fees = SatPerVbyte(feeRate.toLong)
|
||||
val fees = SatPerVbyte(UInt64(feeRate.toLong))
|
||||
val request = FundPsbtRequest(template = rawTemplate,
|
||||
fees = fees,
|
||||
spendUnconfirmed = spendUnconfirmed)
|
||||
|
@ -635,11 +636,11 @@ class LndRpcClient(val instance: LndInstance, binaryOpt: Option[File] = None)(
|
|||
account: String,
|
||||
spendUnconfirmed: Boolean): Future[PSBT] = {
|
||||
val outputMap = outputs.map { case (addr, amt) =>
|
||||
addr.toString -> amt.satoshis.toLong
|
||||
addr.toString -> amt.satoshis.toUInt64
|
||||
}
|
||||
val template = TxTemplate(inputs, outputMap)
|
||||
val rawTemplate = FundPsbtRequest.Template.Raw(template)
|
||||
val fees = SatPerVbyte(feeRate.toLong)
|
||||
val fees = SatPerVbyte(UInt64(feeRate.toLong))
|
||||
val request = FundPsbtRequest(template = rawTemplate,
|
||||
fees = fees,
|
||||
account = account,
|
||||
|
@ -654,7 +655,7 @@ class LndRpcClient(val instance: LndInstance, binaryOpt: Option[File] = None)(
|
|||
account: String,
|
||||
spendUnconfirmed: Boolean): Future[PSBT] = {
|
||||
val template = Psbt(psbt.bytes)
|
||||
val fees = SatPerVbyte(feeRate.toLong)
|
||||
val fees = SatPerVbyte(UInt64(feeRate.toLong))
|
||||
val request = FundPsbtRequest(template = template,
|
||||
fees = fees,
|
||||
account = account,
|
||||
|
@ -668,7 +669,7 @@ class LndRpcClient(val instance: LndInstance, binaryOpt: Option[File] = None)(
|
|||
feeRate: SatoshisPerVirtualByte,
|
||||
spendUnconfirmed: Boolean): Future[PSBT] = {
|
||||
val template = Psbt(psbt.bytes)
|
||||
val fees = SatPerVbyte(feeRate.toLong)
|
||||
val fees = SatPerVbyte(UInt64(feeRate.toLong))
|
||||
val request = FundPsbtRequest(template = template,
|
||||
fees = fees,
|
||||
spendUnconfirmed = spendUnconfirmed)
|
||||
|
@ -678,7 +679,7 @@ class LndRpcClient(val instance: LndInstance, binaryOpt: Option[File] = None)(
|
|||
|
||||
def fundPSBT(psbt: PSBT, feeRate: SatoshisPerVirtualByte): Future[PSBT] = {
|
||||
val template = Psbt(psbt.bytes)
|
||||
val fees = SatPerVbyte(feeRate.toLong)
|
||||
val fees = SatPerVbyte(UInt64(feeRate.toLong))
|
||||
val request = FundPsbtRequest(template, fees)
|
||||
|
||||
fundPSBT(request)
|
||||
|
@ -725,7 +726,7 @@ class LndRpcClient(val instance: LndInstance, binaryOpt: Option[File] = None)(
|
|||
output: TransactionOutput): Future[(ScriptSignature, ScriptWitness)] = {
|
||||
val signDescriptor =
|
||||
SignDescriptor(output = Some(output),
|
||||
sighash = HashType.sigHashAll.num.toInt,
|
||||
sighash = UInt32(HashType.sigHashAll.num.toBigInt),
|
||||
inputIndex = inputIdx)
|
||||
|
||||
computeInputScript(tx, Vector(signDescriptor)).map(_.head)
|
||||
|
@ -766,21 +767,21 @@ class LndRpcClient(val instance: LndInstance, binaryOpt: Option[File] = None)(
|
|||
.listLeases(request)
|
||||
.map(_.lockedUtxos.toVector.map { lease =>
|
||||
val txId = DoubleSha256DigestBE(lease.outpoint.get.txidBytes)
|
||||
val vout = UInt32(lease.outpoint.get.outputIndex)
|
||||
val vout = lease.outpoint.get.outputIndex
|
||||
val outPoint = TransactionOutPoint(txId, vout)
|
||||
UTXOLease(lease.id, outPoint, lease.expiration)
|
||||
UTXOLease(lease.id, outPoint, lease.expiration.toLong)
|
||||
})
|
||||
}
|
||||
|
||||
def leaseOutput(
|
||||
outpoint: TransactionOutPoint,
|
||||
leaseSeconds: Long): Future[Long] = {
|
||||
leaseSeconds: Long): Future[UInt64] = {
|
||||
val outPoint =
|
||||
OutPoint(outpoint.txId.bytes, outputIndex = outpoint.vout.toInt)
|
||||
OutPoint(outpoint.txId.bytes, outputIndex = outpoint.vout)
|
||||
|
||||
val request = LeaseOutputRequest(id = LndRpcClient.leaseId,
|
||||
outpoint = Some(outPoint),
|
||||
expirationSeconds = leaseSeconds)
|
||||
expirationSeconds = UInt64(leaseSeconds))
|
||||
|
||||
leaseOutput(request)
|
||||
}
|
||||
|
@ -791,7 +792,7 @@ class LndRpcClient(val instance: LndInstance, binaryOpt: Option[File] = None)(
|
|||
* @param request LeaseOutputRequest
|
||||
* @return Unix timestamp for when the lease expires
|
||||
*/
|
||||
def leaseOutput(request: LeaseOutputRequest): Future[Long] = {
|
||||
def leaseOutput(request: LeaseOutputRequest): Future[UInt64] = {
|
||||
logger.trace("lnd calling leaseoutput")
|
||||
|
||||
wallet.leaseOutput(request).map(_.expiration)
|
||||
|
@ -799,7 +800,7 @@ class LndRpcClient(val instance: LndInstance, binaryOpt: Option[File] = None)(
|
|||
|
||||
def releaseOutput(outpoint: TransactionOutPoint): Future[Unit] = {
|
||||
val outPoint =
|
||||
OutPoint(outpoint.txId.bytes, outputIndex = outpoint.vout.toInt)
|
||||
OutPoint(outpoint.txId.bytes, outputIndex = outpoint.vout)
|
||||
|
||||
val request =
|
||||
ReleaseOutputRequest(id = LndRpcClient.leaseId, outpoint = Some(outPoint))
|
||||
|
@ -827,9 +828,10 @@ class LndRpcClient(val instance: LndInstance, binaryOpt: Option[File] = None)(
|
|||
peer: NodeId,
|
||||
tpe: BigSizeUInt,
|
||||
data: ByteVector): Future[Unit] = {
|
||||
val request = SendCustomMessageRequest(peer = peer.bytes,
|
||||
`type` = tpe.toInt,
|
||||
data = data)
|
||||
val request =
|
||||
SendCustomMessageRequest(peer = peer.bytes,
|
||||
`type` = UInt32(tpe.toBigInt),
|
||||
data = data)
|
||||
sendCustomMessage(request)
|
||||
}
|
||||
|
||||
|
@ -843,7 +845,7 @@ class LndRpcClient(val instance: LndInstance, binaryOpt: Option[File] = None)(
|
|||
lnd.subscribeCustomMessages(SubscribeCustomMessagesRequest()).map {
|
||||
response =>
|
||||
val nodeId = NodeId(response.peer)
|
||||
val tpe = BigSizeUInt(response.`type`)
|
||||
val tpe = BigSizeUInt(response.`type`.toBigInt)
|
||||
val tlv = TLV.fromTypeAndValue(tpe, response.data)
|
||||
|
||||
(nodeId, tlv)
|
||||
|
|
|
@ -5,11 +5,12 @@ import lnrpc.ChannelPoint.FundingTxid.FundingTxidBytes
|
|||
import lnrpc.{ChannelPoint, OutPoint}
|
||||
import org.bitcoins.commons.jsonmodels.lnd.TxDetails
|
||||
import org.bitcoins.core.currency.Satoshis
|
||||
import org.bitcoins.core.number.UInt32
|
||||
import org.bitcoins.core.number._
|
||||
import org.bitcoins.core.protocol.BitcoinAddress
|
||||
import org.bitcoins.core.protocol.script.ScriptPubKey
|
||||
import org.bitcoins.core.protocol.transaction._
|
||||
import org.bitcoins.crypto._
|
||||
import scalapb.TypeMapper
|
||||
import scodec.bits._
|
||||
import signrpc.TxOut
|
||||
|
||||
|
@ -31,11 +32,10 @@ trait LndUtils {
|
|||
ScriptPubKey.fromAsmBytes(txOut.pkScript))
|
||||
|
||||
implicit def outpointToTxOutPoint(op: OutPoint): TransactionOutPoint =
|
||||
TransactionOutPoint(DoubleSha256DigestBE(op.txidStr),
|
||||
UInt32(op.outputIndex))
|
||||
TransactionOutPoint(DoubleSha256DigestBE(op.txidStr), op.outputIndex)
|
||||
|
||||
implicit def txOutpointToOutpoint(outpoint: TransactionOutPoint): OutPoint =
|
||||
OutPoint(outpoint.txId.bytes, outpoint.txIdBE.hex, outpoint.vout.toInt)
|
||||
OutPoint(outpoint.txId.bytes, outpoint.txIdBE.hex, outpoint.vout)
|
||||
|
||||
// If other kinds of Iterables are needed, there's a fancy thing to do
|
||||
// that is done all over the Seq code using params and an implicit CanBuildFrom
|
||||
|
@ -58,14 +58,13 @@ trait LndUtils {
|
|||
implicit def channelPointToOutpoint(
|
||||
channelPoint: ChannelPoint): TransactionOutPoint = {
|
||||
val txIdBytes = channelPoint.fundingTxid.fundingTxidBytes.get
|
||||
TransactionOutPoint(DoubleSha256Digest(txIdBytes),
|
||||
UInt32(channelPoint.outputIndex))
|
||||
TransactionOutPoint(DoubleSha256Digest(txIdBytes), channelPoint.outputIndex)
|
||||
}
|
||||
|
||||
implicit def outPointToChannelPoint(
|
||||
outPoint: TransactionOutPoint): ChannelPoint = {
|
||||
val txId = FundingTxidBytes(outPoint.txId.bytes)
|
||||
ChannelPoint(txId, outPoint.vout.toInt)
|
||||
ChannelPoint(txId, outPoint.vout)
|
||||
}
|
||||
|
||||
implicit def LndTransactionToTxDetails(
|
||||
|
@ -90,6 +89,12 @@ trait LndUtils {
|
|||
label = details.label
|
||||
)
|
||||
}
|
||||
|
||||
implicit val uint64Mapper: TypeMapper[Long, UInt64] =
|
||||
TypeMapper[Long, UInt64](UInt64.apply)(_.toBigInt.longValue)
|
||||
|
||||
implicit val uint32Mapper: TypeMapper[Int, UInt32] =
|
||||
TypeMapper[Int, UInt32](UInt32.apply)(_.toBigInt.intValue)
|
||||
}
|
||||
|
||||
object LndUtils extends LndUtils
|
||||
|
|
|
@ -11,6 +11,7 @@ import lnrpc.{
|
|||
RouteHint
|
||||
}
|
||||
import org.bitcoins.core.currency.Satoshis
|
||||
import org.bitcoins.core.number._
|
||||
import org.bitcoins.core.protocol.ln.LnInvoice
|
||||
import org.bitcoins.core.protocol.ln.currency.MilliSatoshis
|
||||
import org.bitcoins.core.protocol.ln.node.NodeId
|
||||
|
@ -30,10 +31,10 @@ trait LndRouterClient { self: LndRpcClient =>
|
|||
routeHints: Vector[LnRoute]): Future[QueryRoutesResponse] = {
|
||||
val hopHints = routeHints.map { hint =>
|
||||
HopHint(hint.pubkey.hex,
|
||||
hint.shortChannelID.u64.toLong,
|
||||
hint.feeBaseMsat.msat.toLong.toInt,
|
||||
hint.feePropMilli.u32.toInt,
|
||||
hint.cltvExpiryDelta)
|
||||
hint.shortChannelID.u64,
|
||||
UInt32(hint.feeBaseMsat.msat.toLong),
|
||||
hint.feePropMilli.u32,
|
||||
UInt32(hint.cltvExpiryDelta))
|
||||
}
|
||||
val request =
|
||||
QueryRoutesRequest(pubKey = node.pubKey.hex,
|
||||
|
|
|
@ -21,6 +21,7 @@ object Deps {
|
|||
val slf4j = "1.7.36"
|
||||
val spray = "1.3.6"
|
||||
val zeromq = "0.5.2"
|
||||
val scalapb = "0.11.10"
|
||||
val akkav = "10.2.9"
|
||||
val playv = "2.9.2"
|
||||
val akkaStreamv = "2.6.19"
|
||||
|
@ -98,6 +99,9 @@ object Deps {
|
|||
val zeromq =
|
||||
"org.zeromq" % "jeromq" % V.zeromq withSources () withJavadoc ()
|
||||
|
||||
val scalapb =
|
||||
"com.thesamet.scalapb" %% "scalapb-runtime" % V.scalapb % "protobuf"
|
||||
|
||||
val akkaHttp =
|
||||
"com.typesafe.akka" %% "akka-http" % V.akkav withSources () withJavadoc ()
|
||||
|
||||
|
@ -549,6 +553,7 @@ object Deps {
|
|||
}
|
||||
|
||||
val lndRpc = List(
|
||||
Compile.scalapb,
|
||||
Compile.akkaHttp,
|
||||
Compile.akkaHttp2,
|
||||
Compile.akkaStream,
|
||||
|
|
|
@ -4,6 +4,7 @@ import akka.actor.ActorSystem
|
|||
import grizzled.slf4j.Logging
|
||||
import org.bitcoins.asyncutil.AsyncUtil
|
||||
import org.bitcoins.core.currency.{Bitcoins, CurrencyUnit, Satoshis}
|
||||
import org.bitcoins.core.number.UInt32
|
||||
import org.bitcoins.core.protocol.ln.node.NodeId
|
||||
import org.bitcoins.core.protocol.transaction.TransactionOutPoint
|
||||
import org.bitcoins.core.wallet.fee.SatoshisPerVirtualByte
|
||||
|
@ -139,7 +140,7 @@ trait LndRpcTestUtil extends Logging {
|
|||
for {
|
||||
blockCount <- bitcoind.getBlockCount
|
||||
info <- client.getInfo
|
||||
} yield info.blockHeight == blockCount
|
||||
} yield info.blockHeight == UInt32(blockCount)
|
||||
|
||||
/** Shuts down an lnd daemon and the bitcoind daemon it is associated with
|
||||
*/
|
||||
|
|
Loading…
Add table
Reference in a new issue