invoicesrpc+lnrpc: add msat fields to invoices

This commit is contained in:
Joost Jager 2019-11-15 08:59:14 +01:00
parent 2ab16f7601
commit fcbf1bc07a
No known key found for this signature in database
GPG Key ID: A61B9D4C393C59C7
9 changed files with 660 additions and 590 deletions

View File

@ -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
@ -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.

View File

@ -104,9 +104,17 @@ type AddHoldInvoiceRequest struct {
Memo string `protobuf:"bytes,1,opt,name=memo,proto3" json:"memo,omitempty"`
/// The hash of the preimage
Hash []byte `protobuf:"bytes,2,opt,name=hash,proto3" json:"hash,omitempty"`
/// The value of this invoice in satoshis
//*
//The value of this invoice in satoshis
//
//The fields value and value_msat are mutually exclusive.
Value int64 `protobuf:"varint,3,opt,name=value,proto3" json:"value,omitempty"`
//*
//The value of this invoice in millisatoshis
//
//The fields value and value_msat are mutually exclusive.
ValueMsat int64 `protobuf:"varint,10,opt,name=value_msat,proto3" json:"value_msat,omitempty"`
//*
//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
//of an encoded payment request.
@ -174,6 +182,13 @@ func (m *AddHoldInvoiceRequest) GetValue() int64 {
return 0
}
func (m *AddHoldInvoiceRequest) GetValueMsat() int64 {
if m != nil {
return m.ValueMsat
}
return 0
}
func (m *AddHoldInvoiceRequest) GetDescriptionHash() []byte {
if m != nil {
return m.DescriptionHash
@ -383,39 +398,40 @@ func init() {
func init() { proto.RegisterFile("invoicesrpc/invoices.proto", fileDescriptor_090ab9c4958b987d) }
var fileDescriptor_090ab9c4958b987d = []byte{
// 509 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x53, 0x41, 0x6f, 0xd3, 0x4c,
0x10, 0x95, 0x93, 0x34, 0x4d, 0x26, 0x6d, 0xbf, 0x7c, 0x0b, 0x44, 0x96, 0x45, 0xc1, 0x58, 0x1c,
0xac, 0x1e, 0x6c, 0x48, 0xc5, 0x11, 0x24, 0xe0, 0x12, 0x90, 0xe0, 0xe0, 0x08, 0x0e, 0x5c, 0xa2,
0x8d, 0xbd, 0xd8, 0xab, 0x6e, 0x76, 0x97, 0xdd, 0x75, 0xa0, 0xbf, 0x8a, 0xdf, 0xc3, 0xbf, 0x41,
0x5e, 0x3b, 0x95, 0xed, 0x96, 0xde, 0x66, 0xde, 0xcc, 0x3c, 0x8f, 0xdf, 0x9b, 0x05, 0x8f, 0xf2,
0xbd, 0xa0, 0x29, 0xd1, 0x4a, 0xa6, 0xf1, 0x21, 0x8e, 0xa4, 0x12, 0x46, 0xa0, 0x59, 0xab, 0xe6,
0x3d, 0xce, 0x85, 0xc8, 0x19, 0x89, 0xb1, 0xa4, 0x31, 0xe6, 0x5c, 0x18, 0x6c, 0xa8, 0xe0, 0x4d,
0xab, 0x37, 0x55, 0x32, 0xad, 0xc3, 0xe0, 0x15, 0xcc, 0xdf, 0x63, 0x9e, 0x12, 0xf6, 0xa1, 0x9e,
0xfe, 0xa4, 0x73, 0xf4, 0x0c, 0x4e, 0x24, 0xbe, 0xde, 0x11, 0x6e, 0x36, 0x05, 0xd6, 0x85, 0xeb,
0xf8, 0x4e, 0x78, 0x92, 0xcc, 0x1a, 0x6c, 0x85, 0x75, 0x11, 0x3c, 0x80, 0xff, 0x3b, 0x63, 0x09,
0xd1, 0x32, 0xf8, 0x3d, 0x80, 0x47, 0x6f, 0xb3, 0x6c, 0x25, 0x58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, 0xe2, 0xef, 0x08, 0xa6, 0xed,
0x80, 0x46, 0xdf, 0xe0, 0xf4, 0x6e, 0x2e, 0x74, 0x11, 0x75, 0xee, 0x37, 0xba, 0xf7, 0x83, 0xde,
0x49, 0xab, 0x67, 0x0b, 0xbf, 0x74, 0xd0, 0x17, 0x38, 0xee, 0xdd, 0x23, 0x3a, 0xeb, 0xd1, 0x0d,
0x4f, 0xdc, 0x3b, 0xff, 0x7f, 0xd9, 0x4a, 0xfc, 0x15, 0x4e, 0xfa, 0xc2, 0xa3, 0xa0, 0x37, 0x71,
0xe7, 0x99, 0x7b, 0xcf, 0xee, 0xed, 0xd1, 0xb2, 0x5e, 0xb3, 0xa7, 0xef, 0x60, 0xcd, 0xa1, 0x57,
0x83, 0x35, 0x6f, 0x59, 0xf3, 0xfe, 0xf2, 0xfb, 0xab, 0x82, 0x9a, 0x72, 0xb3, 0x8e, 0x32, 0x51,
0xc5, 0x8c, 0x16, 0xa5, 0xe1, 0x94, 0x17, 0x9c, 0x98, 0x5f, 0x42, 0x5d, 0xc5, 0x8c, 0xe7, 0xb1,
0x55, 0x2a, 0xee, 0xd0, 0xac, 0x27, 0xf6, 0xe5, 0x5f, 0xfe, 0x0b, 0x00, 0x00, 0xff, 0xff, 0x1b,
0x3c, 0xda, 0x98, 0x4d, 0x04, 0x00, 0x00,
}
// Reference imports to suppress errors if they are not otherwise used.

View File

@ -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

View File

@ -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"
@ -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,

View File

@ -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,

File diff suppressed because it is too large Load Diff

View File

@ -2230,9 +2230,20 @@ message Invoice {
*/
bytes r_hash = 4 [json_name = "r_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 = 5 [json_name = "value"];
/**
The value of this invoice in millisatoshis
The fields value and value_msat are mutually exclusive.
*/
int64 value_msat = 23 [json_name = "value_msat"];
/// Whether this invoice has been fulfilled
bool settled = 6 [json_name = "settled", deprecated = true];

View File

@ -2646,7 +2646,14 @@
"value": {
"type": "string",
"format": "int64",
"title": "/ The value of this invoice in satoshis"
"description": "The fields value and value_msat are mutually exclusive.",
"title": "*\nThe value of this invoice in satoshis"
},
"value_msat": {
"type": "string",
"format": "int64",
"description": "The fields value and value_msat are mutually exclusive.",
"title": "*\nThe value of this invoice in millisatoshis"
},
"settled": {
"type": "boolean",

View File

@ -3509,10 +3509,15 @@ func (r *rpcServer) AddInvoice(ctx context.Context,
ChanDB: r.server.chanDB,
}
value, err := lnrpc.UnmarshallAmt(invoice.Value, invoice.ValueMsat)
if err != nil {
return nil, err
}
addInvoiceData := &invoicesrpc.AddInvoiceData{
Memo: invoice.Memo,
Receipt: invoice.Receipt,
Value: btcutil.Amount(invoice.Value),
Value: value,
DescriptionHash: invoice.DescriptionHash,
Expiry: invoice.Expiry,
FallbackAddr: invoice.FallbackAddr,