Commit Graph

25 Commits

Author SHA1 Message Date
Olaoluwa Osuntokun
43c84c2ce5
chainntfs: include height in spending+conf notifications 2016-06-21 13:12:39 -07:00
Olaoluwa Osuntokun
7bff2e07a8
chainntfs: add new RegisterBlockHeightNtfn method
This commit adds a new method to the ChainNotifier interface which
subscribes the caller to a continuous stream of notifications generated
by new blocks added to the tip of the Bitcoin main chain.

Concurrently, this method is intended to be used in order to obtain the
necessary block height information to properly handle the timeout
period on any pending HTLCs. A continuos stream, rather than a one-off
notification is chosen in order to discourage a goroutine-per-HTLC
model which would be rather wasteful.
2016-06-21 13:12:35 -07:00
Olaoluwa Osuntokun
1879c00c55
chainntfs: further specify behavior of RegisterSpendNtfn
This commit updates the documentation for the chainntfs interface to
specify that notifications for spends registered with
`RegisterSpendNtfn` should be triggered *only* once a transaction
spending the target outpoint is *seen* within the network.

This strictness is required in order to allow an ‘honest’ counter-party
to properly sweep funds within channels with short delays.
2016-06-21 13:12:31 -07:00
Olaoluwa Osuntokun
3f0173f19a
chainnfts: export logger for use by concrete implementations 2016-06-21 13:12:27 -07:00
Olaoluwa Osuntokun
fcff17c336
multi: change all imports to roasbeef's forks
This commit will allow the general public to build lnd without jumping
through hoops setting up their local git branches nicely with all of
our forks.
2016-05-15 17:22:37 +03:00
Olaoluwa Osuntokun
f78283a438
chainnfts/btcdnotify: update test to upstream API change.
rpctest.Harness.CoinbaseSpend now takes a list of outputs rather, than
a map from address to output amount.
2016-05-03 20:47:24 -07:00
Olaoluwa Osuntokun
8feb86c4aa multi: create lnd's logging infrastructure 2016-03-22 18:43:10 -07:00
Olaoluwa Osuntokun
9b9f792f10 chainntfns: document the BtcdNotifier implementation of ChainNotifier 2016-02-26 17:38:31 -08:00
Olaoluwa Osuntokun
77d37298f4 chainntfns: close all pending client channels on shutdown for BtcdNotifier 2016-02-26 17:38:31 -08:00
Olaoluwa Osuntokun
3186b3038c chainntfns: document the ChainNotifier interface 2016-02-26 17:38:31 -08:00
Olaoluwa Osuntokun
8ce8c29af6 chainntfns: add basic tests for confirmation+spending notifications
* The tests as written will be general to all future implementations of
ChainNotifier allowing future implementers to easily ensure their
implementation meets the expected behavior.

* The tests will be moved to the outer directory once a registration
mechanism for notifier implementations is in place.
2016-02-26 17:38:31 -08:00
Olaoluwa Osuntokun
19e1b64f2c chainntfs: use an int32 for NegativeConf 2016-02-26 17:38:31 -08:00
Olaoluwa Osuntokun
e92fc5f495 chainntfs: switch BtcdNotifier to directly use btcrpcclient
* Turns out the NotificationServer on btcwallet doesn’t sever full
blocks, nor notify for arbitrary transactions. Instead, we now create a
new client specifically for BtcdNotifier.

* Final implementation is simpler, less dependent on newer btcwallet
features in flux. Additionally, this decouples the chain notifications
from the wallet. Enabling reliance on btcd for notifications, in
conjunction with an independent wallet that satisfies the to-be-drafted
Wallet interface.
2016-02-26 17:38:31 -08:00
Olaoluwa Osuntokun
1c59dfc75c chainntfs: fix the Pop method on confirmationHeap 2016-02-26 17:38:31 -08:00
Olaoluwa Osuntokun
3d478cdd3e chainntfs: use btcwallet's new NotificationServer for BtcdNotifier
* Rather than rely on the legacy notification interface which may be
deprecated in the near future, we’ll now switch to using the
NotificationSever.

* Negative confirmation notifications due to re-orgs are still
unimplemented however.
2016-02-26 17:38:30 -08:00
Olaoluwa Osuntokun
9fb8045bd2 chainntfns: remove source.go it's no longer needed 2016-02-26 17:38:30 -08:00
Olaoluwa Osuntokun
c7402f3462 chainntfns: update BtcdNotifier to adhere to new ChainNotifier interface
* Re-orgs are still unhanded.

* RegisterSpendNtfn should perhaps also register directly with the rpc
client instead of pushing the responsibility to the caller.
2016-02-26 17:38:30 -08:00
Olaoluwa Osuntokun
b913bda472 chainntfs: expand ChainNotifier interface
* The `NotificationTrigger` struct has been dropped. Instead we know
simply employ a non-blocking send over a chan struct. This moves the
responsibility of triggering callbacks a level above to the registering
client.

* Confirmation notifications also now have a counter part in order to
notify a caller of the scenario wherein a funding transaction drops out
of the chain due to a re-org. A “neagtiveConf” value will be sent to
the client over a channel in this case. This will allow a caller to
re-register for another confirmation notification. Note that due to
this scenario, callers should also register for notifications
concerning spends of the counterparty’s inputs to the funding
transaction. If a second spend (other than the funding) is detected,
the channel should be closed immediately.

* Notifications concerning spends now also include the spending
transaction, hash, and the input on the spending transaction at which
the outpoint is spent.
2016-02-26 17:38:30 -08:00
Tadge Dryja
2815afebb7 update imports to github 2016-01-16 10:45:54 -08:00
Olaoluwa Osuntokun
5f705be63b chainntfs: introduce ChainConnection interface to avoid import cycle and for future tests
* Looks rather hack atm. Put in place so progress can be had with
lnwallet before notes is finished.
2016-01-14 23:58:04 -08:00
Olaoluwa Osuntokun
986eb83ceb chainntfs: create new ChainNotifier for bfcd-based notifications
* Currently depends on the wallet, but that will change in the near
future due to new additions to btcwallet currently under review.
* Re-orgs aren’t intelligently handled yet. To be done along with tests
in a later commit.
2016-01-14 23:56:11 -08:00
Olaoluwa Osuntokun
00f2a0d7c0 chainntfs: remove btcd.go
* No longer needed, new package added in next commit.
2016-01-14 23:56:11 -08:00
Olaoluwa Osuntokun
8154b96d67 chainntfs: flesh out initial draft of interface
* So far very simple, only notifications for tx confirmations, and
outpoint spends.
* Our two cases are: waiting for the funding transaction to reach a
depth of N confirmations, and open channels being notified of the
counterpart trying to cheat them by broadcasting an invalidated
commitment tx.
2016-01-14 23:56:11 -08:00
Olaoluwa Osuntokun
e2c4ccbe28 chaintfns: skeleton of first notifier 2015-12-16 22:55:22 -06:00
Olaoluwa Osuntokun
b2522ef75a Create skeleton for chain notifications
* Goal is to backend agnostic source to chain notifications
* Open channels will communicate with this source to register intent
for critical notifications
* Pending notifications will need to be committed to disk.
* Will also need a journal to ensure no notification is missed
* Later goals include extending this to communicate with 3rd party
outsource services
2015-12-16 14:38:21 -06:00