Documentation ¶
Index ¶
- func GetBitcoinChain(ctx context.Context, li lnrpc.LightningClient) (*chaincfg.Params, error)
- func GetClientConnection(ctx context.Context, cfg *peerswaplnd.LndConfig) (*grpc.ClientConn, error)
- func IsContextError(err error) bool
- func LndShortChannelIdToCLShortChannelId(lndCI lnwire.ShortChannelID) string
- func WaitForReady(conn *grpc.ClientConn, timeout time.Duration) error
- type Client
- func (l *Client) AddMessageHandler(f func(peerId string, msgType string, payload []byte) error)
- func (l *Client) AddPaymentCallback(f func(swapId string, invoiceType swap.InvoiceType))
- func (l *Client) AddPaymentNotifier(swapId string, payreq string, invoiceType swap.InvoiceType)
- func (l *Client) BroadcastOpeningTx(unpreparedTxHex string) (txId, txHex string, error error)
- func (l *Client) CheckChannel(shortChannelId string, amountSat uint64) (*lnrpc.Channel, error)
- func (l *Client) CreateCoopSpendingTransaction(swapParams *swap.OpeningParams, claimParams *swap.ClaimParams, ...) (txId, txHex string, error error)
- func (l *Client) CreateCsvSpendingTransaction(swapParams *swap.OpeningParams, claimParams *swap.ClaimParams) (string, string, error)
- func (l *Client) CreateOpeningTransaction(swapParams *swap.OpeningParams) (unpreparedTxHex string, fee uint64, vout uint32, err error)
- func (l *Client) CreatePreimageSpendingTransaction(swapParams *swap.OpeningParams, claimParams *swap.ClaimParams) (string, string, error)
- func (l *Client) DecodePayreq(payreq string) (paymentHash string, amountMsat uint64, expiry int64, err error)
- func (cl *Client) GetAsset() string
- func (l *Client) GetFlatSwapOutFee() (uint64, error)
- func (cl *Client) GetNetwork() string
- func (l *Client) GetOnchainBalance() (uint64, error)
- func (l *Client) GetOutputScript(params *swap.OpeningParams) ([]byte, error)
- func (l *Client) GetPayreq(msatAmount uint64, preimageString string, swapId string, memo string, ...) (string, error)
- func (l *Client) GetPeers() []string
- func (l *Client) GetRefundFee() (uint64, error)
- func (l *Client) NewAddress() (string, error)
- func (l *Client) PayInvoice(payreq string) (preImage string, err error)
- func (l *Client) PayInvoiceViaChannel(payreq, scid string) (preimage string, err error)
- func (l *Client) PrepareOpeningTransaction(address string, amount uint64) (txId string, txHex string, err error)
- func (l *Client) RebalancePayment(payreq string, channelId string) (preimage string, err error)
- func (l *Client) SendMessage(peerId string, message []byte, messageType int) error
- func (l *Client) StartListening() error
- type LndFeeEstimator
- type MessageListener
- type PaymentWatcher
- type PeerListener
- type TxWatcher
- func (t *TxWatcher) AddConfirmationCallback(cb func(swapId string, txHex string) error)
- func (t *TxWatcher) AddCsvCallback(cb func(swapId string) error)
- func (t *TxWatcher) AddWaitForConfirmationTx(swapId string, txId string, _ uint32, heightHint uint32, script []byte)
- func (t *TxWatcher) AddWaitForCsvTx(swapId string, txId string, vout uint32, heightHint uint32, script []byte)
- func (t *TxWatcher) GetBlockHeight() (uint32, error)
- func (t *TxWatcher) Start() error
- func (t *TxWatcher) Stop() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetBitcoinChain ¶
func GetClientConnection ¶
func GetClientConnection(ctx context.Context, cfg *peerswaplnd.LndConfig) (*grpc.ClientConn, error)
func IsContextError ¶
IsContextError returns true if the error is of grpc error type Canceled or DeadlineExceeded. A ContextError always indicates that a grpc stream was closed by the client side.
func LndShortChannelIdToCLShortChannelId ¶
func LndShortChannelIdToCLShortChannelId(lndCI lnwire.ShortChannelID) string
func WaitForReady ¶
func WaitForReady(conn *grpc.ClientConn, timeout time.Duration) error
WaitForReady checks on the status of a grpc client connection. We wait until the connection is READY or until timeout. Is a blocking call. Returns an error on timeout.
Types ¶
type Client ¶
Client combines multiple methods, functions and watchers to a service that is consumed by the swap service. Client fulfils the swap.LightningClient interface. TODO: Rework the swap.LightningClient interface to separate the watchers from the client service. This will make it easier to test and more modular to use.
func NewClient ¶
func NewClient( ctx context.Context, cc *grpc.ClientConn, paymentWatcher *PaymentWatcher, messageListener *MessageListener, chain *onchain.BitcoinOnChain, ) (*Client, error)
func (*Client) AddMessageHandler ¶
func (*Client) AddPaymentCallback ¶
func (l *Client) AddPaymentCallback(f func(swapId string, invoiceType swap.InvoiceType))
func (*Client) AddPaymentNotifier ¶
func (l *Client) AddPaymentNotifier(swapId string, payreq string, invoiceType swap.InvoiceType)
func (*Client) BroadcastOpeningTx ¶
func (*Client) CheckChannel ¶
func (*Client) CreateCoopSpendingTransaction ¶
func (l *Client) CreateCoopSpendingTransaction(swapParams *swap.OpeningParams, claimParams *swap.ClaimParams, takerSigner swap.Signer) (txId, txHex string, error error)
func (*Client) CreateCsvSpendingTransaction ¶
func (l *Client) CreateCsvSpendingTransaction(swapParams *swap.OpeningParams, claimParams *swap.ClaimParams) (string, string, error)
func (*Client) CreateOpeningTransaction ¶
func (*Client) CreatePreimageSpendingTransaction ¶
func (l *Client) CreatePreimageSpendingTransaction(swapParams *swap.OpeningParams, claimParams *swap.ClaimParams) (string, string, error)
func (*Client) DecodePayreq ¶
func (*Client) GetFlatSwapOutFee ¶
GetFlatSwapOutFee returns an estimated size for the opening transaction. This can be used to calculate the amount of the fee invoice and should cover most but not all cases. For an explanation of the estimation see comments of the onchain.EstimatedOpeningTxSize.
func (*Client) GetNetwork ¶
func (*Client) GetOnchainBalance ¶
func (*Client) GetOutputScript ¶
func (l *Client) GetOutputScript(params *swap.OpeningParams) ([]byte, error)
func (*Client) GetRefundFee ¶
func (*Client) NewAddress ¶
func (*Client) PayInvoiceViaChannel ¶
func (*Client) PrepareOpeningTransaction ¶
func (*Client) RebalancePayment ¶
func (*Client) SendMessage ¶
func (*Client) StartListening ¶
type LndFeeEstimator ¶
type LndFeeEstimator struct {
// contains filtered or unexported fields
}
func NewLndFeeEstimator ¶
func NewLndFeeEstimator(ctx context.Context, walletkit walletrpc.WalletKitClient) *LndFeeEstimator
type MessageListener ¶
func NewMessageListener ¶
func NewMessageListener(ctx context.Context, cc *grpc.ClientConn) (*MessageListener, error)
func (*MessageListener) AddMessageHandler ¶
func (m *MessageListener) AddMessageHandler(f func(peerId string, msgType string, payload []byte) error)
func (*MessageListener) Start ¶
func (m *MessageListener) Start() error
func (*MessageListener) Stop ¶
func (m *MessageListener) Stop()
type PaymentWatcher ¶
func NewPaymentWatcher ¶
func NewPaymentWatcher(ctx context.Context, cc *grpc.ClientConn) (*PaymentWatcher, error)
func (*PaymentWatcher) AddPaymentCallback ¶
func (p *PaymentWatcher) AddPaymentCallback(f func(swapId string, invoiceType swap.InvoiceType))
func (*PaymentWatcher) AddWaitForPayment ¶
func (p *PaymentWatcher) AddWaitForPayment(swapId string, payreq string, invoiceType swap.InvoiceType)
func (*PaymentWatcher) Stop ¶
func (p *PaymentWatcher) Stop() error
type PeerListener ¶
func NewPeerListener ¶
func NewPeerListener(ctx context.Context, cc *grpc.ClientConn) (*PeerListener, error)
func (*PeerListener) AddHandler ¶
func (p *PeerListener) AddHandler(evt lnrpc.PeerEvent_EventType, f func(string)) error
func (*PeerListener) Stop ¶
func (p *PeerListener) Stop()
type TxWatcher ¶
func NewTxWatcher ¶
func (*TxWatcher) AddConfirmationCallback ¶
AddConfirmationCallback adds a callback to the watcher that will be called in the case that an active "wait for confirmation" watcher reached the confirmation limit for a swap.
func (*TxWatcher) AddCsvCallback ¶
AddCsvCallback adds a callback to the watcher that will be called in the case that an active "wait for csv limit reached" watcher reached the csv limit for a swap.
func (*TxWatcher) AddWaitForConfirmationTx ¶
func (t *TxWatcher) AddWaitForConfirmationTx(swapId string, txId string, _ uint32, heightHint uint32, script []byte)
AddWaitForConfirmationTx subscribes to the lnd onchain tx watcher and calls the callback as soon as the tx is confirmed. The empty uint32 parameter is due to the Watcher interface of swap expecting a signature with a vout parameter.
func (*TxWatcher) AddWaitForCsvTx ¶
func (t *TxWatcher) AddWaitForCsvTx(swapId string, txId string, vout uint32, heightHint uint32, script []byte)
AddWaitForConfirmationTx subscribes to the lnd onchain tx watcher and calls the callback as soon as the tx is above the csv limit.
func (*TxWatcher) GetBlockHeight ¶
GetBlockHeight returns the current best block from the GetInfo call. Beware that this hight is the best block from the nodes view.