message: [style] Clean up BroadcastTransaction()
diff: @@ -28,19 +28,21 @@ static TransactionError HandleATMPError(const TxValidationState& state, std::str
  TransactionError BroadcastTransaction(NodeContext& node, const CTransactionRef tx, std::string& err_string, const CAmount& max_tx_fee, bool relay, bool wait_callback)
  {
  - // BroadcastTransaction can be called by either sendrawtransaction RPC or wallet RPCs.
  - // node.peerman is assigned both before chain clients and before RPC server is accepting calls,
  - // and reset after chain clients and RPC sever are stopped. node.peerman should never be null here.
  - assert(node.peerman);
  + // BroadcastTransaction can be called by either sendrawtransaction RPC or the wallet.
  + // chainman, mempool and peerman are initialized before the RPC server and wallet are started
  + // and reset after the RPC sever and wallet are stopped.
  + assert(node.chainman);
  assert(node.mempool);
  + assert(node.peerman);
  +
  std::promise<void> promise;
  uint256 txid = tx->GetHash();
  uint256 wtxid = tx->GetWitnessHash();
  bool callback_set = false;
  - { // cs_main scope
  - assert(node.chainman);
  + {
  LOCK(cs_main);
  +
  // If the transaction is already confirmed in the chain, don't do anything
  // and return early.
  CCoinsViewCache &view = node.chainman->ActiveChainstate().CoinsTip();
  @@ -50,6 +52,7 @@ TransactionError BroadcastTransaction(NodeContext& node, const CTransactionRef t
  // So if the output does exist, then this transaction exists in the chain.
  if (!existingCoin.IsSpent()) return TransactionError::ALREADY_IN_CHAIN;
  }
  +
  if (auto mempool_tx = node.mempool->get(txid); mempool_tx) {
  // There's already a transaction in the mempool with this txid. Don't
  // try to submit this transaction to the mempool (since it'll be
  @@ -102,7 +105,6 @@ TransactionError BroadcastTransaction(NodeContext& node, const CTransactionRef t
  callback_set = true;
  }
  }
  -
  } // cs_main
  if (callback_set) {
  