Skip to content

lnrpc: add new WalletKit sub-RPC server#2093

Merged
Roasbeef merged 7 commits into
lightningnetwork:masterfrom
Roasbeef:walletkit-service
Dec 7, 2018
Merged

lnrpc: add new WalletKit sub-RPC server#2093
Roasbeef merged 7 commits into
lightningnetwork:masterfrom
Roasbeef:walletkit-service

Conversation

@Roasbeef
Copy link
Copy Markdown
Member

In this PR, we add a new sub-RPC server to the existing set of gRPC
servers. This new sub-RPC server is the WalletKit. It's a utility
toolkit that contains method which allow clients to perform common
interactions with a wallet such as getting a new address, or sending a
transaction. It also includes some supplementary actions such as fee
estimation.

One thing to note in the RPC file is that we import the existing
signer.proto file in order to get at some existing proto definitions
which are useful in our use case.

Depends on #2081.

Comment thread lnrpc/walletrpc/walletkit_server.go
@Roasbeef Roasbeef added enhancement Improvements to existing features / behaviour gRPC P2 should be fixed if one has time labels Oct 31, 2018
Comment thread lnrpc/walletrpc/walletkit.proto Outdated
The number of satoshis per kilo weight that should be used when crafting
this transaction.
*/
int64 sat_per_kw = 1;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition to this, we need a maximum total fee as well. We don't know how many inputs are needed, so the fee can potentially become (too) large.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So a max for the request, or a max in the response? Once you know the fee rate, you can use the weight estimator to compute what the final fee will be.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking a max for the request. How can I use the weight estimator if I don't know how many inputs are needed?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah OK, IIRC there're two types of fee estimates we care about:

  1. What should the fee be for a transaction I custom craft myself
  2. What's an estimate for the transaction fee if I instruct the wallet to create a certain number of outputs

This PR as is gives us #1, for #2 there's #1228.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am suggesting 3. Set a hard cap on the actually paid tx fee if I instruct the wallet to create a certain nof outputs.

Copy link
Copy Markdown
Member Author

@Roasbeef Roasbeef Dec 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha, will make an issue to track this as this can be added in a new PR (since it also requires wallet modifications).

attempt to re-broadcast the transaction on start up, until it enters the
chain.
*/
rpc PublishTransaction(Transaction) returns (PublishResponse);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this going to work with the rebroadcaster? It needs sign descriptors too.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: instead of PublishTransaction, this could be SendInputs which takes sign descriptors.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So just to check in again, I think we're find with PublishTransaction and may follow up with the two-stage craft+sign process?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes indeed, we leave it for a follow up.

@joostjager
Copy link
Copy Markdown
Contributor

Need a way to persist the SendOutputs tx before it is published, to make sure we never accidentally pay to the same output again.

@Roasbeef Roasbeef force-pushed the walletkit-service branch 2 times, most recently from b505b31 to 3c545bd Compare December 1, 2018 01:15
The number of satoshis per kilo weight that should be used when crafting
this transaction.
*/
int64 sat_per_kw = 1;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking a max for the request. How can I use the weight estimator if I don't know how many inputs are needed?

attempt to re-broadcast the transaction on start up, until it enters the
chain.
*/
rpc PublishTransaction(Transaction) returns (PublishResponse);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes indeed, we leave it for a follow up.

Comment thread lnrpc/walletrpc/walletkit_server.go Outdated
KeyLoc: &signrpc.KeyLocator{
KeyFamily: int32(keyDesc.Family),
KeyIndex: int32(keyDesc.Index),
},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pubkey bytes need to be returned? It looks like it currently just returns the request values.

Comment thread lnrpc/walletrpc/driver.go Outdated
switch {
case config.MacService == nil:
return nil, nil, fmt.Errorf("MacService must be set to " +
"create WalletKit RPC server")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems walletkit cannot be used with nomacaroons

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

@Roasbeef
Copy link
Copy Markdown
Member Author

Roasbeef commented Dec 5, 2018

Addressed all lingering comments, PTAL!

Comment thread lnrpc/walletrpc/log.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs different log tag

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

Comment thread lnrpc/walletrpc/walletkit_server.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: register -> registered

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

Comment thread subrpcserver_config.go Outdated
Copy link
Copy Markdown
Contributor

@cfromknecht cfromknecht left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couple last things from a prior review that weren't addressed

Comment thread lnrpc/walletrpc/walletkit_server.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

started, stopped, and quit don't do anything, they can be removed

Comment thread lnrpc/walletrpc/walletkit_server.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Start() can just return nil

Comment thread lnrpc/walletrpc/walletkit_server.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stop can just return nil

@joostjager
Copy link
Copy Markdown
Contributor

Didn't you want to add signer permission to the admin macaroon in this pr too?

Comment thread lnrpc/walletrpc/walletkit_server.go Outdated
Copy link
Copy Markdown
Contributor

@wpaulino wpaulino Dec 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
log.Infof("Making macaroons for WaleltKit RPC Server at: %v",
log.Infof("Baking macaroons for WalletKit RPC Server at: %v",

😛

In this commit, we add a new sub-RPC server to the existing set of gRPC
servers. This new sub-RPC server is the WalletKit. It's a utility
toolkit that contains method which allow clients to perform common
interactions with a wallet such as getting a new address, or sending a
transaction. It also includes some supplementary actions such as fee
estimation.

One thing to note in the RPC file is that we _import_ the existing
signer.proto file in order to get at some existing proto definitions
which are useful in our use case.
In this commit, we implement the newly defiend WalletKitServer gRPC
service. We use the same template w.r.t build tags as the existing
signrpc service.
In this commit, we extend the admin macaroon with signer capabilities in
order to allow it to be used with the new signer sub-server. As a
result, users will need to clear out their old macaroons in order to
have the new improved admin macaroon generated. In the future, we may
want to restructure the way the admin macaroon functions: rather than
white listing each of these entities and operations, we can instead add
a catch all capability. This capability will instead allow access to any
call, as each new call would be modified to permit this capabilities and
no others.
@Roasbeef
Copy link
Copy Markdown
Member Author

Roasbeef commented Dec 7, 2018

Final comments addressed!

Copy link
Copy Markdown
Contributor

@cfromknecht cfromknecht left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🎉

@Roasbeef Roasbeef merged commit eb16427 into lightningnetwork:master Dec 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Improvements to existing features / behaviour gRPC P2 should be fixed if one has time

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants