Calling BroadcastTransaction with the NO_MEMPOOL_PRIVATE_BROADCAST method skips inserting the transaction into the mempool and returns immediately. This causes problems with software that expects the transaction to be in the mempool after the function returns. For example many third-party wallets or services call sendrawtransaction and expect the transaction to be in the mempool after it returns a successful response.
This PR adds a new TransactionAddedToMempoolSync method to CValidationInterface. This is then used in BroadcastTransaction when the method is NO_MEMPOOL_PRIVATE_BROADCAST to wait for the transaction to have been accepted back into the mempool before returning. It also adds a timeout (default 10 minutes) to BroadcastTransaction and exposes it as an option for sendrawtransaction. Setting the timeout to 0 disables the wait and returns immediately, preserving the current behavior.
Synchronously waiting for mempool acceptance is also a prerequisite for adding private broadcast support to the wallet. The TransactionAddedToMempoolSync method is added specifically for future wallet broadcasting, so a broadcast caller holding cs_wallet will not timeout waiting on another background event that is also trying to acquire cs_wallet.