File tree 2 files changed +22
-2
lines changed
2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -75,6 +75,12 @@ impl RpcApi for Client {
75
75
76
76
self . ledger . add_transaction_unconditionally ( tx. clone ( ) ) ;
77
77
78
+ if !self . ledger . check_transaction ( tx. clone ( ) ) {
79
+ return Err ( bitcoincore_rpc:: Error :: Io ( std:: io:: Error :: other (
80
+ "Transaction not valid." ,
81
+ ) ) ) ;
82
+ }
83
+
78
84
Ok ( tx. compute_txid ( ) )
79
85
}
80
86
@@ -140,8 +146,6 @@ impl RpcApi for Client {
140
146
141
147
let txid = self . send_raw_transaction ( & tx) ?;
142
148
143
- self . ledger . add_transaction_unconditionally ( tx) ;
144
-
145
149
Ok ( txid)
146
150
}
147
151
Original file line number Diff line number Diff line change @@ -36,6 +36,22 @@ impl Ledger {
36
36
pub fn get_transactions ( & self ) -> Vec < Transaction > {
37
37
get_item ! ( self . transactions) ;
38
38
}
39
+ /// Checks if a transaction is OK or not.
40
+ pub fn check_transaction ( & self , transaction : Transaction ) -> bool {
41
+ println ! ( "check tr" ) ;
42
+ if let Ok ( ( ) ) = self
43
+ . database
44
+ . lock ( )
45
+ . unwrap ( )
46
+ . verify_transaction ( & transaction)
47
+ {
48
+ println ! ( "check tr1" ) ;
49
+ return true ;
50
+ } ;
51
+
52
+ println ! ( "check tr2" ) ;
53
+ false
54
+ }
39
55
}
40
56
41
57
#[ cfg( test) ]
You can’t perform that action at this time.
0 commit comments