public List<OutgoingDraftTransactionWrapper> getAllInState(
      com.bitdubai.fermat_ccp_plugin.layer.crypto_transaction.outgoing_draft.developer.bitdubai
              .version_1.enums.TransactionState
          transactionState)
      throws CantLoadTableToMemoryException, InvalidParameterException {
    DatabaseTable transactionTable =
        this.database.getTable(OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_TABLE_NAME);
    transactionTable.addStringFilter(
        OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_TRANSACTION_STATUS_COLUMN_NAME,
        transactionState.getCode(),
        DatabaseFilterType.EQUAL);
    transactionTable.loadToMemory();
    List<DatabaseTableRecord> records = transactionTable.getRecords();
    transactionTable.clearAllFilters();

    return mapConvertToBT(records);
  }
  private void setToState(
      OutgoingDraftTransactionWrapper bitcoinTransaction,
      com.bitdubai.fermat_ccp_plugin.layer.crypto_transaction.outgoing_draft.developer.bitdubai
              .version_1.enums.TransactionState
          status)
      throws CantUpdateRecordException,
          com.bitdubai.fermat_ccp_plugin.layer.crypto_transaction.outgoing_draft.developer.bitdubai
              .version_1.exceptions.OutgoingIntraActorInconsistentTableStateException,
          CantLoadTableToMemoryException {
    DatabaseTable transactionTable =
        this.database.getTable(OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_TABLE_NAME);
    DatabaseTableRecord recordToUpdate = getByPrimaryKey(bitcoinTransaction.getRequestId());

    recordToUpdate.setStringValue(
        OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_TRANSACTION_STATUS_COLUMN_NAME,
        status.getCode());

    transactionTable.addStringFilter(
        OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_TRANSACTION_ID_COLUMN_NAME,
        bitcoinTransaction.getRequestId().toString(),
        DatabaseFilterType.EQUAL);
    transactionTable.updateRecord(recordToUpdate);
  }
  private OutgoingDraftTransactionWrapper convertToBT(DatabaseTableRecord record)
      throws InvalidParameterException {
    //        boolean sameDevice =
    // Boolean.valueOf(record.getStringValue(OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_SAME_DEVICE_COLUMN_NAME));
    String walletPublicKey =
        record.getStringValue(
            OutgoingDraftTransactionDatabaseConstants
                .OUTGOING_DRAFT_WALLET_ID_TO_DEBIT_FROM_COLUMN_NAME);
    UUID transactionId =
        record.getUUIDValue(
            OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_TRANSACTION_ID_COLUMN_NAME);
    String transactionHash =
        record.getStringValue(
            OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_TRANSACTION_HASH_COLUMN_NAME);
    long amount =
        record.getLongValue(
            OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_CRYPTO_AMOUNT_COLUMN_NAME);
    //        String op_Return =
    // record.getStringValue(OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_OP_RETURN_COLUMN_NAME);
    com.bitdubai.fermat_ccp_plugin.layer.crypto_transaction.outgoing_draft.developer.bitdubai
            .version_1.enums.TransactionState
        state =
            com.bitdubai.fermat_ccp_plugin.layer.crypto_transaction.outgoing_draft.developer
                .bitdubai.version_1.enums.TransactionState.getByCode(
                record.getStringValue(
                    OutgoingDraftTransactionDatabaseConstants
                        .OUTGOING_DRAFT_TRANSACTION_STATUS_COLUMN_NAME));
    long timestamp =
        record.getLongValue(
            OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_TIMESTAMP_COLUMN_NAME);
    String memo =
        record.getStringValue(
            OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_DESCRIPTION_COLUMN_NAME);
    //        CryptoStatus cryptoStatus =
    // CryptoStatus.getByCode(record.getStringValue(OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_CRYPTO_STATUS_COLUMN_NAME));
    Actors actorFromType =
        Actors.getByCode(
            record.getStringValue(
                OutgoingDraftTransactionDatabaseConstants
                    .OUTGOING_DRAFT_ACTOR_FROM_TYPE_COLUMN_NAME));
    Actors actorToType =
        Actors.getByCode(
            record.getStringValue(
                OutgoingDraftTransactionDatabaseConstants
                    .OUTGOING_DRAFT_ACTOR_TO_TYPE_COLUMN_NAME));
    String actorFromPublicKey =
        record.getStringValue(
            OutgoingDraftTransactionDatabaseConstants
                .OUTGOING_DRAFT_ACTOR_FROM_PUBLIC_KEY_COLUMN_NAME);
    String actorToPublicKey =
        record.getStringValue(
            OutgoingDraftTransactionDatabaseConstants
                .OUTGOING_DRAFT_ACTOR_TO_PUBLIC_KEY_COLUMN_NAME);
    ReferenceWallet referenceWallet =
        ReferenceWallet.getByCode(
            record.getStringValue(
                OutgoingDraftTransactionDatabaseConstants
                    .OUTGOING_DRAFT_WALLET_REFERENCE_TYPE_COLUMN_NAME));
    String addressFrom =
        record.getStringValue(
            OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_ADDRESS_FROM_COLUMN_NAME);
    String addressTo =
        record.getStringValue(
            OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_ADDRESS_TO_COLUMN_NAME);
    //        CryptoAddress cryptoAddressFrom = null;
    //        if (addressFrom != null) {
    //            cryptoAddressFrom = new CryptoAddress(
    //                    addressFrom,
    //
    // CryptoCurrency.getByCode(OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_CRYPTO_CURRENCY_COLUMN_NAME));
    //        }
    CryptoAddress cryptoAddressTo = null;
    if (addressFrom != null) {
      cryptoAddressTo =
          new CryptoAddress(
              addressTo,
              CryptoCurrency.getByCode(
                  record.getStringValue(
                      OutgoingDraftTransactionDatabaseConstants
                          .OUTGOING_DRAFT_CRYPTO_CURRENCY_COLUMN_NAME)));
    }
    BlockchainNetworkType blockchainNetworkType =
        BlockchainNetworkType.getByCode(
            record.getStringValue(
                OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_RUNNING_NETWORK_TYPE));

    return new OutgoingDraftTransactionWrapper(
        transactionId,
        walletPublicKey,
        amount,
        cryptoAddressTo,
        referenceWallet,
        blockchainNetworkType,
        actorFromPublicKey,
        actorToPublicKey,
        actorFromType,
        actorToType,
        memo,
        timestamp,
        transactionHash);
  }