Documentation ¶
Index ¶
- Variables
- type IdxSig
- type WatchTower
- func (w *WatchTower) BlockHandler(cointype uint32, bchan chan *wire.MsgBlock)
- func (w *WatchTower) BuildJusticeTx(cointype uint32, badTx *wire.MsgTx) (*wire.MsgTx, error)
- func (w *WatchTower) DeleteChannel(m lnutil.WatchDelMsg) error
- func (w *WatchTower) HookLink(dbPath string, param *coinparam.Params, hook uspv.ChainHook) error
- func (w *WatchTower) MatchTxids(cointype uint32, txids []chainhash.Hash) ([]chainhash.Hash, error)
- func (w *WatchTower) NewChannel(m lnutil.WatchDescMsg) error
- func (w *WatchTower) OpenDB(filepath string) error
- func (w *WatchTower) UpdateChannel(m lnutil.WatchStateMsg) error
- type Watcher
Constants ¶
This section is empty.
Variables ¶
var ( BUCKETPKHMap = []byte("pkm") // bucket for idx:pkh mapping BUCKETChandata = []byte("cda") // bucket for channel data (elks, points) BUCKETTxid = []byte("txi") // big bucket with every txid KEYStatic = []byte("sta") // static per channel data as value KEYElkRcv = []byte("elk") // elkrem receiver KEYIdx = []byte("idx") // index mapping )
Functions ¶
This section is empty.
Types ¶
type IdxSig ¶
IdxSig is what we save in the DB for each txid
func BuildIdxSig ¶
don't use this? inline is OK...
func IdxSigFromBytes ¶
type WatchTower ¶
type WatchTower struct { Path string // where the DB goes? needed? WatchDB *bolt.DB // single DB with everything in it Accepting bool // true if new channels and sigs are allowed in Watching bool // true if there are txids to watch for SyncHeight int32 // last block we've sync'd to. Not needed? // map of cointypes to chainhooks Hooks map[uint32]uspv.ChainHook }
The main watchtower struct
func (*WatchTower) BlockHandler ¶
func (w *WatchTower) BlockHandler( cointype uint32, bchan chan *wire.MsgBlock)
func (*WatchTower) BuildJusticeTx ¶
BuildJusticeTx takes the badTx and IdxSig found by IngestTx, and returns a Justice transaction moving funds with great vengeance & furious anger. Re-opens the DB which just was closed by IngestTx, but since this almost never happens, we need to end IngestTx as quickly as possible. Note that you should flag the channel for deletion after the JusticeTx is broadcast.
func (*WatchTower) DeleteChannel ¶
func (w *WatchTower) DeleteChannel(m lnutil.WatchDelMsg) error
TODO implement DeleteChannel. Would be nice to delete old channels.
func (*WatchTower) HookLink ¶
Hooklink is the connection between the watchtower and the blockchain Takes in a channel of blocks, and the cointype. Immediately returns a channel which it will send justice transactions to.
func (*WatchTower) MatchTxids ¶
MatchTxid takes in a txid, checks against the DB, and if there's a hit, returns a IdxSig with which to make a JusticeTx. Hits should be rare.
func (*WatchTower) NewChannel ¶
func (w *WatchTower) NewChannel(m lnutil.WatchDescMsg) error
AddNewChannel puts a new channel into the watchtower db. Probably need some way to prevent overwrites.
func (*WatchTower) OpenDB ¶
func (w *WatchTower) OpenDB(filepath string) error
Opens the DB file for the LnNode
func (*WatchTower) UpdateChannel ¶
func (w *WatchTower) UpdateChannel(m lnutil.WatchStateMsg) error
AddMsg adds a new message describing a penalty tx to the db. optimization would be to add a bunch of messages at once. Not a huge speedup though.
type Watcher ¶
type Watcher interface { // Links to the blockchain. // Uses the same chainhook interface as the wallit does. But only uses // 2 of the functions: PushTx() and RawBlocks() // Blocks come in from the chainhook, and justice transactions come out. // The uint32 is the cointype, the string is the folder to put all db files. HookLink(string, *coinparam.Params, uspv.ChainHook) error // New Channel to watch NewChannel(lnutil.WatchDescMsg) error // Update a channel being watched UpdateChannel(lnutil.WatchStateMsg) error // Delete a channel being watched DeleteChannel(lnutil.WatchDelMsg) error }