[wallet] Add assume_height_reached in PSBTSatisfier
				
					
				
			This commit is contained in:
		
							parent
							
								
									3895b30083
								
							
						
					
					
						commit
						04d04fd0b2
					
				| @ -21,6 +21,7 @@ pub mod utils; | |||||||
| 
 | 
 | ||||||
| pub struct PSBTSatisfier<'a> { | pub struct PSBTSatisfier<'a> { | ||||||
|     input: &'a psbt::Input, |     input: &'a psbt::Input, | ||||||
|  |     assume_height_reached: bool, | ||||||
|     create_height: Option<u32>, |     create_height: Option<u32>, | ||||||
|     current_height: Option<u32>, |     current_height: Option<u32>, | ||||||
| } | } | ||||||
| @ -28,11 +29,13 @@ pub struct PSBTSatisfier<'a> { | |||||||
| impl<'a> PSBTSatisfier<'a> { | impl<'a> PSBTSatisfier<'a> { | ||||||
|     pub fn new( |     pub fn new( | ||||||
|         input: &'a psbt::Input, |         input: &'a psbt::Input, | ||||||
|  |         assume_height_reached: bool, | ||||||
|         create_height: Option<u32>, |         create_height: Option<u32>, | ||||||
|         current_height: Option<u32>, |         current_height: Option<u32>, | ||||||
|     ) -> Self { |     ) -> Self { | ||||||
|         PSBTSatisfier { |         PSBTSatisfier { | ||||||
|             input, |             input, | ||||||
|  |             assume_height_reached, | ||||||
|             create_height, |             create_height, | ||||||
|             current_height, |             current_height, | ||||||
|         } |         } | ||||||
| @ -95,15 +98,23 @@ impl<'a> Satisfier<bitcoin::PublicKey> for PSBTSatisfier<'a> { | |||||||
|         // TODO: also check if `nSequence` right
 |         // TODO: also check if `nSequence` right
 | ||||||
|         debug!("check_older: {}", height); |         debug!("check_older: {}", height); | ||||||
| 
 | 
 | ||||||
|  |         if let Some(current_height) = self.current_height { | ||||||
|             // TODO: test >= / >
 |             // TODO: test >= / >
 | ||||||
|         self.current_height.unwrap_or(0) >= self.create_height.unwrap_or(0) + height |             current_height >= self.create_height.unwrap_or(0) + height | ||||||
|  |         } else { | ||||||
|  |             self.assume_height_reached | ||||||
|  |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     fn check_after(&self, height: u32) -> bool { |     fn check_after(&self, height: u32) -> bool { | ||||||
|         // TODO: also check if `nLockTime` is right
 |         // TODO: also check if `nLockTime` is right
 | ||||||
|         debug!("check_after: {}", height); |         debug!("check_after: {}", height); | ||||||
| 
 | 
 | ||||||
|         self.current_height.unwrap_or(0) > height |         if let Some(current_height) = self.current_height { | ||||||
|  |             current_height > height | ||||||
|  |         } else { | ||||||
|  |             self.assume_height_reached | ||||||
|  |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -656,7 +656,7 @@ where | |||||||
|             }; |             }; | ||||||
| 
 | 
 | ||||||
|             // TODO: use height once we sync headers
 |             // TODO: use height once we sync headers
 | ||||||
|             let satisfier = PSBTSatisfier::new(&psbt.inputs[n], None, None); |             let satisfier = PSBTSatisfier::new(&psbt.inputs[n], true, None, None); | ||||||
| 
 | 
 | ||||||
|             match desc.satisfy(input, satisfier) { |             match desc.satisfy(input, satisfier) { | ||||||
|                 Ok(_) => continue, |                 Ok(_) => continue, | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user