-
Notifications
You must be signed in to change notification settings - Fork 119
[6/?] StaticAddr: Quoting #750
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[6/?] StaticAddr: Quoting #750
Conversation
be24617
to
f6d49f9
Compare
f614090
to
70a74bd
Compare
dbc351a
to
c4012d0
Compare
ac2a2ae
to
e1d833d
Compare
385f3ea
to
17618f2
Compare
18593dc
to
470ce4e
Compare
ec46c45
to
08bb91d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first part of the review :-)
Reviewed until commit staticaddr: static address manager.
@@ -0,0 +1 @@ | |||
DROP TABLE IF EXISTS static_addresses; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line end missing.
-- downgrades their protocol version for static address outputs already in | ||
-- use. | ||
protocol_version INTEGER NOT NULL | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line end missing.
|
||
-- expiry denotes the CSV delay at which funds at a specific static address | ||
-- can be swept back to the client. | ||
expiry INT NOT NULL, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In other places INTEGER
is used, not INT
. Can INTEGER
be used here as well. (Also in next two fields.)
$5, | ||
$6, | ||
$7 | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line end missing.
swapserverrpc/server.proto
Outdated
bytes server_key = 1; | ||
|
||
// The CSV expiry for the MuSig2 static address output. | ||
uint32 expiry = 2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line end missing.
staticaddr/sql_store.go
Outdated
return nil, err | ||
} | ||
|
||
var result []*AddressParameters |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
result := make([]*AddressParameters, 0, len(staticAddresses))
staticaddr/sql_store.go
Outdated
func (s *SqlStore) ExecTx(ctx context.Context, txOptions loopdb.TxOptions, | ||
txBody func(queries *sqlc.Queries) error) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you call baseDB's ExecTx here?
staticaddr/manager.go
Outdated
m.Lock() | ||
addresses, err := m.cfg.Store.GetAllStaticAddresses(ctx) | ||
if err != nil { | ||
m.Unlock() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can m.Unlock()
call be done right after GetAllStaticAddresses
call? In all 3 branches the first action is m.Unlock()
.
staticaddr/manager.go
Outdated
clientPubKey := addresses[0].ClientPubkey | ||
serverPubKey := addresses[0].ServerPubkey | ||
expiry := int64(addresses[0].Expiry) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the order of addresses deterministic? If there are more than one, can addresses[0]
be different in several calls (would be confusing for the user).
staticaddr/manager.go
Outdated
ClientPubkey: clientPubKey.PubKey, | ||
ServerPubkey: serverPubKey, | ||
PkScript: pkScript, | ||
Expiry: serverParams.Expiry, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should serverParams.Expiry
be validated? E.g. that it is within some range (positive, not too high, fits into int32
).
17618f2
to
6f9539b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
loopd/swapclient_server.go
Outdated
// The requested amount is 0 here if the request contained deposit | ||
// outpoints. In case we quote for deposits we send the server both the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be enforced with a check?
if amount != 0 && len(summary.FilteredDeposits) > 0 {
return nil, error
@@ -33,20 +35,36 @@ var quoteInCommand = cli.Command{ | |||
verboseFlag, | |||
privateFlag, | |||
routeHintsFlag, | |||
cli.StringSliceFlag{ | |||
Name: "deposit_outpoint", | |||
Usage: "one or more static address deposit outpoints " + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one or more
Can you specify how to pass multiple outpoints, please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
cmd/loop/quote.go
Outdated
var ( | ||
depositAmt btcutil.Amount | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var depositAmt btcutil.Amount
also it can be moved before the loop, since it is used there.
6f9539b
to
add5263
Compare
d94cabe
to
11e9b12
Compare
loopd/swapclient_server.go
Outdated
@@ -1395,6 +1426,201 @@ func (s *swapClientServer) WithdrawDeposits(ctx context.Context, | |||
return &clientrpc.WithdrawDepositsResponse{}, err | |||
} | |||
|
|||
// GetStaticAddressSummary returns a summary static address related information. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: grammar
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, very clean PR 🎉
cmd/loop/staticaddr.go
Outdated
var summaryCommand = cli.Command{ | ||
Name: "summary", | ||
ShortName: "s", | ||
Usage: "Display a summary of static address related data.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: instead of "data" i'd word it as "information".
loopd/swapclient_server.go
Outdated
func filter(deposits []*deposit.Deposit, f filterFunc) []*clientrpc.Deposit { | ||
var clientDeposits []*clientrpc.Deposit | ||
for _, d := range deposits { | ||
if f(d) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style+nit: if !f(d) { continue }
?
@@ -760,6 +760,13 @@ message QuoteRequest { | |||
probing and payment. | |||
*/ | |||
bool private = 7; | |||
|
|||
/* | |||
Static address deposit outpoints that will be quoted for. This option only |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: commit message could be reformatted for readability.
@@ -33,20 +35,36 @@ var quoteInCommand = cli.Command{ | |||
verboseFlag, | |||
privateFlag, | |||
routeHintsFlag, | |||
cli.StringSliceFlag{ | |||
Name: "deposit_outpoint", | |||
Usage: "one or more static address deposit outpoints " + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
add5263
to
48cc041
Compare
bef49c2
to
5184bbd
Compare
This commit adds static address deposit outpoints to the QuoteRequest message. It allows to quote for loop in swaps with the total value of specified deposits.
This commit adds the number of deposits to the ServerLoopInQuoteRequest that the client wants to quote for.
the last 4 commits are relevantDepends on #721This PR introduces quoting for static address loop-ins while reusing the existing loop-in quoting infrastructure.