mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-01-19 05:43:51 +01:00
Add PSBT functions for LND (#4124)
This commit is contained in:
parent
34b7d18268
commit
5c9d64647e
@ -36,6 +36,8 @@ import org.bitcoins.lnd.rpc.LndUtils._
|
||||
import org.bitcoins.lnd.rpc.config._
|
||||
import scodec.bits._
|
||||
import signrpc._
|
||||
import walletrpc.FundPsbtRequest.Fees.SatPerVbyte
|
||||
import walletrpc.FundPsbtRequest.Template.Psbt
|
||||
import walletrpc.{
|
||||
AddressType => _,
|
||||
ListUnspentRequest => _,
|
||||
@ -562,6 +564,48 @@ class LndRpcClient(val instance: LndInstance, binaryOpt: Option[File] = None)(
|
||||
.map(res => Tx(res.rawTx))
|
||||
}
|
||||
|
||||
def fundPSBT(
|
||||
psbt: PSBT,
|
||||
feeRate: SatoshisPerVirtualByte,
|
||||
spendUnconfirmed: Boolean): Future[PSBT] = {
|
||||
val template = Psbt(psbt.bytes)
|
||||
val fees = SatPerVbyte(feeRate.toLong)
|
||||
val request = FundPsbtRequest(template = template,
|
||||
fees = fees,
|
||||
spendUnconfirmed = spendUnconfirmed)
|
||||
|
||||
fundPSBT(request)
|
||||
}
|
||||
|
||||
def fundPSBT(psbt: PSBT, feeRate: SatoshisPerVirtualByte): Future[PSBT] = {
|
||||
val template = Psbt(psbt.bytes)
|
||||
val fees = SatPerVbyte(feeRate.toLong)
|
||||
val request = FundPsbtRequest(template, fees)
|
||||
|
||||
fundPSBT(request)
|
||||
}
|
||||
|
||||
def fundPSBT(request: FundPsbtRequest): Future[PSBT] = {
|
||||
logger.trace("lnd calling fundpsbt")
|
||||
|
||||
wallet
|
||||
.fundPsbt(request)
|
||||
.map(res => PSBT(res.fundedPsbt))
|
||||
}
|
||||
|
||||
def signPSBT(psbt: PSBT): Future[PSBT] = {
|
||||
val request = SignPsbtRequest(psbt.bytes)
|
||||
signPSBT(request)
|
||||
}
|
||||
|
||||
def signPSBT(request: SignPsbtRequest): Future[PSBT] = {
|
||||
logger.trace("lnd calling signpsbt")
|
||||
|
||||
wallet
|
||||
.signPsbt(request)
|
||||
.map(res => PSBT(res.signedPsbt))
|
||||
}
|
||||
|
||||
def finalizePSBT(psbt: PSBT): Future[PSBT] = {
|
||||
val request = FinalizePsbtRequest(psbt.bytes)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user