File tree Expand file tree Collapse file tree 5 files changed +30
-1
lines changed
bitcoin/src/blockdata/script Expand file tree Collapse file tree 5 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -8209,6 +8209,7 @@ pub fn bitcoin::blockdata::script::Script::is_p2wpkh(&self) -> bool
8209
8209
pub fn bitcoin::blockdata::script::Script::is_p2wsh(&self) -> bool
8210
8210
pub fn bitcoin::blockdata::script::Script::is_provably_unspendable(&self) -> bool
8211
8211
pub fn bitcoin::blockdata::script::Script::is_push_only(&self) -> bool
8212
+ pub fn bitcoin::blockdata::script::Script::is_standard_op_return(&self) -> bool
8212
8213
pub fn bitcoin::blockdata::script::Script::is_witness_program(&self) -> bool
8213
8214
pub fn bitcoin::blockdata::script::Script::len(&self) -> usize
8214
8215
pub fn bitcoin::blockdata::script::Script::minimal_non_dust(&self) -> bitcoin_units::amount::Amount
Original file line number Diff line number Diff line change @@ -7831,6 +7831,7 @@ pub fn bitcoin::blockdata::script::Script::is_p2wpkh(&self) -> bool
7831
7831
pub fn bitcoin::blockdata::script::Script::is_p2wsh(&self) -> bool
7832
7832
pub fn bitcoin::blockdata::script::Script::is_provably_unspendable(&self) -> bool
7833
7833
pub fn bitcoin::blockdata::script::Script::is_push_only(&self) -> bool
7834
+ pub fn bitcoin::blockdata::script::Script::is_standard_op_return(&self) -> bool
7834
7835
pub fn bitcoin::blockdata::script::Script::is_witness_program(&self) -> bool
7835
7836
pub fn bitcoin::blockdata::script::Script::len(&self) -> usize
7836
7837
pub fn bitcoin::blockdata::script::Script::minimal_non_dust(&self) -> bitcoin_units::amount::Amount
Original file line number Diff line number Diff line change @@ -7182,6 +7182,7 @@ pub fn bitcoin::blockdata::script::Script::is_p2wpkh(&self) -> bool
7182
7182
pub fn bitcoin::blockdata::script::Script::is_p2wsh(&self) -> bool
7183
7183
pub fn bitcoin::blockdata::script::Script::is_provably_unspendable(&self) -> bool
7184
7184
pub fn bitcoin::blockdata::script::Script::is_push_only(&self) -> bool
7185
+ pub fn bitcoin::blockdata::script::Script::is_standard_op_return(&self) -> bool
7185
7186
pub fn bitcoin::blockdata::script::Script::is_witness_program(&self) -> bool
7186
7187
pub fn bitcoin::blockdata::script::Script::len(&self) -> usize
7187
7188
pub fn bitcoin::blockdata::script::Script::minimal_non_dust(&self) -> bitcoin_units::amount::Amount
Original file line number Diff line number Diff line change @@ -349,7 +349,10 @@ impl Script {
349
349
&& self . 0 [ 1 ] == OP_PUSHBYTES_32 . to_u8 ( )
350
350
}
351
351
352
- /// Check if this is an OP_RETURN output.
352
+ /// Check if this is a consensus-valid OP_RETURN output.
353
+ ///
354
+ /// To validate if the OP_RETURN obeys Bitcoin Core's current standardness policy, use
355
+ /// [`is_standard_op_return()`](Self::is_standard_op_return) instead.
353
356
#[ inline]
354
357
pub fn is_op_return ( & self ) -> bool {
355
358
match self . 0 . first ( ) {
@@ -358,6 +361,15 @@ impl Script {
358
361
}
359
362
}
360
363
364
+ /// Check if this is an OP_RETURN that obeys Bitcoin Core standardness policy.
365
+ ///
366
+ /// What this function considers to be standard may change without warning pending Bitcoin Core
367
+ /// changes.
368
+ #[ inline]
369
+ pub fn is_standard_op_return ( & self ) -> bool {
370
+ self . is_op_return ( ) && self . 0 . len ( ) <= 80
371
+ }
372
+
361
373
/// Checks whether a script is trivially known to have no satisfying input.
362
374
///
363
375
/// This method has potentially confusing semantics and an unclear purpose, so it's going to be
Original file line number Diff line number Diff line change @@ -406,6 +406,20 @@ fn op_return_test() {
406
406
assert ! ( !ScriptBuf :: from_hex( "" ) . unwrap( ) . is_op_return( ) ) ;
407
407
}
408
408
409
+ #[ test]
410
+ fn standard_op_return_test ( ) {
411
+ assert ! ( ScriptBuf :: from_hex( "6aa9149eb21980dc9d413d8eac27314938b9da920ee53e87" )
412
+ . unwrap( )
413
+ . is_standard_op_return( ) ) ;
414
+ assert ! ( ScriptBuf :: from_hex( "6a48656c6c6f2c2074686973206973206d7920666972737420636f6e747269627574696f6e20746f207275737420626974636f696e2e20506c6561736520617070726f7665206d79205052206672656e" )
415
+ . unwrap( )
416
+ . is_standard_op_return( ) ) ;
417
+
418
+ assert ! ( !ScriptBuf :: from_hex( "6a48656c6c6f2c2074686973206973206d7920666972737420636f6e747269627574696f6e20746f207275737420626974636f696e2e20506c6561736520617070726f7665206d79205052206672656e21" )
419
+ . unwrap( )
420
+ . is_standard_op_return( ) ) ;
421
+ }
422
+
409
423
#[ test]
410
424
fn multisig ( ) {
411
425
// First multisig? 1-of-2
You can’t perform that action at this time.
0 commit comments