mod+cmd/lncli: use google.golang.org/protobuf package

This commit is contained in:
Oliver Gugger committed 2023-05-11 22:51:16 +02:00
1 parent fd9adaf6ce
commit f9436ec05d
11 files changed
+90 -61

No files matched your search

+42
View File
@@ -7,6 +7,7 @@ import (
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/lightningnetwork/lnd/lnwallet"
"google.golang.org/protobuf/encoding/protojson"
)
const (
@@ -16,6 +17,47 @@ const (
RegisterRPCMiddlewareURI = "/lnrpc.Lightning/RegisterRPCMiddleware"
)
var (
// ProtoJSONMarshalOpts is a struct that holds the default marshal
// options for marshaling protobuf messages into JSON in a
// human-readable way. This should only be used in the CLI and in
// integration tests.
//
// TODO(guggero): Use custom fork of this library to support hex
// encoding byte slices instead of the default base64 encoding.
ProtoJSONMarshalOpts = &protojson.MarshalOptions{
EmitUnpopulated: true,
UseProtoNames: true,
Indent: " ",
}
// ProtoJSONUnmarshalOpts is a struct that holds the default unmarshal
// options for un-marshaling lncli JSON into protobuf messages. This
// should only be used in the CLI and in integration tests.
//
// TODO(guggero): Use custom fork of this library to support hex
// encoding byte slices instead of the default base64 encoding.
ProtoJSONUnmarshalOpts = &protojson.UnmarshalOptions{
AllowPartial: false,
}
// RESTJsonMarshalOpts is a struct that holds the default marshal
// options for marshaling protobuf messages into REST JSON in a
// human-readable way. This should be used when interacting with the
// REST proxy only.
RESTJsonMarshalOpts = &protojson.MarshalOptions{
EmitUnpopulated: true,
UseProtoNames: true,
}
// RESTJsonUnmarshalOpts is a struct that holds the default unmarshal
// options for un-marshaling REST JSON into protobuf messages. This
// should be used when interacting with the REST proxy only.
RESTJsonUnmarshalOpts = &protojson.UnmarshalOptions{
AllowPartial: false,
}
)
// RPCTransaction returns a rpc transaction.
func RPCTransaction(tx *lnwallet.TransactionDetail) *Transaction {
var destAddresses []string