public synchronized void queueTransaction(Transaction transaction) {
   // Store transaction in outgoing buffer, so we can broadcast it
   // later
   byte[] rawTransaction = transaction.toBytes();
   _backing.putOutgoingTransaction(transaction.getHash(), rawTransaction);
   markTransactionAsSpent(transaction);
 }
  @Override
  public synchronized BroadcastResult broadcastTransaction(Transaction transaction) {
    checkNotArchived();
    try {
      WapiResponse<BroadcastTransactionResponse> response =
          _wapi.broadcastTransaction(
              new BroadcastTransactionRequest(Wapi.VERSION, transaction.toBytes()));
      if (response.getErrorCode() == Wapi.ERROR_CODE_SUCCESS) {
        if (response.getResult().success) {
          markTransactionAsSpent(transaction);
          postEvent(Event.BROADCASTED_TRANSACTION_ACCEPTED);
          return BroadcastResult.SUCCESS;
        } else {
          // This transaction was rejected must be double spend or
          // malleability, delete it locally.
          _logger.logError(
              "Failed to broadcast transaction due to a double spend or malleability issue");
          postEvent(Event.BROADCASTED_TRANSACTION_DENIED);
          return BroadcastResult.REJECTED;
        }
      } else if (response.getErrorCode() == Wapi.ERROR_CODE_NO_SERVER_CONNECTION) {
        postEvent(Event.SERVER_CONNECTION_ERROR);
        _logger.logError("Server connection failed with ERROR_CODE_NO_SERVER_CONNECTION");
        return BroadcastResult.NO_SERVER_CONNECTION;
      } else {
        postEvent(Event.BROADCASTED_TRANSACTION_DENIED);
        _logger.logError("Server connection failed with error: " + response.getErrorCode());
        return BroadcastResult.REJECTED;
      }

    } catch (WapiException e) {
      postEvent(Event.SERVER_CONNECTION_ERROR);
      _logger.logError("Server connection failed with error code: " + e.errorCode, e);
      return BroadcastResult.NO_SERVER_CONNECTION;
    }
  }