@@ -484,33 +484,33 @@ impl Script {
484
484
#[ inline]
485
485
pub fn is_p2sh ( & self ) -> bool {
486
486
self . 0 . len ( ) == 23
487
- && self . 0 [ 0 ] == opcodes:: all:: OP_HASH160 . into_u8 ( )
488
- && self . 0 [ 1 ] == opcodes:: all:: OP_PUSHBYTES_20 . into_u8 ( )
489
- && self . 0 [ 22 ] == opcodes:: all:: OP_EQUAL . into_u8 ( )
487
+ && self . 0 [ 0 ] == opcodes:: all:: OP_HASH160 . to_u8 ( )
488
+ && self . 0 [ 1 ] == opcodes:: all:: OP_PUSHBYTES_20 . to_u8 ( )
489
+ && self . 0 [ 22 ] == opcodes:: all:: OP_EQUAL . to_u8 ( )
490
490
}
491
491
492
492
/// Checks whether a script pubkey is a P2PKH output.
493
493
#[ inline]
494
494
pub fn is_p2pkh ( & self ) -> bool {
495
495
self . 0 . len ( ) == 25
496
- && self . 0 [ 0 ] == opcodes:: all:: OP_DUP . into_u8 ( )
497
- && self . 0 [ 1 ] == opcodes:: all:: OP_HASH160 . into_u8 ( )
498
- && self . 0 [ 2 ] == opcodes:: all:: OP_PUSHBYTES_20 . into_u8 ( )
499
- && self . 0 [ 23 ] == opcodes:: all:: OP_EQUALVERIFY . into_u8 ( )
500
- && self . 0 [ 24 ] == opcodes:: all:: OP_CHECKSIG . into_u8 ( )
496
+ && self . 0 [ 0 ] == opcodes:: all:: OP_DUP . to_u8 ( )
497
+ && self . 0 [ 1 ] == opcodes:: all:: OP_HASH160 . to_u8 ( )
498
+ && self . 0 [ 2 ] == opcodes:: all:: OP_PUSHBYTES_20 . to_u8 ( )
499
+ && self . 0 [ 23 ] == opcodes:: all:: OP_EQUALVERIFY . to_u8 ( )
500
+ && self . 0 [ 24 ] == opcodes:: all:: OP_CHECKSIG . to_u8 ( )
501
501
}
502
502
503
503
/// Checks whether a script pubkey is a P2PK output.
504
504
#[ inline]
505
505
pub fn is_p2pk ( & self ) -> bool {
506
506
match self . len ( ) {
507
507
67 => {
508
- self . 0 [ 0 ] == opcodes:: all:: OP_PUSHBYTES_65 . into_u8 ( )
509
- && self . 0 [ 66 ] == opcodes:: all:: OP_CHECKSIG . into_u8 ( )
508
+ self . 0 [ 0 ] == opcodes:: all:: OP_PUSHBYTES_65 . to_u8 ( )
509
+ && self . 0 [ 66 ] == opcodes:: all:: OP_CHECKSIG . to_u8 ( )
510
510
}
511
511
35 => {
512
- self . 0 [ 0 ] == opcodes:: all:: OP_PUSHBYTES_33 . into_u8 ( )
513
- && self . 0 [ 34 ] == opcodes:: all:: OP_CHECKSIG . into_u8 ( )
512
+ self . 0 [ 0 ] == opcodes:: all:: OP_PUSHBYTES_33 . to_u8 ( )
513
+ && self . 0 [ 34 ] == opcodes:: all:: OP_CHECKSIG . to_u8 ( )
514
514
}
515
515
_ => false
516
516
}
@@ -530,8 +530,8 @@ impl Script {
530
530
let ver_opcode = opcodes:: All :: from ( self . 0 [ 0 ] ) ; // Version 0 or PUSHNUM_1-PUSHNUM_16
531
531
let push_opbyte = self . 0 [ 1 ] ; // Second byte push opcode 2-40 bytes
532
532
WitnessVersion :: from_opcode ( ver_opcode) . is_ok ( )
533
- && push_opbyte >= opcodes:: all:: OP_PUSHBYTES_2 . into_u8 ( )
534
- && push_opbyte <= opcodes:: all:: OP_PUSHBYTES_40 . into_u8 ( )
533
+ && push_opbyte >= opcodes:: all:: OP_PUSHBYTES_2 . to_u8 ( )
534
+ && push_opbyte <= opcodes:: all:: OP_PUSHBYTES_40 . to_u8 ( )
535
535
// Check that the rest of the script has the correct size
536
536
&& script_len - 2 == push_opbyte as usize
537
537
}
@@ -541,29 +541,29 @@ impl Script {
541
541
pub fn is_v0_p2wsh ( & self ) -> bool {
542
542
self . 0 . len ( ) == 34
543
543
&& self . witness_version ( ) == Some ( WitnessVersion :: V0 )
544
- && self . 0 [ 1 ] == opcodes:: all:: OP_PUSHBYTES_32 . into_u8 ( )
544
+ && self . 0 [ 1 ] == opcodes:: all:: OP_PUSHBYTES_32 . to_u8 ( )
545
545
}
546
546
547
547
/// Checks whether a script pubkey is a P2WPKH output.
548
548
#[ inline]
549
549
pub fn is_v0_p2wpkh ( & self ) -> bool {
550
550
self . 0 . len ( ) == 22
551
551
&& self . witness_version ( ) == Some ( WitnessVersion :: V0 )
552
- && self . 0 [ 1 ] == opcodes:: all:: OP_PUSHBYTES_20 . into_u8 ( )
552
+ && self . 0 [ 1 ] == opcodes:: all:: OP_PUSHBYTES_20 . to_u8 ( )
553
553
}
554
554
555
555
/// Checks whether a script pubkey is a P2TR output.
556
556
#[ inline]
557
557
pub fn is_v1_p2tr ( & self ) -> bool {
558
558
self . 0 . len ( ) == 34
559
559
&& self . witness_version ( ) == Some ( WitnessVersion :: V1 )
560
- && self . 0 [ 1 ] == opcodes:: all:: OP_PUSHBYTES_32 . into_u8 ( )
560
+ && self . 0 [ 1 ] == opcodes:: all:: OP_PUSHBYTES_32 . to_u8 ( )
561
561
}
562
562
563
563
/// Check if this is an OP_RETURN output.
564
564
pub fn is_op_return ( & self ) -> bool {
565
565
match self . 0 . first ( ) {
566
- Some ( b) => * b == opcodes:: all:: OP_RETURN . into_u8 ( ) ,
566
+ Some ( b) => * b == opcodes:: all:: OP_RETURN . to_u8 ( ) ,
567
567
None => false
568
568
}
569
569
}
@@ -878,7 +878,7 @@ impl Builder {
878
878
// We can special-case -1, 1-16
879
879
if data == -1 || ( data >= 1 && data <= 16 ) {
880
880
let opcode = opcodes:: All :: from (
881
- ( data - 1 + opcodes:: OP_TRUE . into_u8 ( ) as i64 ) as u8
881
+ ( data - 1 + opcodes:: OP_TRUE . to_u8 ( ) as i64 ) as u8
882
882
) ;
883
883
self . push_opcode ( opcode)
884
884
}
@@ -902,16 +902,16 @@ impl Builder {
902
902
match data. len ( ) as u64 {
903
903
n if n < opcodes:: Ordinary :: OP_PUSHDATA1 as u64 => { self . 0 . push ( n as u8 ) ; } ,
904
904
n if n < 0x100 => {
905
- self . 0 . push ( opcodes:: Ordinary :: OP_PUSHDATA1 . into_u8 ( ) ) ;
905
+ self . 0 . push ( opcodes:: Ordinary :: OP_PUSHDATA1 . to_u8 ( ) ) ;
906
906
self . 0 . push ( n as u8 ) ;
907
907
} ,
908
908
n if n < 0x10000 => {
909
- self . 0 . push ( opcodes:: Ordinary :: OP_PUSHDATA2 . into_u8 ( ) ) ;
909
+ self . 0 . push ( opcodes:: Ordinary :: OP_PUSHDATA2 . to_u8 ( ) ) ;
910
910
self . 0 . push ( ( n % 0x100 ) as u8 ) ;
911
911
self . 0 . push ( ( n / 0x100 ) as u8 ) ;
912
912
} ,
913
913
n if n < 0x100000000 => {
914
- self . 0 . push ( opcodes:: Ordinary :: OP_PUSHDATA4 . into_u8 ( ) ) ;
914
+ self . 0 . push ( opcodes:: Ordinary :: OP_PUSHDATA4 . to_u8 ( ) ) ;
915
915
self . 0 . push ( ( n % 0x100 ) as u8 ) ;
916
916
self . 0 . push ( ( ( n / 0x100 ) % 0x100 ) as u8 ) ;
917
917
self . 0 . push ( ( ( n / 0x10000 ) % 0x100 ) as u8 ) ;
@@ -941,7 +941,7 @@ impl Builder {
941
941
942
942
/// Adds a single opcode to the script.
943
943
pub fn push_opcode ( mut self , data : opcodes:: All ) -> Builder {
944
- self . 0 . push ( data. into_u8 ( ) ) ;
944
+ self . 0 . push ( data. to_u8 ( ) ) ;
945
945
self . 1 = Some ( data) ;
946
946
self
947
947
}
0 commit comments