Skip to content

Commit f1b9878

Browse files
committed
rpcutils: move RFQ gRPC marshal functionality from taprpc
Move RFQ related gRPC marshalling functionality from the taprpc package to the rpcutils package as preparation for future modularization.
1 parent de0705b commit f1b9878

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

rpcserver.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7561,7 +7561,7 @@ func (r *rpcServer) SendPayment(req *tchrpc.SendPaymentRequest,
75617561
}
75627562

75637563
// Unmarshall the accepted quote's asset rate.
7564-
assetRate, err := rfqrpc.UnmarshalFixedPoint(
7564+
assetRate, err := rpcutils.UnmarshalRfqFixedPoint(
75657565
acceptedQuote.BidAssetRate,
75667566
)
75677567
if err != nil {
@@ -7722,7 +7722,7 @@ func (r *rpcServer) parseRequest(
77227722
func checkOverpayment(quote *rfqrpc.PeerAcceptedSellQuote,
77237723
paymentAmount lnwire.MilliSatoshi, allowOverpay bool) error {
77247724

7725-
rateFP, err := rfqrpc.UnmarshalFixedPoint(quote.BidAssetRate)
7725+
rateFP, err := rpcutils.UnmarshalRfqFixedPoint(quote.BidAssetRate)
77267726
if err != nil {
77277727
return fmt.Errorf("cannot unmarshal asset rate: %w", err)
77287728
}
@@ -8063,7 +8063,7 @@ func validateInvoiceAmount(acceptedQuote *rfqrpc.PeerAcceptedBuyQuote,
80638063
// that we need to pay. We can now update the invoice with this amount.
80648064
//
80658065
// First, un-marshall the ask asset rate from the accepted quote.
8066-
askAssetRate, err := rfqrpc.UnmarshalFixedPoint(
8066+
askAssetRate, err := rpcutils.UnmarshalRfqFixedPoint(
80678067
acceptedQuote.AskAssetRate,
80688068
)
80698069
if err != nil {

taprpc/rfqrpc/marshal.go renamed to rpcutils/rfq_marshal.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1-
package rfqrpc
1+
package rpcutils
22

33
import (
44
"fmt"
55
"math/big"
66

77
"github.com/lightninglabs/taproot-assets/rfqmath"
8+
"github.com/lightninglabs/taproot-assets/taprpc/rfqrpc"
89
)
910

10-
// UnmarshalFixedPoint converts an RPC FixedPoint to a BigIntFixedPoint.
11-
func UnmarshalFixedPoint(fp *FixedPoint) (*rfqmath.BigIntFixedPoint, error) {
11+
// UnmarshalRfqFixedPoint converts an RPC FixedPoint to a BigIntFixedPoint.
12+
func UnmarshalRfqFixedPoint(fp *rfqrpc.FixedPoint) (*rfqmath.BigIntFixedPoint,
13+
error) {
14+
1215
// Return an error is the scale component of the fixed point is greater
1316
// than the max value of uint8.
1417
if fp.Scale > 255 {

0 commit comments

Comments
 (0)