initial checkin
[rust-lightning] / src / chain / bitcoincorerpcchain.rs
1 use bitcoin::blockdata::transaction::Transaction;
2 use bitcoin::blockdata::script::Script;
3 use bitcoin::util::hash::Sha256dHash;
4
5 use chain::chaininterface::{ChainWatchInterface,ChainWatchInterfaceUtil,ChainListener};
6
7 use std::sync::Weak;
8
9 pub struct BitcoinCoreRPCClientChain {
10         util: ChainWatchInterfaceUtil
11 }
12
13 impl ChainWatchInterface for BitcoinCoreRPCClientChain {
14         fn install_watch_script(&self, spk: Script) {
15                 self.util.install_watch_script(spk)
16         }
17
18         fn install_watch_outpoint(&self, outpoint: (Sha256dHash, u32)) {
19                 self.util.install_watch_outpoint(outpoint)
20         }
21
22         fn watch_all_txn(&self) {
23                 self.util.watch_all_txn()
24         }
25
26         fn broadcast_transaction(&self, _tx: &Transaction) {
27                 unimplemented!()
28         }
29
30         fn register_listener(&self, listener: Weak<ChainListener>) {
31                 self.util.register_listener(listener)
32         }
33 }
34
35 impl BitcoinCoreRPCClientChain {
36         pub fn new() -> BitcoinCoreRPCClientChain {
37                 BitcoinCoreRPCClientChain {
38                         util: ChainWatchInterfaceUtil::new(),
39                 }
40         }
41 }