Documentation ¶
Overview ¶
Package account is a generated GoMock package.
Index ¶
- Constants
- Variables
- func AdvanceAccountDerivationIndex(ctx context.Context, minimumIndex uint32, wallet lndclient.WalletKitClient, ...) error
- func AuthChallenge(commitHash [32]byte, nonce [32]byte) [32]byte
- func AuthHash(commitHash, challenge [32]byte) [32]byte
- func CommitAccount(acctPubKey [33]byte, nonce [32]byte) [32]byte
- func CopyPubKey(pub *btcec.PublicKey) *btcec.PublicKey
- func DecodeAndParseKey(key string) (*btcec.PublicKey, error)
- func GenerateRecoveryKeys(ctx context.Context, accountTarget uint32, wallet lndclient.WalletKitClient) ([]*keychain.KeyDescriptor, error)
- func GetAuctioneerData(network string) (string, uint32)
- func IsPoolTx(tx *lnrpc.Transaction) bool
- func NewManager(cfg *ManagerConfig) *manager
- func NumConfsForValue(value, maxAccountValue btcutil.Amount) uint32
- func UseLogger(logger btclog.Logger)
- func ValidateVersion(version Version) error
- type Account
- type AccountTxLabel
- type Action
- type Auctioneer
- type BitcoinConfig
- type FeeExpr
- type Manager
- type ManagerConfig
- type MockAuctioneer
- func (m *MockAuctioneer) EXPECT() *MockAuctioneerMockRecorder
- func (m *MockAuctioneer) InitAccount(arg0 context.Context, arg1 *Account) error
- func (m *MockAuctioneer) ModifyAccount(ctx context.Context, acct *Account, inputs []*wire.TxIn, outputs []*wire.TxOut, ...) ([]byte, []byte, error)
- func (m *MockAuctioneer) ReserveAccount(arg0 context.Context, arg1 btcutil.Amount, arg2 uint32, arg3 *v2.PublicKey, ...) (*Reservation, error)
- func (m *MockAuctioneer) StartAccountSubscription(arg0 context.Context, arg1 *keychain.KeyDescriptor) error
- func (m *MockAuctioneer) Terms(ctx context.Context) (*terms.AuctioneerTerms, error)
- type MockAuctioneerMockRecorder
- func (mr *MockAuctioneerMockRecorder) InitAccount(arg0, arg1 interface{}) *gomock.Call
- func (mr *MockAuctioneerMockRecorder) ModifyAccount(...) *gomock.Call
- func (mr *MockAuctioneerMockRecorder) ReserveAccount(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call
- func (mr *MockAuctioneerMockRecorder) StartAccountSubscription(arg0, arg1 interface{}) *gomock.Call
- func (mr *MockAuctioneerMockRecorder) Terms(ctx interface{}) *gomock.Call
- type MockFeeExpr
- type MockFeeExprMockRecorder
- type MockManager
- func (m *MockManager) BumpAccountFee(ctx context.Context, traderKey *v2.PublicKey, ...) error
- func (m *MockManager) CloseAccount(ctx context.Context, traderKey *v2.PublicKey, feeExpr FeeExpr, ...) (*wire.MsgTx, error)
- func (m *MockManager) DepositAccount(ctx context.Context, traderKey *v2.PublicKey, depositAmount btcutil.Amount, ...) (*Account, *wire.MsgTx, error)
- func (m *MockManager) EXPECT() *MockManagerMockRecorder
- func (m *MockManager) HandleAccountConf(traderKey *v2.PublicKey, confDetails *chainntnfs.TxConfirmation) error
- func (m *MockManager) HandleAccountExpiry(traderKey *v2.PublicKey, height uint32) error
- func (m *MockManager) HandleAccountSpend(traderKey *v2.PublicKey, spendDetails *chainntnfs.SpendDetail) error
- func (m *MockManager) InitAccount(ctx context.Context, value btcutil.Amount, version Version, ...) (*Account, error)
- func (m *MockManager) QuoteAccount(ctx context.Context, value btcutil.Amount, confTarget uint32) (chainfee.SatPerKWeight, btcutil.Amount, error)
- func (m *MockManager) RecoverAccount(ctx context.Context, account *Account) error
- func (m *MockManager) RenewAccount(ctx context.Context, traderKey *v2.PublicKey, newExpiry uint32, ...) (*Account, *wire.MsgTx, error)
- func (m *MockManager) Start() error
- func (m *MockManager) Stop()
- func (m *MockManager) WatchMatchedAccounts(ctx context.Context, matchedAccounts []*v2.PublicKey) error
- func (m *MockManager) WithdrawAccount(ctx context.Context, traderKey *v2.PublicKey, outputs []*wire.TxOut, ...) (*Account, *wire.MsgTx, error)
- type MockManagerMockRecorder
- func (mr *MockManagerMockRecorder) BumpAccountFee(ctx, traderKey, newFeeRate interface{}) *gomock.Call
- func (mr *MockManagerMockRecorder) CloseAccount(ctx, traderKey, feeExpr, bestHeight interface{}) *gomock.Call
- func (mr *MockManagerMockRecorder) DepositAccount(...) *gomock.Call
- func (mr *MockManagerMockRecorder) HandleAccountConf(traderKey, confDetails interface{}) *gomock.Call
- func (mr *MockManagerMockRecorder) HandleAccountExpiry(traderKey, height interface{}) *gomock.Call
- func (mr *MockManagerMockRecorder) HandleAccountSpend(traderKey, spendDetails interface{}) *gomock.Call
- func (mr *MockManagerMockRecorder) InitAccount(ctx, value, version, feeRate, expiry, bestHeight interface{}) *gomock.Call
- func (mr *MockManagerMockRecorder) QuoteAccount(ctx, value, confTarget interface{}) *gomock.Call
- func (mr *MockManagerMockRecorder) RecoverAccount(ctx, account interface{}) *gomock.Call
- func (mr *MockManagerMockRecorder) RenewAccount(ctx, traderKey, newExpiry, feeRate, bestHeight, newVersion interface{}) *gomock.Call
- func (mr *MockManagerMockRecorder) Start() *gomock.Call
- func (mr *MockManagerMockRecorder) Stop() *gomock.Call
- func (mr *MockManagerMockRecorder) WatchMatchedAccounts(ctx, matchedAccounts interface{}) *gomock.Call
- func (mr *MockManagerMockRecorder) WithdrawAccount(...) *gomock.Call
- type MockStore
- func (m *MockStore) Account(arg0 *v2.PublicKey) (*Account, error)
- func (m *MockStore) Accounts() ([]*Account, error)
- func (m *MockStore) AddAccount(arg0 *Account) error
- func (m *MockStore) EXPECT() *MockStoreMockRecorder
- func (m *MockStore) LockID() (wtxmgr.LockID, error)
- func (m *MockStore) MarkBatchComplete() error
- func (m *MockStore) PendingBatch() error
- func (m *MockStore) UpdateAccount(arg0 *Account, arg1 ...Modifier) error
- type MockStoreMockRecorder
- func (mr *MockStoreMockRecorder) Account(arg0 interface{}) *gomock.Call
- func (mr *MockStoreMockRecorder) Accounts() *gomock.Call
- func (mr *MockStoreMockRecorder) AddAccount(arg0 interface{}) *gomock.Call
- func (mr *MockStoreMockRecorder) LockID() *gomock.Call
- func (mr *MockStoreMockRecorder) MarkBatchComplete() *gomock.Call
- func (mr *MockStoreMockRecorder) PendingBatch() *gomock.Call
- func (mr *MockStoreMockRecorder) UpdateAccount(arg0 interface{}, arg1 ...interface{}) *gomock.Call
- type MockTxFeeEstimator
- type MockTxFeeEstimatorMockRecorder
- type MockTxSource
- type MockTxSourceMockRecorder
- type Modifier
- func ExpiryModifier(expiry uint32) Modifier
- func HeightHintModifier(heightHint uint32) Modifier
- func IncrementBatchKey() Modifier
- func LatestTxModifier(tx *wire.MsgTx) Modifier
- func OutPointModifier(op wire.OutPoint) Modifier
- func StateModifier(state State) Modifier
- func ValueModifier(value btcutil.Amount) Modifier
- func VersionModifier(version Version) Modifier
- type OutputWithFee
- type OutputsWithImplicitFee
- type RecoveryConfig
- type Reservation
- type State
- type Store
- type TxFeeEstimator
- type TxLabel
- type TxSource
- type Version
Constants ¶
const ( // DefaultFundingConfTarget is the default value used for the account // funding/init target number of blocks to confirmation. We choose a // very high value of one week to arrive at essentially 1 sat/vByte // which used to be the previous default when creating the transaction. DefaultFundingConfTarget uint32 = 144 * 7 )
const ( // InitialBatchKey is the hard coded starting point for the auctioneer's // batch key in every environment. InitialBatchKey = "02824d0cbac65e01712124c50ff2cc74ce22851d7b444c1bf2" + "ae66afefb8eaf27f" )
const ( // MinAccountValue is the minimum value for an account output in // satoshis. MinAccountValue btcutil.Amount = 100000 )
const Subsystem = "ACCT"
Variables ¶
var ( // DefaultAccountKeyWindow is the number of account keys that are // derived to be checked on recovery. This is the absolute maximum // number of accounts that can ever be restored. But the trader doesn't // necessarily make as many requests on recovery, if no accounts are // found for a certain number of tries. DefaultAccountKeyWindow uint32 = 500 )
var ( // ErrNoPendingBatch is an error returned when we attempt to retrieve // the ID of a pending batch, but one does not exist. ErrNoPendingBatch = errors.New("no pending batch found") )
Functions ¶
func AdvanceAccountDerivationIndex ¶
func AdvanceAccountDerivationIndex(ctx context.Context, minimumIndex uint32, wallet lndclient.WalletKitClient, chainParams *chaincfg.Params) error
AdvanceAccountDerivationIndex asserts that the internal wallet has at least the given minimum index for deriving account keys.
func AuthChallenge ¶
AuthChallenge creates the authentication challenge that is sent from the server as step 2 of the 3-way authentication handshake with the client. It returns the authentication challenge which is SHA256(commit_hash || nonce).
func AuthHash ¶
AuthHash creates the authentication hash that is signed as part of step 3 of the 3-way authentication handshake. It returns the authentication hash which is SHA256(commit_hash || auth_challenge) which is equal to SHA256(SHA256(accountPubKey || nonce1) || SHA256(commit_hash || nonce2)).
func CommitAccount ¶
CommitAccount creates the commitment hash that is used for the first part of the 3-way authentication handshake with the server. It returns the commitment hash which is SHA256(accountPubKey || nonce).
func CopyPubKey ¶
func CopyPubKey(pub *btcec.PublicKey) *btcec.PublicKey
CopyPubKey creates a copy of a public key.
func DecodeAndParseKey ¶
DecodeAndParseKey decode and parse a btc public key.
func GenerateRecoveryKeys ¶
func GenerateRecoveryKeys(ctx context.Context, accountTarget uint32, wallet lndclient.WalletKitClient) ([]*keychain.KeyDescriptor, error)
GenerateRecoveryKeys generates a list of key descriptors for all possible keys that could be used for trader accounts, up to a hard coded limit.
func GetAuctioneerData ¶
GetAuctioneerData returns the auctioneer data for a given environment.
func IsPoolTx ¶
func IsPoolTx(tx *lnrpc.Transaction) bool
IsPoolTx returns true if the given transaction is related to pool.
func NewManager ¶
func NewManager(cfg *ManagerConfig) *manager
NewManager instantiates a new Manager backed by the given config.
func NumConfsForValue ¶
NumConfsForValue chooses an appropriate number of confirmations to wait for an account based on its initial value.
TODO(wilmer): Determine the recommend number of blocks to wait for a particular output size given the current block reward and a user's "risk threshold" (basically a multiplier for the amount of work/fiat-burnt that would need to be done to undo N blocks).
func UseLogger ¶
UseLogger uses a specified Logger to output package logging info. This should be used in preference to SetLogWriter if the caller is also using btclog.
func ValidateVersion ¶
ValidateVersion ensures that a given version is a valid and known version.
Types ¶
type Account ¶
type Account struct { // Value is the value of the account reflected in on-chain output that // backs the existence of an account. Value btcutil.Amount // Expiry is the expiration block height of an account. After this // point, the trader is able to withdraw the funds from their account // without cooperation of the auctioneer. Expiry uint32 // TraderKey is the base trader's key in the 2-of-2 multi-sig // construction of a CLM account. This key will never be included in the // account script, but rather it will be tweaked with the per-batch key // and the account secret to prevent script reuse and provide plausible // deniability between account outputs to third parties. TraderKey *keychain.KeyDescriptor // AuctioneerKey is the base auctioneer's key in the 2-of-2 multi-sig // construction of a CLM account. This key will never be included in the // account script, but rather it will be tweaked with the per-batch // trader key to prevent script reuse and provide plausible deniability // between account outputs to third parties. AuctioneerKey *btcec.PublicKey // BatchKey is the batch key that is used to tweak the trader key of an // account with, along with the secret. This will be incremented by the // curve's base point each time the account is modified or participates // in a cleared batch to prevent output script reuse for accounts // on-chain. BatchKey *btcec.PublicKey // Secret is a static shared secret between the trader and the // auctioneer that is used to tweak the trader key of an account with, // along with the batch key. This ensures that only the trader and // auctioneer are able to successfully identify every past/future output // of an account. Secret [32]byte // State describes the state of the account. State State // HeightHint is the earliest height in the chain at which we can find // the account output in a block. HeightHint uint32 // OutPoint is the outpoint of the output used to fund the account. This // only exists once the account has reached StatePendingOpen. OutPoint wire.OutPoint // LatestTx is the latest transaction of an account. // // NOTE: This is only nil within the StateInitiated phase. There are no // guarantees as to whether the transaction has its witness populated. LatestTx *wire.MsgTx // Version is the version of the account. Version Version }
Account encapsulates all of the details of a CLM account on-chain from the trader's perspective.
func RecoverAccounts ¶
func RecoverAccounts(ctx context.Context, cfg RecoveryConfig) ([]*Account, error)
RecoverAccounts tries to recover valid accounts using the given configuration.
func (*Account) NextOutputScript ¶
NextOutputScript returns the next on-chain output script that is to be 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.
type AccountTxLabel ¶
type Auctioneer ¶
type Auctioneer interface { // ReserveAccount reserves an account of the specified value with the // auctioneer. The auctioneer checks the account value against current // min/max values configured. If the value is valid, it returns the // public key we should use for them in our 2-of-2 multi-sig // construction. To address an edge case in the account recovery where // the trader crashes before confirming the account with the auctioneer, // we also send the trader key and expiry along with the reservation. ReserveAccount(context.Context, btcutil.Amount, uint32, *btcec.PublicKey, Version) (*Reservation, error) // InitAccount initializes an account with the auctioneer such that it // can be used once fully confirmed. InitAccount(context.Context, *Account) error // ModifyAccount sends an intent to the auctioneer that we'd like to // modify the account with the associated trader key. The auctioneer's // signature is returned, allowing us to broadcast a transaction // spending from the account allowing our modifications to take place. // If the account spend is a MuSig2 spend, then the trader's nonces must // be sent and the server's nonces are returned upon success. The inputs // and outputs provided should exclude the account input being spent and // the account output potentially being recreated, since the auctioneer // can construct those themselves. If no modifiers are present, then the // auctioneer will interpret the request as an account closure. The // previous outputs must always contain the UTXO information for _every_ // input of the transaction, so inputs+account_input. ModifyAccount(ctx context.Context, acct *Account, inputs []*wire.TxIn, outputs []*wire.TxOut, modifiers []Modifier, traderNonces []byte, previousOutputs []*wire.TxOut) ([]byte, []byte, error) // StartAccountSubscription opens a stream to the server and subscribes // to all updates that concern the given account, including all orders // that spend from that account. Only a single stream is ever open to // the server, so a second call to this method will send a second // subscription over the same stream, multiplexing all messages into the // same connection. A stream can be long-lived, so this can be called // for every account as soon as it's confirmed open. This method will // return as soon as the authentication was successful. Messages sent // from the server can then be received on the FromServerChan channel. StartAccountSubscription(context.Context, *keychain.KeyDescriptor) error // Terms returns the current dynamic auctioneer terms like max account // size, max order duration in blocks and the auction fee schedule. Terms(ctx context.Context) (*terms.AuctioneerTerms, error) }
Auctioneer provides us with the different ways we are able to communicate with our auctioneer during the process of opening/closing/modifying accounts.
type BitcoinConfig ¶
type BitcoinConfig struct { // Host is the bitcoind/btcd instance address. Host string // User is the bitcoind/btcd user name. User string // Password is the bitcoind/btcd password. Password string // HTTPPostMode uses HTTP Post mode if true. // // Note: bitcoind only supports this mode. HTTPPostMode bool // UseTLS use TLS to connect if ture. // // Note: bitcoind only supports non-TLS connections. UseTLS bool // TLSPath is the path to btcd's TLS certificate. This field is Ignored // if TLS is not enabled. TLSPath string `long:"tlspath" description:"Path to btcd's TLS certificate, if TLS is enabled"` }
BitcoinConfig defines exported config options for the connection to the btcd/bitcoind backend.
type FeeExpr ¶
type FeeExpr interface { // CloseOutputs is the list of outputs that should be used for the // closing transaction of an account based on the concrete fee // expression implementation. CloseOutputs(btcutil.Amount, witnessType) ([]*wire.TxOut, error) }
FeeExpr represents the different ways a transaction fee can be expressed in terms of a transaction's resulting outputs.
type Manager ¶
type Manager interface { // Start resumes all account on-chain operation after a restart. Start() error // Stop safely stops any ongoing operations within the Manager. Stop() // QuoteAccount returns the expected fee rate and total miner fee to // send to an account funding output with the given confTarget. QuoteAccount(ctx context.Context, value btcutil.Amount, confTarget uint32) (chainfee.SatPerKWeight, btcutil.Amount, error) // InitAccount handles a request to create a new account with the // provided parameters. InitAccount(ctx context.Context, value btcutil.Amount, version Version, feeRate chainfee.SatPerKWeight, expiry, bestHeight uint32) (*Account, error) // WatchMatchedAccounts resumes accounts that were just matched in a // batch and are expecting the batch transaction to confirm as their // next account output. This will cancel all previous spend and conf // watchers of all accounts involved in the batch. WatchMatchedAccounts(ctx context.Context, matchedAccounts []*btcec.PublicKey) error // HandleAccountConf takes the necessary steps after detecting the // confirmation of an account on-chain. HandleAccountConf(traderKey *btcec.PublicKey, confDetails *chainntnfs.TxConfirmation) error // HandleAccountSpend handles the different spend paths of an account. // If an account is spent by the expiration path, it'll always be marked // as closed thereafter. If it is spent by the cooperative path with the // auctioneer, then the account will only remain open if the spending // transaction recreates the account with the expected next account // script. Otherwise, it is also marked as closed. In case of multiple // consecutive batches with the same account, we only track the spend of // the latest batch, after it confirmed. So the account/ output in the // spend transaction should always match our database state if it was a // cooperative spend. HandleAccountSpend(traderKey *btcec.PublicKey, spendDetails *chainntnfs.SpendDetail) error // HandleAccountExpiry marks an account as expired within the database. HandleAccountExpiry(traderKey *btcec.PublicKey, height uint32) error // DepositAccount attempts to deposit funds into the account associated // with the given trader key such that the new account value is met // using inputs sourced from the backing lnd node's wallet. If needed, a // change output that does back to lnd may be added to the deposit // transaction. DepositAccount(ctx context.Context, traderKey *btcec.PublicKey, depositAmount btcutil.Amount, feeRate chainfee.SatPerKWeight, bestHeight, expiryHeight uint32, newVersion Version) (*Account, *wire.MsgTx, error) // WithdrawAccount attempts to withdraw funds from the account // associated with the given trader key into the provided outputs. WithdrawAccount(ctx context.Context, traderKey *btcec.PublicKey, outputs []*wire.TxOut, feeRate chainfee.SatPerKWeight, bestHeight, expiryHeight uint32, newVersion Version) (*Account, *wire.MsgTx, error) // RenewAccount updates the expiration of an open/expired account. This // will always require a signature from the auctioneer, even after the // account has expired, to ensure the auctioneer is aware the account is // being renewed. RenewAccount(ctx context.Context, traderKey *btcec.PublicKey, newExpiry uint32, feeRate chainfee.SatPerKWeight, bestHeight uint32, newVersion Version) (*Account, *wire.MsgTx, error) // BumpAccountFee attempts to bump the fee of an account's most recent // transaction. This is done by locating an eligible output for lnd to // CPFP, otherwise the fee bump will not succeed. Further invocations of // this call for the same account will result in the child being // replaced by the higher fee transaction (RBF). BumpAccountFee(ctx context.Context, traderKey *btcec.PublicKey, newFeeRate chainfee.SatPerKWeight) error // CloseAccount attempts to close the account associated with the given // trader key. Closing the account requires a signature of the // auctioneer if the account has not yet expired. The account funds are // swept according to the provided fee expression. CloseAccount(ctx context.Context, traderKey *btcec.PublicKey, feeExpr FeeExpr, bestHeight uint32) (*wire.MsgTx, error) // RecoverAccount re-introduces a recovered account into the database // and starts all watchers necessary depending on the account's state. RecoverAccount(ctx context.Context, account *Account) error }
Manager is the interface a manager implements to deal with the accounts.
type ManagerConfig ¶
type ManagerConfig struct { // Store is responsible for storing and retrieving account information // reliably. Store Store // Auctioneer provides us with the different ways we are able to // communicate with our auctioneer during the process of // opening/closing/modifying accounts. Auctioneer Auctioneer // Wallet handles all of our on-chain transaction interaction, whether // that is deriving keys, creating transactions, etc. Wallet lndclient.WalletKitClient // Signer is responsible for deriving shared secrets for accounts // between the trader and auctioneer and signing account-related // transactions. Signer lndclient.SignerClient // ChainNotifier is responsible for requesting confirmation and spend // notifications for accounts. ChainNotifier lndclient.ChainNotifierClient // TxSource is a source that provides us with transactions previously // broadcast by us. TxSource TxSource // TxFeeEstimator is an estimator that can calculate the total on-chain // fees to send to an account output. TxFeeEstimator TxFeeEstimator // TxLabelPrefix is set, then all transactions the account manager // makes will use this string as a prefix for added transaction labels. TxLabelPrefix string // ChainParams are the currently used chain parameters. ChainParams *chaincfg.Params // LndVersion is the version of the connected lnd node. LndVersion *verrpc.Version }
ManagerConfig contains all of the required dependencies for the Manager to carry out its duties.
type MockAuctioneer ¶
type MockAuctioneer struct {
// contains filtered or unexported fields
}
MockAuctioneer is a mock of Auctioneer interface.
func NewMockAuctioneer ¶
func NewMockAuctioneer(ctrl *gomock.Controller) *MockAuctioneer
NewMockAuctioneer creates a new mock instance.
func (*MockAuctioneer) EXPECT ¶
func (m *MockAuctioneer) EXPECT() *MockAuctioneerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockAuctioneer) InitAccount ¶
func (m *MockAuctioneer) InitAccount(arg0 context.Context, arg1 *Account) error
InitAccount mocks base method.
func (*MockAuctioneer) ModifyAccount ¶
func (m *MockAuctioneer) ModifyAccount(ctx context.Context, acct *Account, inputs []*wire.TxIn, outputs []*wire.TxOut, modifiers []Modifier, traderNonces []byte, previousOutputs []*wire.TxOut) ([]byte, []byte, error)
ModifyAccount mocks base method.
func (*MockAuctioneer) ReserveAccount ¶
func (m *MockAuctioneer) ReserveAccount(arg0 context.Context, arg1 btcutil.Amount, arg2 uint32, arg3 *v2.PublicKey, arg4 Version) (*Reservation, error)
ReserveAccount mocks base method.
func (*MockAuctioneer) StartAccountSubscription ¶
func (m *MockAuctioneer) StartAccountSubscription(arg0 context.Context, arg1 *keychain.KeyDescriptor) error
StartAccountSubscription mocks base method.
func (*MockAuctioneer) Terms ¶
func (m *MockAuctioneer) Terms(ctx context.Context) (*terms.AuctioneerTerms, error)
Terms mocks base method.
type MockAuctioneerMockRecorder ¶
type MockAuctioneerMockRecorder struct {
// contains filtered or unexported fields
}
MockAuctioneerMockRecorder is the mock recorder for MockAuctioneer.
func (*MockAuctioneerMockRecorder) InitAccount ¶
func (mr *MockAuctioneerMockRecorder) InitAccount(arg0, arg1 interface{}) *gomock.Call
InitAccount indicates an expected call of InitAccount.
func (*MockAuctioneerMockRecorder) ModifyAccount ¶
func (mr *MockAuctioneerMockRecorder) ModifyAccount(ctx, acct, inputs, outputs, modifiers, traderNonces, previousOutputs interface{}) *gomock.Call
ModifyAccount indicates an expected call of ModifyAccount.
func (*MockAuctioneerMockRecorder) ReserveAccount ¶
func (mr *MockAuctioneerMockRecorder) ReserveAccount(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call
ReserveAccount indicates an expected call of ReserveAccount.
func (*MockAuctioneerMockRecorder) StartAccountSubscription ¶
func (mr *MockAuctioneerMockRecorder) StartAccountSubscription(arg0, arg1 interface{}) *gomock.Call
StartAccountSubscription indicates an expected call of StartAccountSubscription.
func (*MockAuctioneerMockRecorder) Terms ¶
func (mr *MockAuctioneerMockRecorder) Terms(ctx interface{}) *gomock.Call
Terms indicates an expected call of Terms.
type MockFeeExpr ¶
type MockFeeExpr struct {
// contains filtered or unexported fields
}
MockFeeExpr is a mock of FeeExpr interface.
func NewMockFeeExpr ¶
func NewMockFeeExpr(ctrl *gomock.Controller) *MockFeeExpr
NewMockFeeExpr creates a new mock instance.
func (*MockFeeExpr) CloseOutputs ¶
CloseOutputs mocks base method.
func (*MockFeeExpr) EXPECT ¶
func (m *MockFeeExpr) EXPECT() *MockFeeExprMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
type MockFeeExprMockRecorder ¶
type MockFeeExprMockRecorder struct {
// contains filtered or unexported fields
}
MockFeeExprMockRecorder is the mock recorder for MockFeeExpr.
func (*MockFeeExprMockRecorder) CloseOutputs ¶
func (mr *MockFeeExprMockRecorder) CloseOutputs(arg0, arg1 interface{}) *gomock.Call
CloseOutputs indicates an expected call of CloseOutputs.
type MockManager ¶
type MockManager struct {
// contains filtered or unexported fields
}
MockManager is a mock of Manager interface.
func NewMockManager ¶
func NewMockManager(ctrl *gomock.Controller) *MockManager
NewMockManager creates a new mock instance.
func (*MockManager) BumpAccountFee ¶
func (m *MockManager) BumpAccountFee(ctx context.Context, traderKey *v2.PublicKey, newFeeRate chainfee.SatPerKWeight) error
BumpAccountFee mocks base method.
func (*MockManager) CloseAccount ¶
func (m *MockManager) CloseAccount(ctx context.Context, traderKey *v2.PublicKey, feeExpr FeeExpr, bestHeight uint32) (*wire.MsgTx, error)
CloseAccount mocks base method.
func (*MockManager) DepositAccount ¶
func (m *MockManager) DepositAccount(ctx context.Context, traderKey *v2.PublicKey, depositAmount btcutil.Amount, feeRate chainfee.SatPerKWeight, bestHeight, expiryHeight uint32, newVersion Version) (*Account, *wire.MsgTx, error)
DepositAccount mocks base method.
func (*MockManager) EXPECT ¶
func (m *MockManager) EXPECT() *MockManagerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockManager) HandleAccountConf ¶
func (m *MockManager) HandleAccountConf(traderKey *v2.PublicKey, confDetails *chainntnfs.TxConfirmation) error
HandleAccountConf mocks base method.
func (*MockManager) HandleAccountExpiry ¶
func (m *MockManager) HandleAccountExpiry(traderKey *v2.PublicKey, height uint32) error
HandleAccountExpiry mocks base method.
func (*MockManager) HandleAccountSpend ¶
func (m *MockManager) HandleAccountSpend(traderKey *v2.PublicKey, spendDetails *chainntnfs.SpendDetail) error
HandleAccountSpend mocks base method.
func (*MockManager) InitAccount ¶
func (m *MockManager) InitAccount(ctx context.Context, value btcutil.Amount, version Version, feeRate chainfee.SatPerKWeight, expiry, bestHeight uint32) (*Account, error)
InitAccount mocks base method.
func (*MockManager) QuoteAccount ¶
func (m *MockManager) QuoteAccount(ctx context.Context, value btcutil.Amount, confTarget uint32) (chainfee.SatPerKWeight, btcutil.Amount, error)
QuoteAccount mocks base method.
func (*MockManager) RecoverAccount ¶
func (m *MockManager) RecoverAccount(ctx context.Context, account *Account) error
RecoverAccount mocks base method.
func (*MockManager) RenewAccount ¶
func (m *MockManager) RenewAccount(ctx context.Context, traderKey *v2.PublicKey, newExpiry uint32, feeRate chainfee.SatPerKWeight, bestHeight uint32, newVersion Version) (*Account, *wire.MsgTx, error)
RenewAccount mocks base method.
func (*MockManager) WatchMatchedAccounts ¶
func (m *MockManager) WatchMatchedAccounts(ctx context.Context, matchedAccounts []*v2.PublicKey) error
WatchMatchedAccounts mocks base method.
type MockManagerMockRecorder ¶
type MockManagerMockRecorder struct {
// contains filtered or unexported fields
}
MockManagerMockRecorder is the mock recorder for MockManager.
func (*MockManagerMockRecorder) BumpAccountFee ¶
func (mr *MockManagerMockRecorder) BumpAccountFee(ctx, traderKey, newFeeRate interface{}) *gomock.Call
BumpAccountFee indicates an expected call of BumpAccountFee.
func (*MockManagerMockRecorder) CloseAccount ¶
func (mr *MockManagerMockRecorder) CloseAccount(ctx, traderKey, feeExpr, bestHeight interface{}) *gomock.Call
CloseAccount indicates an expected call of CloseAccount.
func (*MockManagerMockRecorder) DepositAccount ¶
func (mr *MockManagerMockRecorder) DepositAccount(ctx, traderKey, depositAmount, feeRate, bestHeight, expiryHeight, newVersion interface{}) *gomock.Call
DepositAccount indicates an expected call of DepositAccount.
func (*MockManagerMockRecorder) HandleAccountConf ¶
func (mr *MockManagerMockRecorder) HandleAccountConf(traderKey, confDetails interface{}) *gomock.Call
HandleAccountConf indicates an expected call of HandleAccountConf.
func (*MockManagerMockRecorder) HandleAccountExpiry ¶
func (mr *MockManagerMockRecorder) HandleAccountExpiry(traderKey, height interface{}) *gomock.Call
HandleAccountExpiry indicates an expected call of HandleAccountExpiry.
func (*MockManagerMockRecorder) HandleAccountSpend ¶
func (mr *MockManagerMockRecorder) HandleAccountSpend(traderKey, spendDetails interface{}) *gomock.Call
HandleAccountSpend indicates an expected call of HandleAccountSpend.
func (*MockManagerMockRecorder) InitAccount ¶
func (mr *MockManagerMockRecorder) InitAccount(ctx, value, version, feeRate, expiry, bestHeight interface{}) *gomock.Call
InitAccount indicates an expected call of InitAccount.
func (*MockManagerMockRecorder) QuoteAccount ¶
func (mr *MockManagerMockRecorder) QuoteAccount(ctx, value, confTarget interface{}) *gomock.Call
QuoteAccount indicates an expected call of QuoteAccount.
func (*MockManagerMockRecorder) RecoverAccount ¶
func (mr *MockManagerMockRecorder) RecoverAccount(ctx, account interface{}) *gomock.Call
RecoverAccount indicates an expected call of RecoverAccount.
func (*MockManagerMockRecorder) RenewAccount ¶
func (mr *MockManagerMockRecorder) RenewAccount(ctx, traderKey, newExpiry, feeRate, bestHeight, newVersion interface{}) *gomock.Call
RenewAccount indicates an expected call of RenewAccount.
func (*MockManagerMockRecorder) Start ¶
func (mr *MockManagerMockRecorder) Start() *gomock.Call
Start indicates an expected call of Start.
func (*MockManagerMockRecorder) Stop ¶
func (mr *MockManagerMockRecorder) Stop() *gomock.Call
Stop indicates an expected call of Stop.
func (*MockManagerMockRecorder) WatchMatchedAccounts ¶
func (mr *MockManagerMockRecorder) WatchMatchedAccounts(ctx, matchedAccounts interface{}) *gomock.Call
WatchMatchedAccounts indicates an expected call of WatchMatchedAccounts.
func (*MockManagerMockRecorder) WithdrawAccount ¶
func (mr *MockManagerMockRecorder) WithdrawAccount(ctx, traderKey, outputs, feeRate, bestHeight, expiryHeight, newVersion interface{}) *gomock.Call
WithdrawAccount indicates an expected call of WithdrawAccount.
type MockStore ¶
type MockStore struct {
// contains filtered or unexported fields
}
MockStore is a mock of Store interface.
func NewMockStore ¶
func NewMockStore(ctrl *gomock.Controller) *MockStore
NewMockStore creates a new mock instance.
func (*MockStore) AddAccount ¶
AddAccount mocks base method.
func (*MockStore) EXPECT ¶
func (m *MockStore) EXPECT() *MockStoreMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockStore) MarkBatchComplete ¶
MarkBatchComplete mocks base method.
func (*MockStore) PendingBatch ¶
PendingBatch mocks base method.
type MockStoreMockRecorder ¶
type MockStoreMockRecorder struct {
// contains filtered or unexported fields
}
MockStoreMockRecorder is the mock recorder for MockStore.
func (*MockStoreMockRecorder) Account ¶
func (mr *MockStoreMockRecorder) Account(arg0 interface{}) *gomock.Call
Account indicates an expected call of Account.
func (*MockStoreMockRecorder) Accounts ¶
func (mr *MockStoreMockRecorder) Accounts() *gomock.Call
Accounts indicates an expected call of Accounts.
func (*MockStoreMockRecorder) AddAccount ¶
func (mr *MockStoreMockRecorder) AddAccount(arg0 interface{}) *gomock.Call
AddAccount indicates an expected call of AddAccount.
func (*MockStoreMockRecorder) LockID ¶
func (mr *MockStoreMockRecorder) LockID() *gomock.Call
LockID indicates an expected call of LockID.
func (*MockStoreMockRecorder) MarkBatchComplete ¶
func (mr *MockStoreMockRecorder) MarkBatchComplete() *gomock.Call
MarkBatchComplete indicates an expected call of MarkBatchComplete.
func (*MockStoreMockRecorder) PendingBatch ¶
func (mr *MockStoreMockRecorder) PendingBatch() *gomock.Call
PendingBatch indicates an expected call of PendingBatch.
func (*MockStoreMockRecorder) UpdateAccount ¶
func (mr *MockStoreMockRecorder) UpdateAccount(arg0 interface{}, arg1 ...interface{}) *gomock.Call
UpdateAccount indicates an expected call of UpdateAccount.
type MockTxFeeEstimator ¶
type MockTxFeeEstimator struct {
// contains filtered or unexported fields
}
MockTxFeeEstimator is a mock of TxFeeEstimator interface.
func NewMockTxFeeEstimator ¶
func NewMockTxFeeEstimator(ctrl *gomock.Controller) *MockTxFeeEstimator
NewMockTxFeeEstimator creates a new mock instance.
func (*MockTxFeeEstimator) EXPECT ¶
func (m *MockTxFeeEstimator) EXPECT() *MockTxFeeEstimatorMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
type MockTxFeeEstimatorMockRecorder ¶
type MockTxFeeEstimatorMockRecorder struct {
// contains filtered or unexported fields
}
MockTxFeeEstimatorMockRecorder is the mock recorder for MockTxFeeEstimator.
func (*MockTxFeeEstimatorMockRecorder) EstimateFeeToP2WSH ¶
func (mr *MockTxFeeEstimatorMockRecorder) EstimateFeeToP2WSH(ctx, amt, confTarget interface{}) *gomock.Call
EstimateFeeToP2WSH indicates an expected call of EstimateFeeToP2WSH.
type MockTxSource ¶
type MockTxSource struct {
// contains filtered or unexported fields
}
MockTxSource is a mock of TxSource interface.
func NewMockTxSource ¶
func NewMockTxSource(ctrl *gomock.Controller) *MockTxSource
NewMockTxSource creates a new mock instance.
func (*MockTxSource) EXPECT ¶
func (m *MockTxSource) EXPECT() *MockTxSourceMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockTxSource) ListTransactions ¶
func (m *MockTxSource) ListTransactions(ctx context.Context, startHeight, endHeight int32, opts ...lndclient.ListTransactionsOption) ([]lndclient.Transaction, error)
ListTransactions mocks base method.
type MockTxSourceMockRecorder ¶
type MockTxSourceMockRecorder struct {
// contains filtered or unexported fields
}
MockTxSourceMockRecorder is the mock recorder for MockTxSource.
func (*MockTxSourceMockRecorder) ListTransactions ¶
func (mr *MockTxSourceMockRecorder) ListTransactions(ctx, startHeight, endHeight interface{}, opts ...interface{}) *gomock.Call
ListTransactions indicates an expected call of ListTransactions.
type Modifier ¶
type Modifier func(*Account)
Modifier abstracts the modification of an account through a function.
func ExpiryModifier ¶
ExpiryModifier is a functional option that modifies the expiry of an account.
func HeightHintModifier ¶
HeightHintModifier is a functional option that modifies the height hint of an account.
func IncrementBatchKey ¶
func IncrementBatchKey() Modifier
IncrementBatchKey is a functional option that increments the batch key of an account by adding the curve's base point.
func LatestTxModifier ¶
LatestTxModifier is a functional option that modifies the latest transaction of an account.
func OutPointModifier ¶
OutPointModifier is a functional option that modifies the outpoint of an account.
func StateModifier ¶
StateModifier is a functional option that modifies the state of an account.
func ValueModifier ¶
ValueModifier is a functional option that modifies the value of an account.
func VersionModifier ¶
VersionModifier is a functional option that modifies the version of an account.
type OutputWithFee ¶
type OutputWithFee struct { // PkScript is the destination output script. Note that this may be nil, // in which case a wallet-derived P2WKH script should be used. PkScript []byte // FeeRate is the accompanying fee rate to use to determine the // transaction fee. FeeRate chainfee.SatPerKWeight }
OutputWithFee signals that a single transaction output along with a fee rate is used to determine the transaction fee.
func (*OutputWithFee) CloseOutputs ¶
type OutputsWithImplicitFee ¶
OutputsWithImplicitFee signals that the transaction fee is implicitly defined by the output values provided, i.e., the fee is determined by subtracting the total output value from the total input value.
func (OutputsWithImplicitFee) CloseOutputs ¶
func (o OutputsWithImplicitFee) CloseOutputs(_ btcutil.Amount, _ witnessType) ([]*wire.TxOut, error)
CloseOutputs is the list of outputs that should be used for the closing transaction of an account using an implicit fee expression.
func (OutputsWithImplicitFee) Outputs ¶
func (o OutputsWithImplicitFee) Outputs() []*wire.TxOut
Outputs returns the set of outputs.
type RecoveryConfig ¶
type RecoveryConfig struct { // Network to run recovery on. Network string // Number of accounts that we are trying to find. AccountTarget uint32 // FirstBlock block marks the initial height for our search. FirstBlock uint32 // LastBlock block marks the final height for our search. LastBlock uint32 // CurrentBlockHeight is the best known height of the main chain. CurrentBlockHeight int64 // BitcoinConfig defines exported config options for the connection to // the btcd/bitcoind backend. BitcoinConfig *BitcoinConfig // Transactions is a list of all transactions that the lnd wallet is // currently aware of. Transactions []*wire.MsgTx // Signer is the signrpc client used to derive the shared key between // the server and client. Signer lndclient.SignerClient // Wallet is the walletrpc client used to derive all possible account // keys. Wallet lndclient.WalletKitClient // InitialBatchKey is the starting value for the auctioneer's batch key. InitialBatchKey *btcec.PublicKey // AuctioneerPubKey is the static, per-environment public key of the // auctioneer. AuctioneerPubKey *btcec.PublicKey // Quit is a channel that is closed when the server is shutting down. Quit chan struct{} // contains filtered or unexported fields }
RecoveryConfig contains all the required dependencies for carrying out the recovery process duties.
type Reservation ¶
type Reservation struct { // AuctioneerKey is the base auctioneer's key in the 2-of-2 multi-sig // construction of a CLM account. This key will never be included in the // account script, but rather it will be tweaked with the per-batch // trader key to prevent script reuse and provide plausible deniability // between account outputs to third parties. AuctioneerKey *btcec.PublicKey // InitialBatchKey is the initial batch key that is used to tweak the // trader key of an account. InitialBatchKey *btcec.PublicKey }
Reservation contains information about the different keys required for to create a new account.
type State ¶
type State uint8
State describes the different possible states of an account.
const ( // StateInitiated denotes the initial state of an account. When an // account is in this state, then it should be funded with a // transaction. StateInitiated State = 0 // StatePendingOpen denotes that we've broadcast the account's funding // transaction and are currently waiting for its confirmation. StatePendingOpen State = 1 // StatePendingUpdate denotes that the account has undergone an update // on-chain as part of a trader modification and we are currently // waiting for its confirmation. StatePendingUpdate State = 2 // StateOpen denotes that the account's funding transaction has been // included in the chain with sufficient depth. StateOpen State = 3 // StateExpired denotes that the chain has reached an account's // expiration height. An account in this state can still be used if // renewed. StateExpired State = 4 // StatePendingClosed denotes that an account was fully spent by a // transaction broadcast by the trader and is pending its confirmation. StatePendingClosed State = 5 // StateClosed denotes that an account was closed by a transaction // broadcast by the trader that fully spent the account. An account in // this state can no longer be used. StateClosed State = 6 // StateCanceledAfterRecovery denotes that the account was attempted to // be recovered but failed because the opening transaction wasn't found // by lnd. This could be because it was never published or it never // confirmed. Then the funds are SAFU and the account can be considered // to never have been opened in the first place. StateCanceledAfterRecovery State = 7 // StatePendingBatch denotes an account that recently participated in a // batch and is not yet confirmed. StatePendingBatch State = 8 // StateExpiredPendingUpdate denotes that the chain has reached an // account's expiration height while the account had a pending update // that has yet to confirm. This state exists to ensure an account can // only be renewed once confirmed and expired. StateExpiredPendingUpdate State = 9 )
NOTE: We avoid the use of iota as these can be persisted to disk.
type Store ¶
type Store interface { // AddAccount adds a record for the account to the database. AddAccount(*Account) error // UpdateAccount updates an account in the database according to the // given modifiers. UpdateAccount(*Account, ...Modifier) error // Account retrieves the account associated with the given trader key // from the database. Account(*btcec.PublicKey) (*Account, error) // Accounts retrieves all existing accounts. Accounts() ([]*Account, error) // PendingBatch determines whether we currently have a pending batch. // If a batch doesn't exist, ErrNoPendingBatch is returned. PendingBatch() error // MarkBatchComplete marks the batch with the given ID as complete, // indicating that the staged account updates can be applied to disk. MarkBatchComplete() error // LockID retrieves the global lock ID we'll use to lock any outputs // when performing coin selection. LockID() (wtxmgr.LockID, error) }
Store is responsible for storing and retrieving account information reliably.
type TxFeeEstimator ¶
type TxFeeEstimator interface { // EstimateFeeToP2WSH estimates the total chain fees in satoshis to send // the given amount to a single P2WSH output with the given target // confirmation. EstimateFeeToP2WSH(ctx context.Context, amt btcutil.Amount, confTarget int32) (btcutil.Amount, error) }
TxFeeEstimator is a type that provides us with a realistic fee estimation to send coins in a transaction.
type TxLabel ¶
type TxLabel struct {
Account AccountTxLabel `json:"account"`
}
func ParseTxLabel ¶
ParseTxLabel parses and returns data fields stored in a given transaction label.
type TxSource ¶
type TxSource interface { // ListTransactions returns all known transactions of the backing lnd // node. It takes a start and end block height which can be used to // limit the block range that we query over. These values can be left // as zero to include all blocks. To include unconfirmed transactions // in the query, endHeight must be set to -1. ListTransactions(ctx context.Context, startHeight, endHeight int32, opts ...lndclient.ListTransactionsOption) ( []lndclient.Transaction, error) }
TxSource is a source that provides us with transactions previously broadcast by us.
type Version ¶
type Version uint8
Version represents the version of an account.
const ( // VersionInitialNoVersion is the initial version any legacy account has // that technically wasn't versioned at all. The version field isn't // even serialized for those accounts. VersionInitialNoVersion Version = 0 // VersionTaprootEnabled is the version that introduced account // versioning and the upgrade to Taproot (with MuSig2 multi-sig). VersionTaprootEnabled Version = 1 // VersionMuSig2V100RC2 is the version that bumped the MuSig2 protocol // version used to v1.0.0-rc2. This is the very verbose code internal // version name, in anything user facing, we'll just call this // "Taproot v2" to keep it simple and short. VersionMuSig2V100RC2 Version = 2 )
func (Version) ScriptVersion ¶
func (v Version) ScriptVersion() poolscript.Version
ScriptVersion returns the version of the pool script used by this account version.