lnwallet: extend the WalletController with a new txn pub/sub client
This commit adds a new simple interface related to the WalletController which allows for subscribing to new notifications as transactions relevant to the wallet are seen on at the network and/or mined. The TransactionSubscription interface will prove useful for building higher level UI’s on-top of the daemon which update the presentation layer in response to received notifications.
This commit is contained in:
parent
617716ce9a
commit
2eb1936cce
@ -72,6 +72,24 @@ type TransactionDetail struct {
|
|||||||
// TotalFees is the total fee in satoshis paid by this transaction.
|
// TotalFees is the total fee in satoshis paid by this transaction.
|
||||||
TotalFees int64
|
TotalFees int64
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TransactionSubscription is an interface which describes an object capable of
|
||||||
|
// receiving notifications of new transaction related to the underlying wallet.
|
||||||
|
// TODO(roasbeef): add balance updates?
|
||||||
|
type TransactionSubscription interface {
|
||||||
|
// ConfirmedTransactions returns a channel which will be sent on as new
|
||||||
|
// relevant transactions are confirmed.
|
||||||
|
ConfirmedTransactions() chan *TransactionDetail
|
||||||
|
|
||||||
|
// UnconfirmedTransactions returns a channel which will be sent on as
|
||||||
|
// new relevant transactions are seen within the network.
|
||||||
|
UnconfirmedTransactions() chan *TransactionDetail
|
||||||
|
|
||||||
|
// Cancel finalizes the subscription, cleaning up any resources
|
||||||
|
// allocated.
|
||||||
|
Cancel()
|
||||||
|
}
|
||||||
|
|
||||||
// WalletController defines an abstract interface for controlling a local Pure
|
// WalletController defines an abstract interface for controlling a local Pure
|
||||||
// Go wallet, a local or remote wallet via an RPC mechanism, or possibly even
|
// Go wallet, a local or remote wallet via an RPC mechanism, or possibly even
|
||||||
// a daemon assisted hardware wallet. This interface serves the purpose of
|
// a daemon assisted hardware wallet. This interface serves the purpose of
|
||||||
@ -151,6 +169,17 @@ type WalletController interface {
|
|||||||
// then finally broadcasts the passed transaction to the Bitcoin network.
|
// then finally broadcasts the passed transaction to the Bitcoin network.
|
||||||
PublishTransaction(tx *wire.MsgTx) error
|
PublishTransaction(tx *wire.MsgTx) error
|
||||||
|
|
||||||
|
// SubscribeTransactions returns a TransactionSubscription client which
|
||||||
|
// is capable of receiving async notifications as new transactions
|
||||||
|
// related to the wallet are seen within the network, or found in
|
||||||
|
// blocks.
|
||||||
|
//
|
||||||
|
// NOTE: a non-nil error shuold be returned if notifications aren't
|
||||||
|
// supported.
|
||||||
|
//
|
||||||
|
// TODO(roasbeef): make distinct interface?
|
||||||
|
SubscribeTransactions() (TransactionSubscription, error)
|
||||||
|
|
||||||
// Start initializes the wallet, making any neccessary connections,
|
// Start initializes the wallet, making any neccessary connections,
|
||||||
// starting up required goroutines etc.
|
// starting up required goroutines etc.
|
||||||
Start() error
|
Start() error
|
||||||
|
Loading…
Reference in New Issue
Block a user