@@ -16,6 +16,7 @@ use cuprate_constants::rpc::{
1616 MAX_RESTRICTED_GLOBAL_FAKE_OUTS_COUNT , RESTRICTED_SPENT_KEY_IMAGES_COUNT ,
1717 RESTRICTED_TRANSACTIONS_COUNT ,
1818} ;
19+ use cuprate_dandelion_tower:: TxState ;
1920use cuprate_helper:: cast:: usize_to_u64;
2021use cuprate_hex:: { Hex , HexVec } ;
2122use cuprate_p2p_core:: { client:: handshaker:: builder:: DummyAddressBook , ClearNet } ;
@@ -49,11 +50,17 @@ use cuprate_types::{
4950use crate :: {
5051 rpc:: {
5152 constants:: UNSUPPORTED_RPC_CALL ,
52- handlers:: { helper, shared, shared:: not_available} ,
53- service:: { address_book, blockchain, blockchain_context, blockchain_manager, txpool} ,
53+ handlers:: {
54+ helper,
55+ shared:: { self , not_available} ,
56+ } ,
57+ service:: {
58+ address_book, blockchain, blockchain_context, blockchain_manager, tx_handler, txpool,
59+ } ,
5460 CupratedRpcHandler ,
5561 } ,
5662 statics:: START_INSTANT_UNIX ,
63+ txpool:: IncomingTxs ,
5764} ;
5865
5966/// Map a [`OtherRequest`] to the function that will lead to a [`OtherResponse`].
@@ -69,7 +76,9 @@ pub async fn map_request(
6976 Req :: GetTransactions ( r) => Resp :: GetTransactions ( not_available ( ) ?) ,
7077 Req :: GetAltBlocksHashes ( r) => Resp :: GetAltBlocksHashes ( not_available ( ) ?) ,
7178 Req :: IsKeyImageSpent ( r) => Resp :: IsKeyImageSpent ( not_available ( ) ?) ,
72- Req :: SendRawTransaction ( r) => Resp :: SendRawTransaction ( not_available ( ) ?) ,
79+ Req :: SendRawTransaction ( r) => {
80+ Resp :: SendRawTransaction ( send_raw_transaction ( state, r) . await ?)
81+ }
7382 Req :: SaveBc ( r) => Resp :: SaveBc ( not_available ( ) ?) ,
7483 Req :: GetPeerList ( r) => Resp :: GetPeerList ( not_available ( ) ?) ,
7584 Req :: SetLogLevel ( r) => Resp :: SetLogLevel ( not_available ( ) ?) ,
@@ -442,14 +451,32 @@ async fn send_raw_transaction(
442451 }
443452 }
444453
445- // TODO: handle to txpool service.
446- let tx_relay_checks =
447- txpool:: check_maybe_relay_local ( todo ! ( ) , tx, !request. do_not_relay ) . await ?;
454+ if state. is_restricted ( ) && request. do_not_relay {
455+ // FIXME: implement something like `/check_tx` in `cuprated/monerod`.
456+ // boog900:
457+ // > making nodes hold txs in their pool that don't get passed
458+ // > around the network can cause issues, like targeted tx pool double spends
459+ // > there is also no reason to have this for public RPC
460+ return Err ( anyhow ! ( "do_not_relay is not supported on restricted RPC" ) ) ;
461+ }
462+
463+ let txs = vec ! [ tx. serialize( ) . into( ) ] ;
464+
465+ let mut txs = IncomingTxs {
466+ txs,
467+ state : TxState :: Local ,
468+ drop_relay_rule_errors : false ,
469+ do_not_relay : request. do_not_relay ,
470+ } ;
471+
472+ let tx_relay_checks = tx_handler:: handle_incoming_txs ( & mut state. tx_handler , txs) . await ?;
448473
449474 if tx_relay_checks. is_empty ( ) {
450475 return Ok ( resp) ;
451476 }
452477
478+ resp. not_relayed = true ;
479+
453480 // <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.cpp#L124>
454481 fn add_reason ( reasons : & mut String , reason : & ' static str ) {
455482 if !reasons. is_empty ( ) {
0 commit comments