File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -160,6 +160,13 @@ pub fn get_test_single_sig_cltv() -> &'static str {
160
160
"wsh(and_v(v:pk(cVpPVruEDdmutPzisEsYvtST1usBR3ntr8pXSyt6D2YYqXRyPcFW),after(100000)))"
161
161
}
162
162
163
+ /// `wsh` descriptor with policy `and(pk(A),after(1_734_230_218))`
164
+ // the parameter passed to miniscript fragment `after` has to equal or greater than 500_000_000
165
+ // in order to use a lock based on unix time
166
+ pub fn get_test_single_sig_cltv_timestamp ( ) -> & ' static str {
167
+ "wsh(and_v(v:pk(cVpPVruEDdmutPzisEsYvtST1usBR3ntr8pXSyt6D2YYqXRyPcFW),after(1734230218)))"
168
+ }
169
+
163
170
/// taproot single key descriptor
164
171
pub fn get_test_tr_single_sig ( ) -> & ' static str {
165
172
"tr(cNJmN3fH9DDbDt131fQNkVakkpzawJBSeybCUNmP1BovpmGQ45xG)"
Original file line number Diff line number Diff line change @@ -609,6 +609,21 @@ fn test_create_tx_default_locktime_cltv() {
609
609
assert_eq ! ( psbt. unsigned_tx. lock_time. to_consensus_u32( ) , 100_000 ) ;
610
610
}
611
611
612
+ #[ test]
613
+ fn test_create_tx_locktime_cltv_timestamp ( ) {
614
+ let ( mut wallet, _) = get_funded_wallet_single ( get_test_single_sig_cltv_timestamp ( ) ) ;
615
+ let addr = wallet. next_unused_address ( KeychainKind :: External ) ;
616
+ let mut builder = wallet. build_tx ( ) ;
617
+ builder. add_recipient ( addr. script_pubkey ( ) , Amount :: from_sat ( 25_000 ) ) ;
618
+ let mut psbt = builder. finish ( ) . unwrap ( ) ;
619
+
620
+ assert_eq ! ( psbt. unsigned_tx. lock_time. to_consensus_u32( ) , 1_734_230_218 ) ;
621
+
622
+ let finalized = wallet. sign ( & mut psbt, SignOptions :: default ( ) ) . unwrap ( ) ;
623
+
624
+ assert ! ( finalized) ;
625
+ }
626
+
612
627
#[ test]
613
628
fn test_create_tx_custom_locktime ( ) {
614
629
let ( mut wallet, _) = get_funded_wallet_wpkh ( ) ;
You can’t perform that action at this time.
0 commit comments