mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
loopout: use optional routing plugin for the main swap invoice
This commit is contained in:
parent
04ebc8d568
commit
1943edfd78
2 changed files with 175 additions and 44 deletions
16
swap/fees.go
16
swap/fees.go
|
|
@ -6,6 +6,7 @@ import (
|
|||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"github.com/btcsuite/btcutil"
|
||||
"github.com/lightningnetwork/lnd/lntypes"
|
||||
"github.com/lightningnetwork/lnd/routing/route"
|
||||
"github.com/lightningnetwork/lnd/zpay32"
|
||||
)
|
||||
|
||||
|
|
@ -27,24 +28,29 @@ func FeeRateAsPercentage(feeRate int64) float64 {
|
|||
return float64(feeRate) / (FeeRateTotalParts / 100)
|
||||
}
|
||||
|
||||
// DecodeInvoice gets the hash and the amount of an invoice.
|
||||
// DecodeInvoice gets the destination, hash and the amount of an invoice.
|
||||
// It requires an amount to be specified.
|
||||
func DecodeInvoice(params *chaincfg.Params,
|
||||
payReq string) (lntypes.Hash, btcutil.Amount, error) {
|
||||
payReq string) (route.Vertex, lntypes.Hash, btcutil.Amount, error) {
|
||||
|
||||
swapPayReq, err := zpay32.Decode(
|
||||
payReq, params,
|
||||
)
|
||||
if err != nil {
|
||||
return lntypes.Hash{}, 0, err
|
||||
return route.Vertex{}, lntypes.Hash{}, 0, err
|
||||
}
|
||||
|
||||
if swapPayReq.MilliSat == nil {
|
||||
return lntypes.Hash{}, 0, errors.New("no amount in invoice")
|
||||
return route.Vertex{}, lntypes.Hash{}, 0,
|
||||
errors.New("no amount in invoice")
|
||||
}
|
||||
|
||||
var hash lntypes.Hash
|
||||
copy(hash[:], swapPayReq.PaymentHash[:])
|
||||
|
||||
return hash, swapPayReq.MilliSat.ToSatoshis(), nil
|
||||
var destination route.Vertex
|
||||
destPubKey := swapPayReq.Destination.SerializeCompressed()
|
||||
copy(destination[:], destPubKey)
|
||||
|
||||
return destination, hash, swapPayReq.MilliSat.ToSatoshis(), nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue