Most of the code is heavily borrowed from the chanfunding package in
lnd, except for some minor changes to account for the difference in
weights. Ideally, that package is refactored and abstracted such that it
doesn't only apply for channel funding.
We use the same proto message types everywhere for these kinds
of fields:
- absolute amounts (sats): uint64
- fee rates (sat/kWU): uint64
- fee rates (ppm): uint32
- blocks (absolute and relative): uint32
Additionally we unify the comments and remove the [ json_name = "" ]
declarations in the trader proto as they aren't needed with the
jsonpb marshaller that we use.
Then we align the naming of the account key to be called trader key
everywhere instead of user's sub key.
This'll let clients/UIs track the new order by nonce, which can be
useful for looking up later. We'll also use this in the itests to write
more assertions about expected order states.
In this commit, we change the key stored within the internal order kit
into a raw pubkey array. Along the way we fix a bug in the verifier
tests due to using a map with pointer keys rather than the actual value
itself.
Without this change, the thaw height would be relative rather than
absolute. We still need to pick an even more objective anchor to ensure
proper synchrony.
In this commit, we fix a panic in `sendAcceptBatch` due to the fact that
the method as is, creates a slice with enough _capacity_ but a zero
length. In this case, trying to access an index will result in a panic.
In this commit, we shift things over to use append instead of index into
the slice.
In the integration tests, we start the client manually as part of the
set up process. When the trader is run in a standalone manner, we still
need to ensure the client is started, otherwise the auth handshake can't
take place.
The account subscription doesn't need access to the full account,
only its key descriptor. This is a preparation for the account
recovery where we want to subscribe to the auctioneer but don't have
the full account anymore.
More error messages will be added to the server responses soon
so it makes sense to create an error type with the reason set
as a code instead of individual messages for each purpose.