File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
stackslib/src/chainstate/stacks
testnet/stacks-node/src/tests Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ use crate::chainstate::stacks::{TransactionPayloadID, *};
34
34
use crate :: codec:: Error as CodecError ;
35
35
use crate :: core:: * ;
36
36
use crate :: net:: Error as net_error;
37
+ use crate :: util_lib:: boot:: boot_code_addr;
37
38
38
39
impl StacksMessageCodec for TransactionContractCall {
39
40
fn consensus_serialize < W : Write > ( & self , fd : & mut W ) -> Result < ( ) , codec_error > {
@@ -1031,6 +1032,16 @@ impl StacksTransaction {
1031
1032
_ => false ,
1032
1033
}
1033
1034
}
1035
+
1036
+ /// Is this a phantom transaction?
1037
+ pub fn is_phantom ( & self ) -> bool {
1038
+ let boot_address = boot_code_addr ( self . is_mainnet ( ) ) . into ( ) ;
1039
+ if let TransactionPayload :: TokenTransfer ( address, amount, _) = & self . payload {
1040
+ * address == boot_address && * amount == 0
1041
+ } else {
1042
+ false
1043
+ }
1044
+ }
1034
1045
}
1035
1046
1036
1047
impl StacksTransactionSigner {
Original file line number Diff line number Diff line change @@ -578,7 +578,7 @@ pub mod test_observer {
578
578
PROPOSAL_RESPONSES . lock ( ) . unwrap ( ) . clear ( ) ;
579
579
}
580
580
581
- /// Parse the StacksTransactions from a block (does not include burn ops)
581
+ /// Parse the StacksTransactions from a block (does not include burn ops or phantom txs )
582
582
/// panics on any failures to parse
583
583
pub fn parse_transactions ( block : & serde_json:: Value ) -> Vec < StacksTransaction > {
584
584
block
@@ -588,15 +588,20 @@ pub mod test_observer {
588
588
. unwrap ( )
589
589
. iter ( )
590
590
. filter_map ( |tx_json| {
591
+ // Filter out burn ops
591
592
if let Some ( burnchain_op_val) = tx_json. get ( "burnchain_op" ) {
592
593
if !burnchain_op_val. is_null ( ) {
593
594
return None ;
594
595
}
595
596
}
597
+ // Filter out phantom txs
596
598
let tx_hex = tx_json. get ( "raw_tx" ) . unwrap ( ) . as_str ( ) . unwrap ( ) ;
597
599
let tx_bytes = hex_bytes ( & tx_hex[ 2 ..] ) . unwrap ( ) ;
598
600
let tx =
599
601
StacksTransaction :: consensus_deserialize ( & mut tx_bytes. as_slice ( ) ) . unwrap ( ) ;
602
+ if tx. is_phantom ( ) {
603
+ return None ;
604
+ }
600
605
Some ( tx)
601
606
} )
602
607
. collect ( )
You can’t perform that action at this time.
0 commit comments