mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-20 10:39:01 +01:00
Merge pull request #2093 from Roasbeef/walletkit-service
lnrpc: add new WalletKit sub-RPC server
This commit is contained in:
commit
eb16427dfc
@ -107,6 +107,10 @@ type chainControl struct {
|
|||||||
|
|
||||||
signer lnwallet.Signer
|
signer lnwallet.Signer
|
||||||
|
|
||||||
|
keyRing keychain.KeyRing
|
||||||
|
|
||||||
|
wc lnwallet.WalletController
|
||||||
|
|
||||||
msgSigner lnwallet.MessageSigner
|
msgSigner lnwallet.MessageSigner
|
||||||
|
|
||||||
chainNotifier chainntnfs.ChainNotifier
|
chainNotifier chainntnfs.ChainNotifier
|
||||||
@ -502,6 +506,7 @@ func newChainControlFromConfig(cfg *config, chanDB *channeldb.DB,
|
|||||||
cc.msgSigner = wc
|
cc.msgSigner = wc
|
||||||
cc.signer = wc
|
cc.signer = wc
|
||||||
cc.chainIO = wc
|
cc.chainIO = wc
|
||||||
|
cc.wc = wc
|
||||||
|
|
||||||
// Select the default channel constraints for the primary chain.
|
// Select the default channel constraints for the primary chain.
|
||||||
channelConstraints := defaultBtcChannelConstraints
|
channelConstraints := defaultBtcChannelConstraints
|
||||||
@ -512,6 +517,7 @@ func newChainControlFromConfig(cfg *config, chanDB *channeldb.DB,
|
|||||||
keyRing := keychain.NewBtcWalletKeyRing(
|
keyRing := keychain.NewBtcWalletKeyRing(
|
||||||
wc.InternalWallet(), activeNetParams.CoinType,
|
wc.InternalWallet(), activeNetParams.CoinType,
|
||||||
)
|
)
|
||||||
|
cc.keyRing = keyRing
|
||||||
|
|
||||||
// Create, and start the lnwallet, which handles the core payment
|
// Create, and start the lnwallet, which handles the core payment
|
||||||
// channel logic, and exposes control via proxy state machines.
|
// channel logic, and exposes control via proxy state machines.
|
||||||
|
@ -66,10 +66,14 @@ func (m *KeyLocator) GetKeyIndex() int32 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type KeyDescriptor struct {
|
type KeyDescriptor struct {
|
||||||
// Types that are valid to be assigned to Key:
|
// *
|
||||||
// *KeyDescriptor_RawKeyBytes
|
// The raw bytes of the key being identified. Either this or the KeyLocator
|
||||||
// *KeyDescriptor_KeyLoc
|
// must be specified.
|
||||||
Key isKeyDescriptor_Key `protobuf_oneof:"key"`
|
RawKeyBytes []byte `protobuf:"bytes,1,opt,name=raw_key_bytes,json=rawKeyBytes,proto3" json:"raw_key_bytes,omitempty"`
|
||||||
|
// *
|
||||||
|
// The key locator that identifies which key to use for signing. Either this
|
||||||
|
// or the raw bytes of the target key must be specified.
|
||||||
|
KeyLoc *KeyLocator `protobuf:"bytes,2,opt,name=key_loc,json=keyLoc" json:"key_loc,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *KeyDescriptor) Reset() { *m = KeyDescriptor{} }
|
func (m *KeyDescriptor) Reset() { *m = KeyDescriptor{} }
|
||||||
@ -77,111 +81,20 @@ func (m *KeyDescriptor) String() string { return proto.CompactTextStr
|
|||||||
func (*KeyDescriptor) ProtoMessage() {}
|
func (*KeyDescriptor) ProtoMessage() {}
|
||||||
func (*KeyDescriptor) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} }
|
func (*KeyDescriptor) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} }
|
||||||
|
|
||||||
type isKeyDescriptor_Key interface {
|
|
||||||
isKeyDescriptor_Key()
|
|
||||||
}
|
|
||||||
|
|
||||||
type KeyDescriptor_RawKeyBytes struct {
|
|
||||||
RawKeyBytes []byte `protobuf:"bytes,1,opt,name=raw_key_bytes,json=rawKeyBytes,proto3,oneof"`
|
|
||||||
}
|
|
||||||
type KeyDescriptor_KeyLoc struct {
|
|
||||||
KeyLoc *KeyLocator `protobuf:"bytes,2,opt,name=key_loc,json=keyLoc,oneof"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (*KeyDescriptor_RawKeyBytes) isKeyDescriptor_Key() {}
|
|
||||||
func (*KeyDescriptor_KeyLoc) isKeyDescriptor_Key() {}
|
|
||||||
|
|
||||||
func (m *KeyDescriptor) GetKey() isKeyDescriptor_Key {
|
|
||||||
if m != nil {
|
|
||||||
return m.Key
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *KeyDescriptor) GetRawKeyBytes() []byte {
|
func (m *KeyDescriptor) GetRawKeyBytes() []byte {
|
||||||
if x, ok := m.GetKey().(*KeyDescriptor_RawKeyBytes); ok {
|
if m != nil {
|
||||||
return x.RawKeyBytes
|
return m.RawKeyBytes
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *KeyDescriptor) GetKeyLoc() *KeyLocator {
|
func (m *KeyDescriptor) GetKeyLoc() *KeyLocator {
|
||||||
if x, ok := m.GetKey().(*KeyDescriptor_KeyLoc); ok {
|
if m != nil {
|
||||||
return x.KeyLoc
|
return m.KeyLoc
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX_OneofFuncs is for the internal use of the proto package.
|
|
||||||
func (*KeyDescriptor) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) {
|
|
||||||
return _KeyDescriptor_OneofMarshaler, _KeyDescriptor_OneofUnmarshaler, _KeyDescriptor_OneofSizer, []interface{}{
|
|
||||||
(*KeyDescriptor_RawKeyBytes)(nil),
|
|
||||||
(*KeyDescriptor_KeyLoc)(nil),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func _KeyDescriptor_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
|
|
||||||
m := msg.(*KeyDescriptor)
|
|
||||||
// key
|
|
||||||
switch x := m.Key.(type) {
|
|
||||||
case *KeyDescriptor_RawKeyBytes:
|
|
||||||
b.EncodeVarint(1<<3 | proto.WireBytes)
|
|
||||||
b.EncodeRawBytes(x.RawKeyBytes)
|
|
||||||
case *KeyDescriptor_KeyLoc:
|
|
||||||
b.EncodeVarint(2<<3 | proto.WireBytes)
|
|
||||||
if err := b.EncodeMessage(x.KeyLoc); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
case nil:
|
|
||||||
default:
|
|
||||||
return fmt.Errorf("KeyDescriptor.Key has unexpected type %T", x)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func _KeyDescriptor_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
|
|
||||||
m := msg.(*KeyDescriptor)
|
|
||||||
switch tag {
|
|
||||||
case 1: // key.raw_key_bytes
|
|
||||||
if wire != proto.WireBytes {
|
|
||||||
return true, proto.ErrInternalBadWireType
|
|
||||||
}
|
|
||||||
x, err := b.DecodeRawBytes(true)
|
|
||||||
m.Key = &KeyDescriptor_RawKeyBytes{x}
|
|
||||||
return true, err
|
|
||||||
case 2: // key.key_loc
|
|
||||||
if wire != proto.WireBytes {
|
|
||||||
return true, proto.ErrInternalBadWireType
|
|
||||||
}
|
|
||||||
msg := new(KeyLocator)
|
|
||||||
err := b.DecodeMessage(msg)
|
|
||||||
m.Key = &KeyDescriptor_KeyLoc{msg}
|
|
||||||
return true, err
|
|
||||||
default:
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func _KeyDescriptor_OneofSizer(msg proto.Message) (n int) {
|
|
||||||
m := msg.(*KeyDescriptor)
|
|
||||||
// key
|
|
||||||
switch x := m.Key.(type) {
|
|
||||||
case *KeyDescriptor_RawKeyBytes:
|
|
||||||
n += proto.SizeVarint(1<<3 | proto.WireBytes)
|
|
||||||
n += proto.SizeVarint(uint64(len(x.RawKeyBytes)))
|
|
||||||
n += len(x.RawKeyBytes)
|
|
||||||
case *KeyDescriptor_KeyLoc:
|
|
||||||
s := proto.Size(x.KeyLoc)
|
|
||||||
n += proto.SizeVarint(2<<3 | proto.WireBytes)
|
|
||||||
n += proto.SizeVarint(uint64(s))
|
|
||||||
n += s
|
|
||||||
case nil:
|
|
||||||
default:
|
|
||||||
panic(fmt.Sprintf("proto: unexpected type %T in oneof", x))
|
|
||||||
}
|
|
||||||
return n
|
|
||||||
}
|
|
||||||
|
|
||||||
type TxOut struct {
|
type TxOut struct {
|
||||||
// / The value of the output being spent.
|
// / The value of the output being spent.
|
||||||
Value int64 `protobuf:"varint,1,opt,name=value" json:"value,omitempty"`
|
Value int64 `protobuf:"varint,1,opt,name=value" json:"value,omitempty"`
|
||||||
@ -376,6 +289,7 @@ func (m *InputScript) GetSigScript() []byte {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type InputScriptResp struct {
|
type InputScriptResp struct {
|
||||||
|
// / The set of fully valid input scripts requested.
|
||||||
InputScripts []*InputScript `protobuf:"bytes,1,rep,name=input_scripts,json=inputScripts" json:"input_scripts,omitempty"`
|
InputScripts []*InputScript `protobuf:"bytes,1,rep,name=input_scripts,json=inputScripts" json:"input_scripts,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -550,39 +464,38 @@ var _Signer_serviceDesc = grpc.ServiceDesc{
|
|||||||
func init() { proto.RegisterFile("signrpc/signer.proto", fileDescriptor0) }
|
func init() { proto.RegisterFile("signrpc/signer.proto", fileDescriptor0) }
|
||||||
|
|
||||||
var fileDescriptor0 = []byte{
|
var fileDescriptor0 = []byte{
|
||||||
// 536 bytes of a gzipped FileDescriptorProto
|
// 526 bytes of a gzipped FileDescriptorProto
|
||||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x93, 0xd1, 0x8f, 0xd2, 0x40,
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x53, 0x5f, 0x6f, 0xd3, 0x3e,
|
||||||
0x10, 0xc6, 0x0f, 0x10, 0xca, 0x4d, 0x5b, 0xd4, 0x95, 0x68, 0xd5, 0x18, 0xb1, 0xf1, 0x0c, 0x4f,
|
0x14, 0x55, 0xd7, 0x5f, 0x9b, 0xee, 0x26, 0xd9, 0x0f, 0x4c, 0x05, 0x01, 0x84, 0x28, 0x91, 0x86,
|
||||||
0x18, 0xd1, 0x98, 0xe8, 0x93, 0x39, 0xcd, 0x85, 0x0b, 0x97, 0x5c, 0xb2, 0xf0, 0xde, 0x94, 0xb2,
|
0xfa, 0x80, 0x8a, 0x28, 0x08, 0x09, 0x9e, 0x10, 0xa0, 0x89, 0xa9, 0x93, 0x26, 0xb9, 0x7d, 0x8f,
|
||||||
0xf6, 0x36, 0xe5, 0xda, 0x5e, 0x77, 0x6b, 0xe9, 0x9b, 0xff, 0x83, 0xff, 0xb0, 0x99, 0xdd, 0x05,
|
0xdc, 0xd4, 0x64, 0x56, 0xba, 0xc4, 0x8b, 0x1d, 0xd2, 0xbc, 0xf1, 0x1d, 0xf8, 0xc2, 0xe8, 0xda,
|
||||||
0x8a, 0xde, 0x13, 0x7c, 0x5f, 0x67, 0x67, 0x7e, 0x3b, 0x5f, 0x0b, 0x43, 0xc1, 0xe3, 0xb4, 0xc8,
|
0xee, 0x3f, 0xe0, 0xa9, 0x39, 0xc7, 0xf7, 0xde, 0x73, 0x7c, 0x4f, 0x0d, 0x43, 0x25, 0xb2, 0xa2,
|
||||||
0xa3, 0xf7, 0xf8, 0xcb, 0x8a, 0x49, 0x5e, 0x64, 0x32, 0x23, 0x96, 0x71, 0xfd, 0x19, 0xc0, 0x9c,
|
0x92, 0xe9, 0x6b, 0xfc, 0xe5, 0xd5, 0x44, 0x56, 0xa5, 0x2e, 0x89, 0xe7, 0xd8, 0xf8, 0x1b, 0xc0,
|
||||||
0xd5, 0x57, 0x59, 0x14, 0xca, 0xac, 0x20, 0xaf, 0x00, 0x12, 0x56, 0x07, 0x3f, 0xc3, 0x5b, 0xbe,
|
0x8c, 0xb7, 0x57, 0x65, 0xca, 0x74, 0x59, 0x91, 0x67, 0x00, 0x39, 0x6f, 0x93, 0xef, 0xec, 0x56,
|
||||||
0xa9, 0xbd, 0xd6, 0xa8, 0x35, 0xee, 0xd2, 0xd3, 0x84, 0xd5, 0x17, 0xca, 0x20, 0x2f, 0x01, 0x45,
|
0xac, 0xdb, 0xa8, 0x33, 0xea, 0x8c, 0x7b, 0xf4, 0x34, 0xe7, 0xed, 0x85, 0x21, 0xc8, 0x53, 0x40,
|
||||||
0xc0, 0xd3, 0x35, 0xdb, 0x7a, 0x6d, 0xf5, 0xb4, 0x9f, 0xb0, 0xfa, 0x12, 0xb5, 0xbf, 0x01, 0x77,
|
0x90, 0x88, 0x62, 0xc5, 0x37, 0xd1, 0x89, 0x39, 0x1d, 0xe4, 0xbc, 0xbd, 0x44, 0x1c, 0x33, 0x08,
|
||||||
0xce, 0xea, 0x1f, 0x4c, 0x44, 0x05, 0xcf, 0xb1, 0xd9, 0x5b, 0x70, 0x8b, 0xb0, 0x0a, 0xf0, 0xc4,
|
0x67, 0xbc, 0xfd, 0xca, 0x55, 0x5a, 0x09, 0x89, 0xc3, 0x62, 0x08, 0x2b, 0xd6, 0x24, 0xd8, 0xb1,
|
||||||
0xaa, 0x96, 0x4c, 0xa8, 0x7e, 0xce, 0xec, 0x84, 0xda, 0x45, 0x58, 0xcd, 0x59, 0x7d, 0x8e, 0x26,
|
0x6c, 0x35, 0x57, 0x66, 0x5e, 0x40, 0xfd, 0x8a, 0x35, 0x33, 0xde, 0x7e, 0x46, 0x8a, 0xbc, 0x02,
|
||||||
0x99, 0x80, 0x85, 0x15, 0x9b, 0x2c, 0x52, 0x1d, 0xed, 0xe9, 0x93, 0x89, 0x61, 0x9b, 0x1c, 0xc0,
|
0x0f, 0xcf, 0xd7, 0x65, 0x6a, 0xe6, 0xf9, 0xd3, 0x07, 0x13, 0xe7, 0x6c, 0xb2, 0xb7, 0x45, 0xfb,
|
||||||
0x66, 0x27, 0xb4, 0x97, 0x28, 0x75, 0xde, 0x85, 0x4e, 0xc2, 0x6a, 0xff, 0x2b, 0x74, 0x97, 0xdb,
|
0xb9, 0xf9, 0x8e, 0x3f, 0x42, 0x6f, 0xb1, 0xb9, 0xae, 0x35, 0x19, 0x42, 0xef, 0x07, 0x5b, 0xd7,
|
||||||
0xeb, 0x52, 0x92, 0x21, 0x74, 0x7f, 0x85, 0x9b, 0x92, 0xa9, 0xee, 0x1d, 0xaa, 0x05, 0x92, 0xe6,
|
0xdc, 0x8c, 0xec, 0x52, 0x0b, 0xd0, 0x9e, 0xcc, 0x13, 0xab, 0x6f, 0xc6, 0x05, 0x74, 0x20, 0xf3,
|
||||||
0x49, 0xa0, 0x51, 0x54, 0x5f, 0x87, 0xf6, 0xf3, 0x64, 0xa1, 0xb4, 0xff, 0xa7, 0x0d, 0x83, 0x05,
|
0xb9, 0xc1, 0xf1, 0xaf, 0x13, 0x38, 0x9b, 0x8b, 0xac, 0x38, 0x30, 0xf8, 0x06, 0xd0, 0x7d, 0xb2,
|
||||||
0x8f, 0xd3, 0x06, 0xeb, 0x07, 0xc0, 0x8b, 0x04, 0x6b, 0x26, 0x22, 0xd5, 0xc8, 0x9e, 0x3e, 0x6d,
|
0xe2, 0x2a, 0x35, 0x83, 0xfc, 0xe9, 0xc3, 0x43, 0xf5, 0x7d, 0x25, 0x45, 0x93, 0x08, 0xc9, 0x0b,
|
||||||
0x62, 0x1c, 0x2a, 0x29, 0xd2, 0xa2, 0x24, 0x6f, 0xc0, 0x11, 0x3c, 0x8d, 0x37, 0x2c, 0x90, 0x15,
|
0x08, 0x94, 0x28, 0xb2, 0x35, 0x4f, 0x74, 0xc3, 0x59, 0xee, 0x54, 0x7c, 0xcb, 0x2d, 0x90, 0xc2,
|
||||||
0x0b, 0x13, 0x33, 0xc5, 0xd6, 0xde, 0x12, 0x2d, 0x2c, 0x59, 0x67, 0xe5, 0x6a, 0x5f, 0xd2, 0xd1,
|
0x92, 0x55, 0x59, 0x2f, 0x77, 0x25, 0x5d, 0x5b, 0x62, 0x39, 0x5b, 0x72, 0x0e, 0x67, 0x8d, 0xd0,
|
||||||
0x25, 0xda, 0xd3, 0x25, 0x67, 0x30, 0xa8, 0xb8, 0x4c, 0x99, 0x10, 0x3b, 0xda, 0x07, 0xaa, 0xc8,
|
0x05, 0x57, 0x6a, 0xeb, 0xf6, 0x3f, 0x53, 0x14, 0x3a, 0xd6, 0x5a, 0x26, 0x2f, 0xa1, 0x5f, 0xd6,
|
||||||
0x35, 0xae, 0x46, 0x26, 0xef, 0xa0, 0x97, 0x95, 0x32, 0x2f, 0xa5, 0xd7, 0x55, 0x74, 0x83, 0x3d,
|
0x5a, 0xd6, 0x3a, 0xea, 0x19, 0x77, 0x67, 0x3b, 0x77, 0x66, 0x0b, 0xd4, 0x9d, 0x92, 0x08, 0x30,
|
||||||
0x9d, 0xda, 0x02, 0x35, 0x4f, 0x89, 0x07, 0x98, 0xec, 0x4d, 0x28, 0x6e, 0x3c, 0x6b, 0xd4, 0x1a,
|
0xce, 0x1b, 0xa6, 0x6e, 0x22, 0x6f, 0xd4, 0x19, 0x87, 0x74, 0x0b, 0xc9, 0x73, 0xf0, 0x45, 0x21,
|
||||||
0xbb, 0x74, 0x27, 0xc9, 0x6b, 0xb0, 0x79, 0x9a, 0x97, 0xd2, 0xa4, 0xd7, 0x57, 0xe9, 0x81, 0xb2,
|
0x6b, 0xed, 0x22, 0x1b, 0x98, 0xc8, 0xc0, 0x50, 0x36, 0xb4, 0x14, 0x3c, 0x5c, 0x0a, 0xe5, 0x77,
|
||||||
0x74, 0x7e, 0x11, 0x58, 0xb8, 0x14, 0xca, 0xee, 0xc8, 0x08, 0x1c, 0x4c, 0x4e, 0x6e, 0x9b, 0xc1,
|
0x64, 0x04, 0x01, 0xc6, 0xa5, 0x37, 0x47, 0x69, 0x41, 0xc5, 0x9a, 0xc5, 0xc6, 0x86, 0xf5, 0x1e,
|
||||||
0x51, 0x28, 0xc2, 0x6a, 0xb9, 0xd5, 0xa9, 0x7d, 0x06, 0x40, 0x00, 0xb5, 0x30, 0xe1, 0xb5, 0x47,
|
0x00, 0x0d, 0x98, 0x85, 0xa9, 0xe8, 0x64, 0xd4, 0x1d, 0xfb, 0xd3, 0x47, 0x3b, 0x4f, 0xc7, 0xcb,
|
||||||
0x9d, 0xb1, 0x3d, 0x7d, 0xb6, 0x67, 0x3a, 0x5e, 0x2e, 0x3d, 0x15, 0x46, 0x0b, 0xff, 0x0c, 0xfa,
|
0xa5, 0xa7, 0xca, 0x61, 0x15, 0x9f, 0xc3, 0xc0, 0x8a, 0x28, 0x49, 0x1e, 0xc3, 0x00, 0x55, 0x94,
|
||||||
0x7a, 0x88, 0xc8, 0xc9, 0x73, 0xe8, 0xe3, 0x14, 0xc1, 0x63, 0x9c, 0xd0, 0x19, 0x3b, 0xd4, 0x2a,
|
0xc8, 0x50, 0xa1, 0x3b, 0x0e, 0xa8, 0x57, 0xb1, 0x66, 0x2e, 0x32, 0x15, 0x5f, 0x80, 0x7f, 0x89,
|
||||||
0xc2, 0x6a, 0xc1, 0x63, 0xe1, 0x5f, 0x80, 0x7d, 0x89, 0x64, 0xe6, 0xf6, 0x1e, 0x58, 0x66, 0x1d,
|
0xce, 0xdc, 0xed, 0x23, 0xf0, 0xdc, 0x3a, 0xb6, 0x85, 0x0e, 0xe2, 0xbf, 0x54, 0x89, 0xec, 0x38,
|
||||||
0xbb, 0x42, 0x23, 0xf1, 0x85, 0x15, 0x3c, 0x3e, 0x0e, 0x1a, 0xc7, 0x99, 0xa4, 0xaf, 0xe0, 0x61,
|
0x68, 0x94, 0x73, 0x49, 0x5f, 0xc1, 0xff, 0x07, 0x73, 0x8c, 0xea, 0x07, 0x08, 0xed, 0x1e, 0x6c,
|
||||||
0xa3, 0x8f, 0x9a, 0xfa, 0x05, 0x5c, 0xbd, 0x07, 0x7d, 0x46, 0x77, 0xb4, 0xa7, 0xc3, 0x3d, 0x7c,
|
0x8f, 0x9d, 0xe8, 0x4f, 0x87, 0x3b, 0xf3, 0x87, 0x0d, 0x81, 0xd8, 0x03, 0x35, 0xfd, 0xd9, 0x81,
|
||||||
0xf3, 0x80, 0xc3, 0x0f, 0x42, 0x4c, 0x7f, 0xb7, 0xa0, 0xb7, 0x50, 0x5f, 0x11, 0xf9, 0x04, 0x2e,
|
0xfe, 0xdc, 0x3c, 0x1d, 0xf2, 0x0e, 0x42, 0xfc, 0xba, 0x36, 0x5b, 0xa7, 0xac, 0x21, 0xf7, 0x8e,
|
||||||
0xfe, 0xbb, 0x56, 0x5b, 0xa7, 0x61, 0x45, 0x1e, 0x1d, 0x5d, 0x9e, 0xb2, 0xbb, 0x17, 0x8f, 0xff,
|
0x2e, 0x4f, 0xf9, 0xdd, 0x93, 0xfb, 0x7f, 0x30, 0x4a, 0x92, 0x4f, 0x40, 0xbe, 0x94, 0xb7, 0xb2,
|
||||||
0x71, 0x44, 0x4e, 0xbe, 0x01, 0xf9, 0x9e, 0xdd, 0xe6, 0xa5, 0x64, 0xcd, 0xdb, 0xfd, 0x7f, 0xd4,
|
0xd6, 0xfc, 0xf0, 0x76, 0x7f, 0xb7, 0x46, 0xff, 0x34, 0xc3, 0x95, 0x5c, 0xf6, 0xcd, 0x9b, 0x7d,
|
||||||
0xbb, 0x17, 0x86, 0x89, 0x7c, 0xd5, 0x53, 0x9f, 0xef, 0xc7, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff,
|
0xfb, 0x3b, 0x00, 0x00, 0xff, 0xff, 0xe8, 0x77, 0xc6, 0x62, 0xcb, 0x03, 0x00, 0x00,
|
||||||
0x7b, 0x48, 0x93, 0x2a, 0xd6, 0x03, 0x00, 0x00,
|
|
||||||
}
|
}
|
||||||
|
@ -11,19 +11,17 @@ message KeyLocator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
message KeyDescriptor {
|
message KeyDescriptor {
|
||||||
oneof key {
|
/**
|
||||||
/**
|
The raw bytes of the key being identified. Either this or the KeyLocator
|
||||||
The raw bytes of the key being identified. Either this or the KeyLocator
|
must be specified.
|
||||||
must be specified.
|
*/
|
||||||
*/
|
bytes raw_key_bytes = 1;
|
||||||
bytes raw_key_bytes = 1;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The key locator that identifies which key to use for signing. Either this
|
The key locator that identifies which key to use for signing. Either this
|
||||||
or the raw bytes of the target key must be specified.
|
or the raw bytes of the target key must be specified.
|
||||||
*/
|
*/
|
||||||
KeyLocator key_loc = 2;
|
KeyLocator key_loc = 2;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message TxOut {
|
message TxOut {
|
||||||
|
41
lnrpc/walletrpc/config_active.go
Normal file
41
lnrpc/walletrpc/config_active.go
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
// +build walletrpc
|
||||||
|
|
||||||
|
package walletrpc
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/lightningnetwork/lnd/keychain"
|
||||||
|
"github.com/lightningnetwork/lnd/lnwallet"
|
||||||
|
"github.com/lightningnetwork/lnd/macaroons"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Config is the primary configuration struct for the WalletKit RPC server. It
|
||||||
|
// contains all the items required for the signer rpc server to carry out its
|
||||||
|
// duties. The fields with struct tags are meant to be parsed as normal
|
||||||
|
// configuration options, while if able to be populated, the latter fields MUST
|
||||||
|
// also be specified.
|
||||||
|
type Config struct {
|
||||||
|
// WalletKitMacPath is the path for the signer macaroon. If unspecified
|
||||||
|
// then we assume that the macaroon will be found under the network
|
||||||
|
// directory, named DefaultWalletKitMacFilename.
|
||||||
|
WalletKitMacPath string `long:"walletkitmacaroonpath" description:"Path to the wallet kit macaroon"`
|
||||||
|
|
||||||
|
// NetworkDir is the main network directory wherein the signer rpc
|
||||||
|
// server will find the macaroon named DefaultWalletKitMacFilename.
|
||||||
|
NetworkDir string
|
||||||
|
|
||||||
|
// MacService is the main macaroon service that we'll use to handle
|
||||||
|
// authentication for the signer rpc server.
|
||||||
|
MacService *macaroons.Service
|
||||||
|
|
||||||
|
// FeeEstimator is an instance of the primary fee estimator instance
|
||||||
|
// the WalletKit will use to respond to fee estimation requests.
|
||||||
|
FeeEstimator lnwallet.FeeEstimator
|
||||||
|
|
||||||
|
// Wallet is the primary wallet that the WalletKit will use to proxy
|
||||||
|
// any relevant requests to.
|
||||||
|
Wallet lnwallet.WalletController
|
||||||
|
|
||||||
|
// KeyRing is an interface that the WalletKit will use to derive any
|
||||||
|
// keys due to incoming client requests.
|
||||||
|
KeyRing keychain.KeyRing
|
||||||
|
}
|
8
lnrpc/walletrpc/config_default.go
Normal file
8
lnrpc/walletrpc/config_default.go
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
// +build !walletrpc
|
||||||
|
|
||||||
|
package walletrpc
|
||||||
|
|
||||||
|
// Config is the primary configuration struct for the WalletKit RPC server.
|
||||||
|
// When the server isn't active (via the build flag), callers outside this
|
||||||
|
// package will see this shell of a config file.
|
||||||
|
type Config struct{}
|
73
lnrpc/walletrpc/driver.go
Normal file
73
lnrpc/walletrpc/driver.go
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
// +build walletrpc
|
||||||
|
|
||||||
|
package walletrpc
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
|
)
|
||||||
|
|
||||||
|
// createNewSubServer is a helper method that will create the new WalletKit RPC
|
||||||
|
// sub server given the main config dispatcher method. If we're unable to find
|
||||||
|
// the config that is meant for us in the config dispatcher, then we'll exit
|
||||||
|
// with an error.
|
||||||
|
func createNewSubServer(configRegistry lnrpc.SubServerConfigDispatcher) (lnrpc.SubServer, lnrpc.MacaroonPerms, error) {
|
||||||
|
// We'll attempt to look up the config that we expect, according to our
|
||||||
|
// subServerName name. If we can't find this, then we'll exit with an
|
||||||
|
// error, as we're unable to properly initialize ourselves without this
|
||||||
|
// config.
|
||||||
|
walletKitServerConf, ok := configRegistry.FetchConfig(subServerName)
|
||||||
|
if !ok {
|
||||||
|
return nil, nil, fmt.Errorf("unable to find config for "+
|
||||||
|
"subserver type %s", subServerName)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now that we've found an object mapping to our service name, we'll
|
||||||
|
// ensure that it's the type we need.
|
||||||
|
config, ok := walletKitServerConf.(*Config)
|
||||||
|
if !ok {
|
||||||
|
return nil, nil, fmt.Errorf("wrong type of config for "+
|
||||||
|
"subserver %s, expected %T got %T", subServerName,
|
||||||
|
&Config{}, walletKitServerConf)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Before we try to make the new WalletKit service instance, we'll
|
||||||
|
// perform some sanity checks on the arguments to ensure that they're
|
||||||
|
// useable.
|
||||||
|
switch {
|
||||||
|
case config.MacService != nil && config.NetworkDir == "":
|
||||||
|
return nil, nil, fmt.Errorf("NetworkDir must be set to " +
|
||||||
|
"create WalletKit RPC server")
|
||||||
|
|
||||||
|
case config.FeeEstimator == nil:
|
||||||
|
return nil, nil, fmt.Errorf("FeeEstimator must be set to " +
|
||||||
|
"create WalletKit RPC server")
|
||||||
|
|
||||||
|
case config.Wallet == nil:
|
||||||
|
return nil, nil, fmt.Errorf("Wallet must be set to create " +
|
||||||
|
"WalletKit RPC server")
|
||||||
|
|
||||||
|
case config.KeyRing == nil:
|
||||||
|
return nil, nil, fmt.Errorf("KeyRing must be set to create " +
|
||||||
|
"WalletKit RPC server")
|
||||||
|
}
|
||||||
|
|
||||||
|
return New(config)
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
subServer := &lnrpc.SubServerDriver{
|
||||||
|
SubServerName: subServerName,
|
||||||
|
New: func(c lnrpc.SubServerConfigDispatcher) (lnrpc.SubServer, lnrpc.MacaroonPerms, error) {
|
||||||
|
return createNewSubServer(c)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the build tag is active, then we'll register ourselves as a
|
||||||
|
// sub-RPC server within the global lnrpc package namespace.
|
||||||
|
if err := lnrpc.RegisterSubServer(subServer); err != nil {
|
||||||
|
panic(fmt.Sprintf("failed to register sub server driver '%s': %v",
|
||||||
|
subServerName, err))
|
||||||
|
}
|
||||||
|
}
|
6
lnrpc/walletrpc/gen_protos.sh
Executable file
6
lnrpc/walletrpc/gen_protos.sh
Executable file
@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
protoc -I/usr/local/include -I. \
|
||||||
|
-I$GOPATH/src \
|
||||||
|
--go_out=plugins=grpc:. \
|
||||||
|
walletkit.proto
|
45
lnrpc/walletrpc/log.go
Normal file
45
lnrpc/walletrpc/log.go
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
package walletrpc
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/btcsuite/btclog"
|
||||||
|
"github.com/lightningnetwork/lnd/build"
|
||||||
|
)
|
||||||
|
|
||||||
|
// log is a logger that is initialized with no output filters. This means the
|
||||||
|
// package will not perform any logging by default until the caller requests
|
||||||
|
// it.
|
||||||
|
var log btclog.Logger
|
||||||
|
|
||||||
|
// The default amount of logging is none.
|
||||||
|
func init() {
|
||||||
|
UseLogger(build.NewSubLogger("WLKT", nil))
|
||||||
|
}
|
||||||
|
|
||||||
|
// DisableLog disables all library log output. Logging output is disabled by
|
||||||
|
// by default until UseLogger is called.
|
||||||
|
func DisableLog() {
|
||||||
|
UseLogger(btclog.Disabled)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UseLogger uses a specified Logger to output package logging info. This
|
||||||
|
// should be used in preference to SetLogWriter if the caller is also using
|
||||||
|
// btclog.
|
||||||
|
func UseLogger(logger btclog.Logger) {
|
||||||
|
log = logger
|
||||||
|
}
|
||||||
|
|
||||||
|
// logClosure is used to provide a closure over expensive logging operations so
|
||||||
|
// don't have to be performed when the logging level doesn't warrant it.
|
||||||
|
type logClosure func() string
|
||||||
|
|
||||||
|
// String invokes the underlying function and returns the result.
|
||||||
|
func (c logClosure) String() string {
|
||||||
|
return c()
|
||||||
|
}
|
||||||
|
|
||||||
|
// newLogClosure returns a new closure over a function that returns a string
|
||||||
|
// which itself provides a Stringer interface so that it can be used with the
|
||||||
|
// logging system.
|
||||||
|
func newLogClosure(c func() string) logClosure {
|
||||||
|
return logClosure(c)
|
||||||
|
}
|
555
lnrpc/walletrpc/walletkit.pb.go
Normal file
555
lnrpc/walletrpc/walletkit.pb.go
Normal file
@ -0,0 +1,555 @@
|
|||||||
|
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||||
|
// source: walletrpc/walletkit.proto
|
||||||
|
|
||||||
|
/*
|
||||||
|
Package walletrpc is a generated protocol buffer package.
|
||||||
|
|
||||||
|
It is generated from these files:
|
||||||
|
walletrpc/walletkit.proto
|
||||||
|
|
||||||
|
It has these top-level messages:
|
||||||
|
KeyReq
|
||||||
|
AddrRequest
|
||||||
|
AddrResponse
|
||||||
|
Transaction
|
||||||
|
PublishResponse
|
||||||
|
SendOutputsRequest
|
||||||
|
SendOutputsResponse
|
||||||
|
EstimateFeeRequest
|
||||||
|
EstimateFeeResponse
|
||||||
|
*/
|
||||||
|
package walletrpc
|
||||||
|
|
||||||
|
import proto "github.com/golang/protobuf/proto"
|
||||||
|
import fmt "fmt"
|
||||||
|
import math "math"
|
||||||
|
import signrpc "github.com/lightningnetwork/lnd/lnrpc/signrpc"
|
||||||
|
|
||||||
|
import (
|
||||||
|
context "golang.org/x/net/context"
|
||||||
|
grpc "google.golang.org/grpc"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Reference imports to suppress errors if they are not otherwise used.
|
||||||
|
var _ = proto.Marshal
|
||||||
|
var _ = fmt.Errorf
|
||||||
|
var _ = math.Inf
|
||||||
|
|
||||||
|
// This is a compile-time assertion to ensure that this generated file
|
||||||
|
// is compatible with the proto package it is being compiled against.
|
||||||
|
// A compilation error at this line likely means your copy of the
|
||||||
|
// proto package needs to be updated.
|
||||||
|
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
|
||||||
|
|
||||||
|
type KeyReq struct {
|
||||||
|
// *
|
||||||
|
// Is the key finger print of the root pubkey that this request is targeting.
|
||||||
|
// This allows the WalletKit to possibly serve out keys for multiple HD chains
|
||||||
|
// via public derivation.
|
||||||
|
KeyFingerPrint int32 `protobuf:"varint,1,opt,name=key_finger_print,json=keyFingerPrint" json:"key_finger_print,omitempty"`
|
||||||
|
// *
|
||||||
|
// The target key family to derive a key from. In other contexts, this is
|
||||||
|
// known as the "account".
|
||||||
|
KeyFamily int32 `protobuf:"varint,2,opt,name=key_family,json=keyFamily" json:"key_family,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *KeyReq) Reset() { *m = KeyReq{} }
|
||||||
|
func (m *KeyReq) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*KeyReq) ProtoMessage() {}
|
||||||
|
func (*KeyReq) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
|
||||||
|
|
||||||
|
func (m *KeyReq) GetKeyFingerPrint() int32 {
|
||||||
|
if m != nil {
|
||||||
|
return m.KeyFingerPrint
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *KeyReq) GetKeyFamily() int32 {
|
||||||
|
if m != nil {
|
||||||
|
return m.KeyFamily
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
type AddrRequest struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *AddrRequest) Reset() { *m = AddrRequest{} }
|
||||||
|
func (m *AddrRequest) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*AddrRequest) ProtoMessage() {}
|
||||||
|
func (*AddrRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} }
|
||||||
|
|
||||||
|
type AddrResponse struct {
|
||||||
|
// *
|
||||||
|
// The address encoded using a bech32 format.
|
||||||
|
Addr string `protobuf:"bytes,1,opt,name=addr" json:"addr,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *AddrResponse) Reset() { *m = AddrResponse{} }
|
||||||
|
func (m *AddrResponse) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*AddrResponse) ProtoMessage() {}
|
||||||
|
func (*AddrResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} }
|
||||||
|
|
||||||
|
func (m *AddrResponse) GetAddr() string {
|
||||||
|
if m != nil {
|
||||||
|
return m.Addr
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
type Transaction struct {
|
||||||
|
// *
|
||||||
|
// The raw serialized transaction.
|
||||||
|
TxHex []byte `protobuf:"bytes,1,opt,name=tx_hex,json=txHex,proto3" json:"tx_hex,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Transaction) Reset() { *m = Transaction{} }
|
||||||
|
func (m *Transaction) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*Transaction) ProtoMessage() {}
|
||||||
|
func (*Transaction) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} }
|
||||||
|
|
||||||
|
func (m *Transaction) GetTxHex() []byte {
|
||||||
|
if m != nil {
|
||||||
|
return m.TxHex
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type PublishResponse struct {
|
||||||
|
// *
|
||||||
|
// If blank, then no error occurred and the transaction was successfully
|
||||||
|
// published. If not the empty string, then a string representation of the
|
||||||
|
// broadcast error.
|
||||||
|
//
|
||||||
|
// TODO(roasbeef): map to a proper enum type
|
||||||
|
PublishError string `protobuf:"bytes,1,opt,name=publish_error,json=publishError" json:"publish_error,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *PublishResponse) Reset() { *m = PublishResponse{} }
|
||||||
|
func (m *PublishResponse) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*PublishResponse) ProtoMessage() {}
|
||||||
|
func (*PublishResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{4} }
|
||||||
|
|
||||||
|
func (m *PublishResponse) GetPublishError() string {
|
||||||
|
if m != nil {
|
||||||
|
return m.PublishError
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
type SendOutputsRequest struct {
|
||||||
|
// *
|
||||||
|
// The number of satoshis per kilo weight that should be used when crafting
|
||||||
|
// this transaction.
|
||||||
|
SatPerKw int64 `protobuf:"varint,1,opt,name=sat_per_kw,json=satPerKw" json:"sat_per_kw,omitempty"`
|
||||||
|
// *
|
||||||
|
// A slice of the outputs that should be created in the transaction produced.
|
||||||
|
Outputs []*signrpc.TxOut `protobuf:"bytes,2,rep,name=outputs" json:"outputs,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *SendOutputsRequest) Reset() { *m = SendOutputsRequest{} }
|
||||||
|
func (m *SendOutputsRequest) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*SendOutputsRequest) ProtoMessage() {}
|
||||||
|
func (*SendOutputsRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{5} }
|
||||||
|
|
||||||
|
func (m *SendOutputsRequest) GetSatPerKw() int64 {
|
||||||
|
if m != nil {
|
||||||
|
return m.SatPerKw
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *SendOutputsRequest) GetOutputs() []*signrpc.TxOut {
|
||||||
|
if m != nil {
|
||||||
|
return m.Outputs
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type SendOutputsResponse struct {
|
||||||
|
// *
|
||||||
|
// The serialized transaction sent out on the network.
|
||||||
|
RawTx []byte `protobuf:"bytes,1,opt,name=raw_tx,json=rawTx,proto3" json:"raw_tx,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *SendOutputsResponse) Reset() { *m = SendOutputsResponse{} }
|
||||||
|
func (m *SendOutputsResponse) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*SendOutputsResponse) ProtoMessage() {}
|
||||||
|
func (*SendOutputsResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{6} }
|
||||||
|
|
||||||
|
func (m *SendOutputsResponse) GetRawTx() []byte {
|
||||||
|
if m != nil {
|
||||||
|
return m.RawTx
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type EstimateFeeRequest struct {
|
||||||
|
// *
|
||||||
|
// The number of confirmations to shoot for when estimating the fee.
|
||||||
|
ConfTarget int32 `protobuf:"varint,1,opt,name=conf_target,json=confTarget" json:"conf_target,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *EstimateFeeRequest) Reset() { *m = EstimateFeeRequest{} }
|
||||||
|
func (m *EstimateFeeRequest) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*EstimateFeeRequest) ProtoMessage() {}
|
||||||
|
func (*EstimateFeeRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{7} }
|
||||||
|
|
||||||
|
func (m *EstimateFeeRequest) GetConfTarget() int32 {
|
||||||
|
if m != nil {
|
||||||
|
return m.ConfTarget
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
type EstimateFeeResponse struct {
|
||||||
|
// *
|
||||||
|
// The amount of satoshis per kw that should be used in order to reach the
|
||||||
|
// confirmation target in the request.
|
||||||
|
SatPerKw int64 `protobuf:"varint,1,opt,name=sat_per_kw,json=satPerKw" json:"sat_per_kw,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *EstimateFeeResponse) Reset() { *m = EstimateFeeResponse{} }
|
||||||
|
func (m *EstimateFeeResponse) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*EstimateFeeResponse) ProtoMessage() {}
|
||||||
|
func (*EstimateFeeResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{8} }
|
||||||
|
|
||||||
|
func (m *EstimateFeeResponse) GetSatPerKw() int64 {
|
||||||
|
if m != nil {
|
||||||
|
return m.SatPerKw
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
proto.RegisterType((*KeyReq)(nil), "walletrpc.KeyReq")
|
||||||
|
proto.RegisterType((*AddrRequest)(nil), "walletrpc.AddrRequest")
|
||||||
|
proto.RegisterType((*AddrResponse)(nil), "walletrpc.AddrResponse")
|
||||||
|
proto.RegisterType((*Transaction)(nil), "walletrpc.Transaction")
|
||||||
|
proto.RegisterType((*PublishResponse)(nil), "walletrpc.PublishResponse")
|
||||||
|
proto.RegisterType((*SendOutputsRequest)(nil), "walletrpc.SendOutputsRequest")
|
||||||
|
proto.RegisterType((*SendOutputsResponse)(nil), "walletrpc.SendOutputsResponse")
|
||||||
|
proto.RegisterType((*EstimateFeeRequest)(nil), "walletrpc.EstimateFeeRequest")
|
||||||
|
proto.RegisterType((*EstimateFeeResponse)(nil), "walletrpc.EstimateFeeResponse")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reference imports to suppress errors if they are not otherwise used.
|
||||||
|
var _ context.Context
|
||||||
|
var _ grpc.ClientConn
|
||||||
|
|
||||||
|
// This is a compile-time assertion to ensure that this generated file
|
||||||
|
// is compatible with the grpc package it is being compiled against.
|
||||||
|
const _ = grpc.SupportPackageIsVersion4
|
||||||
|
|
||||||
|
// Client API for WalletKit service
|
||||||
|
|
||||||
|
type WalletKitClient interface {
|
||||||
|
// *
|
||||||
|
// DeriveNextKey attempts to derive the *next* key within the key family
|
||||||
|
// (account in BIP43) specified. This method should return the next external
|
||||||
|
// child within this branch.
|
||||||
|
DeriveNextKey(ctx context.Context, in *KeyReq, opts ...grpc.CallOption) (*signrpc.KeyDescriptor, error)
|
||||||
|
// *
|
||||||
|
// DeriveKey attempts to derive an arbitrary key specified by the passed
|
||||||
|
// KeyLocator.
|
||||||
|
DeriveKey(ctx context.Context, in *signrpc.KeyLocator, opts ...grpc.CallOption) (*signrpc.KeyDescriptor, error)
|
||||||
|
// *
|
||||||
|
// NextAddr returns the next unused address within the wallet.
|
||||||
|
NextAddr(ctx context.Context, in *AddrRequest, opts ...grpc.CallOption) (*AddrResponse, error)
|
||||||
|
// *
|
||||||
|
// PublishTransaction attempts to publish the passed transaction to the
|
||||||
|
// network. Once this returns without an error, the wallet will continually
|
||||||
|
// attempt to re-broadcast the transaction on start up, until it enters the
|
||||||
|
// chain.
|
||||||
|
PublishTransaction(ctx context.Context, in *Transaction, opts ...grpc.CallOption) (*PublishResponse, error)
|
||||||
|
// *
|
||||||
|
// SendOutputs is similar to the existing sendmany call in Bitcoind, and
|
||||||
|
// allows the caller to create a transaction that sends to several outputs at
|
||||||
|
// once. This is ideal when wanting to batch create a set of transactions.
|
||||||
|
SendOutputs(ctx context.Context, in *SendOutputsRequest, opts ...grpc.CallOption) (*SendOutputsResponse, error)
|
||||||
|
// *
|
||||||
|
// EstimateFee attempts to query the internal fee estimator of the wallet to
|
||||||
|
// determine the fee (in sat/kw) to attach to a transaction in order to
|
||||||
|
// achieve the confirmation target.
|
||||||
|
EstimateFee(ctx context.Context, in *EstimateFeeRequest, opts ...grpc.CallOption) (*EstimateFeeResponse, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type walletKitClient struct {
|
||||||
|
cc *grpc.ClientConn
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewWalletKitClient(cc *grpc.ClientConn) WalletKitClient {
|
||||||
|
return &walletKitClient{cc}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *walletKitClient) DeriveNextKey(ctx context.Context, in *KeyReq, opts ...grpc.CallOption) (*signrpc.KeyDescriptor, error) {
|
||||||
|
out := new(signrpc.KeyDescriptor)
|
||||||
|
err := grpc.Invoke(ctx, "/walletrpc.WalletKit/DeriveNextKey", in, out, c.cc, opts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *walletKitClient) DeriveKey(ctx context.Context, in *signrpc.KeyLocator, opts ...grpc.CallOption) (*signrpc.KeyDescriptor, error) {
|
||||||
|
out := new(signrpc.KeyDescriptor)
|
||||||
|
err := grpc.Invoke(ctx, "/walletrpc.WalletKit/DeriveKey", in, out, c.cc, opts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *walletKitClient) NextAddr(ctx context.Context, in *AddrRequest, opts ...grpc.CallOption) (*AddrResponse, error) {
|
||||||
|
out := new(AddrResponse)
|
||||||
|
err := grpc.Invoke(ctx, "/walletrpc.WalletKit/NextAddr", in, out, c.cc, opts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *walletKitClient) PublishTransaction(ctx context.Context, in *Transaction, opts ...grpc.CallOption) (*PublishResponse, error) {
|
||||||
|
out := new(PublishResponse)
|
||||||
|
err := grpc.Invoke(ctx, "/walletrpc.WalletKit/PublishTransaction", in, out, c.cc, opts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *walletKitClient) SendOutputs(ctx context.Context, in *SendOutputsRequest, opts ...grpc.CallOption) (*SendOutputsResponse, error) {
|
||||||
|
out := new(SendOutputsResponse)
|
||||||
|
err := grpc.Invoke(ctx, "/walletrpc.WalletKit/SendOutputs", in, out, c.cc, opts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *walletKitClient) EstimateFee(ctx context.Context, in *EstimateFeeRequest, opts ...grpc.CallOption) (*EstimateFeeResponse, error) {
|
||||||
|
out := new(EstimateFeeResponse)
|
||||||
|
err := grpc.Invoke(ctx, "/walletrpc.WalletKit/EstimateFee", in, out, c.cc, opts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Server API for WalletKit service
|
||||||
|
|
||||||
|
type WalletKitServer interface {
|
||||||
|
// *
|
||||||
|
// DeriveNextKey attempts to derive the *next* key within the key family
|
||||||
|
// (account in BIP43) specified. This method should return the next external
|
||||||
|
// child within this branch.
|
||||||
|
DeriveNextKey(context.Context, *KeyReq) (*signrpc.KeyDescriptor, error)
|
||||||
|
// *
|
||||||
|
// DeriveKey attempts to derive an arbitrary key specified by the passed
|
||||||
|
// KeyLocator.
|
||||||
|
DeriveKey(context.Context, *signrpc.KeyLocator) (*signrpc.KeyDescriptor, error)
|
||||||
|
// *
|
||||||
|
// NextAddr returns the next unused address within the wallet.
|
||||||
|
NextAddr(context.Context, *AddrRequest) (*AddrResponse, error)
|
||||||
|
// *
|
||||||
|
// PublishTransaction attempts to publish the passed transaction to the
|
||||||
|
// network. Once this returns without an error, the wallet will continually
|
||||||
|
// attempt to re-broadcast the transaction on start up, until it enters the
|
||||||
|
// chain.
|
||||||
|
PublishTransaction(context.Context, *Transaction) (*PublishResponse, error)
|
||||||
|
// *
|
||||||
|
// SendOutputs is similar to the existing sendmany call in Bitcoind, and
|
||||||
|
// allows the caller to create a transaction that sends to several outputs at
|
||||||
|
// once. This is ideal when wanting to batch create a set of transactions.
|
||||||
|
SendOutputs(context.Context, *SendOutputsRequest) (*SendOutputsResponse, error)
|
||||||
|
// *
|
||||||
|
// EstimateFee attempts to query the internal fee estimator of the wallet to
|
||||||
|
// determine the fee (in sat/kw) to attach to a transaction in order to
|
||||||
|
// achieve the confirmation target.
|
||||||
|
EstimateFee(context.Context, *EstimateFeeRequest) (*EstimateFeeResponse, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
func RegisterWalletKitServer(s *grpc.Server, srv WalletKitServer) {
|
||||||
|
s.RegisterService(&_WalletKit_serviceDesc, srv)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _WalletKit_DeriveNextKey_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(KeyReq)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(WalletKitServer).DeriveNextKey(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: "/walletrpc.WalletKit/DeriveNextKey",
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(WalletKitServer).DeriveNextKey(ctx, req.(*KeyReq))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _WalletKit_DeriveKey_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(signrpc.KeyLocator)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(WalletKitServer).DeriveKey(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: "/walletrpc.WalletKit/DeriveKey",
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(WalletKitServer).DeriveKey(ctx, req.(*signrpc.KeyLocator))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _WalletKit_NextAddr_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(AddrRequest)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(WalletKitServer).NextAddr(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: "/walletrpc.WalletKit/NextAddr",
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(WalletKitServer).NextAddr(ctx, req.(*AddrRequest))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _WalletKit_PublishTransaction_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(Transaction)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(WalletKitServer).PublishTransaction(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: "/walletrpc.WalletKit/PublishTransaction",
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(WalletKitServer).PublishTransaction(ctx, req.(*Transaction))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _WalletKit_SendOutputs_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(SendOutputsRequest)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(WalletKitServer).SendOutputs(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: "/walletrpc.WalletKit/SendOutputs",
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(WalletKitServer).SendOutputs(ctx, req.(*SendOutputsRequest))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _WalletKit_EstimateFee_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(EstimateFeeRequest)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(WalletKitServer).EstimateFee(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: "/walletrpc.WalletKit/EstimateFee",
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(WalletKitServer).EstimateFee(ctx, req.(*EstimateFeeRequest))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
var _WalletKit_serviceDesc = grpc.ServiceDesc{
|
||||||
|
ServiceName: "walletrpc.WalletKit",
|
||||||
|
HandlerType: (*WalletKitServer)(nil),
|
||||||
|
Methods: []grpc.MethodDesc{
|
||||||
|
{
|
||||||
|
MethodName: "DeriveNextKey",
|
||||||
|
Handler: _WalletKit_DeriveNextKey_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "DeriveKey",
|
||||||
|
Handler: _WalletKit_DeriveKey_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "NextAddr",
|
||||||
|
Handler: _WalletKit_NextAddr_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "PublishTransaction",
|
||||||
|
Handler: _WalletKit_PublishTransaction_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "SendOutputs",
|
||||||
|
Handler: _WalletKit_SendOutputs_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "EstimateFee",
|
||||||
|
Handler: _WalletKit_EstimateFee_Handler,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Streams: []grpc.StreamDesc{},
|
||||||
|
Metadata: "walletrpc/walletkit.proto",
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() { proto.RegisterFile("walletrpc/walletkit.proto", fileDescriptor0) }
|
||||||
|
|
||||||
|
var fileDescriptor0 = []byte{
|
||||||
|
// 514 bytes of a gzipped FileDescriptorProto
|
||||||
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x53, 0x4d, 0x6f, 0xd3, 0x40,
|
||||||
|
0x10, 0x55, 0x1b, 0x1a, 0x9a, 0x49, 0x52, 0x60, 0xa3, 0x96, 0x60, 0x51, 0xa8, 0x0c, 0x87, 0x1c,
|
||||||
|
0x90, 0x23, 0xb5, 0x02, 0xa1, 0x72, 0x42, 0x6a, 0xab, 0x4a, 0xa9, 0x68, 0x30, 0x91, 0xb8, 0x20,
|
||||||
|
0x59, 0x1b, 0x7b, 0xea, 0xac, 0xe2, 0xec, 0xba, 0xeb, 0x31, 0xb6, 0xff, 0x0f, 0x3f, 0x14, 0xf9,
|
||||||
|
0x23, 0xc6, 0x21, 0x94, 0x93, 0xd7, 0x6f, 0xde, 0xbc, 0x99, 0xd9, 0x79, 0x0b, 0x2f, 0x12, 0x1e,
|
||||||
|
0x04, 0x48, 0x3a, 0x74, 0xc7, 0xe5, 0x69, 0x29, 0xc8, 0x0a, 0xb5, 0x22, 0xc5, 0x3a, 0x75, 0xc8,
|
||||||
|
0x38, 0xf7, 0x05, 0x2d, 0xe2, 0xb9, 0xe5, 0xaa, 0xd5, 0x38, 0x10, 0xfe, 0x82, 0xa4, 0x90, 0xbe,
|
||||||
|
0x44, 0x4a, 0x94, 0x5e, 0x8e, 0x03, 0xe9, 0x8d, 0x03, 0x99, 0x2b, 0x44, 0xc2, 0xaf, 0xbf, 0xa8,
|
||||||
|
0x4b, 0x19, 0xf3, 0x2b, 0xb4, 0x27, 0x98, 0xd9, 0x78, 0xcf, 0x46, 0xf0, 0x74, 0x89, 0x99, 0x73,
|
||||||
|
0x27, 0xa4, 0x8f, 0xda, 0x09, 0xb5, 0x90, 0x34, 0xdc, 0x39, 0xd9, 0x19, 0xed, 0xd9, 0x07, 0x4b,
|
||||||
|
0xcc, 0xae, 0x0a, 0x78, 0x9a, 0xa3, 0xec, 0x18, 0xa0, 0x60, 0xf2, 0x95, 0x08, 0xb2, 0xe1, 0x6e,
|
||||||
|
0xc1, 0xe9, 0xe4, 0x9c, 0x02, 0x30, 0xfb, 0xd0, 0xfd, 0xec, 0x79, 0xda, 0xc6, 0xfb, 0x18, 0x23,
|
||||||
|
0x32, 0x4d, 0xe8, 0x95, 0xbf, 0x51, 0xa8, 0x64, 0x84, 0x8c, 0xc1, 0x23, 0xee, 0x79, 0xba, 0xd0,
|
||||||
|
0xee, 0xd8, 0xc5, 0xd9, 0x7c, 0x0b, 0xdd, 0x99, 0xe6, 0x32, 0xe2, 0x2e, 0x09, 0x25, 0xd9, 0x21,
|
||||||
|
0xb4, 0x29, 0x75, 0x16, 0x98, 0x16, 0xa4, 0x9e, 0xbd, 0x47, 0xe9, 0x35, 0xa6, 0xe6, 0x07, 0x78,
|
||||||
|
0x32, 0x8d, 0xe7, 0x81, 0x88, 0x16, 0xb5, 0xd8, 0x1b, 0xe8, 0x87, 0x25, 0xe4, 0xa0, 0xd6, 0x6a,
|
||||||
|
0xad, 0xda, 0xab, 0xc0, 0xcb, 0x1c, 0x33, 0x7f, 0x00, 0xfb, 0x86, 0xd2, 0xbb, 0x8d, 0x29, 0x8c,
|
||||||
|
0x29, 0xaa, 0xfa, 0x62, 0x2f, 0x01, 0x22, 0x4e, 0x4e, 0x88, 0xda, 0x59, 0x26, 0x45, 0x5e, 0xcb,
|
||||||
|
0xde, 0x8f, 0x38, 0x4d, 0x51, 0x4f, 0x12, 0x36, 0x82, 0xc7, 0xaa, 0xe4, 0x0f, 0x77, 0x4f, 0x5a,
|
||||||
|
0xa3, 0xee, 0xe9, 0x81, 0x55, 0xdd, 0x9f, 0x35, 0x4b, 0x6f, 0x63, 0xb2, 0xd7, 0x61, 0xf3, 0x1d,
|
||||||
|
0x0c, 0x36, 0xd4, 0xab, 0xce, 0x0e, 0xa1, 0xad, 0x79, 0xe2, 0x50, 0x3d, 0x83, 0xe6, 0xc9, 0x2c,
|
||||||
|
0x35, 0xdf, 0x03, 0xbb, 0x8c, 0x48, 0xac, 0x38, 0xe1, 0x15, 0xe2, 0xba, 0x97, 0xd7, 0xd0, 0x75,
|
||||||
|
0x95, 0xbc, 0x73, 0x88, 0x6b, 0x1f, 0xd7, 0xd7, 0x0e, 0x39, 0x34, 0x2b, 0x10, 0xf3, 0x0c, 0x06,
|
||||||
|
0x1b, 0x69, 0x55, 0x91, 0xff, 0xce, 0x70, 0xfa, 0xab, 0x05, 0x9d, 0xef, 0x85, 0x4b, 0x26, 0x82,
|
||||||
|
0xd8, 0x39, 0xf4, 0x2f, 0x50, 0x8b, 0x9f, 0xf8, 0x05, 0x53, 0x9a, 0x60, 0xc6, 0x9e, 0x59, 0xb5,
|
||||||
|
0x85, 0xac, 0xd2, 0x03, 0xc6, 0x51, 0x3d, 0xe4, 0x04, 0xb3, 0x0b, 0x8c, 0x5c, 0x2d, 0x42, 0x52,
|
||||||
|
0x9a, 0x7d, 0x84, 0x4e, 0x99, 0x9b, 0xe7, 0x0d, 0x9a, 0xa4, 0x1b, 0xe5, 0x72, 0x52, 0xfa, 0xc1,
|
||||||
|
0xcc, 0x4f, 0xb0, 0x9f, 0xd7, 0xcb, 0x1d, 0xc0, 0x8e, 0x1a, 0x05, 0x1b, 0x0e, 0x31, 0x9e, 0x6f,
|
||||||
|
0xe1, 0xd5, 0x78, 0xd7, 0xc0, 0xaa, 0x85, 0x37, 0xdd, 0xd1, 0x94, 0x69, 0xe0, 0x86, 0xd1, 0xc0,
|
||||||
|
0xff, 0xf6, 0xc9, 0x0d, 0x74, 0x1b, 0x4b, 0x62, 0xc7, 0x0d, 0xea, 0xb6, 0x35, 0x8c, 0x57, 0x0f,
|
||||||
|
0x85, 0xff, 0xa8, 0x35, 0xb6, 0xb1, 0xa1, 0xb6, 0xbd, 0xdc, 0x0d, 0xb5, 0x7f, 0x2c, 0x71, 0xde,
|
||||||
|
0x2e, 0x5e, 0xe2, 0xd9, 0xef, 0x00, 0x00, 0x00, 0xff, 0xff, 0xad, 0xc3, 0xe0, 0x58, 0xed, 0x03,
|
||||||
|
0x00, 0x00,
|
||||||
|
}
|
122
lnrpc/walletrpc/walletkit.proto
Normal file
122
lnrpc/walletrpc/walletkit.proto
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
import "github.com/lightningnetwork/lnd/lnrpc/signrpc/signer.proto";
|
||||||
|
|
||||||
|
package walletrpc;
|
||||||
|
|
||||||
|
message KeyReq {
|
||||||
|
/**
|
||||||
|
Is the key finger print of the root pubkey that this request is targeting.
|
||||||
|
This allows the WalletKit to possibly serve out keys for multiple HD chains
|
||||||
|
via public derivation.
|
||||||
|
*/
|
||||||
|
int32 key_finger_print = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
The target key family to derive a key from. In other contexts, this is
|
||||||
|
known as the "account".
|
||||||
|
*/
|
||||||
|
int32 key_family = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message AddrRequest{
|
||||||
|
// No fields, as we always give out a p2wkh address.
|
||||||
|
}
|
||||||
|
message AddrResponse {
|
||||||
|
/**
|
||||||
|
The address encoded using a bech32 format.
|
||||||
|
*/
|
||||||
|
string addr = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message Transaction {
|
||||||
|
/**
|
||||||
|
The raw serialized transaction.
|
||||||
|
*/
|
||||||
|
bytes tx_hex = 1;
|
||||||
|
}
|
||||||
|
message PublishResponse {
|
||||||
|
/**
|
||||||
|
If blank, then no error occurred and the transaction was successfully
|
||||||
|
published. If not the empty string, then a string representation of the
|
||||||
|
broadcast error.
|
||||||
|
|
||||||
|
TODO(roasbeef): map to a proper enum type
|
||||||
|
*/
|
||||||
|
string publish_error = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message SendOutputsRequest {
|
||||||
|
/**
|
||||||
|
The number of satoshis per kilo weight that should be used when crafting
|
||||||
|
this transaction.
|
||||||
|
*/
|
||||||
|
int64 sat_per_kw = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
A slice of the outputs that should be created in the transaction produced.
|
||||||
|
*/
|
||||||
|
repeated signrpc.TxOut outputs = 2;
|
||||||
|
}
|
||||||
|
message SendOutputsResponse {
|
||||||
|
/**
|
||||||
|
The serialized transaction sent out on the network.
|
||||||
|
*/
|
||||||
|
bytes raw_tx = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message EstimateFeeRequest {
|
||||||
|
/**
|
||||||
|
The number of confirmations to shoot for when estimating the fee.
|
||||||
|
*/
|
||||||
|
int32 conf_target = 1;
|
||||||
|
}
|
||||||
|
message EstimateFeeResponse {
|
||||||
|
/**
|
||||||
|
The amount of satoshis per kw that should be used in order to reach the
|
||||||
|
confirmation target in the request.
|
||||||
|
*/
|
||||||
|
int64 sat_per_kw = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
service WalletKit {
|
||||||
|
/**
|
||||||
|
DeriveNextKey attempts to derive the *next* key within the key family
|
||||||
|
(account in BIP43) specified. This method should return the next external
|
||||||
|
child within this branch.
|
||||||
|
*/
|
||||||
|
rpc DeriveNextKey(KeyReq) returns (signrpc.KeyDescriptor);
|
||||||
|
|
||||||
|
/**
|
||||||
|
DeriveKey attempts to derive an arbitrary key specified by the passed
|
||||||
|
KeyLocator.
|
||||||
|
*/
|
||||||
|
rpc DeriveKey(signrpc.KeyLocator) returns (signrpc.KeyDescriptor);
|
||||||
|
|
||||||
|
/**
|
||||||
|
NextAddr returns the next unused address within the wallet.
|
||||||
|
*/
|
||||||
|
rpc NextAddr(AddrRequest) returns (AddrResponse);
|
||||||
|
|
||||||
|
/**
|
||||||
|
PublishTransaction attempts to publish the passed transaction to the
|
||||||
|
network. Once this returns without an error, the wallet will continually
|
||||||
|
attempt to re-broadcast the transaction on start up, until it enters the
|
||||||
|
chain.
|
||||||
|
*/
|
||||||
|
rpc PublishTransaction(Transaction) returns (PublishResponse);
|
||||||
|
|
||||||
|
/**
|
||||||
|
SendOutputs is similar to the existing sendmany call in Bitcoind, and
|
||||||
|
allows the caller to create a transaction that sends to several outputs at
|
||||||
|
once. This is ideal when wanting to batch create a set of transactions.
|
||||||
|
*/
|
||||||
|
rpc SendOutputs(SendOutputsRequest) returns (SendOutputsResponse);
|
||||||
|
|
||||||
|
/**
|
||||||
|
EstimateFee attempts to query the internal fee estimator of the wallet to
|
||||||
|
determine the fee (in sat/kw) to attach to a transaction in order to
|
||||||
|
achieve the confirmation target.
|
||||||
|
*/
|
||||||
|
rpc EstimateFee(EstimateFeeRequest) returns (EstimateFeeResponse);
|
||||||
|
}
|
343
lnrpc/walletrpc/walletkit_server.go
Normal file
343
lnrpc/walletrpc/walletkit_server.go
Normal file
@ -0,0 +1,343 @@
|
|||||||
|
// +build walletrpc
|
||||||
|
|
||||||
|
package walletrpc
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
fmt "fmt"
|
||||||
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
|
"github.com/btcsuite/btcd/wire"
|
||||||
|
"github.com/lightningnetwork/lnd/keychain"
|
||||||
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
|
signrpc "github.com/lightningnetwork/lnd/lnrpc/signrpc"
|
||||||
|
"github.com/lightningnetwork/lnd/lnwallet"
|
||||||
|
context "golang.org/x/net/context"
|
||||||
|
grpc "google.golang.org/grpc"
|
||||||
|
"gopkg.in/macaroon-bakery.v2/bakery"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// subServerName is the name of the sub rpc server. We'll use this name
|
||||||
|
// to register ourselves, and we also require that the main
|
||||||
|
// SubServerConfigDispatcher instance recognize as the name of our
|
||||||
|
subServerName = "WalletKitRPC"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
// macaroonOps are the set of capabilities that our minted macaroon (if
|
||||||
|
// it doesn't already exist) will have.
|
||||||
|
macaroonOps = []bakery.Op{
|
||||||
|
{
|
||||||
|
Entity: "address",
|
||||||
|
Action: "write",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Entity: "address",
|
||||||
|
Action: "read",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Entity: "onchain",
|
||||||
|
Action: "write",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Entity: "onchain",
|
||||||
|
Action: "read",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// macPermissions maps RPC calls to the permissions they require.
|
||||||
|
macPermissions = map[string][]bakery.Op{
|
||||||
|
"/walletrpc.WalletKit/DeriveNextKey": {{
|
||||||
|
Entity: "address",
|
||||||
|
Action: "read",
|
||||||
|
}},
|
||||||
|
"/walletrpc.WalletKit/DeriveKey": {{
|
||||||
|
Entity: "address",
|
||||||
|
Action: "read",
|
||||||
|
}},
|
||||||
|
"/walletrpc.WalletKit/NextAddr": {{
|
||||||
|
Entity: "address",
|
||||||
|
Action: "read",
|
||||||
|
}},
|
||||||
|
"/walletrpc.WalletKit/PublishTransaction": {{
|
||||||
|
Entity: "onchain",
|
||||||
|
Action: "write",
|
||||||
|
}},
|
||||||
|
"/walletrpc.WalletKit/SendOutputs": {{
|
||||||
|
Entity: "onchain",
|
||||||
|
Action: "write",
|
||||||
|
}},
|
||||||
|
"/walletrpc.WalletKit/EstimateFee": {{
|
||||||
|
Entity: "onchain",
|
||||||
|
Action: "read",
|
||||||
|
}},
|
||||||
|
}
|
||||||
|
|
||||||
|
// DefaultWalletKitMacFilename is the default name of the wallet kit
|
||||||
|
// macaroon that we expect to find via a file handle within the main
|
||||||
|
// configuration file in this package.
|
||||||
|
DefaultWalletKitMacFilename = "walletkit.macaroon"
|
||||||
|
)
|
||||||
|
|
||||||
|
// WalletKit is a sub-RPC server that exposes a tool kit which allows clients
|
||||||
|
// to execute common wallet operations. This includes requesting new addresses,
|
||||||
|
// keys (for contracts!), and publishing transactions.
|
||||||
|
type WalletKit struct {
|
||||||
|
cfg *Config
|
||||||
|
}
|
||||||
|
|
||||||
|
// A compile time check to ensure that WalletKit fully implements the
|
||||||
|
// WalletKitServer gRPC service.
|
||||||
|
var _ WalletKitServer = (*WalletKit)(nil)
|
||||||
|
|
||||||
|
// fileExists reports whether the named file or directory exists.
|
||||||
|
func fileExists(name string) bool {
|
||||||
|
if _, err := os.Stat(name); err != nil {
|
||||||
|
if os.IsNotExist(err) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// New creates a new instance of the WalletKit sub-RPC server.
|
||||||
|
func New(cfg *Config) (*WalletKit, lnrpc.MacaroonPerms, error) {
|
||||||
|
// If the path of the wallet kit macaroon wasn't specified, then we'll
|
||||||
|
// assume that it's found at the default network directory.
|
||||||
|
if cfg.WalletKitMacPath == "" {
|
||||||
|
cfg.WalletKitMacPath = filepath.Join(
|
||||||
|
cfg.NetworkDir, DefaultWalletKitMacFilename,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now that we know the full path of the wallet kit macaroon, we can
|
||||||
|
// check to see if we need to create it or not.
|
||||||
|
macFilePath := cfg.WalletKitMacPath
|
||||||
|
if !fileExists(macFilePath) && cfg.MacService != nil {
|
||||||
|
log.Infof("Baking macaroons for WaleltKit RPC Server at: %v",
|
||||||
|
macFilePath)
|
||||||
|
|
||||||
|
// At this point, we know that the wallet kit macaroon doesn't
|
||||||
|
// yet, exist, so we need to create it with the help of the
|
||||||
|
// main macaroon service.
|
||||||
|
walletKitMac, err := cfg.MacService.Oven.NewMacaroon(
|
||||||
|
context.Background(), bakery.LatestVersion, nil,
|
||||||
|
macaroonOps...,
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
walletKitMacBytes, err := walletKitMac.M().MarshalBinary()
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
err = ioutil.WriteFile(macFilePath, walletKitMacBytes, 0644)
|
||||||
|
if err != nil {
|
||||||
|
os.Remove(macFilePath)
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
walletKit := &WalletKit{
|
||||||
|
cfg: cfg,
|
||||||
|
}
|
||||||
|
|
||||||
|
return walletKit, macPermissions, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start launches any helper goroutines required for the sub-server to function.
|
||||||
|
//
|
||||||
|
// NOTE: This is part of the lnrpc.SubServer interface.
|
||||||
|
func (w *WalletKit) Start() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stop signals any active goroutines for a graceful closure.
|
||||||
|
//
|
||||||
|
// NOTE: This is part of the lnrpc.SubServer interface.
|
||||||
|
func (w *WalletKit) Stop() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Name returns a unique string representation of the sub-server. This can be
|
||||||
|
// used to identify the sub-server and also de-duplicate them.
|
||||||
|
//
|
||||||
|
// NOTE: This is part of the lnrpc.SubServer interface.
|
||||||
|
func (w *WalletKit) Name() string {
|
||||||
|
return subServerName
|
||||||
|
}
|
||||||
|
|
||||||
|
// RegisterWithRootServer will be called by the root gRPC server to direct a
|
||||||
|
// sub RPC server to register itself with the main gRPC root server. Until this
|
||||||
|
// is called, each sub-server won't be able to have requests routed towards it.
|
||||||
|
//
|
||||||
|
// NOTE: This is part of the lnrpc.SubServer interface.
|
||||||
|
func (w *WalletKit) RegisterWithRootServer(grpcServer *grpc.Server) error {
|
||||||
|
// We make sure that we register it with the main gRPC server to ensure
|
||||||
|
// all our methods are routed properly.
|
||||||
|
RegisterWalletKitServer(grpcServer, w)
|
||||||
|
|
||||||
|
log.Debugf("WalletKit RPC server successfully registered with " +
|
||||||
|
"root gRPC server")
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeriveNextKey attempts to derive the *next* key within the key family
|
||||||
|
// (account in BIP43) specified. This method should return the next external
|
||||||
|
// child within this branch.
|
||||||
|
func (w *WalletKit) DeriveNextKey(ctx context.Context,
|
||||||
|
req *KeyReq) (*signrpc.KeyDescriptor, error) {
|
||||||
|
|
||||||
|
nextKeyDesc, err := w.cfg.KeyRing.DeriveNextKey(
|
||||||
|
keychain.KeyFamily(req.KeyFamily),
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &signrpc.KeyDescriptor{
|
||||||
|
KeyLoc: &signrpc.KeyLocator{
|
||||||
|
KeyFamily: int32(nextKeyDesc.Family),
|
||||||
|
KeyIndex: int32(nextKeyDesc.Index),
|
||||||
|
},
|
||||||
|
RawKeyBytes: nextKeyDesc.PubKey.SerializeCompressed(),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeriveKey attempts to derive an arbitrary key specified by the passed
|
||||||
|
// KeyLocator.
|
||||||
|
func (w *WalletKit) DeriveKey(ctx context.Context,
|
||||||
|
req *signrpc.KeyLocator) (*signrpc.KeyDescriptor, error) {
|
||||||
|
|
||||||
|
keyDesc, err := w.cfg.KeyRing.DeriveKey(keychain.KeyLocator{
|
||||||
|
Family: keychain.KeyFamily(req.KeyFamily),
|
||||||
|
Index: uint32(req.KeyIndex),
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &signrpc.KeyDescriptor{
|
||||||
|
KeyLoc: &signrpc.KeyLocator{
|
||||||
|
KeyFamily: int32(keyDesc.Family),
|
||||||
|
KeyIndex: int32(keyDesc.Index),
|
||||||
|
},
|
||||||
|
RawKeyBytes: keyDesc.PubKey.SerializeCompressed(),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// NextAddr returns the next unused address within the wallet.
|
||||||
|
func (w *WalletKit) NextAddr(ctx context.Context,
|
||||||
|
req *AddrRequest) (*AddrResponse, error) {
|
||||||
|
|
||||||
|
addr, err := w.cfg.Wallet.NewAddress(lnwallet.WitnessPubKey, false)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &AddrResponse{
|
||||||
|
Addr: addr.String(),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Attempts to publish the passed transaction to the network. Once this returns
|
||||||
|
// without an error, the wallet will continually attempt to re-broadcast the
|
||||||
|
// transaction on start up, until it enters the chain.
|
||||||
|
func (w *WalletKit) PublishTransaction(ctx context.Context,
|
||||||
|
req *Transaction) (*PublishResponse, error) {
|
||||||
|
|
||||||
|
switch {
|
||||||
|
// If the client doesn't specify a transaction, then there's nothing to
|
||||||
|
// publish.
|
||||||
|
case len(req.TxHex) == 0:
|
||||||
|
return nil, fmt.Errorf("must provide a transaction to " +
|
||||||
|
"publish")
|
||||||
|
}
|
||||||
|
|
||||||
|
tx := &wire.MsgTx{}
|
||||||
|
txReader := bytes.NewReader(req.TxHex)
|
||||||
|
if err := tx.Deserialize(txReader); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err := w.cfg.Wallet.PublishTransaction(tx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &PublishResponse{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SendOutputs is similar to the existing sendmany call in Bitcoind, and allows
|
||||||
|
// the caller to create a transaction that sends to several outputs at once.
|
||||||
|
// This is ideal when wanting to batch create a set of transactions.
|
||||||
|
func (w *WalletKit) SendOutputs(ctx context.Context,
|
||||||
|
req *SendOutputsRequest) (*SendOutputsResponse, error) {
|
||||||
|
|
||||||
|
switch {
|
||||||
|
// If the client didn't specify any outputs to create, then we can't
|
||||||
|
// proceed .
|
||||||
|
case len(req.Outputs) == 0:
|
||||||
|
return nil, fmt.Errorf("must specify at least one output " +
|
||||||
|
"to create")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Before we can request this transaction to be created, we'll need to
|
||||||
|
// amp the protos back into the format that the internal wallet will
|
||||||
|
// recognize.
|
||||||
|
outputsToCreate := make([]*wire.TxOut, 0, len(req.Outputs))
|
||||||
|
for _, output := range req.Outputs {
|
||||||
|
outputsToCreate = append(outputsToCreate, &wire.TxOut{
|
||||||
|
Value: output.Value,
|
||||||
|
PkScript: output.PkScript,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now that we have the outputs mapped, we can request that the wallet
|
||||||
|
// attempt to create this transaction.
|
||||||
|
tx, err := w.cfg.Wallet.SendOutputs(
|
||||||
|
outputsToCreate, lnwallet.SatPerKWeight(req.SatPerKw),
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var b bytes.Buffer
|
||||||
|
if err := tx.Serialize(&b); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &SendOutputsResponse{
|
||||||
|
RawTx: b.Bytes(),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// EstimateFee attempts to query the internal fee estimator of the wallet to
|
||||||
|
// determine the fee (in sat/kw) to attach to a transaction in order to achieve
|
||||||
|
// the confirmation target.
|
||||||
|
func (w *WalletKit) EstimateFee(ctx context.Context,
|
||||||
|
req *EstimateFeeRequest) (*EstimateFeeResponse, error) {
|
||||||
|
|
||||||
|
switch {
|
||||||
|
// A confirmation target of zero doesn't make any sense. Similarly, we
|
||||||
|
// reject confirmation targets of 1 as they're unreasonable.
|
||||||
|
case req.ConfTarget == 0 || req.ConfTarget == 1:
|
||||||
|
return nil, fmt.Errorf("confirmation target must be greater " +
|
||||||
|
"than 1")
|
||||||
|
}
|
||||||
|
|
||||||
|
satPerKw, err := w.cfg.FeeEstimator.EstimateFeePerKW(
|
||||||
|
uint32(req.ConfTarget),
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &EstimateFeeResponse{
|
||||||
|
SatPerKw: int64(satPerKw),
|
||||||
|
}, nil
|
||||||
|
}
|
4
log.go
4
log.go
@ -20,6 +20,7 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/discovery"
|
"github.com/lightningnetwork/lnd/discovery"
|
||||||
"github.com/lightningnetwork/lnd/htlcswitch"
|
"github.com/lightningnetwork/lnd/htlcswitch"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/signrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/signrpc"
|
||||||
|
"github.com/lightningnetwork/lnd/lnrpc/walletrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnwallet"
|
"github.com/lightningnetwork/lnd/lnwallet"
|
||||||
"github.com/lightningnetwork/lnd/routing"
|
"github.com/lightningnetwork/lnd/routing"
|
||||||
"github.com/lightningnetwork/lnd/signal"
|
"github.com/lightningnetwork/lnd/signal"
|
||||||
@ -67,6 +68,7 @@ var (
|
|||||||
sphxLog = build.NewSubLogger("SPHX", backendLog.Logger)
|
sphxLog = build.NewSubLogger("SPHX", backendLog.Logger)
|
||||||
swprLog = build.NewSubLogger("SWPR", backendLog.Logger)
|
swprLog = build.NewSubLogger("SWPR", backendLog.Logger)
|
||||||
sgnrLog = build.NewSubLogger("SGNR", backendLog.Logger)
|
sgnrLog = build.NewSubLogger("SGNR", backendLog.Logger)
|
||||||
|
wlktLog = build.NewSubLogger("WLKT", backendLog.Logger)
|
||||||
)
|
)
|
||||||
|
|
||||||
// Initialize package-global logger variables.
|
// Initialize package-global logger variables.
|
||||||
@ -85,6 +87,7 @@ func init() {
|
|||||||
signal.UseLogger(ltndLog)
|
signal.UseLogger(ltndLog)
|
||||||
sweep.UseLogger(swprLog)
|
sweep.UseLogger(swprLog)
|
||||||
signrpc.UseLogger(sgnrLog)
|
signrpc.UseLogger(sgnrLog)
|
||||||
|
walletrpc.UseLogger(wlktLog)
|
||||||
}
|
}
|
||||||
|
|
||||||
// subsystemLoggers maps each subsystem identifier to its associated logger.
|
// subsystemLoggers maps each subsystem identifier to its associated logger.
|
||||||
@ -109,6 +112,7 @@ var subsystemLoggers = map[string]btclog.Logger{
|
|||||||
"SPHX": sphxLog,
|
"SPHX": sphxLog,
|
||||||
"SWPR": swprLog,
|
"SWPR": swprLog,
|
||||||
"SGNR": sgnrLog,
|
"SGNR": sgnrLog,
|
||||||
|
"WLKT": wlktLog,
|
||||||
}
|
}
|
||||||
|
|
||||||
// initLogRotator initializes the logging rotator to write logs to logFile and
|
// initLogRotator initializes the logging rotator to write logs to logFile and
|
||||||
|
@ -129,6 +129,10 @@ var (
|
|||||||
Entity: "invoices",
|
Entity: "invoices",
|
||||||
Action: "write",
|
Action: "write",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Entity: "signer",
|
||||||
|
Action: "generate",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// invoicePermissions is a slice of all the entities that allows a user
|
// invoicePermissions is a slice of all the entities that allows a user
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/signrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/signrpc"
|
||||||
|
"github.com/lightningnetwork/lnd/lnrpc/walletrpc"
|
||||||
"github.com/lightningnetwork/lnd/macaroons"
|
"github.com/lightningnetwork/lnd/macaroons"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -18,6 +19,12 @@ type subRPCServerConfigs struct {
|
|||||||
// SignRPC is a sub-RPC server that exposes signing of arbitrary inputs
|
// SignRPC is a sub-RPC server that exposes signing of arbitrary inputs
|
||||||
// as a gRPC service.
|
// as a gRPC service.
|
||||||
SignRPC *signrpc.Config `group:"signrpc" namespace:"signrpc"`
|
SignRPC *signrpc.Config `group:"signrpc" namespace:"signrpc"`
|
||||||
|
|
||||||
|
// WalletKitRPC is a sub-RPC server that exposes functionality allowing
|
||||||
|
// a client to send transactions through a wallet, publish them, and
|
||||||
|
// also requests keys and addresses under control of the backing
|
||||||
|
// wallet.
|
||||||
|
WalletKitRPC *walletrpc.Config `group:"walletrpc" namespace:"walletrpc"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// PopulateDependencies attempts to iterate through all the sub-server configs
|
// PopulateDependencies attempts to iterate through all the sub-server configs
|
||||||
@ -66,6 +73,25 @@ func (s *subRPCServerConfigs) PopulateDependencies(cc *chainControl,
|
|||||||
reflect.ValueOf(cc.signer),
|
reflect.ValueOf(cc.signer),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
case *walletrpc.Config:
|
||||||
|
subCfgValue := extractReflectValue(cfg)
|
||||||
|
|
||||||
|
subCfgValue.FieldByName("NetworkDir").Set(
|
||||||
|
reflect.ValueOf(networkDir),
|
||||||
|
)
|
||||||
|
subCfgValue.FieldByName("MacService").Set(
|
||||||
|
reflect.ValueOf(macService),
|
||||||
|
)
|
||||||
|
subCfgValue.FieldByName("FeeEstimator").Set(
|
||||||
|
reflect.ValueOf(cc.feeEstimator),
|
||||||
|
)
|
||||||
|
subCfgValue.FieldByName("Wallet").Set(
|
||||||
|
reflect.ValueOf(cc.wallet),
|
||||||
|
)
|
||||||
|
subCfgValue.FieldByName("KeyRing").Set(
|
||||||
|
reflect.ValueOf(cc.keyRing),
|
||||||
|
)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("unknown field: %v, %T", fieldName,
|
return fmt.Errorf("unknown field: %v, %T", fieldName,
|
||||||
cfg)
|
cfg)
|
||||||
@ -88,7 +114,6 @@ func (s *subRPCServerConfigs) FetchConfig(subServerName string) (interface{}, bo
|
|||||||
// Now that we have the value of the struct, we can check to see if it
|
// Now that we have the value of the struct, we can check to see if it
|
||||||
// has an attribute with the same name as the subServerName.
|
// has an attribute with the same name as the subServerName.
|
||||||
configVal := selfVal.FieldByName(subServerName)
|
configVal := selfVal.FieldByName(subServerName)
|
||||||
configValElem := configVal.Elem()
|
|
||||||
|
|
||||||
// We'll now ensure that this field actually exists in this value. If
|
// We'll now ensure that this field actually exists in this value. If
|
||||||
// not, then we'll return false for the ok value to indicate to the
|
// not, then we'll return false for the ok value to indicate to the
|
||||||
@ -97,6 +122,8 @@ func (s *subRPCServerConfigs) FetchConfig(subServerName string) (interface{}, bo
|
|||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
configValElem := configVal.Elem()
|
||||||
|
|
||||||
// If a config of this type is found, it doesn't have any fields, then
|
// If a config of this type is found, it doesn't have any fields, then
|
||||||
// it's the same as if it wasn't present. This can happen if the build
|
// it's the same as if it wasn't present. This can happen if the build
|
||||||
// tag for the sub-server is inactive.
|
// tag for the sub-server is inactive.
|
||||||
|
Loading…
Reference in New Issue
Block a user