Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

invoicesrpc+lnrpc: add msat fields to invoices #3729

Merged
merged 1 commit into from
Nov 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lnrpc/invoicesrpc/addinvoice.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ type AddInvoiceData struct {
// htlc will be accepted and held until the preimage becomes known.
Hash *lntypes.Hash

// The value of this invoice in satoshis.
Value btcutil.Amount
// The value of this invoice in millisatoshis.
Value lnwire.MilliSatoshi

// Hash (SHA-256) of a description of the payment. Used if the
// description of payment (memo) is too long to naturally fit within the
Expand Down Expand Up @@ -169,7 +169,7 @@ func AddInvoice(ctx context.Context, cfg *AddInvoiceConfig,
"are not allowed, value is %v", invoice.Value)
}

amtMSat := lnwire.NewMSatFromSatoshis(invoice.Value)
amtMSat := invoice.Value

// The value of the invoice must also not exceed the current soft-limit
// on the largest payment within the network.
Expand Down
84 changes: 50 additions & 34 deletions lnrpc/invoicesrpc/invoices.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion lnrpc/invoicesrpc/invoices.proto
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,20 @@ message AddHoldInvoiceRequest {
/// The hash of the preimage
bytes hash = 2 [json_name = "hash"];

/// The value of this invoice in satoshis
/**
The value of this invoice in satoshis

The fields value and value_msat are mutually exclusive.
*/
int64 value = 3 [json_name = "value"];

/**
The value of this invoice in millisatoshis

The fields value and value_msat are mutually exclusive.
*/
int64 value_msat = 10 [json_name = "value_msat"];

/**
Hash (SHA-256) of a description of the payment. Used if the description of
payment (memo) is too long to naturally fit within the description field
Expand Down
8 changes: 6 additions & 2 deletions lnrpc/invoicesrpc/invoices_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"google.golang.org/grpc"
"gopkg.in/macaroon-bakery.v2/bakery"

"github.com/btcsuite/btcutil"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/lnrpc"
"github.com/lightningnetwork/lnd/lntypes"
Expand Down Expand Up @@ -261,10 +260,15 @@ func (s *Server) AddHoldInvoice(ctx context.Context,
return nil, err
}

value, err := lnrpc.UnmarshallAmt(invoice.Value, invoice.ValueMsat)
if err != nil {
return nil, err
}

addInvoiceData := &AddInvoiceData{
Memo: invoice.Memo,
Hash: &hash,
Value: btcutil.Amount(invoice.Value),
Value: value,
DescriptionHash: invoice.DescriptionHash,
Expiry: invoice.Expiry,
FallbackAddr: invoice.FallbackAddr,
Expand Down
1 change: 1 addition & 0 deletions lnrpc/invoicesrpc/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ func CreateRPCInvoice(invoice *channeldb.Invoice,
Receipt: invoice.Receipt[:],
RHash: decoded.PaymentHash[:],
Value: int64(satAmt),
ValueMsat: int64(invoice.Terms.Value),
CreationDate: invoice.CreationDate.Unix(),
SettleDate: settleDate,
Settled: isSettled,
Expand Down
Loading