Conversation
gossipd/gossipd.h
Outdated
| struct feature_set *our_features; | ||
|
|
||
| /* The channel lease rates we're advertising */ | ||
| struct lease_rates *rates; |
There was a problem hiding this comment.
Probably could be const?
| fromwire_lease_rates(pptr, max, entry->rates); | ||
| } else | ||
| entry->rates = NULL; | ||
|
|
There was a problem hiding this comment.
Oops, these functions are no longer used and should have been totally deleted. Will do after.
| sizes[0] = 2 + fromwire_u16(&flen, &len); | ||
| assert(flen != NULL && len >= 4); | ||
|
|
||
| /* BOLT-0fe3485a5320efaa2be8cfa0e570ad4d0259cec3 #7: |
There was a problem hiding this comment.
FWIW, I've stared using BOLT= instead, rather than commit message. Makes it a bit harder to check, but good fi spec is in flux.
gossipd/gossip_generation.c
Outdated
| get_nannounce_parts(orig, oparts, osizes); | ||
| get_nannounce_parts(nannounce, nparts, nsizes); | ||
|
|
||
| *only_missing_tlv = memeq(oparts[0], osizes[0], nparts[0], nsizes[0]) |
There was a problem hiding this comment.
Let this be NULL? One caller wants that...
| } | ||
| } | ||
|
|
||
| sign_and_send_nannounce(daemon, nannounce, timestamp); |
There was a problem hiding this comment.
THis looks like a lot of cut and paste in what could be a flag? Can be fixed after though.
bitcoin/psbt.c
Outdated
| * | ||
| * The minimum witness weight for an input is 110. | ||
| */ | ||
| weight += 110; |
There was a problem hiding this comment.
+= ?? This seems wrong?
Also, psbt_input_weight is a very generic name for something containing this: suggest minweight as a parameter?
There was a problem hiding this comment.
Whatever code that I was using for this no longer exists, so I'm deleting this commit.
| "funding_feerate": funding_feerate, | ||
| } | ||
| return self.call("queryrates", payload) | ||
|
|
There was a problem hiding this comment.
You can avoid adding it to lightning.py: it converts unknown calls automatically.
| msgdata,dualopend_validate_lease,their_pubkey,pubkey, | ||
|
|
||
| msgtype,dualopend_validate_lease_reply,7127 | ||
| msgdata,dualopend_validate_lease_reply,err_msg,?wirestring, |
There was a problem hiding this comment.
I probably would have left dualopend to validate the signature, and hand it up when it says channel is open, but this works too (and can be simplified later if we want).
There was a problem hiding this comment.
it seems made the (incorrect) assumption that only lightningd could verify these. Ooof. Will leave as is for now.
bitcoin/script.c
Outdated
| * OP_ENDIF | ||
| * OP_CHECKSIG | ||
| */ | ||
| u8 *bitcoin_wscript_to_local(const tal_t *ctx, u16 to_self_delay, u32 csv, |
There was a problem hiding this comment.
csv is a terrible name for this parameter! lease_remaining?
|
|
||
| The **parsefeerate** command returns the current feerate for any valid | ||
| *feerate_str*. This is useful for finding the current feerate that a | ||
| **fundpsbt** or **utxopsbt** command might use. |
There was a problem hiding this comment.
This whole commit seems unnecessary? feerates does this already?
There was a problem hiding this comment.
Not exactly, feerates returns the named current feerates; this takes any arbitrary feerate string and returns its value in perkw. I mean, technically, I could halfway parse the feerate string, figure out if it's a plain number or a named fee rate and if it's the latter match it up with the returned fields from feerates. Except that's a bit more work than just piping it through to lightningd to do it for me instead?
e364d06 to
5829b2f
Compare
|
Added some neatening commits on the end, and trivial rebase now first commit is merged. |
5829b2f to
396cd51
Compare
| u32 *lease_basis, *channel_fee_max_ppt, *funding_weight; | ||
|
|
||
| if (!param(cmd, buffer, params, | ||
| p_req("lease_fee_base_msat", param_sat, &lease_base_sat), |
There was a problem hiding this comment.
I really struggled with what to name this. The field itself is satoshi only, but given that we print our RPCs out uniformly as msats, I went with the msat designation... (even though only sats are valid.)
common/lease_rates.c
Outdated
| /* FIXME: why can't i do memeqzero? */ | ||
| return rates->funding_weight == 0 | ||
| && rates->channel_fee_max_base_msat == 0 | ||
| && rates->channel_fee_max_proportional_thousandths == 0 | ||
| && rates->lease_fee_base_sat == 0 | ||
| && rates->lease_fee_basis == 0; |
There was a problem hiding this comment.
acking your later fix :)
| assert funder_opts['per_channel_max'] == '4294967295000msat' | ||
| assert funder_opts['reserve_tank'] == '0msat' | ||
| assert funder_opts['fuzz_percent'] == 5 | ||
| assert funder_opts['fuzz_percent'] == 0 |
There was a problem hiding this comment.
Broken out to separate commit.
| || chan_fee_msats) | ||
| policy->rates = default_lease_rates(policy); | ||
| else | ||
| policy->rates = NULL; |
There was a problem hiding this comment.
The true default is NULL; we only use the defaults iff any one of the parameters is set.
bitcoin/psbt.c
Outdated
| * | ||
| * The minimum witness weight for an input is 110. | ||
| */ | ||
| weight += 110; |
There was a problem hiding this comment.
Whatever code that I was using for this no longer exists, so I'm deleting this commit.
| msgdata,dualopend_validate_lease,their_pubkey,pubkey, | ||
|
|
||
| msgtype,dualopend_validate_lease_reply,7127 | ||
| msgdata,dualopend_validate_lease_reply,err_msg,?wirestring, |
There was a problem hiding this comment.
it seems made the (incorrect) assumption that only lightningd could verify these. Ooof. Will leave as is for now.
bitcoin/script.c
Outdated
| * OP_ENDIF | ||
| * OP_CHECKSIG | ||
| */ | ||
| u8 *bitcoin_wscript_to_local(const tal_t *ctx, u16 to_self_delay, u32 csv, |
|
|
||
| The **parsefeerate** command returns the current feerate for any valid | ||
| *feerate_str*. This is useful for finding the current feerate that a | ||
| **fundpsbt** or **utxopsbt** command might use. |
There was a problem hiding this comment.
Not exactly, feerates returns the named current feerates; this takes any arbitrary feerate string and returns its value in perkw. I mean, technically, I could halfway parse the feerate string, figure out if it's a plain number or a named fee rate and if it's the latter match it up with the returned fields from feerates. Except that's a bit more work than just piping it through to lightningd to do it for me instead?
plugins/libplugin.c
Outdated
| const struct json_out *params TAKES, | ||
| const char *guide, | ||
| ...) | ||
| static const char *rpc_scan_list(const tal_t *ctx, |
There was a problem hiding this comment.
I don't actually end up using this commit, I'm throwing it away.
ed51715 to
ac8e879
Compare
Import the wires from spec. Here we go!
When we get a node announcement out, we can now pull out its offer characteristic
Correctly mark whether or not the TLV's are the same/different, given two node announcements
If there's a rate-card for liquidity, we don't know about it until after startup (the plugin *should* call us at init to tell us what their current rates are)
Changelog-Experimental: JSON-RPC: new RPC `setleaserates`, for passing in the rates to advertise for a channel lease (option_will_fund)
Note that we use the names from the spec. Changelog-Experimental: JSON-RPC: `listnodes` now includes the `lease_rates`, if available
A couple of the fields for liquidity_ads are u16
ac8e879 to
314e1b6
Compare
If received lease rates are empty (all zeroes), turn them off
As we move to advertising liquidity, set the default to not have any fuzz. This means we won't randomly reject an offer to buy liquidity.
Implement support for liquidity ads in `funder` plugin. We set the command line options for the leases, as well as sending the updated ads to lightningd (who then passes them through to gossipd)
Make sure everything updates/flows through as expected.
convenience, mostly
When we accept a bid to create a channel lease, we send back a signature committing to our max channel lease amounts.
When a request comes through, we forward it over to the funder who uses the currently set policy to figure out how to handle it. Includes small update to the policy engine which decides whether or not to fund a request. Changelog-Experimental: Plugins: `openchannel2` hook now includes optional fields for a channel lease request
Changelog-Experimental: EXPERIMENTAL-DUAL-FUND: JSON-RPC: openchannel_init now takes a `requested_amt`, which is an amount to request from peer
Changelog-Added: JSON-RPC: `fundchannel` now takes optional `request_amt` parameter
Adds new tables to database, backfills, basically copies the fee_rates state machine for channeld.
Useful for parsing a passed in feerate before calling lightningd with it, e.g. when you need to know what the feerate is for a fundpsbt before calling fundpsbt Changelog-Added: JSON-RPC: new command `parsefeerate` which takes a feerate string and returns the calculated perkw/perkb
If the channel is under lease, the lessor's (accepter, really) funds have a CSV lock that reflects the length of the remainder of the lease.
Channel leases modify the CSV height that an output is eligible for being spent at, persist this to the database
If an output's CSV lock hasn't been surpassed yet, don't try to include it in a transaction
Typically we forget a channel if 2016 blocks have passed and the funding transaction hasn't been mined yet, however we SHOULD NOT forget these channels if we've got funds in them!
If the channel is leased and our peer is too far behind, fail the channel.
By default, we won't close a channel that we leased to a peer. You can override this with the `force_lease_closed` flag. Changelog-Added: JSON-RPC: close now has parameter to force close a leased channel (option_will_fund)
We need to update the peer wrt our blockheight on reconnect
We're gonna need them
We need to know what the lease we're expecting is. To do this we pass around the hex encoded portion of the wire format. We can use this passed in expected lease rates to confirm that the peer is, in fact, using the same rates as what we have currently. Changelog-Added: JSON-RPC: fundchannel, multifundchannel, and openchannel_init now accept a 'compact_lease' for any requested funds
We need to parse the feerate string, so we can figure out what our weight fee will be for a leased channel, so we go get the feerate and use that to calculate what our expected lease fee will be for the requested amount.
If there's no plugin currently in place, we simply won't return any funding at all, in which case we'd expect them to handle however they want. (our implementation would fail the open, as we only accept opens that have at least as much as we've requested provided)
Make it easier to figure out what the inputs were to check_balances on two failure cases
We need the 'actual' accepter's funding for the reserve calculations, which includes the lease fee that the opener is paying them, so we calculate it before doing all that jazz. However, we MUST send the actual "on paper" (e.g. without lease fee) amount to the peer in accept_channel2, so we stash the original amount and send it.
with channel leases, we use the open_tlv data after a round of talking to the peer (which clears out the tmpctx). It'll get cleaned up when this peer opens/fails.
Check that channel leases work as expected for unilateral closes and cheats!
Since we now use 'compact_lease' to gate an open (if the rates have changed, we fail), we no longer need to rely on query rates for figuring things out, so we make it dev-only. Changelog-Changed: JSON-API: queryrates is now developer only
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
We don't actually use the NULL-is-equal in the one caller, so ignore that. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
And fix up lease_rates_fromhex to be the obvious calling convention. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
e37f3ac to
103d3f1
Compare
|
ACK 7be8e71 |
Implements lightning/bolts#878