mirror of
https://github.com/lightninglabs/pool.git
synced 2026-08-13 12:33:04 +02:00
multi: rename project from llm to pool
This commit is contained in:
parent
33678c0ee6
commit
ffc9c60b13
45 changed files with 425 additions and 425 deletions
8
.gitignore
vendored
8
.gitignore
vendored
|
|
@ -1,4 +1,4 @@
|
|||
/llm
|
||||
/llmd
|
||||
cmd/llm/llm
|
||||
cmd/llmd/llmd
|
||||
/pool
|
||||
/poold
|
||||
cmd/pool/pool
|
||||
cmd/poold/poold
|
||||
|
|
|
|||
14
Dockerfile
14
Dockerfile
|
|
@ -1,7 +1,7 @@
|
|||
FROM golang:1.14-alpine as builder
|
||||
|
||||
# Copy in the local repository to build from.
|
||||
COPY . /go/src/github.com/lightninglabs/llm
|
||||
COPY . /go/src/github.com/lightninglabs/pool
|
||||
|
||||
# Force Go to use the cgo based DNS resolver. This is required to ensure DNS
|
||||
# queries required to connect to linked containers succeed.
|
||||
|
|
@ -10,26 +10,26 @@ ENV GODEBUG netdns=cgo
|
|||
# Explicitly turn on the use of modules (until this becomes the default).
|
||||
ENV GO111MODULE on
|
||||
|
||||
# Install dependencies and install/build llm.
|
||||
# Install dependencies and install/build pool.
|
||||
RUN apk add --no-cache --update alpine-sdk \
|
||||
git \
|
||||
make \
|
||||
&& cd /go/src/github.com/lightninglabs/llm \
|
||||
&& cd /go/src/github.com/lightninglabs/pool \
|
||||
&& make install
|
||||
|
||||
# Start a new, final image to reduce size.
|
||||
FROM alpine as final
|
||||
|
||||
# Expose llmd ports (gRPC and REST).
|
||||
# Expose poold ports (gRPC and REST).
|
||||
EXPOSE 12010 8281
|
||||
|
||||
# Copy the binaries from the builder image.
|
||||
COPY --from=builder /go/bin/llm /bin/
|
||||
COPY --from=builder /go/bin/llmd /bin/
|
||||
COPY --from=builder /go/bin/pool /bin/
|
||||
COPY --from=builder /go/bin/poold /bin/
|
||||
|
||||
# Add bash.
|
||||
RUN apk add --no-cache \
|
||||
bash \
|
||||
ca-certificates
|
||||
|
||||
ENTRYPOINT ["llmd"]
|
||||
ENTRYPOINT ["poold"]
|
||||
|
|
|
|||
22
Makefile
22
Makefile
|
|
@ -1,5 +1,5 @@
|
|||
PKG := github.com/lightninglabs/llm
|
||||
ESCPKG := github.com\/lightninglabs\/llm
|
||||
PKG := github.com/lightninglabs/pool
|
||||
ESCPKG := github.com\/lightninglabs\/pool
|
||||
|
||||
LINT_PKG := github.com/golangci/golangci-lint/cmd/golangci-lint
|
||||
GOVERALLS_PKG := github.com/mattn/goveralls
|
||||
|
|
@ -68,14 +68,14 @@ $(GOACC_BIN):
|
|||
# ============
|
||||
|
||||
build:
|
||||
@$(call print, "Building llm.")
|
||||
$(GOBUILD) $(PKG)/cmd/llm
|
||||
$(GOBUILD) $(PKG)/cmd/llmd
|
||||
@$(call print, "Building Pool.")
|
||||
$(GOBUILD) $(PKG)/cmd/pool
|
||||
$(GOBUILD) $(PKG)/cmd/poold
|
||||
|
||||
install:
|
||||
@$(call print, "Installing llm.")
|
||||
$(GOINSTALL) $(PKG)/cmd/llm
|
||||
$(GOINSTALL) $(PKG)/cmd/llmd
|
||||
@$(call print, "Installing Pool.")
|
||||
$(GOINSTALL) $(PKG)/cmd/pool
|
||||
$(GOINSTALL) $(PKG)/cmd/poold
|
||||
|
||||
scratch: build
|
||||
|
||||
|
|
@ -134,10 +134,10 @@ list:
|
|||
|
||||
rpc:
|
||||
@$(call print, "Compiling protos.")
|
||||
cd ./clmrpc; ./gen_protos.sh
|
||||
cd ./poolrpc; ./gen_protos.sh
|
||||
|
||||
clean:
|
||||
@$(call print, "Cleaning source.$(NC)")
|
||||
$(RM) ./llm
|
||||
$(RM) ./llmd
|
||||
$(RM) ./pool
|
||||
$(RM) ./poold
|
||||
$(RM) coverage.txt
|
||||
|
|
|
|||
92
README.md
92
README.md
|
|
@ -1,14 +1,13 @@
|
|||
# Lightning Pool
|
||||
|
||||
# Lightning Liquidity Marketplace (LLM)
|
||||
|
||||
The Lightning Lightning Marketplace (LLM) is a non-custodial batched uniform
|
||||
clearing-price auction for Channel Liquidity Bonds (CLB). A CLB packages up
|
||||
inbound (or outbound!) channel liquidity (ability to send/receive funds) as a
|
||||
fixed incoming asset (earning interest over time) with a maturity date
|
||||
expressed in blocks. The maturity date of each of the channels is enforced by
|
||||
Bitcoin contracts, ensuring that the funds of the maker (the party that sold
|
||||
the channel) can't be swept until the maturity height. All cleared orders
|
||||
(purchased channels) are cleared in a single batched on-chain transaction.
|
||||
Lightning Pool is a non-custodial batched uniform clearing-price auction for
|
||||
Channel Liquidity Bonds (CLB). A CLB packages up inbound (or outbound!) channel
|
||||
liquidity (ability to send/receive funds) as a fixed incoming asset (earning
|
||||
interest over time) with a maturity date expressed in blocks. The maturity date
|
||||
of each of the channels is enforced by Bitcoin contracts, ensuring that the
|
||||
funds of the maker (the party that sold the channel) can't be swept until the
|
||||
maturity height. All cleared orders (purchased channels) are cleared in a
|
||||
single batched on-chain transaction.
|
||||
|
||||
The existence of an open auction to acquire/sell channel liquidity provides all
|
||||
participants on the network with a more _stable_ income source in addition to
|
||||
|
|
@ -17,7 +16,7 @@ are able to price their channels to ensure that they're compensated for the
|
|||
time-value of their coins within a channel, accounting for worst-case force
|
||||
close CSV delays.
|
||||
|
||||
The LLM critically allows participants on the network to exchange pricing
|
||||
Pool critically allows participants on the network to exchange pricing
|
||||
signals to determine where liquidity in the network is most _demanded_. A
|
||||
channel opened to an area of the sub-graph that doesn't actually need that
|
||||
liquidity will likely remain dormant and not earn any active routing fees.
|
||||
|
|
@ -26,7 +25,7 @@ being placed where it's most demanded, we can better utilize the allocated
|
|||
capital on the network, and also allow new participants to easily identify
|
||||
where their capital is most needed.
|
||||
|
||||
Amongst several other uses cases, the LLM allows a new participant in the
|
||||
Amongst several other uses cases, the Pool allows a new participant in the
|
||||
network to easily _boostrap_ their ability to receive funds by paying only a
|
||||
percentage of the total amount of inbound funds acquired. As an example, a node
|
||||
could acquire 100 million satoshis (1000 units, more on that below) for 100,000
|
||||
|
|
@ -40,19 +39,19 @@ A non-exhaustive list of use cases includes:
|
|||
to Bitcoin entirely, how can she join the Lightning Network without her,
|
||||
herself, making any new on-chain Bitcoin transactions? It’s desirable to a
|
||||
solution to on boarding new users on to the neowrk which is as as simple as
|
||||
sending coins to a fresh address. The LLM solves this by allowing a third
|
||||
sending coins to a fresh address. The Pool solves this by allowing a third
|
||||
party Carol, to purchase a channel _for_ Alice, which includes starting
|
||||
_outbound_ liquidity.
|
||||
|
||||
* **Demand fueled routing node channel selection**: Another common question
|
||||
with regards to the LN is: "where should I open my channels to , such that
|
||||
they'll actually be routed through"?. The LLM provides a new signal for
|
||||
they'll actually be routed through"?. Pool provides a new signal for
|
||||
autopilot agents: a market demand signal. The node can offer up its
|
||||
liquidity and have it automatically be allocated where it's most demanded.
|
||||
|
||||
* **Bootstrapping new services to Lightning**: Any new service launched on
|
||||
the Lightning network will likely need to figure out how to obtain inbound
|
||||
channels so they can accept payments. For this LLM provides an elegant
|
||||
channels so they can accept payments. For this Pool provides an elegant
|
||||
solution in that a marchant can set up a series of "introduction points"
|
||||
negotiated via the market place. The merchant can pay a small percentage of
|
||||
the total amount of liquidity allocated towards it, and also ensure that
|
||||
|
|
@ -63,21 +62,22 @@ A non-exhaustive list of use cases includes:
|
|||
soon as they set up a wallet. Some wallet providers have chosen to open new
|
||||
inbound channels to users themselves. This gives users the inbound
|
||||
bandwidth they need to receive, but can come at a high capital cost to the
|
||||
wallet provider as they need to commit funds with a 1:1 ratio. The LLM
|
||||
allows them to acheive some leverage in a sense, as they can pay only a
|
||||
percentage of the funds to be allocated to a new user. As an eaxmple, they
|
||||
can pay 1000 satohis to have 1 million satoshis be alloacted to a user.
|
||||
wallet provider as they need to commit funds with a 1:1 ratio. The
|
||||
Lightning Pool allows them to acheive some leverage in a sense, as they can
|
||||
pay only a percentage of the funds to be allocated to a new user. As an
|
||||
eaxmple, they can pay 1000 satohis to have 1 million satoshis be alloacted
|
||||
to a user.
|
||||
|
||||
## The Auction Lifecycle
|
||||
|
||||
In this section, we'll walk through the typical auction lifecycle, and in the
|
||||
process explain some key components of the LLM, and also illustrate how to
|
||||
drive your `llmd` on the command line.
|
||||
process explain some key components of the Pool, and also illustrate how to
|
||||
drive your `poold` on the command line.
|
||||
|
||||
### Accounts
|
||||
|
||||
Like any exchange/auction, before you can start trading, you'll need an
|
||||
account! Accounts in the LLM are actually special on-chain contracts. A user
|
||||
account! Accounts in the Pool are actually special on-chain contracts. A user
|
||||
deposits a certain amount of funds into an account which has a set expiry. By
|
||||
having users commit funds to an account in order to place orders, we ensure
|
||||
that they're unable to spoof orders (placing an order that they can't fulfil).
|
||||
|
|
@ -107,9 +107,9 @@ transaction.
|
|||
Creating an account has two parameters: the size of the account, and the expiry
|
||||
of an account. As you'll see below, both values can be adjusted at any time.
|
||||
|
||||
We can create an account using `llm`, like so:
|
||||
We can create an account using `pool`, like so:
|
||||
```
|
||||
🏔 llm accounts new --amt=50000000 --expiry_height=1773394
|
||||
🏔 pool accounts new --amt=50000000 --expiry_height=1773394
|
||||
{
|
||||
"trader_key": "0288096be9917f8ebdfc6eb2701635fe658f4eae1e0274dcce41418b3fb5145732",
|
||||
"outpoint": "c6f62c80095c98a57f2eef485a7ff06611f97dc856754cad330f4eeb538ff514:0",
|
||||
|
|
@ -131,7 +131,7 @@ to sign orders), and the outpoint of my new account.
|
|||
Once at least 3 blocks has passed (in the alpha), the account will be confirmed
|
||||
and ready for use:
|
||||
```
|
||||
🏔 llm accounts list
|
||||
🏔 pool accounts list
|
||||
{
|
||||
"accounts": [
|
||||
{
|
||||
|
|
@ -148,7 +148,7 @@ and ready for use:
|
|||
|
||||
#### Depositing To An Account
|
||||
|
||||
We can add more funds to an account using the `llm accounts deposit` command.
|
||||
We can add more funds to an account using the `pool accounts deposit` command.
|
||||
Under the hood, we can actually batch _other_ transactions with account
|
||||
modifications (make other payments, etc), but for now we expose only the basic
|
||||
functionality over the CLI.
|
||||
|
|
@ -159,7 +159,7 @@ won't be picked up by the auctioneer.
|
|||
Let's say I want to deposit an extra 1 million satoshis into my account, I can
|
||||
do so with the following command:
|
||||
```
|
||||
🏔 llm accounts deposit --trader_key=0288096be9917f8ebdfc6eb2701635fe658f4eae1e0274dcce41418b3fb5145732 --amt=1000000 --sat_per_vbyte=5
|
||||
🏔 pool accounts deposit --trader_key=0288096be9917f8ebdfc6eb2701635fe658f4eae1e0274dcce41418b3fb5145732 --amt=1000000 --sat_per_vbyte=5
|
||||
{
|
||||
"account": {
|
||||
"trader_key": "0288096be9917f8ebdfc6eb2701635fe658f4eae1e0274dcce41418b3fb5145732",
|
||||
|
|
@ -173,12 +173,12 @@ do so with the following command:
|
|||
}
|
||||
```
|
||||
|
||||
I specify my `trader_key` explicitly, as it's possible for `llmd` to manage
|
||||
I specify my `trader_key` explicitly, as it's possible for `poold` to manage
|
||||
_multiple_ accounts. The response shows my modified account, along side with
|
||||
the `txid` that'll be used to service the deposit. Once this transaction has
|
||||
confirmed, I'll be able to use my account again.
|
||||
|
||||
Note that these funds came from the backing `lnd` node that `llmd` is connected
|
||||
Note that these funds came from the backing `lnd` node that `poold` is connected
|
||||
to. At a future time we also plan to support a traditional _deposit_ address as
|
||||
well.
|
||||
|
||||
|
|
@ -189,7 +189,7 @@ similar to the deposit command. If I wanted to extract that 1 million from that
|
|||
account (let's say it's my profit for the past week) and send elsewhere, I can
|
||||
do so with the following command:
|
||||
```
|
||||
🏔 llm accounts withdraw --trader_key=0288096be9917f8ebdfc6eb2701635fe658f4eae1e0274dcce41418b3fb5145732 --amt=1000000 --sat_per_vbyte=5 --addr=tb1qe3ueyx8jhlj4h0s6mgywmtl8vlwxqkgkgp3m3s
|
||||
🏔 pool accounts withdraw --trader_key=0288096be9917f8ebdfc6eb2701635fe658f4eae1e0274dcce41418b3fb5145732 --amt=1000000 --sat_per_vbyte=5 --addr=tb1qe3ueyx8jhlj4h0s6mgywmtl8vlwxqkgkgp3m3s
|
||||
{
|
||||
"account": {
|
||||
"trader_key": "0288096be9917f8ebdfc6eb2701635fe658f4eae1e0274dcce41418b3fb5145732",
|
||||
|
|
@ -209,23 +209,23 @@ Finally, if you wish to send _all_ your funds elsewhere, it's possible to close
|
|||
your account out before the main expiration period. We can close out the
|
||||
account we created above with the following command:
|
||||
```
|
||||
🏔 llm accounts close --trader_key=0288096be9917f8ebdfc6eb2701635fe658f4eae1e0274dcce41418b3fb5145732
|
||||
🏔 pool accounts close --trader_key=0288096be9917f8ebdfc6eb2701635fe658f4eae1e0274dcce41418b3fb5145732
|
||||
```
|
||||
|
||||
### Orders
|
||||
|
||||
Now that we have our account set up and funded, it's time to trade some channels!
|
||||
|
||||
There're two types of orders in the current version of the LLM: asks, and bids.
|
||||
There're two types of orders in the current version of Pool: asks, and bids.
|
||||
You submit an ask when you have some coins that you want to _lease out_ as
|
||||
inbound liquidity for a maximum period of time (expressed in blocks), at a
|
||||
fixed rate compounded per block. You submit a bid when you need to acquire
|
||||
inbound liquidity (ability to receive), for a minimum amount of time (again
|
||||
expressed in blocks), paying out a fixed rate that compounds per-block.
|
||||
|
||||
In the alpha version of LLM, a single lump sum premium is paid after order
|
||||
execution. In future versions, we plan on introducing "coupon channels" which
|
||||
allow for _streaming interest_ to be paid out.
|
||||
In the alpha version of Lightning Pool, a single lump sum premium is paid after
|
||||
order execution. In future versions, we plan on introducing "coupon channels"
|
||||
which allow for _streaming interest_ to be paid out.
|
||||
|
||||
One important aspect of the market is that rather than buy/sell satoshis, we
|
||||
use _units_. A unit is imply 100,000 satoshis and represents the _smallest_
|
||||
|
|
@ -236,7 +236,7 @@ BTC that's been burning a hole in our SD card for the past year. We'll place a
|
|||
single order for 10 million satoshis, wanting to receive 0.3% (30 bps)
|
||||
over a 3000 block period (a bit under 3 weeks):
|
||||
```
|
||||
🏔 llm orders submit ask 10000000 0288096be9917f8ebdfc6eb2701635fe658f4eae1e0274dcce41418b3fb5145732 --interest_rate_percent=0.3 --max_duration_blocks=3000
|
||||
🏔 pool orders submit ask 10000000 0288096be9917f8ebdfc6eb2701635fe658f4eae1e0274dcce41418b3fb5145732 --interest_rate_percent=0.3 --max_duration_blocks=3000
|
||||
-- Order Details --
|
||||
Ask Amount: 0.1 BTC
|
||||
Ask Duration: 3000
|
||||
|
|
@ -276,7 +276,7 @@ orders, and also for authentication purposes.
|
|||
|
||||
We can then check out the order we just placed with the following command:
|
||||
```
|
||||
🏔 llm orders list
|
||||
🏔 pool orders list
|
||||
{
|
||||
"asks": [
|
||||
{
|
||||
|
|
@ -308,7 +308,7 @@ min partial match size.
|
|||
### Batched Uniform-Price Clearing
|
||||
|
||||
Now that we have orders submitted, how does the rest of the auction actually
|
||||
work? As mentioned above, LLM conducts a _discrete_ batch auction every 10
|
||||
work? As mentioned above, Pool conducts a _discrete_ batch auction every 10
|
||||
minutes. This is distinct from regular continuous exchanges in that orders are
|
||||
only cleared every 10 minutes. Orders are also sealed-bid, meaning that other
|
||||
traders in the venue are unable to see what others have bid. On top
|
||||
|
|
@ -339,13 +339,13 @@ allows for thousands of channels to be bought/sold atomically in a single
|
|||
block. We call the transaction that executes the orders the Batch Execution
|
||||
Transaction.
|
||||
|
||||
The `llm auction` sub-command houses a number of useful commands to explore the
|
||||
The `pool auction` sub-command houses a number of useful commands to explore the
|
||||
past batches, and examine the current auction parameters.
|
||||
|
||||
Once can browse the latest cleared batch using the `llm auction snapshot`
|
||||
Once can browse the latest cleared batch using the `pool auction snapshot`
|
||||
command:
|
||||
```
|
||||
🏔 llm auction snapshot
|
||||
🏔 pool auction snapshot
|
||||
{
|
||||
"version": 0,
|
||||
"batch_id": "02824d0cbac65e01712124c50ff2cc74ce22851d7b444c1bf2ae66afefb8eaf27f",
|
||||
|
|
@ -388,12 +388,12 @@ The command also accept a target `batch_id` as well. Here we can use the
|
|||
`prev_batch_id` to examine the _prior_ batch, similar to traversing a
|
||||
link-listed/blockchain:
|
||||
```
|
||||
🏔 llm auction snapshot --batch_id=03687baa3c7414e800ddba37edacb3281999739303b7290a69bd457f428ecd9b2c
|
||||
🏔 pool auction snapshot --batch_id=03687baa3c7414e800ddba37edacb3281999739303b7290a69bd457f428ecd9b2c
|
||||
```
|
||||
|
||||
### Service Level Lifetime Enforcement
|
||||
|
||||
In the alpha version of LLM, _script level enforcement_ isn't yet implemented.
|
||||
In the alpha version of Pool, _script level enforcement_ isn't yet implemented.
|
||||
Script level enforcement would lock the maker's funds in the channel for the
|
||||
lease period. This ensures that they can't just collect the premium (before
|
||||
coupon channels) and close out the channel instantly. With script enforcement,
|
||||
|
|
@ -409,16 +409,16 @@ channel, then we'll ban them from the market for a set period of time.
|
|||
|
||||
The following section assumes at least Go 1.13 is installed.
|
||||
|
||||
To install the primary daemon (`llmd`) and the CLI used to control the daemon,
|
||||
To install the primary daemon (`poold`) and the CLI used to control the daemon,
|
||||
the following command should be run:
|
||||
```
|
||||
🏔 make install
|
||||
```
|
||||
|
||||
Assuming `llmd` is now in your `$PATH`, you can start the daemon with the
|
||||
Assuming `poold` is now in your `$PATH`, you can start the daemon with the
|
||||
following command (assuming you have a local testnet `lnd` running):
|
||||
```
|
||||
🏔 llmd --network=testnet --auctionserver=clm.testnet.lightningcluster.com:12010 --debuglevel=trace
|
||||
🏔 poold --network=testnet --auctionserver=clm.testnet.lightningcluster.com:12010 --debuglevel=trace
|
||||
```
|
||||
|
||||
The current server is reachable at `clm.testnet.lightningcluster.com:12010`,
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ import (
|
|||
"github.com/btcsuite/btcutil"
|
||||
"github.com/btcsuite/btcwallet/wallet/txrules"
|
||||
"github.com/btcsuite/btcwallet/wtxmgr"
|
||||
"github.com/lightninglabs/llm/clmscript"
|
||||
"github.com/lightninglabs/llm/terms"
|
||||
"github.com/lightninglabs/pool/poolscript"
|
||||
"github.com/lightninglabs/pool/terms"
|
||||
"github.com/lightninglabs/lndclient"
|
||||
"github.com/lightningnetwork/lnd/input"
|
||||
"github.com/lightningnetwork/lnd/keychain"
|
||||
|
|
@ -184,7 +184,7 @@ const (
|
|||
|
||||
// Output returns the current on-chain output associated with the account.
|
||||
func (a *Account) Output() (*wire.TxOut, error) {
|
||||
script, err := clmscript.AccountScript(
|
||||
script, err := poolscript.AccountScript(
|
||||
a.Expiry, a.TraderKey.PubKey, a.AuctioneerKey, a.BatchKey,
|
||||
a.Secret,
|
||||
)
|
||||
|
|
@ -202,8 +202,8 @@ func (a *Account) Output() (*wire.TxOut, error) {
|
|||
// associated with the account. This is done by using the next batch key, which
|
||||
// results from incrementing the current one by its curve's base point.
|
||||
func (a *Account) NextOutputScript() ([]byte, error) {
|
||||
nextBatchKey := clmscript.IncrementKey(a.BatchKey)
|
||||
return clmscript.AccountScript(
|
||||
nextBatchKey := poolscript.IncrementKey(a.BatchKey)
|
||||
return poolscript.AccountScript(
|
||||
a.Expiry, a.TraderKey.PubKey, a.AuctioneerKey, nextBatchKey,
|
||||
a.Secret,
|
||||
)
|
||||
|
|
@ -276,7 +276,7 @@ func ExpiryModifier(expiry uint32) Modifier {
|
|||
// account by adding the curve's base point.
|
||||
func IncrementBatchKey() Modifier {
|
||||
return func(account *Account) {
|
||||
account.BatchKey = clmscript.IncrementKey(account.BatchKey)
|
||||
account.BatchKey = poolscript.IncrementKey(account.BatchKey)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -429,9 +429,9 @@ func (o *OutputWithFee) CloseOutputs(accountValue btcutil.Amount,
|
|||
// type.
|
||||
switch witnessType {
|
||||
case expiryWitness:
|
||||
weightEstimator.AddWitnessInput(clmscript.ExpiryWitnessSize)
|
||||
weightEstimator.AddWitnessInput(poolscript.ExpiryWitnessSize)
|
||||
case multiSigWitness:
|
||||
weightEstimator.AddWitnessInput(clmscript.MultiSigWitnessSize)
|
||||
weightEstimator.AddWitnessInput(poolscript.MultiSigWitnessSize)
|
||||
default:
|
||||
return nil, fmt.Errorf("unhandled witness type %v", witnessType)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package account
|
|||
|
||||
import (
|
||||
"github.com/btcsuite/btclog"
|
||||
"github.com/lightninglabs/llm/account/watcher"
|
||||
"github.com/lightninglabs/pool/account/watcher"
|
||||
"github.com/lightningnetwork/lnd/build"
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@ import (
|
|||
"github.com/btcsuite/btcutil"
|
||||
"github.com/btcsuite/btcutil/txsort"
|
||||
"github.com/btcsuite/btcwallet/wallet/txrules"
|
||||
"github.com/lightninglabs/llm/account/watcher"
|
||||
"github.com/lightninglabs/llm/clmscript"
|
||||
"github.com/lightninglabs/pool/account/watcher"
|
||||
"github.com/lightninglabs/pool/poolscript"
|
||||
"github.com/lightninglabs/lndclient"
|
||||
"github.com/lightningnetwork/lnd/chainntnfs"
|
||||
"github.com/lightningnetwork/lnd/input"
|
||||
|
|
@ -293,7 +293,7 @@ func (m *Manager) InitAccount(ctx context.Context, value btcutil.Amount,
|
|||
// We'll start by deriving a key for ourselves that we'll use in our
|
||||
// 2-of-2 multi-sig construction.
|
||||
keyDesc, err := m.cfg.Wallet.DeriveNextKey(
|
||||
ctx, int32(clmscript.AccountKeyFamily),
|
||||
ctx, int32(poolscript.AccountKeyFamily),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
@ -484,7 +484,7 @@ func (m *Manager) resumeAccount(ctx context.Context, account *Account, // nolint
|
|||
// outpoint and store it to disk. This will be the main way we
|
||||
// identify our accounts, and is also required to watch for its
|
||||
// spend.
|
||||
outputIndex, ok := clmscript.LocateOutputScript(
|
||||
outputIndex, ok := poolscript.LocateOutputScript(
|
||||
accountTx, accountOutput.PkScript,
|
||||
)
|
||||
if !ok {
|
||||
|
|
@ -643,7 +643,7 @@ func (m *Manager) locateTxByOutput(ctx context.Context,
|
|||
}
|
||||
|
||||
for _, tx := range txs {
|
||||
idx, ok := clmscript.LocateOutputScript(tx.Tx, output.PkScript)
|
||||
idx, ok := poolscript.LocateOutputScript(tx.Tx, output.PkScript)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
|
@ -778,13 +778,13 @@ func (m *Manager) handleAccountSpend(traderKey *btcec.PublicKey,
|
|||
// If the witness is for a spend of the account expiration path, then
|
||||
// we'll mark the account as closed as the account has expired and all
|
||||
// the funds have been withdrawn.
|
||||
case clmscript.IsExpirySpend(spendWitness):
|
||||
case poolscript.IsExpirySpend(spendWitness):
|
||||
break
|
||||
|
||||
// If the witness is for a multi-sig spend, then either an order by the
|
||||
// trader was matched, or the account was closed. If it was closed, then
|
||||
// the account output shouldn't have been recreated.
|
||||
case clmscript.IsMultiSigSpend(spendWitness):
|
||||
case poolscript.IsMultiSigSpend(spendWitness):
|
||||
// If there's a pending batch which has yet to be completed,
|
||||
// we'll mark it as so now. This can happen if the trader is not
|
||||
// connected to the auctioneer when the auctioneer sends them
|
||||
|
|
@ -829,7 +829,7 @@ func (m *Manager) handleAccountSpend(traderKey *btcec.PublicKey,
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, ok := clmscript.LocateOutputScript(
|
||||
_, ok := poolscript.LocateOutputScript(
|
||||
spendTx, accountOutput.PkScript,
|
||||
)
|
||||
if ok {
|
||||
|
|
@ -1173,7 +1173,7 @@ func (m *Manager) spendAccount(ctx context.Context, account *Account,
|
|||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
idx, ok := clmscript.LocateOutputScript(
|
||||
idx, ok := poolscript.LocateOutputScript(
|
||||
spendPkg.tx, newAccountOutput.PkScript,
|
||||
)
|
||||
if !ok {
|
||||
|
|
@ -1262,7 +1262,7 @@ func (m *Manager) spendAccountExpiry(ctx context.Context, account *Account,
|
|||
return nil, err
|
||||
}
|
||||
|
||||
spendPkg.tx.TxIn[0].Witness = clmscript.SpendExpiry(
|
||||
spendPkg.tx.TxIn[0].Witness = poolscript.SpendExpiry(
|
||||
spendPkg.witnessScript, spendPkg.ourSig,
|
||||
)
|
||||
|
||||
|
|
@ -1310,7 +1310,7 @@ func (m *Manager) constructMultiSigWitness(ctx context.Context,
|
|||
return nil, err
|
||||
}
|
||||
|
||||
return clmscript.SpendMultiSig(
|
||||
return poolscript.SpendMultiSig(
|
||||
spendPkg.witnessScript, spendPkg.ourSig, auctioneerSig,
|
||||
), nil
|
||||
}
|
||||
|
|
@ -1405,9 +1405,9 @@ func addBaseAccountModificationWeight(weightEstimator *input.TxWeightEstimator,
|
|||
var accountInputWitnessSize int
|
||||
switch witnessType {
|
||||
case expiryWitness:
|
||||
accountInputWitnessSize = clmscript.ExpiryWitnessSize
|
||||
accountInputWitnessSize = poolscript.ExpiryWitnessSize
|
||||
case multiSigWitness:
|
||||
accountInputWitnessSize = clmscript.MultiSigWitnessSize
|
||||
accountInputWitnessSize = poolscript.MultiSigWitnessSize
|
||||
default:
|
||||
return fmt.Errorf("unknown witness type %v", witnessType)
|
||||
}
|
||||
|
|
@ -1683,10 +1683,10 @@ func (m *Manager) signAccountInput(ctx context.Context, tx *wire.MsgTx,
|
|||
account *Account, idx int, sigHashType txscript.SigHashType) ([]byte,
|
||||
[]byte, error) {
|
||||
|
||||
traderKeyTweak := clmscript.TraderKeyTweak(
|
||||
traderKeyTweak := poolscript.TraderKeyTweak(
|
||||
account.BatchKey, account.Secret, account.TraderKey.PubKey,
|
||||
)
|
||||
witnessScript, err := clmscript.AccountWitnessScript(
|
||||
witnessScript, err := poolscript.AccountWitnessScript(
|
||||
account.Expiry, account.TraderKey.PubKey, account.AuctioneerKey,
|
||||
account.BatchKey, account.Secret,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ import (
|
|||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/btcsuite/btcutil"
|
||||
"github.com/btcsuite/btcwallet/wtxmgr"
|
||||
"github.com/lightninglabs/llm/clmscript"
|
||||
"github.com/lightninglabs/llm/terms"
|
||||
"github.com/lightninglabs/pool/poolscript"
|
||||
"github.com/lightninglabs/pool/terms"
|
||||
"github.com/lightninglabs/lndclient"
|
||||
"github.com/lightningnetwork/lnd/chainntnfs"
|
||||
"github.com/lightningnetwork/lnd/input"
|
||||
|
|
@ -32,7 +32,7 @@ var (
|
|||
|
||||
testTraderKeyDesc = &keychain.KeyDescriptor{
|
||||
KeyLocator: keychain.KeyLocator{
|
||||
Family: clmscript.AccountKeyFamily,
|
||||
Family: poolscript.AccountKeyFamily,
|
||||
Index: 0,
|
||||
},
|
||||
PubKey: testTraderKey,
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package account
|
|||
import (
|
||||
"context"
|
||||
|
||||
"github.com/lightninglabs/llm/clmscript"
|
||||
"github.com/lightninglabs/pool/poolscript"
|
||||
"github.com/lightninglabs/lndclient"
|
||||
"github.com/lightningnetwork/lnd/keychain"
|
||||
)
|
||||
|
|
@ -25,7 +25,7 @@ func GenerateRecoveryKeys(ctx context.Context,
|
|||
acctKeys := make([]*keychain.KeyDescriptor, DefaultAccountKeyWindow)
|
||||
for i := uint32(0); i < DefaultAccountKeyWindow; i++ {
|
||||
key, err := wallet.DeriveKey(ctx, &keychain.KeyLocator{
|
||||
Family: clmscript.AccountKeyFamily,
|
||||
Family: poolscript.AccountKeyFamily,
|
||||
Index: i,
|
||||
})
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import (
|
|||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/lightninglabs/llm/internal/test"
|
||||
"github.com/lightninglabs/pool/internal/test"
|
||||
)
|
||||
|
||||
// TestGenerateRecoveryKeys tests that a certain number of keys can be created
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@ import (
|
|||
"crypto/rand"
|
||||
"fmt"
|
||||
|
||||
"github.com/lightninglabs/llm/account"
|
||||
"github.com/lightninglabs/llm/clmrpc"
|
||||
"github.com/lightninglabs/llm/order"
|
||||
"github.com/lightninglabs/pool/account"
|
||||
"github.com/lightninglabs/pool/poolrpc"
|
||||
"github.com/lightninglabs/pool/order"
|
||||
"github.com/lightninglabs/lndclient"
|
||||
"github.com/lightningnetwork/lnd/keychain"
|
||||
)
|
||||
|
|
@ -18,9 +18,9 @@ import (
|
|||
type acctSubscription struct {
|
||||
acctKey *keychain.KeyDescriptor
|
||||
commitHash [32]byte
|
||||
sendMsg func(*clmrpc.ClientAuctionMessage) error
|
||||
sendMsg func(*poolrpc.ClientAuctionMessage) error
|
||||
signer lndclient.SignerClient
|
||||
msgChan chan *clmrpc.ServerAuctionMessage
|
||||
msgChan chan *poolrpc.ServerAuctionMessage
|
||||
quit <-chan struct{}
|
||||
}
|
||||
|
||||
|
|
@ -45,9 +45,9 @@ func (s *acctSubscription) authenticate(ctx context.Context) error {
|
|||
// a challenge back. We need to track the subscription from now on so
|
||||
// the goroutine reading the incoming messages knows which subscription
|
||||
// to add the received challenge to.
|
||||
err = s.sendMsg(&clmrpc.ClientAuctionMessage{
|
||||
Msg: &clmrpc.ClientAuctionMessage_Commit{
|
||||
Commit: &clmrpc.AccountCommitment{
|
||||
err = s.sendMsg(&poolrpc.ClientAuctionMessage{
|
||||
Msg: &poolrpc.ClientAuctionMessage_Commit{
|
||||
Commit: &poolrpc.AccountCommitment{
|
||||
CommitHash: s.commitHash[:],
|
||||
BatchVersion: uint32(order.CurrentVersion),
|
||||
},
|
||||
|
|
@ -66,7 +66,7 @@ func (s *acctSubscription) authenticate(ctx context.Context) error {
|
|||
"was received")
|
||||
}
|
||||
|
||||
msg, ok := srvMsg.Msg.(*clmrpc.ServerAuctionMessage_Challenge)
|
||||
msg, ok := srvMsg.Msg.(*poolrpc.ServerAuctionMessage_Challenge)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected server message in auth "+
|
||||
"process: %v", msg)
|
||||
|
|
@ -84,9 +84,9 @@ func (s *acctSubscription) authenticate(ctx context.Context) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return s.sendMsg(&clmrpc.ClientAuctionMessage{
|
||||
Msg: &clmrpc.ClientAuctionMessage_Subscribe{
|
||||
Subscribe: &clmrpc.AccountSubscription{
|
||||
return s.sendMsg(&poolrpc.ClientAuctionMessage{
|
||||
Msg: &poolrpc.ClientAuctionMessage_Subscribe{
|
||||
Subscribe: &poolrpc.AccountSubscription{
|
||||
TraderKey: acctPubKey[:],
|
||||
CommitNonce: nonce[:],
|
||||
AuthSig: sig,
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec"
|
||||
"github.com/lightninglabs/llm/clmrpc"
|
||||
"github.com/lightninglabs/llm/internal/test"
|
||||
"github.com/lightninglabs/pool/poolrpc"
|
||||
"github.com/lightninglabs/pool/internal/test"
|
||||
"github.com/lightningnetwork/lnd/keychain"
|
||||
)
|
||||
|
||||
|
|
@ -31,10 +31,10 @@ var (
|
|||
// handshake is performed correctly when subscribing for account updates.
|
||||
func TestAccountSubscriptionAuthenticate(t *testing.T) {
|
||||
var (
|
||||
msgChan = make(chan *clmrpc.ClientAuctionMessage)
|
||||
srvMsgChan = make(chan *clmrpc.ServerAuctionMessage)
|
||||
msgChan = make(chan *poolrpc.ClientAuctionMessage)
|
||||
srvMsgChan = make(chan *poolrpc.ServerAuctionMessage)
|
||||
errChan = make(chan error)
|
||||
sendMsg = func(msg *clmrpc.ClientAuctionMessage) error {
|
||||
sendMsg = func(msg *poolrpc.ClientAuctionMessage) error {
|
||||
msgChan <- msg
|
||||
return nil
|
||||
}
|
||||
|
|
@ -55,7 +55,7 @@ func TestAccountSubscriptionAuthenticate(t *testing.T) {
|
|||
// Step 1: We expect a commitment message.
|
||||
select {
|
||||
case msg := <-msgChan:
|
||||
if _, ok := msg.Msg.(*clmrpc.ClientAuctionMessage_Commit); !ok {
|
||||
if _, ok := msg.Msg.(*poolrpc.ClientAuctionMessage_Commit); !ok {
|
||||
t.Fatalf("unexpected message type: %v", msg)
|
||||
}
|
||||
|
||||
|
|
@ -64,9 +64,9 @@ func TestAccountSubscriptionAuthenticate(t *testing.T) {
|
|||
}
|
||||
|
||||
// Step 2: Simulate the server sending back the challenge.
|
||||
srvMsgChan <- &clmrpc.ServerAuctionMessage{
|
||||
Msg: &clmrpc.ServerAuctionMessage_Challenge{
|
||||
Challenge: &clmrpc.ServerChallenge{
|
||||
srvMsgChan <- &poolrpc.ServerAuctionMessage{
|
||||
Msg: &poolrpc.ServerAuctionMessage_Challenge{
|
||||
Challenge: &poolrpc.ServerChallenge{
|
||||
Challenge: []byte{11, 99, 11},
|
||||
},
|
||||
},
|
||||
|
|
@ -75,7 +75,7 @@ func TestAccountSubscriptionAuthenticate(t *testing.T) {
|
|||
// Step 3: We expect the final message, the subscription.
|
||||
select {
|
||||
case msg := <-msgChan:
|
||||
subMsg, ok := msg.Msg.(*clmrpc.ClientAuctionMessage_Subscribe)
|
||||
subMsg, ok := msg.Msg.(*poolrpc.ClientAuctionMessage_Subscribe)
|
||||
if !ok {
|
||||
t.Fatalf("unexpected message type: %v", msg)
|
||||
}
|
||||
|
|
@ -93,10 +93,10 @@ func TestAccountSubscriptionAuthenticate(t *testing.T) {
|
|||
// handshake is canceled if the channel is closed prematurely.
|
||||
func TestAccountSubscriptionAuthenticateAbort(t *testing.T) {
|
||||
var (
|
||||
msgChan = make(chan *clmrpc.ClientAuctionMessage)
|
||||
srvMsgChan = make(chan *clmrpc.ServerAuctionMessage)
|
||||
msgChan = make(chan *poolrpc.ClientAuctionMessage)
|
||||
srvMsgChan = make(chan *poolrpc.ServerAuctionMessage)
|
||||
errChan = make(chan error)
|
||||
sendMsg = func(msg *clmrpc.ClientAuctionMessage) error {
|
||||
sendMsg = func(msg *poolrpc.ClientAuctionMessage) error {
|
||||
msgChan <- msg
|
||||
return nil
|
||||
}
|
||||
|
|
@ -117,7 +117,7 @@ func TestAccountSubscriptionAuthenticateAbort(t *testing.T) {
|
|||
// Step 1: We expect a commitment message.
|
||||
select {
|
||||
case msg := <-msgChan:
|
||||
if _, ok := msg.Msg.(*clmrpc.ClientAuctionMessage_Commit); !ok {
|
||||
if _, ok := msg.Msg.(*poolrpc.ClientAuctionMessage_Commit); !ok {
|
||||
t.Fatalf("unexpected message type: %v", msg)
|
||||
}
|
||||
|
||||
|
|
@ -145,10 +145,10 @@ func TestAccountSubscriptionAuthenticateAbort(t *testing.T) {
|
|||
// authentication handshake is canceled if the context is canceled prematurely.
|
||||
func TestAccountSubscriptionAuthenticateContextClose(t *testing.T) {
|
||||
var (
|
||||
msgChan = make(chan *clmrpc.ClientAuctionMessage)
|
||||
srvMsgChan = make(chan *clmrpc.ServerAuctionMessage)
|
||||
msgChan = make(chan *poolrpc.ClientAuctionMessage)
|
||||
srvMsgChan = make(chan *poolrpc.ServerAuctionMessage)
|
||||
errChan = make(chan error)
|
||||
sendMsg = func(msg *clmrpc.ClientAuctionMessage) error {
|
||||
sendMsg = func(msg *poolrpc.ClientAuctionMessage) error {
|
||||
msgChan <- msg
|
||||
return nil
|
||||
}
|
||||
|
|
@ -170,7 +170,7 @@ func TestAccountSubscriptionAuthenticateContextClose(t *testing.T) {
|
|||
// Step 1: We expect a commitment message.
|
||||
select {
|
||||
case msg := <-msgChan:
|
||||
if _, ok := msg.Msg.(*clmrpc.ClientAuctionMessage_Commit); !ok {
|
||||
if _, ok := msg.Msg.(*poolrpc.ClientAuctionMessage_Commit); !ok {
|
||||
t.Fatalf("unexpected message type: %v", msg)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,9 +7,9 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/lightninglabs/llm/account"
|
||||
"github.com/lightninglabs/llm/clmrpc"
|
||||
"github.com/lightninglabs/llm/order"
|
||||
"github.com/lightninglabs/pool/account"
|
||||
"github.com/lightninglabs/pool/poolrpc"
|
||||
"github.com/lightninglabs/pool/order"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
@ -66,7 +66,7 @@ func (c *Client) checkPendingBatch() error {
|
|||
// finalizedBatchTx retrieves the finalized transaction of a batch according to
|
||||
// the auctioneer, i.e., the transaction that will be broadcast to the network.
|
||||
func (c *Client) finalizedBatchTx(id order.BatchID) (*wire.MsgTx, error) {
|
||||
req := &clmrpc.RelevantBatchRequest{Id: id[:]}
|
||||
req := &poolrpc.RelevantBatchRequest{Id: id[:]}
|
||||
batch, err := c.client.RelevantBatchSnapshot(context.Background(), req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
|||
|
|
@ -15,10 +15,10 @@ import (
|
|||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/btcsuite/btcutil"
|
||||
"github.com/lightninglabs/llm/account"
|
||||
"github.com/lightninglabs/llm/clmrpc"
|
||||
"github.com/lightninglabs/llm/order"
|
||||
"github.com/lightninglabs/llm/terms"
|
||||
"github.com/lightninglabs/pool/account"
|
||||
"github.com/lightninglabs/pool/poolrpc"
|
||||
"github.com/lightninglabs/pool/order"
|
||||
"github.com/lightninglabs/pool/terms"
|
||||
"github.com/lightninglabs/lndclient"
|
||||
"github.com/lightningnetwork/lnd/keychain"
|
||||
"google.golang.org/grpc"
|
||||
|
|
@ -93,14 +93,14 @@ type Client struct {
|
|||
stopped uint32
|
||||
|
||||
StreamErrChan chan error
|
||||
FromServerChan chan *clmrpc.ServerAuctionMessage
|
||||
FromServerChan chan *poolrpc.ServerAuctionMessage
|
||||
|
||||
serverConn *grpc.ClientConn
|
||||
client clmrpc.ChannelAuctioneerClient
|
||||
client poolrpc.ChannelAuctioneerClient
|
||||
|
||||
quit chan struct{}
|
||||
wg sync.WaitGroup
|
||||
serverStream clmrpc.ChannelAuctioneer_SubscribeBatchAuctionClient
|
||||
serverStream poolrpc.ChannelAuctioneer_SubscribeBatchAuctionClient
|
||||
streamMutex sync.Mutex
|
||||
streamCancel func()
|
||||
subscribedAccts map[[33]byte]*acctSubscription
|
||||
|
|
@ -118,7 +118,7 @@ func NewClient(cfg *Config) (*Client, error) {
|
|||
|
||||
return &Client{
|
||||
cfg: cfg,
|
||||
FromServerChan: make(chan *clmrpc.ServerAuctionMessage),
|
||||
FromServerChan: make(chan *poolrpc.ServerAuctionMessage),
|
||||
StreamErrChan: make(chan error),
|
||||
quit: make(chan struct{}),
|
||||
subscribedAccts: make(map[[33]byte]*acctSubscription),
|
||||
|
|
@ -138,7 +138,7 @@ func (c *Client) Start() error {
|
|||
}
|
||||
|
||||
c.serverConn = serverConn
|
||||
c.client = clmrpc.NewChannelAuctioneerClient(serverConn)
|
||||
c.client = poolrpc.NewChannelAuctioneerClient(serverConn)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
@ -220,7 +220,7 @@ func (c *Client) ReserveAccount(ctx context.Context, value btcutil.Amount,
|
|||
expiry uint32, traderKey *btcec.PublicKey) (*account.Reservation,
|
||||
error) {
|
||||
|
||||
resp, err := c.client.ReserveAccount(ctx, &clmrpc.ReserveAccountRequest{
|
||||
resp, err := c.client.ReserveAccount(ctx, &poolrpc.ReserveAccountRequest{
|
||||
AccountValue: uint64(value),
|
||||
TraderKey: traderKey.SerializeCompressed(),
|
||||
AccountExpiry: expiry,
|
||||
|
|
@ -256,8 +256,8 @@ func (c *Client) InitAccount(ctx context.Context, account *account.Account) erro
|
|||
return fmt.Errorf("unable to construct account output: %v", err)
|
||||
}
|
||||
|
||||
_, err = c.client.InitAccount(ctx, &clmrpc.ServerInitAccountRequest{
|
||||
AccountPoint: &clmrpc.OutPoint{
|
||||
_, err = c.client.InitAccount(ctx, &poolrpc.ServerInitAccountRequest{
|
||||
AccountPoint: &poolrpc.OutPoint{
|
||||
Txid: account.OutPoint.Hash[:],
|
||||
OutputIndex: account.OutPoint.Index,
|
||||
},
|
||||
|
|
@ -281,34 +281,34 @@ func (c *Client) ModifyAccount(ctx context.Context, account *account.Account,
|
|||
inputs []*wire.TxIn, outputs []*wire.TxOut,
|
||||
modifiers []account.Modifier) ([]byte, error) {
|
||||
|
||||
rpcInputs := make([]*clmrpc.ServerInput, 0, len(inputs))
|
||||
rpcInputs := make([]*poolrpc.ServerInput, 0, len(inputs))
|
||||
for _, input := range inputs {
|
||||
op := input.PreviousOutPoint
|
||||
rpcInputs = append(rpcInputs, &clmrpc.ServerInput{
|
||||
Outpoint: &clmrpc.OutPoint{
|
||||
rpcInputs = append(rpcInputs, &poolrpc.ServerInput{
|
||||
Outpoint: &poolrpc.OutPoint{
|
||||
Txid: op.Hash[:],
|
||||
OutputIndex: op.Index,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
rpcOutputs := make([]*clmrpc.ServerOutput, 0, len(outputs))
|
||||
rpcOutputs := make([]*poolrpc.ServerOutput, 0, len(outputs))
|
||||
for _, output := range outputs {
|
||||
rpcOutputs = append(rpcOutputs, &clmrpc.ServerOutput{
|
||||
rpcOutputs = append(rpcOutputs, &poolrpc.ServerOutput{
|
||||
Value: uint64(output.Value),
|
||||
Script: output.PkScript,
|
||||
})
|
||||
}
|
||||
|
||||
var rpcNewParams *clmrpc.ServerModifyAccountRequest_NewAccountParameters
|
||||
var rpcNewParams *poolrpc.ServerModifyAccountRequest_NewAccountParameters
|
||||
modifiedAccount := account.Copy(modifiers...)
|
||||
if len(modifiers) > 0 {
|
||||
rpcNewParams = &clmrpc.ServerModifyAccountRequest_NewAccountParameters{
|
||||
rpcNewParams = &poolrpc.ServerModifyAccountRequest_NewAccountParameters{
|
||||
Value: uint64(modifiedAccount.Value),
|
||||
}
|
||||
}
|
||||
|
||||
resp, err := c.client.ModifyAccount(ctx, &clmrpc.ServerModifyAccountRequest{
|
||||
resp, err := c.client.ModifyAccount(ctx, &poolrpc.ServerModifyAccountRequest{
|
||||
TraderKey: account.TraderKey.PubKey.SerializeCompressed(),
|
||||
NewInputs: rpcInputs,
|
||||
NewOutputs: rpcOutputs,
|
||||
|
|
@ -328,15 +328,15 @@ func (c *Client) SubmitOrder(ctx context.Context, o order.Order,
|
|||
|
||||
// Prepare everything that is common to both ask and bid orders.
|
||||
nonce := o.Nonce()
|
||||
rpcRequest := &clmrpc.ServerSubmitOrderRequest{}
|
||||
nodeAddrs := make([]*clmrpc.NodeAddress, 0, len(serverParams.Addrs))
|
||||
rpcRequest := &poolrpc.ServerSubmitOrderRequest{}
|
||||
nodeAddrs := make([]*poolrpc.NodeAddress, 0, len(serverParams.Addrs))
|
||||
for _, addr := range serverParams.Addrs {
|
||||
nodeAddrs = append(nodeAddrs, &clmrpc.NodeAddress{
|
||||
nodeAddrs = append(nodeAddrs, &poolrpc.NodeAddress{
|
||||
Network: addr.Network(),
|
||||
Addr: addr.String(),
|
||||
})
|
||||
}
|
||||
details := &clmrpc.ServerOrder{
|
||||
details := &poolrpc.ServerOrder{
|
||||
TraderKey: o.Details().AcctKey[:],
|
||||
RateFixed: o.Details().FixedRate,
|
||||
Amt: uint64(o.Details().Amt),
|
||||
|
|
@ -351,22 +351,22 @@ func (c *Client) SubmitOrder(ctx context.Context, o order.Order,
|
|||
// Split into server message which is type specific.
|
||||
switch castOrder := o.(type) {
|
||||
case *order.Ask:
|
||||
serverAsk := &clmrpc.ServerAsk{
|
||||
serverAsk := &poolrpc.ServerAsk{
|
||||
Details: details,
|
||||
MaxDurationBlocks: castOrder.MaxDuration,
|
||||
Version: uint32(castOrder.Version),
|
||||
}
|
||||
rpcRequest.Details = &clmrpc.ServerSubmitOrderRequest_Ask{
|
||||
rpcRequest.Details = &poolrpc.ServerSubmitOrderRequest_Ask{
|
||||
Ask: serverAsk,
|
||||
}
|
||||
|
||||
case *order.Bid:
|
||||
serverBid := &clmrpc.ServerBid{
|
||||
serverBid := &poolrpc.ServerBid{
|
||||
Details: details,
|
||||
MinDurationBlocks: castOrder.MinDuration,
|
||||
Version: uint32(castOrder.Version),
|
||||
}
|
||||
rpcRequest.Details = &clmrpc.ServerSubmitOrderRequest_Bid{
|
||||
rpcRequest.Details = &poolrpc.ServerSubmitOrderRequest_Bid{
|
||||
Bid: serverBid,
|
||||
}
|
||||
|
||||
|
|
@ -380,13 +380,13 @@ func (c *Client) SubmitOrder(ctx context.Context, o order.Order,
|
|||
return err
|
||||
}
|
||||
switch submitResp := resp.Details.(type) {
|
||||
case *clmrpc.ServerSubmitOrderResponse_InvalidOrder:
|
||||
case *poolrpc.ServerSubmitOrderResponse_InvalidOrder:
|
||||
return &order.UserError{
|
||||
FailMsg: submitResp.InvalidOrder.FailString,
|
||||
Details: submitResp.InvalidOrder,
|
||||
}
|
||||
|
||||
case *clmrpc.ServerSubmitOrderResponse_Accepted:
|
||||
case *poolrpc.ServerSubmitOrderResponse_Accepted:
|
||||
return nil
|
||||
|
||||
default:
|
||||
|
|
@ -396,7 +396,7 @@ func (c *Client) SubmitOrder(ctx context.Context, o order.Order,
|
|||
|
||||
// CancelOrder sends an order cancellation message to the server.
|
||||
func (c *Client) CancelOrder(ctx context.Context, nonce order.Nonce) error {
|
||||
_, err := c.client.CancelOrder(ctx, &clmrpc.ServerCancelOrderRequest{
|
||||
_, err := c.client.CancelOrder(ctx, &poolrpc.ServerCancelOrderRequest{
|
||||
OrderNonce: nonce[:],
|
||||
})
|
||||
return err
|
||||
|
|
@ -406,9 +406,9 @@ func (c *Client) CancelOrder(ctx context.Context, nonce order.Nonce) error {
|
|||
// state as it's currently known to the server's database. For real-time updates
|
||||
// on the state, the SubscribeBatchAuction stream should be used.
|
||||
func (c *Client) OrderState(ctx context.Context, nonce order.Nonce) (
|
||||
*clmrpc.ServerOrderStateResponse, error) {
|
||||
*poolrpc.ServerOrderStateResponse, error) {
|
||||
|
||||
return c.client.OrderState(ctx, &clmrpc.ServerOrderStateRequest{
|
||||
return c.client.OrderState(ctx, &poolrpc.ServerOrderStateRequest{
|
||||
OrderNonce: nonce[:],
|
||||
})
|
||||
}
|
||||
|
|
@ -473,7 +473,7 @@ func (c *Client) connectAndAuthenticate(ctx context.Context,
|
|||
acctKey: acctKey,
|
||||
sendMsg: c.SendAuctionMessage,
|
||||
signer: c.cfg.Signer,
|
||||
msgChan: make(chan *clmrpc.ServerAuctionMessage),
|
||||
msgChan: make(chan *poolrpc.ServerAuctionMessage),
|
||||
quit: c.quit,
|
||||
}
|
||||
c.subscribedAccts[acctPubKey] = sub
|
||||
|
|
@ -516,7 +516,7 @@ func (c *Client) connectAndAuthenticate(ctx context.Context,
|
|||
// normal recovery in that case because the account
|
||||
// subscription cannot be completed. This needs to be
|
||||
// handled specifically so we return a typed error now.
|
||||
if errMsg.ErrorCode == clmrpc.SubscribeError_INCOMPLETE_ACCOUNT_RESERVATION {
|
||||
if errMsg.ErrorCode == poolrpc.SubscribeError_INCOMPLETE_ACCOUNT_RESERVATION {
|
||||
return sub, true, AcctResNotCompletedErrFromRPC(
|
||||
*errMsg.AccountReservation,
|
||||
)
|
||||
|
|
@ -525,7 +525,7 @@ func (c *Client) connectAndAuthenticate(ctx context.Context,
|
|||
// The account doesn't exist. We are in recovery mode so
|
||||
// this is fine. We just skip this account key and try
|
||||
// the next one.
|
||||
if errMsg.ErrorCode == clmrpc.SubscribeError_ACCOUNT_DOES_NOT_EXIST {
|
||||
if errMsg.ErrorCode == poolrpc.SubscribeError_ACCOUNT_DOES_NOT_EXIST {
|
||||
return sub, false, nil
|
||||
}
|
||||
|
||||
|
|
@ -612,9 +612,9 @@ func (c *Client) RecoverAccounts(ctx context.Context,
|
|||
// its database. The response to this message will be handled
|
||||
// outside of the client.
|
||||
numNotFoundAccounts = 0
|
||||
err = c.SendAuctionMessage(&clmrpc.ClientAuctionMessage{
|
||||
Msg: &clmrpc.ClientAuctionMessage_Recover{
|
||||
Recover: &clmrpc.AccountRecovery{
|
||||
err = c.SendAuctionMessage(&poolrpc.ClientAuctionMessage{
|
||||
Msg: &poolrpc.ClientAuctionMessage_Recover{
|
||||
Recover: &poolrpc.AccountRecovery{
|
||||
TraderKey: acctKeyBytes,
|
||||
},
|
||||
},
|
||||
|
|
@ -627,7 +627,7 @@ func (c *Client) RecoverAccounts(ctx context.Context,
|
|||
// Now we wait for the server to send us the account to recover.
|
||||
select {
|
||||
case msg := <-subscription.msgChan:
|
||||
acctMsg, ok := msg.Msg.(*clmrpc.ServerAuctionMessage_Account)
|
||||
acctMsg, ok := msg.Msg.(*poolrpc.ServerAuctionMessage_Account)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("received unexpected "+
|
||||
"recovery message from server: %v",
|
||||
|
|
@ -707,7 +707,7 @@ func incompleteAcctFromErr(traderKey *keychain.KeyDescriptor,
|
|||
// SendAuctionMessage sends an auction message through the long-lived stream to
|
||||
// the auction server. A message can only be sent as a response to a server
|
||||
// message, therefore the stream must already be open.
|
||||
func (c *Client) SendAuctionMessage(msg *clmrpc.ClientAuctionMessage) error {
|
||||
func (c *Client) SendAuctionMessage(msg *poolrpc.ClientAuctionMessage) error {
|
||||
if c.serverStream == nil {
|
||||
return fmt.Errorf("cannot send message, stream not open")
|
||||
}
|
||||
|
|
@ -844,7 +844,7 @@ func (c *Client) readIncomingStream() { // nolint:gocyclo
|
|||
switch t := msg.Msg.(type) {
|
||||
// The server sends us the challenge that we need to complete
|
||||
// the 3-way handshake.
|
||||
case *clmrpc.ServerAuctionMessage_Challenge:
|
||||
case *poolrpc.ServerAuctionMessage_Challenge:
|
||||
// Try to find the subscription this message is for so
|
||||
// we can send it over the correct chan.
|
||||
var commitHash [32]byte
|
||||
|
|
@ -871,7 +871,7 @@ func (c *Client) readIncomingStream() { // nolint:gocyclo
|
|||
// The server confirms the account subscription. We only really
|
||||
// care about this response in the recovery case because it
|
||||
// means we can recover this account.
|
||||
case *clmrpc.ServerAuctionMessage_Success:
|
||||
case *poolrpc.ServerAuctionMessage_Success:
|
||||
err := c.sendToSubscription(t.Success.TraderKey, msg)
|
||||
if err != nil {
|
||||
c.StreamErrChan <- err
|
||||
|
|
@ -881,7 +881,7 @@ func (c *Client) readIncomingStream() { // nolint:gocyclo
|
|||
// We've requested to recover an account and the auctioneer now
|
||||
// sent us their state of the account. We'll try to restore it
|
||||
// in our database.
|
||||
case *clmrpc.ServerAuctionMessage_Account:
|
||||
case *poolrpc.ServerAuctionMessage_Account:
|
||||
err := c.sendToSubscription(t.Account.TraderKey, msg)
|
||||
if err != nil {
|
||||
c.StreamErrChan <- err
|
||||
|
|
@ -891,13 +891,13 @@ func (c *Client) readIncomingStream() { // nolint:gocyclo
|
|||
// The shutdown message and the account not found error are sent
|
||||
// as general error messages. We only handle these two specific
|
||||
// cases here, the rest is forwarded to the handler.
|
||||
case *clmrpc.ServerAuctionMessage_Error:
|
||||
case *poolrpc.ServerAuctionMessage_Error:
|
||||
errCode := t.Error.ErrorCode
|
||||
|
||||
switch errCode {
|
||||
// The server is shutting down. No need to forward this,
|
||||
// we can just shutdown the stream and try to reconnect.
|
||||
case clmrpc.SubscribeError_SERVER_SHUTDOWN:
|
||||
case poolrpc.SubscribeError_SERVER_SHUTDOWN:
|
||||
err := c.HandleServerShutdown(nil)
|
||||
if err != nil {
|
||||
select {
|
||||
|
|
@ -910,8 +910,8 @@ func (c *Client) readIncomingStream() { // nolint:gocyclo
|
|||
// We received an account not found error. This is not
|
||||
// a reason to abort in case we are in recovery mode.
|
||||
// We let the subscription decide what to do.
|
||||
case clmrpc.SubscribeError_ACCOUNT_DOES_NOT_EXIST,
|
||||
clmrpc.SubscribeError_INCOMPLETE_ACCOUNT_RESERVATION:
|
||||
case poolrpc.SubscribeError_ACCOUNT_DOES_NOT_EXIST,
|
||||
poolrpc.SubscribeError_INCOMPLETE_ACCOUNT_RESERVATION:
|
||||
|
||||
err := c.sendToSubscription(
|
||||
t.Error.TraderKey, msg,
|
||||
|
|
@ -945,7 +945,7 @@ func (c *Client) readIncomingStream() { // nolint:gocyclo
|
|||
// sendToSubscription finds the subscription for a trader's account public key
|
||||
// and forwards the given message to it.
|
||||
func (c *Client) sendToSubscription(traderAccountKey []byte,
|
||||
msg *clmrpc.ServerAuctionMessage) error {
|
||||
msg *poolrpc.ServerAuctionMessage) error {
|
||||
|
||||
// Try to find the subscription this message is for so we can send it
|
||||
// over the correct chan. If the key isn't a valid pubkey we'll just not
|
||||
|
|
@ -1021,7 +1021,7 @@ func (c *Client) HandleServerShutdown(err error) error {
|
|||
// unmarshallServerAccount parses the account information sent from the
|
||||
// auctioneer into our local account struct.
|
||||
func unmarshallServerRecoveredAccount(keyDesc *keychain.KeyDescriptor,
|
||||
a *clmrpc.AuctionAccount) (*account.Account, error) {
|
||||
a *poolrpc.AuctionAccount) (*account.Account, error) {
|
||||
|
||||
// Parse all raw public keys.
|
||||
auctioneerKey, err := btcec.ParsePubKey(a.AuctioneerKey, btcec.S256())
|
||||
|
|
@ -1041,21 +1041,21 @@ func unmarshallServerRecoveredAccount(keyDesc *keychain.KeyDescriptor,
|
|||
// side.
|
||||
state := account.StateClosed
|
||||
switch a.State {
|
||||
case clmrpc.AuctionAccountState_STATE_OPEN,
|
||||
clmrpc.AuctionAccountState_STATE_PENDING_OPEN:
|
||||
case poolrpc.AuctionAccountState_STATE_OPEN,
|
||||
poolrpc.AuctionAccountState_STATE_PENDING_OPEN:
|
||||
|
||||
state = account.StateInitiated
|
||||
|
||||
case clmrpc.AuctionAccountState_STATE_CLOSED:
|
||||
case poolrpc.AuctionAccountState_STATE_CLOSED:
|
||||
state = account.StatePendingClosed
|
||||
|
||||
case clmrpc.AuctionAccountState_STATE_PENDING_UPDATE:
|
||||
case poolrpc.AuctionAccountState_STATE_PENDING_UPDATE:
|
||||
state = account.StatePendingUpdate
|
||||
|
||||
case clmrpc.AuctionAccountState_STATE_PENDING_BATCH:
|
||||
case poolrpc.AuctionAccountState_STATE_PENDING_BATCH:
|
||||
state = account.StatePendingBatch
|
||||
|
||||
case clmrpc.AuctionAccountState_STATE_EXPIRED:
|
||||
case poolrpc.AuctionAccountState_STATE_EXPIRED:
|
||||
state = account.StateExpired
|
||||
}
|
||||
|
||||
|
|
@ -1071,7 +1071,7 @@ func unmarshallServerRecoveredAccount(keyDesc *keychain.KeyDescriptor,
|
|||
// The latest transaction is only known to the auctioneer after it's
|
||||
// been confirmed.
|
||||
var latestTx *wire.MsgTx
|
||||
if a.State != clmrpc.AuctionAccountState_STATE_PENDING_OPEN {
|
||||
if a.State != poolrpc.AuctionAccountState_STATE_PENDING_OPEN {
|
||||
latestTx = &wire.MsgTx{}
|
||||
err := latestTx.Deserialize(bytes.NewReader(a.LatestTx))
|
||||
if err != nil {
|
||||
|
|
@ -1098,7 +1098,7 @@ func unmarshallServerRecoveredAccount(keyDesc *keychain.KeyDescriptor,
|
|||
// Terms returns the current dynamic auctioneer terms like max account size, max
|
||||
// order duration in blocks and the auction fee schedule.
|
||||
func (c *Client) Terms(ctx context.Context) (*terms.AuctioneerTerms, error) {
|
||||
resp, err := c.client.Terms(ctx, &clmrpc.TermsRequest{})
|
||||
resp, err := c.client.Terms(ctx, &poolrpc.TermsRequest{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -1117,9 +1117,9 @@ func (c *Client) Terms(ctx context.Context) (*terms.AuctioneerTerms, error) {
|
|||
// NOTE: This isn't wrapped in "native" types, as atm we only use this to
|
||||
// shuffle information back to the client over our RPC interface.
|
||||
func (c *Client) BatchSnapshot(ctx context.Context,
|
||||
targetBatch order.BatchID) (*clmrpc.BatchSnapshotResponse, error) {
|
||||
targetBatch order.BatchID) (*poolrpc.BatchSnapshotResponse, error) {
|
||||
|
||||
return c.client.BatchSnapshot(ctx, &clmrpc.BatchSnapshotRequest{
|
||||
return c.client.BatchSnapshot(ctx, &poolrpc.BatchSnapshotRequest{
|
||||
BatchId: targetBatch[:],
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import (
|
|||
"fmt"
|
||||
|
||||
"github.com/btcsuite/btcutil"
|
||||
"github.com/lightninglabs/llm/clmrpc"
|
||||
"github.com/lightninglabs/pool/poolrpc"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
@ -60,7 +60,7 @@ func (e *AcctResNotCompletedError) Unwrap() error {
|
|||
// AcctResNotCompletedErrFromRPC creates a new AcctResNotCompletedError from an
|
||||
// RPC account message.
|
||||
func AcctResNotCompletedErrFromRPC(
|
||||
rpcAcc clmrpc.AuctionAccount) *AcctResNotCompletedError {
|
||||
rpcAcc poolrpc.AuctionAccount) *AcctResNotCompletedError {
|
||||
|
||||
result := &AcctResNotCompletedError{
|
||||
Value: btcutil.Amount(rpcAcc.Value),
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import (
|
|||
"io"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec"
|
||||
"github.com/lightninglabs/llm/account"
|
||||
"github.com/lightninglabs/pool/account"
|
||||
"go.etcd.io/bbolt"
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ import (
|
|||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/btcsuite/btcutil"
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
"github.com/lightninglabs/llm/account"
|
||||
"github.com/lightninglabs/llm/clmscript"
|
||||
"github.com/lightninglabs/pool/account"
|
||||
"github.com/lightninglabs/pool/poolscript"
|
||||
"github.com/lightningnetwork/lnd/keychain"
|
||||
)
|
||||
|
||||
|
|
@ -26,7 +26,7 @@ var (
|
|||
testTraderKey, _ = btcec.ParsePubKey(testRawTraderKey, btcec.S256())
|
||||
testTraderKeyDesc = &keychain.KeyDescriptor{
|
||||
KeyLocator: keychain.KeyLocator{
|
||||
Family: clmscript.AccountKeyFamily,
|
||||
Family: poolscript.AccountKeyFamily,
|
||||
Index: 0,
|
||||
},
|
||||
PubKey: testTraderKey,
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ import (
|
|||
"fmt"
|
||||
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/lightninglabs/llm/account"
|
||||
"github.com/lightninglabs/llm/order"
|
||||
"github.com/lightninglabs/pool/account"
|
||||
"github.com/lightninglabs/pool/order"
|
||||
"go.etcd.io/bbolt"
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ import (
|
|||
"github.com/btcsuite/btcd/btcec"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/btcsuite/btcutil"
|
||||
"github.com/lightninglabs/llm/account"
|
||||
"github.com/lightninglabs/llm/order"
|
||||
"github.com/lightninglabs/pool/account"
|
||||
"github.com/lightninglabs/pool/order"
|
||||
"github.com/lightningnetwork/lnd/keychain"
|
||||
"go.etcd.io/bbolt"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ import (
|
|||
"reflect"
|
||||
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/lightninglabs/llm/account"
|
||||
"github.com/lightninglabs/llm/order"
|
||||
"github.com/lightninglabs/pool/account"
|
||||
"github.com/lightninglabs/pool/order"
|
||||
"github.com/lightningnetwork/lnd/keychain"
|
||||
"github.com/lightningnetwork/lnd/lntypes"
|
||||
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/btcsuite/btcutil"
|
||||
"github.com/lightninglabs/llm/account"
|
||||
"github.com/lightninglabs/pool/account"
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.etcd.io/bbolt"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import (
|
|||
|
||||
const (
|
||||
// dbFilename is the default filename of the client database.
|
||||
dbFilename = "llm.db"
|
||||
dbFilename = "pool.db"
|
||||
|
||||
// dbFilePermission is the default permission the client database file
|
||||
// is created with.
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import (
|
|||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/lightninglabs/llm/order"
|
||||
"github.com/lightninglabs/pool/order"
|
||||
"go.etcd.io/bbolt"
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import (
|
|||
|
||||
"github.com/btcsuite/btcutil"
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
"github.com/lightninglabs/llm/order"
|
||||
"github.com/lightninglabs/pool/order"
|
||||
"github.com/lightningnetwork/lnd/keychain"
|
||||
"github.com/lightningnetwork/lnd/lntypes"
|
||||
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
|
||||
|
|
|
|||
16
config.go
16
config.go
|
|
@ -1,4 +1,4 @@
|
|||
package llm
|
||||
package pool
|
||||
|
||||
import (
|
||||
"net"
|
||||
|
|
@ -10,15 +10,15 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
// DefaultBaseDir is the default root data directory where llm will
|
||||
// DefaultBaseDir is the default root data directory where pool will
|
||||
// store all its data. On UNIX like systems this will resolve to
|
||||
// ~/.llm. Below this directory the logs and network directory will be
|
||||
// ~/.pool. Below this directory the logs and network directory will be
|
||||
// created.
|
||||
DefaultBaseDir = btcutil.AppDataDir("llm", false)
|
||||
DefaultBaseDir = btcutil.AppDataDir("pool", false)
|
||||
|
||||
// DefaultLogFilename is the default name that is given to the llm log
|
||||
// DefaultLogFilename is the default name that is given to the pool log
|
||||
// file.
|
||||
DefaultLogFilename = "llmd.log"
|
||||
DefaultLogFilename = "poold.log"
|
||||
|
||||
defaultLogLevel = "info"
|
||||
defaultLogDirname = "logs"
|
||||
|
|
@ -45,7 +45,7 @@ type Config struct {
|
|||
TLSPathAuctSrv string `long:"tlspathauctserver" description:"Path to auction server tls certificate"`
|
||||
RPCListen string `long:"rpclisten" description:"Address to listen on for gRPC clients"`
|
||||
RESTListen string `long:"restlisten" description:"Address to listen on for REST clients"`
|
||||
BaseDir string `long:"basedir" description:"The base directory where llm stores all its data"`
|
||||
BaseDir string `long:"basedir" description:"The base directory where pool stores all its data"`
|
||||
|
||||
LogDir string `long:"logdir" description:"Directory to log output."`
|
||||
MaxLogFiles int `long:"maxlogfiles" description:"Maximum logfiles to keep (0 for no rotation)"`
|
||||
|
|
@ -62,7 +62,7 @@ type Config struct {
|
|||
|
||||
Lnd *LndConfig `group:"lnd" namespace:"lnd"`
|
||||
|
||||
// RPCListener is a network listener that can be set if llmd should be
|
||||
// RPCListener is a network listener that can be set if poold should be
|
||||
// used as a library and listen on the given listener instead of what is
|
||||
// configured in the --rpclisten parameter. Setting this will also
|
||||
// disable REST.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package llm
|
||||
package pool
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
@ -11,10 +11,10 @@ import (
|
|||
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/lightninglabs/llm/chaninfo"
|
||||
"github.com/lightninglabs/llm/clientdb"
|
||||
"github.com/lightninglabs/llm/clmrpc"
|
||||
"github.com/lightninglabs/llm/order"
|
||||
"github.com/lightninglabs/pool/chaninfo"
|
||||
"github.com/lightninglabs/pool/clientdb"
|
||||
"github.com/lightninglabs/pool/poolrpc"
|
||||
"github.com/lightninglabs/pool/order"
|
||||
"github.com/lightninglabs/lndclient"
|
||||
"github.com/lightningnetwork/lnd/input"
|
||||
"github.com/lightningnetwork/lnd/lnrpc"
|
||||
|
|
@ -37,7 +37,7 @@ var (
|
|||
// matchRejectErr is an error type that is returned from the funding manager if
|
||||
// the trader rejects certain orders instead of the whole batch.
|
||||
type matchRejectErr struct {
|
||||
rejectedOrders map[order.Nonce]*clmrpc.OrderReject
|
||||
rejectedOrders map[order.Nonce]*poolrpc.OrderReject
|
||||
}
|
||||
|
||||
// Error returns the underlying error string.
|
||||
|
|
@ -328,7 +328,7 @@ func (f *fundingMgr) batchChannelSetup(batch *order.Batch) (
|
|||
var (
|
||||
eg errgroup.Group
|
||||
chanPoints = make(map[wire.OutPoint]order.Nonce)
|
||||
fundingRejects = make(map[order.Nonce]*clmrpc.OrderReject)
|
||||
fundingRejects = make(map[order.Nonce]*poolrpc.OrderReject)
|
||||
fundingRejectsMtx sync.Mutex
|
||||
)
|
||||
partialReject := func(nonce order.Nonce, reason string,
|
||||
|
|
@ -337,8 +337,8 @@ func (f *fundingMgr) batchChannelSetup(batch *order.Batch) (
|
|||
fundingRejectsMtx.Lock()
|
||||
defer fundingRejectsMtx.Unlock()
|
||||
|
||||
fundingRejects[nonce] = &clmrpc.OrderReject{
|
||||
ReasonCode: clmrpc.OrderReject_CHANNEL_FUNDING_FAILED,
|
||||
fundingRejects[nonce] = &poolrpc.OrderReject{
|
||||
ReasonCode: poolrpc.OrderReject_CHANNEL_FUNDING_FAILED,
|
||||
Reason: reason,
|
||||
}
|
||||
|
||||
|
|
@ -705,7 +705,7 @@ func (f *fundingMgr) waitForPeerConnections(ctx context.Context,
|
|||
// rejected because they would create channels to peers that the trader already
|
||||
// has channels with.
|
||||
func (f *fundingMgr) rejectDuplicateChannels(
|
||||
batch *order.Batch) (map[order.Nonce]*clmrpc.OrderReject, error) {
|
||||
batch *order.Batch) (map[order.Nonce]*poolrpc.OrderReject, error) {
|
||||
|
||||
// We gather all peers from the open and pending channels.
|
||||
ctxb := context.Background()
|
||||
|
|
@ -730,8 +730,8 @@ func (f *fundingMgr) rejectDuplicateChannels(
|
|||
// Gather the list of matches we reject because they are to peers we
|
||||
// already have channels with.
|
||||
const haveChannel = "already have open/pending channel with peer"
|
||||
const rejectCode = clmrpc.OrderReject_DUPLICATE_PEER
|
||||
fundingRejects := make(map[order.Nonce]*clmrpc.OrderReject)
|
||||
const rejectCode = poolrpc.OrderReject_DUPLICATE_PEER
|
||||
fundingRejects := make(map[order.Nonce]*poolrpc.OrderReject)
|
||||
for _, matchedOrders := range batch.MatchedOrders {
|
||||
for _, matchedOrder := range matchedOrders {
|
||||
_, ok := peers[matchedOrder.NodeKey]
|
||||
|
|
@ -742,7 +742,7 @@ func (f *fundingMgr) rejectDuplicateChannels(
|
|||
fndgLog.Debugf("Rejecting channel to node %x: %v",
|
||||
matchedOrder.NodeKey[:], haveChannel)
|
||||
otherNonce := matchedOrder.Order.Nonce()
|
||||
fundingRejects[otherNonce] = &clmrpc.OrderReject{
|
||||
fundingRejects[otherNonce] = &poolrpc.OrderReject{
|
||||
ReasonCode: rejectCode,
|
||||
Reason: haveChannel,
|
||||
}
|
||||
|
|
@ -755,13 +755,13 @@ func (f *fundingMgr) rejectDuplicateChannels(
|
|||
// rejectFailedConnections gathers a list of all matched orders that are to
|
||||
// peers to which we couldn't connect and want to reject because of that.
|
||||
func (f *fundingMgr) rejectFailedConnections(peers map[route.Vertex]struct{},
|
||||
batch *order.Batch) map[order.Nonce]*clmrpc.OrderReject {
|
||||
batch *order.Batch) map[order.Nonce]*poolrpc.OrderReject {
|
||||
|
||||
// Gather the list of matches we reject because the connection to them
|
||||
// failed.
|
||||
const connFailed = "connection not established before timeout"
|
||||
const rejectCode = clmrpc.OrderReject_CHANNEL_FUNDING_FAILED
|
||||
fundingRejects := make(map[order.Nonce]*clmrpc.OrderReject)
|
||||
const rejectCode = poolrpc.OrderReject_CHANNEL_FUNDING_FAILED
|
||||
fundingRejects := make(map[order.Nonce]*poolrpc.OrderReject)
|
||||
for _, matchedOrders := range batch.MatchedOrders {
|
||||
for _, matchedOrder := range matchedOrders {
|
||||
_, ok := peers[matchedOrder.NodeKey]
|
||||
|
|
@ -772,7 +772,7 @@ func (f *fundingMgr) rejectFailedConnections(peers map[route.Vertex]struct{},
|
|||
fndgLog.Debugf("Rejecting channel to node %x: %v",
|
||||
matchedOrder.NodeKey[:], connFailed)
|
||||
otherNonce := matchedOrder.Order.Nonce()
|
||||
fundingRejects[otherNonce] = &clmrpc.OrderReject{
|
||||
fundingRejects[otherNonce] = &poolrpc.OrderReject{
|
||||
ReasonCode: rejectCode,
|
||||
Reason: connFailed,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package llm
|
||||
package pool
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
@ -12,10 +12,10 @@ import (
|
|||
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/btcsuite/btcutil"
|
||||
"github.com/lightninglabs/llm/clientdb"
|
||||
"github.com/lightninglabs/llm/clmrpc"
|
||||
"github.com/lightninglabs/llm/internal/test"
|
||||
"github.com/lightninglabs/llm/order"
|
||||
"github.com/lightninglabs/pool/clientdb"
|
||||
"github.com/lightninglabs/pool/poolrpc"
|
||||
"github.com/lightninglabs/pool/internal/test"
|
||||
"github.com/lightninglabs/pool/order"
|
||||
"github.com/lightninglabs/lndclient"
|
||||
"github.com/lightningnetwork/lnd/input"
|
||||
"github.com/lightningnetwork/lnd/keychain"
|
||||
|
|
@ -358,9 +358,9 @@ func TestFundingManager(t *testing.T) {
|
|||
require.Error(t, err)
|
||||
|
||||
expectedErr := &matchRejectErr{
|
||||
rejectedOrders: map[order.Nonce]*clmrpc.OrderReject{
|
||||
rejectedOrders: map[order.Nonce]*poolrpc.OrderReject{
|
||||
ask.Nonce(): {
|
||||
ReasonCode: clmrpc.OrderReject_DUPLICATE_PEER,
|
||||
ReasonCode: poolrpc.OrderReject_DUPLICATE_PEER,
|
||||
Reason: "already have open/pending channel " +
|
||||
"with peer",
|
||||
},
|
||||
|
|
@ -376,9 +376,9 @@ func TestFundingManager(t *testing.T) {
|
|||
require.Error(t, err)
|
||||
|
||||
expectedErr = &matchRejectErr{
|
||||
rejectedOrders: map[order.Nonce]*clmrpc.OrderReject{
|
||||
rejectedOrders: map[order.Nonce]*poolrpc.OrderReject{
|
||||
ask.Nonce(): {
|
||||
ReasonCode: clmrpc.OrderReject_CHANNEL_FUNDING_FAILED,
|
||||
ReasonCode: poolrpc.OrderReject_CHANNEL_FUNDING_FAILED,
|
||||
Reason: "connection not established before " +
|
||||
"timeout",
|
||||
},
|
||||
|
|
@ -434,13 +434,13 @@ func TestFundingManager(t *testing.T) {
|
|||
_, err = h.mgr.batchChannelSetup(batch)
|
||||
require.Error(t, err)
|
||||
|
||||
code := &clmrpc.OrderReject{
|
||||
ReasonCode: clmrpc.OrderReject_CHANNEL_FUNDING_FAILED,
|
||||
code := &poolrpc.OrderReject{
|
||||
ReasonCode: poolrpc.OrderReject_CHANNEL_FUNDING_FAILED,
|
||||
Reason: "timed out waiting for pending open " +
|
||||
"channel notification",
|
||||
}
|
||||
expectedErr = &matchRejectErr{
|
||||
rejectedOrders: map[order.Nonce]*clmrpc.OrderReject{
|
||||
rejectedOrders: map[order.Nonce]*poolrpc.OrderReject{
|
||||
ask.Nonce(): code,
|
||||
bid.Nonce(): code,
|
||||
},
|
||||
|
|
@ -533,12 +533,12 @@ func TestWaitForPeerConnections(t *testing.T) {
|
|||
err = h.mgr.waitForPeerConnections(ctxt, expectedConnections, fakeBatch)
|
||||
require.Error(t, err)
|
||||
|
||||
code := &clmrpc.OrderReject{
|
||||
ReasonCode: clmrpc.OrderReject_CHANNEL_FUNDING_FAILED,
|
||||
code := &poolrpc.OrderReject{
|
||||
ReasonCode: poolrpc.OrderReject_CHANNEL_FUNDING_FAILED,
|
||||
Reason: "connection not established before timeout",
|
||||
}
|
||||
expectedErr := &matchRejectErr{
|
||||
rejectedOrders: map[order.Nonce]*clmrpc.OrderReject{
|
||||
rejectedOrders: map[order.Nonce]*poolrpc.OrderReject{
|
||||
fakeNonce2: code,
|
||||
},
|
||||
}
|
||||
|
|
|
|||
10
log.go
10
log.go
|
|
@ -1,16 +1,16 @@
|
|||
// As this file is very similar in every package, ignore the linter here.
|
||||
// nolint:dupl,interfacer
|
||||
package llm
|
||||
package pool
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/btcsuite/btclog"
|
||||
"github.com/lightninglabs/aperture/lsat"
|
||||
"github.com/lightninglabs/llm/account"
|
||||
"github.com/lightninglabs/llm/auctioneer"
|
||||
"github.com/lightninglabs/llm/clientdb"
|
||||
"github.com/lightninglabs/llm/order"
|
||||
"github.com/lightninglabs/pool/account"
|
||||
"github.com/lightninglabs/pool/auctioneer"
|
||||
"github.com/lightninglabs/pool/clientdb"
|
||||
"github.com/lightninglabs/pool/order"
|
||||
"github.com/lightninglabs/lndclient"
|
||||
"github.com/lightningnetwork/lnd/build"
|
||||
"github.com/lightningnetwork/lnd/signal"
|
||||
|
|
|
|||
|
|
@ -9,9 +9,9 @@ import (
|
|||
"github.com/btcsuite/btcd/btcec"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/btcsuite/btcutil"
|
||||
"github.com/lightninglabs/llm/account"
|
||||
"github.com/lightninglabs/llm/clmrpc"
|
||||
"github.com/lightninglabs/llm/terms"
|
||||
"github.com/lightninglabs/pool/account"
|
||||
"github.com/lightninglabs/pool/poolrpc"
|
||||
"github.com/lightninglabs/pool/terms"
|
||||
"github.com/lightningnetwork/lnd/lnrpc"
|
||||
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
|
||||
)
|
||||
|
|
@ -57,7 +57,7 @@ type AccountDiff struct {
|
|||
|
||||
// EndingState is the ending on-chain state of the account after the
|
||||
// executed batch as the auctioneer calculated it.
|
||||
EndingState clmrpc.AccountDiff_AccountState
|
||||
EndingState poolrpc.AccountDiff_AccountState
|
||||
|
||||
// EndingBalance is the ending balance for a trader's account.
|
||||
EndingBalance btcutil.Amount
|
||||
|
|
@ -86,9 +86,9 @@ func (d *AccountDiff) validateEndingState(tx *wire.MsgTx,
|
|||
// by a simple transaction and not create a dust output. We
|
||||
// expect the server to set the state correctly and not re-
|
||||
// create an account outpoint.
|
||||
if state != clmrpc.AccountDiff_OUTPUT_DUST_EXTENDED_OFFCHAIN &&
|
||||
state != clmrpc.AccountDiff_OUTPUT_DUST_ADDED_TO_FEES &&
|
||||
state != clmrpc.AccountDiff_OUTPUT_FULLY_SPENT {
|
||||
if state != poolrpc.AccountDiff_OUTPUT_DUST_EXTENDED_OFFCHAIN &&
|
||||
state != poolrpc.AccountDiff_OUTPUT_DUST_ADDED_TO_FEES &&
|
||||
state != poolrpc.AccountDiff_OUTPUT_FULLY_SPENT {
|
||||
|
||||
return wrongStateErr
|
||||
}
|
||||
|
|
@ -99,7 +99,7 @@ func (d *AccountDiff) validateEndingState(tx *wire.MsgTx,
|
|||
} else {
|
||||
// There should be enough balance left to justify a new account
|
||||
// output. We should get the outpoint from the server.
|
||||
if state != clmrpc.AccountDiff_OUTPUT_RECREATED {
|
||||
if state != poolrpc.AccountDiff_OUTPUT_RECREATED {
|
||||
return wrongStateErr
|
||||
}
|
||||
if d.OutpointIndex < 0 {
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ import (
|
|||
|
||||
"github.com/btcsuite/btcd/btcec"
|
||||
"github.com/btcsuite/btcd/txscript"
|
||||
"github.com/lightninglabs/llm/account"
|
||||
"github.com/lightninglabs/llm/clmscript"
|
||||
"github.com/lightninglabs/pool/account"
|
||||
"github.com/lightninglabs/pool/poolscript"
|
||||
"github.com/lightninglabs/lndclient"
|
||||
)
|
||||
|
||||
|
|
@ -55,10 +55,10 @@ func (s *batchSigner) Sign(batch *Batch) (BatchSignature, error) {
|
|||
|
||||
// Gather the remaining components required to sign the
|
||||
// transaction and sign it.
|
||||
traderKeyTweak := clmscript.TraderKeyTweak(
|
||||
traderKeyTweak := poolscript.TraderKeyTweak(
|
||||
acct.BatchKey, acct.Secret, acct.TraderKey.PubKey,
|
||||
)
|
||||
witnessScript, err := clmscript.AccountWitnessScript(
|
||||
witnessScript, err := poolscript.AccountWitnessScript(
|
||||
acct.Expiry, acct.TraderKey.PubKey, acct.AuctioneerKey,
|
||||
acct.BatchKey, acct.Secret,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ import (
|
|||
|
||||
"github.com/btcsuite/btcd/btcec"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/lightninglabs/llm/account"
|
||||
"github.com/lightninglabs/llm/clmrpc"
|
||||
"github.com/lightninglabs/pool/account"
|
||||
"github.com/lightninglabs/pool/poolrpc"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
@ -93,7 +93,7 @@ func (s *batchStorer) StorePendingBatch(batch *Batch, bestHeight uint32) error {
|
|||
switch diff.EndingState {
|
||||
// The account output has been recreated and needs to wait to be
|
||||
// confirmed again.
|
||||
case clmrpc.AccountDiff_OUTPUT_RECREATED:
|
||||
case poolrpc.AccountDiff_OUTPUT_RECREATED:
|
||||
modifiers = append(
|
||||
modifiers,
|
||||
account.StateModifier(account.StatePendingBatch),
|
||||
|
|
@ -106,9 +106,9 @@ func (s *batchStorer) StorePendingBatch(batch *Batch, bestHeight uint32) error {
|
|||
|
||||
// The account was fully spent on-chain. We need to wait for the
|
||||
// batch (spend) TX to be confirmed still.
|
||||
case clmrpc.AccountDiff_OUTPUT_FULLY_SPENT,
|
||||
clmrpc.AccountDiff_OUTPUT_DUST_ADDED_TO_FEES,
|
||||
clmrpc.AccountDiff_OUTPUT_DUST_EXTENDED_OFFCHAIN:
|
||||
case poolrpc.AccountDiff_OUTPUT_FULLY_SPENT,
|
||||
poolrpc.AccountDiff_OUTPUT_DUST_ADDED_TO_FEES,
|
||||
poolrpc.AccountDiff_OUTPUT_DUST_EXTENDED_OFFCHAIN:
|
||||
|
||||
modifiers = append(
|
||||
modifiers,
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/lightninglabs/llm/account"
|
||||
"github.com/lightninglabs/llm/clmrpc"
|
||||
"github.com/lightninglabs/pool/account"
|
||||
"github.com/lightninglabs/pool/poolrpc"
|
||||
"github.com/lightningnetwork/lnd/keychain"
|
||||
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
|
||||
)
|
||||
|
|
@ -67,14 +67,14 @@ func TestBatchStorer(t *testing.T) {
|
|||
{
|
||||
AccountKeyRaw: acctIDBig,
|
||||
AccountKey: acctKeyBig,
|
||||
EndingState: clmrpc.AccountDiff_OUTPUT_RECREATED,
|
||||
EndingState: poolrpc.AccountDiff_OUTPUT_RECREATED,
|
||||
OutpointIndex: 0,
|
||||
EndingBalance: 600_000,
|
||||
},
|
||||
{
|
||||
AccountKeyRaw: acctIDSmall,
|
||||
AccountKey: acctKeySmall,
|
||||
EndingState: clmrpc.AccountDiff_OUTPUT_FULLY_SPENT,
|
||||
EndingState: poolrpc.AccountDiff_OUTPUT_FULLY_SPENT,
|
||||
OutpointIndex: -1,
|
||||
EndingBalance: 0,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ import (
|
|||
|
||||
"github.com/btcsuite/btcd/btcec"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/lightninglabs/llm/account"
|
||||
"github.com/lightninglabs/llm/terms"
|
||||
"github.com/lightninglabs/pool/account"
|
||||
"github.com/lightninglabs/pool/terms"
|
||||
"github.com/lightninglabs/lndclient"
|
||||
"github.com/lightningnetwork/lnd/input"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -8,10 +8,10 @@ import (
|
|||
"github.com/btcsuite/btcd/btcec"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/btcsuite/btcutil"
|
||||
"github.com/lightninglabs/llm/account"
|
||||
"github.com/lightninglabs/llm/clmrpc"
|
||||
"github.com/lightninglabs/llm/internal/test"
|
||||
"github.com/lightninglabs/llm/terms"
|
||||
"github.com/lightninglabs/pool/account"
|
||||
"github.com/lightninglabs/pool/poolrpc"
|
||||
"github.com/lightninglabs/pool/internal/test"
|
||||
"github.com/lightninglabs/pool/terms"
|
||||
"github.com/lightningnetwork/lnd/input"
|
||||
"github.com/lightningnetwork/lnd/keychain"
|
||||
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
|
||||
|
|
@ -28,8 +28,8 @@ var (
|
|||
execFeeBase = btcutil.Amount(1_100)
|
||||
execFeeRate = btcutil.Amount(50)
|
||||
clearingPrice = FixedRatePremium(5000)
|
||||
stateRecreated = clmrpc.AccountDiff_OUTPUT_RECREATED
|
||||
stateExtendedOffchain = clmrpc.AccountDiff_OUTPUT_DUST_EXTENDED_OFFCHAIN
|
||||
stateRecreated = poolrpc.AccountDiff_OUTPUT_RECREATED
|
||||
stateExtendedOffchain = poolrpc.AccountDiff_OUTPUT_DUST_EXTENDED_OFFCHAIN
|
||||
)
|
||||
|
||||
func TestBatchVerifier(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -10,9 +10,9 @@ import (
|
|||
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/btcsuite/btcutil"
|
||||
"github.com/lightninglabs/llm/account"
|
||||
"github.com/lightninglabs/llm/clmrpc"
|
||||
"github.com/lightninglabs/llm/terms"
|
||||
"github.com/lightninglabs/pool/account"
|
||||
"github.com/lightninglabs/pool/poolrpc"
|
||||
"github.com/lightninglabs/pool/terms"
|
||||
"github.com/lightningnetwork/lnd/keychain"
|
||||
"github.com/lightningnetwork/lnd/lntypes"
|
||||
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
|
||||
|
|
@ -496,7 +496,7 @@ type Store interface {
|
|||
// an invalid action or information provided by the user.
|
||||
type UserError struct {
|
||||
FailMsg string
|
||||
Details *clmrpc.InvalidOrder
|
||||
Details *poolrpc.InvalidOrder
|
||||
}
|
||||
|
||||
// Error returns the string representation of the underlying failure message.
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/btcsuite/btcutil"
|
||||
"github.com/lightninglabs/llm/terms"
|
||||
"github.com/lightninglabs/pool/terms"
|
||||
)
|
||||
|
||||
// TestOrderReservedValue checks orders' ReservedValue merhod returning the
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ import (
|
|||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/lightninglabs/llm/account"
|
||||
"github.com/lightninglabs/llm/terms"
|
||||
"github.com/lightninglabs/pool/account"
|
||||
"github.com/lightninglabs/pool/terms"
|
||||
"github.com/lightninglabs/lndclient"
|
||||
"github.com/lightningnetwork/lnd/keychain"
|
||||
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
|
||||
|
|
@ -42,7 +42,7 @@ type ManagerConfig struct {
|
|||
AcctStore account.Store
|
||||
|
||||
// Lightning is used to access the main RPC to get information about the
|
||||
// lnd node that llmd is connected to.
|
||||
// lnd node that poold is connected to.
|
||||
Lightning lndclient.LightningClient
|
||||
|
||||
// Wallet is responsible for deriving new keys we need to sign orders.
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/btcsuite/btcutil"
|
||||
"github.com/lightninglabs/llm/account"
|
||||
"github.com/lightninglabs/llm/terms"
|
||||
"github.com/lightninglabs/pool/account"
|
||||
"github.com/lightninglabs/pool/terms"
|
||||
"github.com/lightningnetwork/lnd/keychain"
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import (
|
|||
|
||||
"github.com/btcsuite/btcd/btcec"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/lightninglabs/llm/account"
|
||||
"github.com/lightninglabs/pool/account"
|
||||
)
|
||||
|
||||
type mockStore struct {
|
||||
|
|
|
|||
|
|
@ -10,15 +10,15 @@ import (
|
|||
"github.com/btcsuite/btcd/btcec"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/btcsuite/btcutil"
|
||||
"github.com/lightninglabs/llm/clmrpc"
|
||||
"github.com/lightninglabs/llm/terms"
|
||||
"github.com/lightninglabs/pool/poolrpc"
|
||||
"github.com/lightninglabs/pool/terms"
|
||||
"github.com/lightningnetwork/lnd/lntypes"
|
||||
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
|
||||
)
|
||||
|
||||
// ParseRPCOrder parses the incoming raw RPC order into the go native data
|
||||
// types used in the order struct.
|
||||
func ParseRPCOrder(version uint32, details *clmrpc.Order) (*Kit, error) {
|
||||
func ParseRPCOrder(version uint32, details *poolrpc.Order) (*Kit, error) {
|
||||
var nonce Nonce
|
||||
copy(nonce[:], details.OrderNonce)
|
||||
kit := NewKit(nonce)
|
||||
|
|
@ -48,7 +48,7 @@ func ParseRPCOrder(version uint32, details *clmrpc.Order) (*Kit, error) {
|
|||
|
||||
// ParseRPCServerOrder parses the incoming raw RPC server order into the go
|
||||
// native data types used in the order struct.
|
||||
func ParseRPCServerOrder(version uint32, details *clmrpc.ServerOrder,
|
||||
func ParseRPCServerOrder(version uint32, details *poolrpc.ServerOrder,
|
||||
orderIsAsk bool) (*Kit, [33]byte, []net.Addr, [33]byte, error) {
|
||||
|
||||
var (
|
||||
|
|
@ -116,7 +116,7 @@ func ParseRPCServerOrder(version uint32, details *clmrpc.ServerOrder,
|
|||
|
||||
// ParseRPCServerAsk parses the incoming raw RPC server ask into the go
|
||||
// native data types used in the order struct.
|
||||
func ParseRPCServerAsk(details *clmrpc.ServerAsk) (*MatchedOrder, error) {
|
||||
func ParseRPCServerAsk(details *poolrpc.ServerAsk) (*MatchedOrder, error) {
|
||||
var (
|
||||
o = &MatchedOrder{}
|
||||
kit *Kit
|
||||
|
|
@ -137,7 +137,7 @@ func ParseRPCServerAsk(details *clmrpc.ServerAsk) (*MatchedOrder, error) {
|
|||
|
||||
// ParseRPCServerBid parses the incoming raw RPC server bid into the go
|
||||
// native data types used in the order struct.
|
||||
func ParseRPCServerBid(details *clmrpc.ServerBid) (*MatchedOrder, error) {
|
||||
func ParseRPCServerBid(details *poolrpc.ServerBid) (*MatchedOrder, error) {
|
||||
var (
|
||||
o = &MatchedOrder{}
|
||||
kit *Kit
|
||||
|
|
@ -158,7 +158,7 @@ func ParseRPCServerBid(details *clmrpc.ServerBid) (*MatchedOrder, error) {
|
|||
|
||||
// ParseRPCBatch parses the incoming raw RPC batch into the go native data types
|
||||
// used by the order manager.
|
||||
func ParseRPCBatch(prepareMsg *clmrpc.OrderMatchPrepare) (*Batch,
|
||||
func ParseRPCBatch(prepareMsg *poolrpc.OrderMatchPrepare) (*Batch,
|
||||
error) {
|
||||
|
||||
b := &Batch{
|
||||
|
|
@ -238,7 +238,7 @@ func ParseRPCBatch(prepareMsg *clmrpc.OrderMatchPrepare) (*Batch,
|
|||
|
||||
// ParseRPCMatchedOrders parses the incoming raw RPC matched orders into the go
|
||||
// native structs used by the order manager.
|
||||
func ParseRPCMatchedOrders(orders *clmrpc.MatchedOrder) ([]*MatchedOrder,
|
||||
func ParseRPCMatchedOrders(orders *poolrpc.MatchedOrder) ([]*MatchedOrder,
|
||||
error) {
|
||||
|
||||
var result []*MatchedOrder
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ import (
|
|||
"github.com/btcsuite/btcd/blockchain"
|
||||
"github.com/btcsuite/btcutil"
|
||||
"github.com/btcsuite/btcwallet/wallet/txrules"
|
||||
"github.com/lightninglabs/llm/clmscript"
|
||||
"github.com/lightninglabs/llm/terms"
|
||||
"github.com/lightninglabs/pool/poolscript"
|
||||
"github.com/lightninglabs/pool/terms"
|
||||
"github.com/lightningnetwork/lnd/input"
|
||||
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
|
||||
)
|
||||
|
|
@ -90,7 +90,7 @@ func EstimateTraderFee(numTraderChans uint32,
|
|||
|
||||
// Finally, we tack on the size of the witness spending the account
|
||||
// outpoint.
|
||||
weightEstimate += clmscript.MultiSigWitnessSize
|
||||
weightEstimate += poolscript.MultiSigWitnessSize
|
||||
|
||||
return feeRate.FeeForWeight(weightEstimate)
|
||||
}
|
||||
|
|
@ -220,7 +220,7 @@ func minNoDustAccountSize() btcutil.Amount {
|
|||
// Calculate the minimum fee we would need to pay to coop close the
|
||||
// account to a P2WKH output.
|
||||
var weightEstimator input.TxWeightEstimator
|
||||
weightEstimator.AddWitnessInput(clmscript.MultiSigWitnessSize)
|
||||
weightEstimator.AddWitnessInput(poolscript.MultiSigWitnessSize)
|
||||
weightEstimator.AddP2WKHOutput()
|
||||
minimumFee := chainfee.FeePerKwFloor.FeeForWeight(
|
||||
int64(weightEstimator.Weight()),
|
||||
|
|
|
|||
212
rpcserver.go
212
rpcserver.go
|
|
@ -1,4 +1,4 @@
|
|||
package llm
|
||||
package pool
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
|
@ -16,13 +16,13 @@ import (
|
|||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/btcsuite/btcutil"
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
"github.com/lightninglabs/llm/account"
|
||||
"github.com/lightninglabs/llm/auctioneer"
|
||||
"github.com/lightninglabs/llm/chaninfo"
|
||||
"github.com/lightninglabs/llm/clientdb"
|
||||
"github.com/lightninglabs/llm/clmrpc"
|
||||
"github.com/lightninglabs/llm/order"
|
||||
"github.com/lightninglabs/llm/terms"
|
||||
"github.com/lightninglabs/pool/account"
|
||||
"github.com/lightninglabs/pool/auctioneer"
|
||||
"github.com/lightninglabs/pool/chaninfo"
|
||||
"github.com/lightninglabs/pool/clientdb"
|
||||
"github.com/lightninglabs/pool/poolrpc"
|
||||
"github.com/lightninglabs/pool/order"
|
||||
"github.com/lightninglabs/pool/terms"
|
||||
"github.com/lightninglabs/lndclient"
|
||||
"github.com/lightningnetwork/lnd"
|
||||
"github.com/lightningnetwork/lnd/chanbackup"
|
||||
|
|
@ -353,10 +353,10 @@ func (s *rpcServer) updateHeight(height int32) {
|
|||
|
||||
// handleServerMessage reads a gRPC message received in the stream from the
|
||||
// auctioneer server and passes it to the correct manager.
|
||||
func (s *rpcServer) handleServerMessage(rpcMsg *clmrpc.ServerAuctionMessage) error {
|
||||
func (s *rpcServer) handleServerMessage(rpcMsg *poolrpc.ServerAuctionMessage) error {
|
||||
switch msg := rpcMsg.Msg.(type) {
|
||||
// A new batch has been assembled with some of our orders.
|
||||
case *clmrpc.ServerAuctionMessage_Prepare:
|
||||
case *poolrpc.ServerAuctionMessage_Prepare:
|
||||
// Parse and formally validate what we got from the server.
|
||||
rpcLog.Tracef("Received prepare msg from server, batch_id=%x: %v",
|
||||
msg.Prepare.BatchId, spew.Sdump(msg))
|
||||
|
|
@ -420,7 +420,7 @@ func (s *rpcServer) handleServerMessage(rpcMsg *clmrpc.ServerAuctionMessage) err
|
|||
return s.sendRejectBatch(batch, err)
|
||||
}
|
||||
|
||||
case *clmrpc.ServerAuctionMessage_Sign:
|
||||
case *poolrpc.ServerAuctionMessage_Sign:
|
||||
// We were able to accept the batch. Inform the auctioneer,
|
||||
// then start negotiating with the remote peers. We'll sign
|
||||
// once all channel partners have responded.
|
||||
|
|
@ -449,7 +449,7 @@ func (s *rpcServer) handleServerMessage(rpcMsg *clmrpc.ServerAuctionMessage) err
|
|||
|
||||
// The previously prepared batch has been executed and we can finalize
|
||||
// it by opening the channel and persisting the account and order diffs.
|
||||
case *clmrpc.ServerAuctionMessage_Finalize:
|
||||
case *poolrpc.ServerAuctionMessage_Finalize:
|
||||
rpcLog.Tracef("Received finalize msg from server, batch_id=%x: %v",
|
||||
msg.Finalize.BatchId, spew.Sdump(msg))
|
||||
|
||||
|
|
@ -489,7 +489,7 @@ func (s *rpcServer) handleServerMessage(rpcMsg *clmrpc.ServerAuctionMessage) err
|
|||
}
|
||||
|
||||
func (s *rpcServer) QuoteAccount(ctx context.Context,
|
||||
req *clmrpc.QuoteAccountRequest) (*clmrpc.QuoteAccountResponse, error) {
|
||||
req *poolrpc.QuoteAccountRequest) (*poolrpc.QuoteAccountResponse, error) {
|
||||
|
||||
// Determine the desired transaction fee.
|
||||
confTarget := req.GetConfTarget()
|
||||
|
|
@ -505,14 +505,14 @@ func (s *rpcServer) QuoteAccount(ctx context.Context,
|
|||
return nil, err
|
||||
}
|
||||
|
||||
return &clmrpc.QuoteAccountResponse{
|
||||
return &poolrpc.QuoteAccountResponse{
|
||||
MinerFeeRateSatPerKw: uint64(feeRate),
|
||||
MinerFeeTotal: uint64(totalFee),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *rpcServer) InitAccount(ctx context.Context,
|
||||
req *clmrpc.InitAccountRequest) (*clmrpc.Account, error) {
|
||||
req *poolrpc.InitAccountRequest) (*poolrpc.Account, error) {
|
||||
|
||||
bestHeight := atomic.LoadUint32(&s.bestHeight)
|
||||
|
||||
|
|
@ -549,14 +549,14 @@ func (s *rpcServer) InitAccount(ctx context.Context,
|
|||
}
|
||||
|
||||
func (s *rpcServer) ListAccounts(ctx context.Context,
|
||||
req *clmrpc.ListAccountsRequest) (*clmrpc.ListAccountsResponse, error) {
|
||||
req *poolrpc.ListAccountsRequest) (*poolrpc.ListAccountsResponse, error) {
|
||||
|
||||
accounts, err := s.server.db.Accounts()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rpcAccounts := make([]*clmrpc.Account, 0, len(accounts))
|
||||
rpcAccounts := make([]*poolrpc.Account, 0, len(accounts))
|
||||
for _, account := range accounts {
|
||||
rpcAccount, err := marshallAccount(account)
|
||||
if err != nil {
|
||||
|
|
@ -620,37 +620,37 @@ func (s *rpcServer) ListAccounts(ctx context.Context,
|
|||
rpcAccount.AvailableBalance = availableBalance
|
||||
}
|
||||
|
||||
return &clmrpc.ListAccountsResponse{
|
||||
return &poolrpc.ListAccountsResponse{
|
||||
Accounts: rpcAccounts,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func marshallAccount(a *account.Account) (*clmrpc.Account, error) {
|
||||
var rpcState clmrpc.AccountState
|
||||
func marshallAccount(a *account.Account) (*poolrpc.Account, error) {
|
||||
var rpcState poolrpc.AccountState
|
||||
switch a.State {
|
||||
case account.StateInitiated, account.StatePendingOpen:
|
||||
rpcState = clmrpc.AccountState_PENDING_OPEN
|
||||
rpcState = poolrpc.AccountState_PENDING_OPEN
|
||||
|
||||
case account.StatePendingUpdate:
|
||||
rpcState = clmrpc.AccountState_PENDING_UPDATE
|
||||
rpcState = poolrpc.AccountState_PENDING_UPDATE
|
||||
|
||||
case account.StateOpen:
|
||||
rpcState = clmrpc.AccountState_OPEN
|
||||
rpcState = poolrpc.AccountState_OPEN
|
||||
|
||||
case account.StateExpired:
|
||||
rpcState = clmrpc.AccountState_EXPIRED
|
||||
rpcState = poolrpc.AccountState_EXPIRED
|
||||
|
||||
case account.StatePendingClosed:
|
||||
rpcState = clmrpc.AccountState_PENDING_CLOSED
|
||||
rpcState = poolrpc.AccountState_PENDING_CLOSED
|
||||
|
||||
case account.StateClosed:
|
||||
rpcState = clmrpc.AccountState_CLOSED
|
||||
rpcState = poolrpc.AccountState_CLOSED
|
||||
|
||||
case account.StateCanceledAfterRecovery:
|
||||
rpcState = clmrpc.AccountState_RECOVERY_FAILED
|
||||
rpcState = poolrpc.AccountState_RECOVERY_FAILED
|
||||
|
||||
case account.StatePendingBatch:
|
||||
rpcState = clmrpc.AccountState_PENDING_BATCH
|
||||
rpcState = poolrpc.AccountState_PENDING_BATCH
|
||||
|
||||
default:
|
||||
return nil, fmt.Errorf("unknown state %v", a.State)
|
||||
|
|
@ -663,9 +663,9 @@ func marshallAccount(a *account.Account) (*clmrpc.Account, error) {
|
|||
latestTxHash = a.LatestTx.TxHash()
|
||||
}
|
||||
|
||||
return &clmrpc.Account{
|
||||
return &poolrpc.Account{
|
||||
TraderKey: a.TraderKey.PubKey.SerializeCompressed(),
|
||||
Outpoint: &clmrpc.OutPoint{
|
||||
Outpoint: &poolrpc.OutPoint{
|
||||
Txid: a.OutPoint.Hash[:],
|
||||
OutputIndex: a.OutPoint.Index,
|
||||
},
|
||||
|
|
@ -679,7 +679,7 @@ func marshallAccount(a *account.Account) (*clmrpc.Account, error) {
|
|||
// DepositAccount handles a trader's request to deposit funds into the specified
|
||||
// account by spending the specified inputs.
|
||||
func (s *rpcServer) DepositAccount(ctx context.Context,
|
||||
req *clmrpc.DepositAccountRequest) (*clmrpc.DepositAccountResponse, error) {
|
||||
req *poolrpc.DepositAccountRequest) (*poolrpc.DepositAccountResponse, error) {
|
||||
|
||||
rpcLog.Infof("Depositing %v into acct=%x",
|
||||
btcutil.Amount(req.AmountSat), req.TraderKey)
|
||||
|
|
@ -713,7 +713,7 @@ func (s *rpcServer) DepositAccount(ctx context.Context,
|
|||
}
|
||||
txHash := tx.TxHash()
|
||||
|
||||
return &clmrpc.DepositAccountResponse{
|
||||
return &poolrpc.DepositAccountResponse{
|
||||
Account: rpcModifiedAccount,
|
||||
DepositTxid: txHash[:],
|
||||
}, nil
|
||||
|
|
@ -723,7 +723,7 @@ func (s *rpcServer) DepositAccount(ctx context.Context,
|
|||
// specified account by spending the current account output to the specified
|
||||
// outputs.
|
||||
func (s *rpcServer) WithdrawAccount(ctx context.Context,
|
||||
req *clmrpc.WithdrawAccountRequest) (*clmrpc.WithdrawAccountResponse, error) {
|
||||
req *poolrpc.WithdrawAccountRequest) (*poolrpc.WithdrawAccountResponse, error) {
|
||||
|
||||
rpcLog.Infof("Withdrawing from acct=%x", req.TraderKey)
|
||||
|
||||
|
|
@ -765,7 +765,7 @@ func (s *rpcServer) WithdrawAccount(ctx context.Context,
|
|||
}
|
||||
txHash := tx.TxHash()
|
||||
|
||||
return &clmrpc.WithdrawAccountResponse{
|
||||
return &poolrpc.WithdrawAccountResponse{
|
||||
Account: rpcModifiedAccount,
|
||||
WithdrawTxid: txHash[:],
|
||||
}, nil
|
||||
|
|
@ -778,7 +778,7 @@ func (s *rpcServer) WithdrawAccount(ctx context.Context,
|
|||
// and this RPC is invoked again, then a replacing transaction (RBF) of the
|
||||
// child will be broadcast.
|
||||
func (s *rpcServer) BumpAccountFee(ctx context.Context,
|
||||
req *clmrpc.BumpAccountFeeRequest) (*clmrpc.BumpAccountFeeResponse, error) {
|
||||
req *poolrpc.BumpAccountFeeRequest) (*poolrpc.BumpAccountFeeResponse, error) {
|
||||
|
||||
traderKey, err := btcec.ParsePubKey(req.TraderKey, btcec.S256())
|
||||
if err != nil {
|
||||
|
|
@ -791,12 +791,12 @@ func (s *rpcServer) BumpAccountFee(ctx context.Context,
|
|||
return nil, err
|
||||
}
|
||||
|
||||
return &clmrpc.BumpAccountFeeResponse{}, nil
|
||||
return &poolrpc.BumpAccountFeeResponse{}, nil
|
||||
}
|
||||
|
||||
// CloseAccount handles a trader's request to close the specified account.
|
||||
func (s *rpcServer) CloseAccount(ctx context.Context,
|
||||
req *clmrpc.CloseAccountRequest) (*clmrpc.CloseAccountResponse, error) {
|
||||
req *poolrpc.CloseAccountRequest) (*poolrpc.CloseAccountResponse, error) {
|
||||
|
||||
rpcLog.Infof("Closing acct=%x", req.TraderKey)
|
||||
|
||||
|
|
@ -810,7 +810,7 @@ func (s *rpcServer) CloseAccount(ctx context.Context,
|
|||
switch dest := req.FundsDestination.(type) {
|
||||
// The fee is expressed as a combination of an output along with a fee
|
||||
// rate.
|
||||
case *clmrpc.CloseAccountRequest_OutputWithFee:
|
||||
case *poolrpc.CloseAccountRequest_OutputWithFee:
|
||||
// Parse the output script if one was provided and ensure it's
|
||||
// valid.
|
||||
var pkScript []byte
|
||||
|
|
@ -827,7 +827,7 @@ func (s *rpcServer) CloseAccount(ctx context.Context,
|
|||
// Parse the provided fee rate.
|
||||
var feeRate chainfee.SatPerKWeight
|
||||
switch feeExpr := dest.OutputWithFee.Fees.(type) {
|
||||
case *clmrpc.OutputWithFee_ConfTarget:
|
||||
case *poolrpc.OutputWithFee_ConfTarget:
|
||||
var err error
|
||||
feeRate, err = s.lndServices.WalletKit.EstimateFee(
|
||||
ctx, int32(feeExpr.ConfTarget),
|
||||
|
|
@ -836,7 +836,7 @@ func (s *rpcServer) CloseAccount(ctx context.Context,
|
|||
return nil, err
|
||||
}
|
||||
|
||||
case *clmrpc.OutputWithFee_FeeRateSatPerKw:
|
||||
case *poolrpc.OutputWithFee_FeeRateSatPerKw:
|
||||
feeRate = chainfee.SatPerKWeight(feeExpr.FeeRateSatPerKw)
|
||||
}
|
||||
|
||||
|
|
@ -853,7 +853,7 @@ func (s *rpcServer) CloseAccount(ctx context.Context,
|
|||
|
||||
// The fee is expressed as implicitly defined by the total output value
|
||||
// of the provided outputs.
|
||||
case *clmrpc.CloseAccountRequest_Outputs:
|
||||
case *poolrpc.CloseAccountRequest_Outputs:
|
||||
if len(dest.Outputs.Outputs) == 0 {
|
||||
return nil, errors.New("no outputs provided")
|
||||
}
|
||||
|
|
@ -920,7 +920,7 @@ func (s *rpcServer) CloseAccount(ctx context.Context,
|
|||
}
|
||||
closeTxHash := closeTx.TxHash()
|
||||
|
||||
return &clmrpc.CloseAccountResponse{
|
||||
return &poolrpc.CloseAccountResponse{
|
||||
CloseTxid: closeTxHash[:],
|
||||
}, nil
|
||||
}
|
||||
|
|
@ -940,8 +940,8 @@ func (s *rpcServer) parseOutputScript(addrStr string) ([]byte, error) {
|
|||
return txscript.PayToAddrScript(addr)
|
||||
}
|
||||
|
||||
// parseRPCOutputs maps []*clmrpc.Output -> []*wire.TxOut.
|
||||
func (s *rpcServer) parseRPCOutputs(outputs []*clmrpc.Output) ([]*wire.TxOut,
|
||||
// parseRPCOutputs maps []*poolrpc.Output -> []*wire.TxOut.
|
||||
func (s *rpcServer) parseRPCOutputs(outputs []*poolrpc.Output) ([]*wire.TxOut,
|
||||
error) {
|
||||
|
||||
res := make([]*wire.TxOut, 0, len(outputs))
|
||||
|
|
@ -960,7 +960,7 @@ func (s *rpcServer) parseRPCOutputs(outputs []*clmrpc.Output) ([]*wire.TxOut,
|
|||
}
|
||||
|
||||
func (s *rpcServer) RecoverAccounts(ctx context.Context,
|
||||
_ *clmrpc.RecoverAccountsRequest) (*clmrpc.RecoverAccountsResponse,
|
||||
_ *poolrpc.RecoverAccountsRequest) (*poolrpc.RecoverAccountsResponse,
|
||||
error) {
|
||||
|
||||
log.Infof("Attempting to recover accounts...")
|
||||
|
|
@ -1010,7 +1010,7 @@ func (s *rpcServer) RecoverAccounts(ctx context.Context,
|
|||
s.recoveryPending = false
|
||||
s.recoveryMutex.Unlock()
|
||||
|
||||
return &clmrpc.RecoverAccountsResponse{
|
||||
return &poolrpc.RecoverAccountsResponse{
|
||||
NumRecoveredAccounts: uint32(numRecovered),
|
||||
}, nil
|
||||
}
|
||||
|
|
@ -1019,11 +1019,11 @@ func (s *rpcServer) RecoverAccounts(ctx context.Context,
|
|||
// from the trader's lnd node, signs it and then sends the order to the server
|
||||
// to be included in the auctioneer's order book.
|
||||
func (s *rpcServer) SubmitOrder(ctx context.Context,
|
||||
req *clmrpc.SubmitOrderRequest) (*clmrpc.SubmitOrderResponse, error) {
|
||||
req *poolrpc.SubmitOrderRequest) (*poolrpc.SubmitOrderResponse, error) {
|
||||
|
||||
var o order.Order
|
||||
switch requestOrder := req.Details.(type) {
|
||||
case *clmrpc.SubmitOrderRequest_Ask:
|
||||
case *poolrpc.SubmitOrderRequest_Ask:
|
||||
a := requestOrder.Ask
|
||||
kit, err := order.ParseRPCOrder(a.Version, a.Details)
|
||||
if err != nil {
|
||||
|
|
@ -1034,7 +1034,7 @@ func (s *rpcServer) SubmitOrder(ctx context.Context,
|
|||
MaxDuration: a.MaxDurationBlocks,
|
||||
}
|
||||
|
||||
case *clmrpc.SubmitOrderRequest_Bid:
|
||||
case *poolrpc.SubmitOrderRequest_Bid:
|
||||
b := requestOrder.Bid
|
||||
kit, err := order.ParseRPCOrder(b.Version, b.Details)
|
||||
if err != nil {
|
||||
|
|
@ -1114,8 +1114,8 @@ func (s *rpcServer) SubmitOrder(ctx context.Context,
|
|||
if userErr, ok := err.(*order.UserError); ok {
|
||||
rpcLog.Warnf("Invalid order details: %v", userErr)
|
||||
|
||||
return &clmrpc.SubmitOrderResponse{
|
||||
Details: &clmrpc.SubmitOrderResponse_InvalidOrder{
|
||||
return &poolrpc.SubmitOrderResponse{
|
||||
Details: &poolrpc.SubmitOrderResponse_InvalidOrder{
|
||||
InvalidOrder: userErr.Details,
|
||||
},
|
||||
}, nil
|
||||
|
|
@ -1131,8 +1131,8 @@ func (s *rpcServer) SubmitOrder(ctx context.Context,
|
|||
|
||||
// ServerOrder is accepted.
|
||||
orderNonce := o.Nonce()
|
||||
return &clmrpc.SubmitOrderResponse{
|
||||
Details: &clmrpc.SubmitOrderResponse_AcceptedOrderNonce{
|
||||
return &poolrpc.SubmitOrderResponse{
|
||||
Details: &poolrpc.SubmitOrderResponse_AcceptedOrderNonce{
|
||||
AcceptedOrderNonce: orderNonce[:],
|
||||
},
|
||||
}, nil
|
||||
|
|
@ -1141,8 +1141,8 @@ func (s *rpcServer) SubmitOrder(ctx context.Context,
|
|||
// ListOrders returns a list of all orders that is currently known to the trader
|
||||
// client's local store. The state of each order is queried on the auction
|
||||
// server and returned as well.
|
||||
func (s *rpcServer) ListOrders(ctx context.Context, _ *clmrpc.ListOrdersRequest) (
|
||||
*clmrpc.ListOrdersResponse, error) {
|
||||
func (s *rpcServer) ListOrders(ctx context.Context, _ *poolrpc.ListOrdersRequest) (
|
||||
*poolrpc.ListOrdersResponse, error) {
|
||||
|
||||
// Get all orders from our local store first.
|
||||
dbOrders, err := s.server.db.GetOrders()
|
||||
|
|
@ -1161,42 +1161,42 @@ func (s *rpcServer) ListOrders(ctx context.Context, _ *clmrpc.ListOrdersRequest)
|
|||
}
|
||||
|
||||
// The RPC is split by order type so we have to separate them now.
|
||||
asks := make([]*clmrpc.Ask, 0, len(dbOrders))
|
||||
bids := make([]*clmrpc.Bid, 0, len(dbOrders))
|
||||
asks := make([]*poolrpc.Ask, 0, len(dbOrders))
|
||||
bids := make([]*poolrpc.Bid, 0, len(dbOrders))
|
||||
for _, dbOrder := range dbOrders {
|
||||
nonce := dbOrder.Nonce()
|
||||
dbDetails := dbOrder.Details()
|
||||
|
||||
var orderState clmrpc.OrderState
|
||||
var orderState poolrpc.OrderState
|
||||
switch dbDetails.State {
|
||||
|
||||
case order.StateSubmitted:
|
||||
orderState = clmrpc.OrderState_ORDER_SUBMITTED
|
||||
orderState = poolrpc.OrderState_ORDER_SUBMITTED
|
||||
|
||||
case order.StateCleared:
|
||||
orderState = clmrpc.OrderState_ORDER_CLEARED
|
||||
orderState = poolrpc.OrderState_ORDER_CLEARED
|
||||
|
||||
case order.StatePartiallyFilled:
|
||||
orderState = clmrpc.OrderState_ORDER_PARTIALLY_FILLED
|
||||
orderState = poolrpc.OrderState_ORDER_PARTIALLY_FILLED
|
||||
|
||||
case order.StateExecuted:
|
||||
orderState = clmrpc.OrderState_ORDER_EXECUTED
|
||||
orderState = poolrpc.OrderState_ORDER_EXECUTED
|
||||
|
||||
case order.StateCanceled:
|
||||
orderState = clmrpc.OrderState_ORDER_CANCELED
|
||||
orderState = poolrpc.OrderState_ORDER_CANCELED
|
||||
|
||||
case order.StateExpired:
|
||||
orderState = clmrpc.OrderState_ORDER_EXPIRED
|
||||
orderState = poolrpc.OrderState_ORDER_EXPIRED
|
||||
|
||||
case order.StateFailed:
|
||||
orderState = clmrpc.OrderState_ORDER_FAILED
|
||||
orderState = poolrpc.OrderState_ORDER_FAILED
|
||||
|
||||
default:
|
||||
return nil, fmt.Errorf("unknown state: %v",
|
||||
dbDetails.State)
|
||||
}
|
||||
|
||||
details := &clmrpc.Order{
|
||||
details := &poolrpc.Order{
|
||||
TraderKey: dbDetails.AcctKey[:],
|
||||
RateFixed: dbDetails.FixedRate,
|
||||
Amt: uint64(dbDetails.Amt),
|
||||
|
|
@ -1214,7 +1214,7 @@ func (s *rpcServer) ListOrders(ctx context.Context, _ *clmrpc.ListOrdersRequest)
|
|||
|
||||
switch o := dbOrder.(type) {
|
||||
case *order.Ask:
|
||||
rpcAsk := &clmrpc.Ask{
|
||||
rpcAsk := &poolrpc.Ask{
|
||||
Details: details,
|
||||
MaxDurationBlocks: o.MaxDuration,
|
||||
Version: uint32(o.Version),
|
||||
|
|
@ -1222,7 +1222,7 @@ func (s *rpcServer) ListOrders(ctx context.Context, _ *clmrpc.ListOrdersRequest)
|
|||
asks = append(asks, rpcAsk)
|
||||
|
||||
case *order.Bid:
|
||||
rpcBid := &clmrpc.Bid{
|
||||
rpcBid := &poolrpc.Bid{
|
||||
Details: details,
|
||||
MinDurationBlocks: o.MinDuration,
|
||||
Version: uint32(o.Version),
|
||||
|
|
@ -1234,7 +1234,7 @@ func (s *rpcServer) ListOrders(ctx context.Context, _ *clmrpc.ListOrdersRequest)
|
|||
o)
|
||||
}
|
||||
}
|
||||
return &clmrpc.ListOrdersResponse{
|
||||
return &poolrpc.ListOrdersResponse{
|
||||
Asks: asks,
|
||||
Bids: bids,
|
||||
}, nil
|
||||
|
|
@ -1243,7 +1243,7 @@ func (s *rpcServer) ListOrders(ctx context.Context, _ *clmrpc.ListOrdersRequest)
|
|||
// CancelOrder cancels the order on the server and updates the state of the
|
||||
// local order accordingly.
|
||||
func (s *rpcServer) CancelOrder(ctx context.Context,
|
||||
req *clmrpc.CancelOrderRequest) (*clmrpc.CancelOrderResponse, error) {
|
||||
req *poolrpc.CancelOrderRequest) (*poolrpc.CancelOrderResponse, error) {
|
||||
|
||||
var nonce order.Nonce
|
||||
copy(nonce[:], req.OrderNonce)
|
||||
|
|
@ -1267,7 +1267,7 @@ func (s *rpcServer) CancelOrder(ctx context.Context,
|
|||
return nil, err
|
||||
}
|
||||
|
||||
return &clmrpc.CancelOrderResponse{}, nil
|
||||
return &poolrpc.CancelOrderResponse{}, nil
|
||||
}
|
||||
|
||||
// sendRejectBatch sends a reject message to the server with the properly
|
||||
|
|
@ -1286,8 +1286,8 @@ func (s *rpcServer) sendRejectBatch(batch *order.Batch, failure error) error {
|
|||
return err
|
||||
}
|
||||
|
||||
msg := &clmrpc.ClientAuctionMessage_Reject{
|
||||
Reject: &clmrpc.OrderMatchReject{
|
||||
msg := &poolrpc.ClientAuctionMessage_Reject{
|
||||
Reject: &poolrpc.OrderMatchReject{
|
||||
BatchId: batch.ID[:],
|
||||
Reason: failure.Error(),
|
||||
},
|
||||
|
|
@ -1297,20 +1297,20 @@ func (s *rpcServer) sendRejectBatch(batch *order.Batch, failure error) error {
|
|||
var partialReject *matchRejectErr
|
||||
switch {
|
||||
case errors.Is(failure, order.ErrVersionMismatch):
|
||||
msg.Reject.ReasonCode = clmrpc.OrderMatchReject_BATCH_VERSION_MISMATCH
|
||||
msg.Reject.ReasonCode = poolrpc.OrderMatchReject_BATCH_VERSION_MISMATCH
|
||||
|
||||
case errors.Is(failure, order.ErrMismatchErr):
|
||||
msg.Reject.ReasonCode = clmrpc.OrderMatchReject_SERVER_MISBEHAVIOR
|
||||
msg.Reject.ReasonCode = poolrpc.OrderMatchReject_SERVER_MISBEHAVIOR
|
||||
|
||||
case errors.As(failure, &partialReject):
|
||||
msg.Reject.ReasonCode = clmrpc.OrderMatchReject_PARTIAL_REJECT
|
||||
msg.Reject.RejectedOrders = make(map[string]*clmrpc.OrderReject)
|
||||
msg.Reject.ReasonCode = poolrpc.OrderMatchReject_PARTIAL_REJECT
|
||||
msg.Reject.RejectedOrders = make(map[string]*poolrpc.OrderReject)
|
||||
for nonce, reject := range partialReject.rejectedOrders {
|
||||
msg.Reject.RejectedOrders[nonce.String()] = reject
|
||||
}
|
||||
|
||||
default:
|
||||
msg.Reject.ReasonCode = clmrpc.OrderMatchReject_UNKNOWN
|
||||
msg.Reject.ReasonCode = poolrpc.OrderMatchReject_UNKNOWN
|
||||
}
|
||||
|
||||
rpcLog.Infof("Sending batch rejection message for batch %x with "+
|
||||
|
|
@ -1320,7 +1320,7 @@ func (s *rpcServer) sendRejectBatch(batch *order.Batch, failure error) error {
|
|||
// Send the message to the server. If a new error happens we return that
|
||||
// one because we know the causing error has at least been logged at
|
||||
// some point before.
|
||||
err = s.auctioneer.SendAuctionMessage(&clmrpc.ClientAuctionMessage{
|
||||
err = s.auctioneer.SendAuctionMessage(&poolrpc.ClientAuctionMessage{
|
||||
Msg: msg,
|
||||
})
|
||||
if err != nil {
|
||||
|
|
@ -1338,9 +1338,9 @@ func (s *rpcServer) sendAcceptBatch(batch *order.Batch) error {
|
|||
rpcLog.Infof("Accepting batch=%x", batch.ID[:])
|
||||
|
||||
// Send the message to the server.
|
||||
return s.auctioneer.SendAuctionMessage(&clmrpc.ClientAuctionMessage{
|
||||
Msg: &clmrpc.ClientAuctionMessage_Accept{
|
||||
Accept: &clmrpc.OrderMatchAccept{
|
||||
return s.auctioneer.SendAuctionMessage(&poolrpc.ClientAuctionMessage{
|
||||
Msg: &poolrpc.ClientAuctionMessage_Accept{
|
||||
Accept: &poolrpc.OrderMatchAccept{
|
||||
BatchId: batch.ID[:],
|
||||
},
|
||||
},
|
||||
|
|
@ -1349,7 +1349,7 @@ func (s *rpcServer) sendAcceptBatch(batch *order.Batch) error {
|
|||
|
||||
// GetLsatTokens returns all tokens that are contained in the LSAT token store.
|
||||
func (s *rpcServer) GetLsatTokens(_ context.Context,
|
||||
_ *clmrpc.TokensRequest) (*clmrpc.TokensResponse, error) {
|
||||
_ *poolrpc.TokensRequest) (*poolrpc.TokensResponse, error) {
|
||||
|
||||
log.Infof("Get LSAT tokens request received")
|
||||
|
||||
|
|
@ -1358,14 +1358,14 @@ func (s *rpcServer) GetLsatTokens(_ context.Context,
|
|||
return nil, err
|
||||
}
|
||||
|
||||
rpcTokens := make([]*clmrpc.LsatToken, len(tokens))
|
||||
rpcTokens := make([]*poolrpc.LsatToken, len(tokens))
|
||||
idx := 0
|
||||
for key, token := range tokens {
|
||||
macBytes, err := token.BaseMacaroon().MarshalBinary()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
rpcTokens[idx] = &clmrpc.LsatToken{
|
||||
rpcTokens[idx] = &poolrpc.LsatToken{
|
||||
BaseMacaroon: macBytes,
|
||||
PaymentHash: token.PaymentHash[:],
|
||||
PaymentPreimage: token.Preimage[:],
|
||||
|
|
@ -1378,7 +1378,7 @@ func (s *rpcServer) GetLsatTokens(_ context.Context,
|
|||
idx++
|
||||
}
|
||||
|
||||
return &clmrpc.TokensResponse{Tokens: rpcTokens}, nil
|
||||
return &poolrpc.TokensResponse{Tokens: rpcTokens}, nil
|
||||
}
|
||||
|
||||
// sendSignBatch sends a sign message to the server with the witness stacks of
|
||||
|
|
@ -1394,19 +1394,19 @@ func (s *rpcServer) sendSignBatch(batch *order.Batch, sigs order.BatchSignature,
|
|||
rpcSigs[key] = sig.Serialize()
|
||||
}
|
||||
|
||||
rpcChannelInfos := make(map[string]*clmrpc.ChannelInfo, len(chanInfos))
|
||||
rpcChannelInfos := make(map[string]*poolrpc.ChannelInfo, len(chanInfos))
|
||||
for chanPoint, chanInfo := range chanInfos {
|
||||
var channelType clmrpc.ChannelType
|
||||
var channelType poolrpc.ChannelType
|
||||
switch chanInfo.Version {
|
||||
case chanbackup.TweaklessCommitVersion:
|
||||
channelType = clmrpc.ChannelType_TWEAKLESS
|
||||
channelType = poolrpc.ChannelType_TWEAKLESS
|
||||
case chanbackup.AnchorsCommitVersion:
|
||||
channelType = clmrpc.ChannelType_ANCHORS
|
||||
channelType = poolrpc.ChannelType_ANCHORS
|
||||
default:
|
||||
return fmt.Errorf("unknown channel type: %v",
|
||||
chanInfo.Version)
|
||||
}
|
||||
rpcChannelInfos[chanPoint.String()] = &clmrpc.ChannelInfo{
|
||||
rpcChannelInfos[chanPoint.String()] = &poolrpc.ChannelInfo{
|
||||
Type: channelType,
|
||||
LocalNodeKey: chanInfo.LocalNodeKey.
|
||||
SerializeCompressed(),
|
||||
|
|
@ -1421,9 +1421,9 @@ func (s *rpcServer) sendSignBatch(batch *order.Batch, sigs order.BatchSignature,
|
|||
|
||||
rpcLog.Infof("Sending OrderMatchSign for batch %x", batch.ID[:])
|
||||
|
||||
return s.auctioneer.SendAuctionMessage(&clmrpc.ClientAuctionMessage{
|
||||
Msg: &clmrpc.ClientAuctionMessage_Sign{
|
||||
Sign: &clmrpc.OrderMatchSign{
|
||||
return s.auctioneer.SendAuctionMessage(&poolrpc.ClientAuctionMessage{
|
||||
Msg: &poolrpc.ClientAuctionMessage_Sign{
|
||||
Sign: &poolrpc.OrderMatchSign{
|
||||
BatchId: batch.ID[:],
|
||||
AccountSigs: rpcSigs,
|
||||
ChannelInfos: rpcChannelInfos,
|
||||
|
|
@ -1435,7 +1435,7 @@ func (s *rpcServer) sendSignBatch(batch *order.Batch, sigs order.BatchSignature,
|
|||
// AuctionFee returns the current fee rate charged for matched orders within
|
||||
// the auction.
|
||||
func (s *rpcServer) AuctionFee(ctx context.Context,
|
||||
_ *clmrpc.AuctionFeeRequest) (*clmrpc.AuctionFeeResponse, error) {
|
||||
_ *poolrpc.AuctionFeeRequest) (*poolrpc.AuctionFeeResponse, error) {
|
||||
|
||||
terms, err := s.auctioneer.Terms(ctx)
|
||||
if err != nil {
|
||||
|
|
@ -1444,8 +1444,8 @@ func (s *rpcServer) AuctionFee(ctx context.Context,
|
|||
}
|
||||
|
||||
// TODO(roasbeef): accept the amt of order instead?
|
||||
return &clmrpc.AuctionFeeResponse{
|
||||
ExecutionFee: &clmrpc.ExecutionFee{
|
||||
return &poolrpc.AuctionFeeResponse{
|
||||
ExecutionFee: &poolrpc.ExecutionFee{
|
||||
BaseFee: uint64(terms.OrderExecBaseFee),
|
||||
FeeRate: uint64(terms.OrderExecFeeRate),
|
||||
},
|
||||
|
|
@ -1455,7 +1455,7 @@ func (s *rpcServer) AuctionFee(ctx context.Context,
|
|||
// BatchSnapshot returns information about a target batch including the
|
||||
// clearing price of the batch, and the set of orders matched within the batch.
|
||||
func (s *rpcServer) BatchSnapshot(ctx context.Context,
|
||||
req *clmrpc.BatchSnapshotRequest) (*clmrpc.BatchSnapshotResponse, error) {
|
||||
req *poolrpc.BatchSnapshotRequest) (*poolrpc.BatchSnapshotResponse, error) {
|
||||
|
||||
// THe current version of this call just proxies the request to the
|
||||
// auctioneer, as we may only have information about the batch if we
|
||||
|
|
@ -1467,30 +1467,30 @@ func (s *rpcServer) BatchSnapshot(ctx context.Context,
|
|||
|
||||
// rpcOrderStateToDBState maps the order state as received over the RPC
|
||||
// protocol to the local state that we use in the database.
|
||||
func rpcOrderStateToDBState(state clmrpc.OrderState) (order.State, error) {
|
||||
func rpcOrderStateToDBState(state poolrpc.OrderState) (order.State, error) {
|
||||
|
||||
var orderState order.State
|
||||
switch state {
|
||||
|
||||
case clmrpc.OrderState_ORDER_SUBMITTED:
|
||||
case poolrpc.OrderState_ORDER_SUBMITTED:
|
||||
orderState = order.StateSubmitted
|
||||
|
||||
case clmrpc.OrderState_ORDER_CLEARED:
|
||||
case poolrpc.OrderState_ORDER_CLEARED:
|
||||
orderState = order.StateCleared
|
||||
|
||||
case clmrpc.OrderState_ORDER_PARTIALLY_FILLED:
|
||||
case poolrpc.OrderState_ORDER_PARTIALLY_FILLED:
|
||||
orderState = order.StatePartiallyFilled
|
||||
|
||||
case clmrpc.OrderState_ORDER_EXECUTED:
|
||||
case poolrpc.OrderState_ORDER_EXECUTED:
|
||||
orderState = order.StateExecuted
|
||||
|
||||
case clmrpc.OrderState_ORDER_CANCELED:
|
||||
case poolrpc.OrderState_ORDER_CANCELED:
|
||||
orderState = order.StateCanceled
|
||||
|
||||
case clmrpc.OrderState_ORDER_EXPIRED:
|
||||
case poolrpc.OrderState_ORDER_EXPIRED:
|
||||
orderState = order.StateExpired
|
||||
|
||||
case clmrpc.OrderState_ORDER_FAILED:
|
||||
case poolrpc.OrderState_ORDER_FAILED:
|
||||
orderState = order.StateFailed
|
||||
|
||||
default:
|
||||
|
|
|
|||
2
run.go
2
run.go
|
|
@ -1,4 +1,4 @@
|
|||
package llm
|
||||
package pool
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
|
|
|||
22
server.go
22
server.go
|
|
@ -1,4 +1,4 @@
|
|||
package llm
|
||||
package pool
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
|
@ -14,10 +14,10 @@ import (
|
|||
|
||||
proxy "github.com/grpc-ecosystem/grpc-gateway/runtime"
|
||||
"github.com/lightninglabs/aperture/lsat"
|
||||
"github.com/lightninglabs/llm/auctioneer"
|
||||
"github.com/lightninglabs/llm/clientdb"
|
||||
"github.com/lightninglabs/llm/clmrpc"
|
||||
"github.com/lightninglabs/llm/order"
|
||||
"github.com/lightninglabs/pool/auctioneer"
|
||||
"github.com/lightninglabs/pool/clientdb"
|
||||
"github.com/lightninglabs/pool/poolrpc"
|
||||
"github.com/lightninglabs/pool/order"
|
||||
"github.com/lightninglabs/lndclient"
|
||||
"github.com/lightningnetwork/lnd/lnrpc"
|
||||
"github.com/lightningnetwork/lnd/lnrpc/verrpc"
|
||||
|
|
@ -28,7 +28,7 @@ import (
|
|||
|
||||
var (
|
||||
// minimalCompatibleVersion is the minimum version and build tags
|
||||
// required in lnd to run llm.
|
||||
// required in lnd to run pool.
|
||||
minimalCompatibleVersion = &verrpc.Version{
|
||||
AppMajor: 0,
|
||||
AppMinor: 11,
|
||||
|
|
@ -37,7 +37,7 @@ var (
|
|||
}
|
||||
)
|
||||
|
||||
// Server is the main llmd trader server.
|
||||
// Server is the main poold trader server.
|
||||
type Server struct {
|
||||
// To be used atomically.
|
||||
started int32
|
||||
|
|
@ -73,7 +73,7 @@ func NewServer(cfg *Config) *Server {
|
|||
}
|
||||
}
|
||||
|
||||
// Start runs llmd in daemon mode. It will listen for grpc connections, execute
|
||||
// Start runs poold in daemon mode. It will listen for grpc connections, execute
|
||||
// commands and pass back auction status information.
|
||||
func (s *Server) Start() error {
|
||||
if atomic.AddInt32(&s.started, 1) != 1 {
|
||||
|
|
@ -124,10 +124,10 @@ func (s *Server) Start() error {
|
|||
),
|
||||
}
|
||||
s.grpcServer = grpc.NewServer(serverOpts...)
|
||||
clmrpc.RegisterTraderServer(s.grpcServer, s.rpcServer)
|
||||
poolrpc.RegisterTraderServer(s.grpcServer, s.rpcServer)
|
||||
|
||||
// Next, start the gRPC server listening for HTTP/2 connections.
|
||||
// If the provided grpcListener is not nil, it means llmd is being
|
||||
// If the provided grpcListener is not nil, it means poold is being
|
||||
// used as a library and the listener might not be a real network
|
||||
// connection (but maybe a UNIX socket or bufconn). So we don't spin up
|
||||
// a REST listener in that case.
|
||||
|
|
@ -147,7 +147,7 @@ func (s *Server) Start() error {
|
|||
defer cancel()
|
||||
mux := proxy.NewServeMux()
|
||||
proxyOpts := []grpc.DialOption{grpc.WithInsecure()}
|
||||
err = clmrpc.RegisterTraderHandlerFromEndpoint(
|
||||
err = poolrpc.RegisterTraderHandlerFromEndpoint(
|
||||
ctx, mux, s.cfg.RPCListen, proxyOpts,
|
||||
)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package llm
|
||||
package pool
|
||||
|
||||
// Copyright (c) 2013-2017 The btcsuite developers
|
||||
// Copyright (c) 2015-2016 The Decred developers
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue