Skip to content

Commit e41ddf2

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 ef73f75 commit e41ddf2

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
@@ -7616,7 +7616,7 @@ func (r *rpcServer) SendPayment(req *tchrpc.SendPaymentRequest,
76167616
}
76177617

76187618
// Unmarshall the accepted quote's asset rate.
7619-
assetRate, err := rfqrpc.UnmarshalFixedPoint(
7619+
assetRate, err := rpcutils.UnmarshalRfqFixedPoint(
76207620
acceptedQuote.BidAssetRate,
76217621
)
76227622
if err != nil {
@@ -7777,7 +7777,7 @@ func (r *rpcServer) parseRequest(
77777777
func checkOverpayment(quote *rfqrpc.PeerAcceptedSellQuote,
77787778
paymentAmount lnwire.MilliSatoshi, allowOverpay bool) error {
77797779

7780-
rateFP, err := rfqrpc.UnmarshalFixedPoint(quote.BidAssetRate)
7780+
rateFP, err := rpcutils.UnmarshalRfqFixedPoint(quote.BidAssetRate)
77817781
if err != nil {
77827782
return fmt.Errorf("cannot unmarshal asset rate: %w", err)
77837783
}
@@ -8118,7 +8118,7 @@ func validateInvoiceAmount(acceptedQuote *rfqrpc.PeerAcceptedBuyQuote,
81188118
// that we need to pay. We can now update the invoice with this amount.
81198119
//
81208120
// First, un-marshall the ask asset rate from the accepted quote.
8121-
askAssetRate, err := rfqrpc.UnmarshalFixedPoint(
8121+
askAssetRate, err := rpcutils.UnmarshalRfqFixedPoint(
81228122
acceptedQuote.AskAssetRate,
81238123
)
81248124
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)