diff --git a/chainntfs/chainntfs.go b/chainntfs/chainntfs.go index bc06445a..a7489f75 100644 --- a/chainntfs/chainntfs.go +++ b/chainntfs/chainntfs.go @@ -2,6 +2,7 @@ package chainntnfs import "github.com/btcsuite/btcd/wire" +// ChainNotifier ... // TODO(roasbeef): finish // * multiple backends for interface // * btcd - websockets @@ -12,14 +13,39 @@ import "github.com/btcsuite/btcd/wire" // * SPV bloomfilter // * other stuff maybe... type ChainNotifier interface { - RegisterConfirmationsNotification(txid *wire.ShaHash, numConfs uint32, trigger *NotificationTrigger) error - RegisterSpendNotification(outpoint *wire.OutPoint, trigger *NotificationTrigger) error + RegisterConfirmationsNtfn(txid *wire.ShaHash, numConfs uint32) (*ConfirmationEvent, error) + RegisterSpendNtfn(outpoint *wire.OutPoint) (*SpendEvent, error) Start() error Stop() error } -type NotificationTrigger struct { - TriggerChan chan struct{} - Callback func() +// TODO(roasbeef): ln channels should request spend ntfns for counterparty's +// inputs to funding tx also, consider channel closed if funding tx re-org'd +// out and inputs double spent. + +// ConfirmationEvent ... +type ConfirmationEvent struct { + Confirmed chan struct{} // MUST be buffered. + + // TODO(roasbeef): all goroutines on ln channel updates should also + // have a struct chan that's closed if funding gets re-org out. Need + // to sync, to request another confirmation event ntfn, then re-open + // channel after confs. + + NegativeConf chan uint32 // MUST be buffered. +} + +// SpendDetail ... +type SpendDetail struct { + SpentOutPoint *wire.OutPoint + + SpendingTx *wire.MsgTx + SpenderTxHash *wire.ShaHash + SpenderInputIndex uint32 +} + +// SpendEvent ... +type SpendEvent struct { + Spend chan *SpendDetail // MUST be buffered. }