@@ -22,7 +22,6 @@ use std::collections::HashMap;
2222
2323use bitcoin:: Block ;
2424use bitcoin:: { OutPoint , Script , Transaction , TxOut } ;
25- use bitcoin_hashes:: sha256d;
2625use rand:: thread_rng;
2726
2827use account:: { KeyDerivation , MasterAccount } ;
@@ -44,7 +43,7 @@ pub struct Coins {
4443 /// confirmed coins (these have SPV proofs)
4544 confirmed : HashMap < OutPoint , Coin > ,
4645 /// SPV proofs of transactions confirming coins
47- proofs : HashMap < sha256d :: Hash , ProvedTransaction > ,
46+ proofs : HashMap < bitcoin :: Txid , ProvedTransaction > ,
4847}
4948
5049impl Coins {
@@ -130,13 +129,13 @@ impl Coins {
130129 & self . unconfirmed
131130 }
132131
133- pub fn proofs ( & self ) -> & HashMap < sha256d :: Hash , ProvedTransaction > {
132+ pub fn proofs ( & self ) -> & HashMap < bitcoin :: Txid , ProvedTransaction > {
134133 & self . proofs
135134 }
136135
137136 pub fn available_balance < H > ( & self , height : u32 , block_height : H ) -> u64
138137 where
139- H : Fn ( & sha256d :: Hash ) -> Option < u32 > ,
138+ H : Fn ( & bitcoin :: BlockHash ) -> Option < u32 > ,
140139 {
141140 self . available_coins ( height, block_height)
142141 . iter ( )
@@ -146,7 +145,7 @@ impl Coins {
146145
147146 pub fn available_coins < H > ( & self , height : u32 , block_height : H ) -> Vec < ( OutPoint , Coin , u32 ) >
148147 where
149- H : Fn ( & sha256d :: Hash ) -> Option < u32 > ,
148+ H : Fn ( & bitcoin :: BlockHash ) -> Option < u32 > ,
150149 {
151150 self . confirmed
152151 . iter ( )
@@ -182,7 +181,7 @@ impl Coins {
182181 }
183182
184183 /// unwind the tip of the trunk
185- pub fn unwind_tip ( & mut self , block_hash : & sha256d :: Hash ) {
184+ pub fn unwind_tip ( & mut self , block_hash : & bitcoin :: BlockHash ) {
186185 // this means we might have lost control of coins at least temporarily
187186 let lost_coins = self
188187 . proofs
@@ -280,7 +279,7 @@ impl Coins {
280279 block_height : H ,
281280 ) -> Vec < ( OutPoint , Coin , u32 ) >
282281 where
283- H : Fn ( & sha256d :: Hash ) -> Option < u32 > ,
282+ H : Fn ( & bitcoin :: BlockHash ) -> Option < u32 > ,
284283 {
285284 use rand:: prelude:: SliceRandom ;
286285 // TODO: knapsack
@@ -326,17 +325,16 @@ mod test {
326325 use bitcoin:: blockdata:: script:: Builder ;
327326 use bitcoin:: util:: bip32:: ExtendedPubKey ;
328327 use bitcoin:: {
329- network:: constants:: Network , util :: hash :: MerkleRoot , Address , BitcoinHash , Block ,
330- BlockHeader , OutPoint , Transaction , TxIn , TxOut ,
328+ network:: constants:: Network , Address , BitcoinHash , Block , BlockHeader , OutPoint ,
329+ Transaction , TxIn , TxOut ,
331330 } ;
332- use bitcoin_hashes:: sha256d;
333331
334332 use account:: { Account , AccountAddressType , MasterAccount , Unlocker } ;
335333 use coins:: Coins ;
336334
337335 const NEW_COINS : u64 = 5000000000 ;
338336
339- fn new_block ( prev : & sha256d :: Hash ) -> Block {
337+ fn new_block ( prev : & bitcoin :: BlockHash ) -> Block {
340338 Block {
341339 header : BlockHeader {
342340 version : 1 ,
@@ -347,7 +345,7 @@ mod test {
347345 nonce : 0 ,
348346 bits : 0x1d00ffff ,
349347 prev_blockhash : prev. clone ( ) ,
350- merkle_root : sha256d :: Hash :: default ( ) ,
348+ merkle_root : bitcoin :: TxMerkleNode :: default ( ) ,
351349 } ,
352350 txdata : Vec :: new ( ) ,
353351 }
@@ -361,7 +359,7 @@ mod test {
361359 sequence: 0xffffffff ,
362360 witness: Vec :: new( ) ,
363361 previous_output: OutPoint {
364- txid: sha256d :: Hash :: default ( ) ,
362+ txid: bitcoin :: Txid :: default ( ) ,
365363 vout: 0 ,
366364 } ,
367365 script_sig: Builder :: new( ) . push_int( height as i64 ) . into_script( ) ,
@@ -390,7 +388,7 @@ mod test {
390388 master
391389 }
392390
393- fn mine ( tip : & sha256d :: Hash , height : u32 , miner : Address ) -> Block {
391+ fn mine ( tip : & bitcoin :: BlockHash , height : u32 , miner : Address ) -> Block {
394392 let mut block = new_block ( tip) ;
395393 add_tx ( & mut block, coin_base ( miner, height) ) ;
396394 block
0 commit comments