Skip to content

Commit

Permalink
create TxMarshalingErr
Browse files Browse the repository at this point in the history
Signed-off-by: ozkanonur <work@onurozkan.dev>
  • Loading branch information
onur-ozkan committed Aug 12, 2022
1 parent e50c347 commit 4ae28fb
Show file tree
Hide file tree
Showing 15 changed files with 68 additions and 51 deletions.
10 changes: 5 additions & 5 deletions mm2src/coins/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ use super::{coin_conf, AsyncMutex, BalanceError, BalanceFut, CoinBalance, CoinPr
RawTransactionRequest, RawTransactionRes, RawTransactionResult, RpcClientType, RpcTransportEventHandler,
RpcTransportEventHandlerShared, SearchForSwapTxSpendInput, SignatureError, SignatureResult, SwapOps,
TradeFee, TradePreimageError, TradePreimageFut, TradePreimageResult, TradePreimageValue, Transaction,
TransactionDetails, TransactionEnum, TransactionErr, TransactionFut, UnexpectedDerivationMethod,
ValidateAddressResult, ValidatePaymentInput, VerificationError, VerificationResult, WithdrawError,
WithdrawFee, WithdrawFut, WithdrawRequest, WithdrawResult};
TransactionDetails, TransactionEnum, TransactionErr, TransactionFut, TxMarshalingErr,
UnexpectedDerivationMethod, ValidateAddressResult, ValidatePaymentInput, VerificationError,
VerificationResult, WithdrawError, WithdrawFee, WithdrawFut, WithdrawRequest, WithdrawResult};

pub use rlp;

Expand Down Expand Up @@ -1376,10 +1376,10 @@ impl MarketCoinOps for EthCoin {
Box::new(fut.boxed().compat())
}

fn tx_enum_from_bytes(&self, bytes: &[u8]) -> Result<TransactionEnum, MmError<TransactionErr>> {
fn tx_enum_from_bytes(&self, bytes: &[u8]) -> Result<TransactionEnum, MmError<TxMarshalingErr>> {
signed_eth_tx_from_bytes(bytes)
.map(TransactionEnum::from)
.map_to_mm(TransactionErr::InvalidTx)
.map_to_mm(TxMarshalingErr::InvalidInput)
}

fn current_block(&self) -> Box<dyn Future<Item = u64, Error = String> + Send> {
Expand Down
6 changes: 3 additions & 3 deletions mm2src/coins/lightning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use crate::utxo::{sat_from_big_decimal, BlockchainNetwork, FeePolicy, GetUtxoLis
use crate::{BalanceFut, CoinBalance, FeeApproxStage, FoundSwapTxSpend, HistorySyncState, MarketCoinOps, MmCoin,
NegotiateSwapContractAddrErr, RawTransactionFut, RawTransactionRequest, SearchForSwapTxSpendInput,
SignatureError, SignatureResult, SwapOps, TradeFee, TradePreimageFut, TradePreimageResult,
TradePreimageValue, TransactionEnum, TransactionErr, TransactionFut, UnexpectedDerivationMethod,
TradePreimageValue, TransactionEnum, TransactionFut, TxMarshalingErr, UnexpectedDerivationMethod,
UtxoStandardCoin, ValidateAddressResult, ValidatePaymentInput, VerificationError, VerificationResult,
WithdrawError, WithdrawFut, WithdrawRequest};
use async_trait::async_trait;
Expand Down Expand Up @@ -482,8 +482,8 @@ impl MarketCoinOps for LightningCoin {
}

// Todo: Implement this when implementing swaps for lightning as it's is used mainly for swaps
fn tx_enum_from_bytes(&self, _bytes: &[u8]) -> Result<TransactionEnum, MmError<TransactionErr>> {
MmError::err(TransactionErr::Plain(
fn tx_enum_from_bytes(&self, _bytes: &[u8]) -> Result<TransactionEnum, MmError<TxMarshalingErr>> {
MmError::err(TxMarshalingErr::NotSupported(
"tx_enum_from_bytes is not supported for Lightning yet.".to_string(),
))
}
Expand Down
13 changes: 10 additions & 3 deletions mm2src/coins/lp_coins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,14 +370,22 @@ impl Deref for TransactionEnum {
}
}

/// Error type for handling tx serialization/deserialization operations.
#[derive(Debug, Clone)]
pub enum TxMarshalingErr {
InvalidInput(String),
/// For cases where serialized and deserialized values doesn't verify each other.
CrossCheckFailed(String),
NotSupported(String),
}

#[derive(Debug, Clone)]
#[allow(clippy::large_enum_variant)]
pub enum TransactionErr {
/// Keeps transactions while throwing errors.
TxRecoverable(TransactionEnum, String),
/// Simply for plain error messages.
Plain(String),
InvalidTx(String),
}

impl TransactionErr {
Expand All @@ -396,7 +404,6 @@ impl TransactionErr {
match self {
TransactionErr::TxRecoverable(_, err) => err.to_string(),
TransactionErr::Plain(err) => err.to_string(),
TransactionErr::InvalidTx(err) => err.to_string(),
}
}
}
Expand Down Expand Up @@ -627,7 +634,7 @@ pub trait MarketCoinOps {
swap_contract_address: &Option<BytesJson>,
) -> TransactionFut;

fn tx_enum_from_bytes(&self, bytes: &[u8]) -> Result<TransactionEnum, MmError<TransactionErr>>;
fn tx_enum_from_bytes(&self, bytes: &[u8]) -> Result<TransactionEnum, MmError<TxMarshalingErr>>;

fn current_block(&self) -> Box<dyn Future<Item = u64, Error = String> + Send>;

Expand Down
7 changes: 4 additions & 3 deletions mm2src/coins/qrc20.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ use crate::{BalanceError, BalanceFut, CoinBalance, FeeApproxStage, FoundSwapTxSp
MmCoin, NegotiateSwapContractAddrErr, PrivKeyNotAllowed, RawTransactionFut, RawTransactionRequest,
SearchForSwapTxSpendInput, SignatureResult, SwapOps, TradeFee, TradePreimageError, TradePreimageFut,
TradePreimageResult, TradePreimageValue, TransactionDetails, TransactionEnum, TransactionErr,
TransactionFut, TransactionType, UnexpectedDerivationMethod, ValidateAddressResult, ValidatePaymentInput,
VerificationResult, WithdrawError, WithdrawFee, WithdrawFut, WithdrawRequest, WithdrawResult};
TransactionFut, TransactionType, TxMarshalingErr, UnexpectedDerivationMethod, ValidateAddressResult,
ValidatePaymentInput, VerificationResult, WithdrawError, WithdrawFee, WithdrawFut, WithdrawRequest,
WithdrawResult};
use async_trait::async_trait;
use bitcrypto::{dhash160, sha256};
use chain::TransactionOutput;
Expand Down Expand Up @@ -1110,7 +1111,7 @@ impl MarketCoinOps for Qrc20Coin {
Box::new(fut.boxed().compat())
}

fn tx_enum_from_bytes(&self, bytes: &[u8]) -> Result<TransactionEnum, MmError<TransactionErr>> {
fn tx_enum_from_bytes(&self, bytes: &[u8]) -> Result<TransactionEnum, MmError<TxMarshalingErr>> {
utxo_common::tx_enum_from_bytes(self.as_ref(), bytes)
}

Expand Down
8 changes: 4 additions & 4 deletions mm2src/coins/solana.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use crate::solana::solana_common::{lamports_to_sol, PrepareTransferData, Suffici
use crate::solana::spl::SplTokenInfo;
use crate::{BalanceError, BalanceFut, FeeApproxStage, FoundSwapTxSpend, NegotiateSwapContractAddrErr,
RawTransactionFut, RawTransactionRequest, SearchForSwapTxSpendInput, SignatureResult, TradePreimageFut,
TradePreimageResult, TradePreimageValue, TransactionDetails, TransactionErr, TransactionFut,
TransactionType, UnexpectedDerivationMethod, ValidateAddressResult, ValidatePaymentInput,
TradePreimageResult, TradePreimageValue, TransactionDetails, TransactionFut, TransactionType,
TxMarshalingErr, UnexpectedDerivationMethod, ValidateAddressResult, ValidatePaymentInput,
VerificationResult, WithdrawError, WithdrawFut, WithdrawRequest, WithdrawResult};
use async_trait::async_trait;
use base58::ToBase58;
Expand Down Expand Up @@ -429,8 +429,8 @@ impl MarketCoinOps for SolanaCoin {
unimplemented!()
}

fn tx_enum_from_bytes(&self, bytes: &[u8]) -> Result<TransactionEnum, MmError<TransactionErr>> {
MmError::err(TransactionErr::Plain(
fn tx_enum_from_bytes(&self, bytes: &[u8]) -> Result<TransactionEnum, MmError<TxMarshalingErr>> {
MmError::err(TxMarshalingErr::NotSupported(
"tx_enum_from_bytes is not supported for Solana yet.".to_string(),
))
}
Expand Down
8 changes: 4 additions & 4 deletions mm2src/coins/solana/spl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use crate::solana::solana_common::{ui_amount_to_amount, PrepareTransferData, Suf
use crate::solana::{solana_common, AccountError, SolanaCommonOps, SolanaFeeDetails};
use crate::{BalanceFut, FeeApproxStage, FoundSwapTxSpend, NegotiateSwapContractAddrErr, RawTransactionFut,
RawTransactionRequest, SearchForSwapTxSpendInput, SignatureResult, SolanaCoin, TradePreimageFut,
TradePreimageResult, TradePreimageValue, TransactionDetails, TransactionErr, TransactionFut,
TransactionType, UnexpectedDerivationMethod, ValidateAddressResult, ValidatePaymentInput,
TradePreimageResult, TradePreimageValue, TransactionDetails, TransactionFut, TransactionType,
TxMarshalingErr, UnexpectedDerivationMethod, ValidateAddressResult, ValidatePaymentInput,
VerificationResult, WithdrawError, WithdrawFut, WithdrawRequest, WithdrawResult};
use async_trait::async_trait;
use bincode::serialize;
Expand Down Expand Up @@ -267,8 +267,8 @@ impl MarketCoinOps for SplToken {
unimplemented!()
}

fn tx_enum_from_bytes(&self, _bytes: &[u8]) -> Result<TransactionEnum, MmError<TransactionErr>> {
MmError::err(TransactionErr::Plain(
fn tx_enum_from_bytes(&self, _bytes: &[u8]) -> Result<TransactionEnum, MmError<TxMarshalingErr>> {
MmError::err(TxMarshalingErr::NotSupported(
"tx_enum_from_bytes is not supported for Spl yet.".to_string(),
))
}
Expand Down
6 changes: 3 additions & 3 deletions mm2src/coins/tendermint/tendermint_coin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{big_decimal_from_sat_unsigned, BalanceError, BalanceFut, BigDecimal,
FoundSwapTxSpend, HistorySyncState, MarketCoinOps, MmCoin, NegotiateSwapContractAddrErr,
RawTransactionFut, RawTransactionRequest, SearchForSwapTxSpendInput, SignatureResult, SwapOps, TradeFee,
TradePreimageFut, TradePreimageResult, TradePreimageValue, TransactionDetails, TransactionEnum,
TransactionErr, TransactionFut, TransactionType, TxFeeDetails, UnexpectedDerivationMethod,
TransactionFut, TransactionType, TxFeeDetails, TxMarshalingErr, UnexpectedDerivationMethod,
ValidateAddressResult, ValidatePaymentInput, VerificationResult, WithdrawError, WithdrawFut,
WithdrawRequest};
use async_trait::async_trait;
Expand Down Expand Up @@ -482,8 +482,8 @@ impl MarketCoinOps for TendermintCoin {
todo!()
}

fn tx_enum_from_bytes(&self, bytes: &[u8]) -> Result<TransactionEnum, MmError<TransactionErr>> {
MmError::err(TransactionErr::Plain(
fn tx_enum_from_bytes(&self, bytes: &[u8]) -> Result<TransactionEnum, MmError<TxMarshalingErr>> {
MmError::err(TxMarshalingErr::NotSupported(
"tx_enum_from_bytes is not supported for Tendermint yet.".to_string(),
))
}
Expand Down
6 changes: 3 additions & 3 deletions mm2src/coins/test_coin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use super::{CoinBalance, HistorySyncState, MarketCoinOps, MmCoin, RawTransaction
TradeFee, TransactionEnum, TransactionFut};
use crate::{BalanceFut, CanRefundHtlc, FeeApproxStage, FoundSwapTxSpend, NegotiateSwapContractAddrErr,
SearchForSwapTxSpendInput, SignatureResult, TradePreimageFut, TradePreimageResult, TradePreimageValue,
TransactionErr, UnexpectedDerivationMethod, ValidateAddressResult, ValidatePaymentInput,
TxMarshalingErr, UnexpectedDerivationMethod, ValidateAddressResult, ValidatePaymentInput,
VerificationResult, WithdrawFut, WithdrawRequest};
use async_trait::async_trait;
use futures01::Future;
Expand Down Expand Up @@ -78,8 +78,8 @@ impl MarketCoinOps for TestCoin {
unimplemented!()
}

fn tx_enum_from_bytes(&self, _bytes: &[u8]) -> Result<TransactionEnum, MmError<TransactionErr>> {
MmError::err(TransactionErr::Plain(
fn tx_enum_from_bytes(&self, _bytes: &[u8]) -> Result<TransactionEnum, MmError<TxMarshalingErr>> {
MmError::err(TxMarshalingErr::NotSupported(
"tx_enum_from_bytes is not supported for Test coin yet.".to_string(),
))
}
Expand Down
6 changes: 3 additions & 3 deletions mm2src/coins/utxo/bch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use crate::utxo::utxo_builder::{UtxoArcBuilder, UtxoCoinBuilder};
use crate::utxo::utxo_common::big_decimal_from_sat_unsigned;
use crate::{BlockHeightAndTime, CanRefundHtlc, CoinBalance, CoinProtocol, NegotiateSwapContractAddrErr,
PrivKeyBuildPolicy, RawTransactionFut, RawTransactionRequest, SearchForSwapTxSpendInput, SignatureResult,
SwapOps, TradePreimageValue, TransactionFut, TransactionType, TxFeeDetails, UnexpectedDerivationMethod,
ValidateAddressResult, ValidatePaymentInput, VerificationResult, WithdrawFut};
SwapOps, TradePreimageValue, TransactionFut, TransactionType, TxFeeDetails, TxMarshalingErr,
UnexpectedDerivationMethod, ValidateAddressResult, ValidatePaymentInput, VerificationResult, WithdrawFut};
use common::log::warn;
use derive_more::Display;
use futures::{FutureExt, TryFutureExt};
Expand Down Expand Up @@ -1130,7 +1130,7 @@ impl MarketCoinOps for BchCoin {
)
}

fn tx_enum_from_bytes(&self, bytes: &[u8]) -> Result<TransactionEnum, MmError<TransactionErr>> {
fn tx_enum_from_bytes(&self, bytes: &[u8]) -> Result<TransactionEnum, MmError<TxMarshalingErr>> {
utxo_common::tx_enum_from_bytes(self.as_ref(), bytes)
}

Expand Down
7 changes: 4 additions & 3 deletions mm2src/coins/utxo/qtum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ use crate::utxo::utxo_builder::{BlockHeaderUtxoArcOps, MergeUtxoArcOps, UtxoCoin
UtxoFieldsWithIguanaPrivKeyBuilder};
use crate::{eth, CanRefundHtlc, CoinBalance, CoinWithDerivationMethod, DelegationError, DelegationFut,
GetWithdrawSenderAddress, NegotiateSwapContractAddrErr, PrivKeyBuildPolicy, SearchForSwapTxSpendInput,
SignatureResult, StakingInfosFut, SwapOps, TradePreimageValue, TransactionFut, UnexpectedDerivationMethod,
ValidateAddressResult, ValidatePaymentInput, VerificationResult, WithdrawFut, WithdrawSenderAddress};
SignatureResult, StakingInfosFut, SwapOps, TradePreimageValue, TransactionFut, TxMarshalingErr,
UnexpectedDerivationMethod, ValidateAddressResult, ValidatePaymentInput, VerificationResult, WithdrawFut,
WithdrawSenderAddress};
use crypto::trezor::utxo::TrezorUtxoCoin;
use crypto::Bip44Chain;
use ethereum_types::H160;
Expand Down Expand Up @@ -782,7 +783,7 @@ impl MarketCoinOps for QtumCoin {
)
}

fn tx_enum_from_bytes(&self, bytes: &[u8]) -> Result<TransactionEnum, MmError<TransactionErr>> {
fn tx_enum_from_bytes(&self, bytes: &[u8]) -> Result<TransactionEnum, MmError<TxMarshalingErr>> {
utxo_common::tx_enum_from_bytes(self.as_ref(), bytes)
}

Expand Down
8 changes: 4 additions & 4 deletions mm2src/coins/utxo/slp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ use crate::{BalanceFut, CoinBalance, FeeApproxStage, FoundSwapTxSpend, HistorySy
NegotiateSwapContractAddrErr, NumConversError, PrivKeyNotAllowed, RawTransactionFut,
RawTransactionRequest, SearchForSwapTxSpendInput, SignatureResult, SwapOps, TradeFee, TradePreimageError,
TradePreimageFut, TradePreimageResult, TradePreimageValue, TransactionDetails, TransactionEnum,
TransactionErr, TransactionFut, TxFeeDetails, UnexpectedDerivationMethod, ValidateAddressResult,
ValidatePaymentInput, VerificationError, VerificationResult, WithdrawError, WithdrawFee, WithdrawFut,
WithdrawRequest};
TransactionErr, TransactionFut, TxFeeDetails, TxMarshalingErr, UnexpectedDerivationMethod,
ValidateAddressResult, ValidatePaymentInput, VerificationError, VerificationResult, WithdrawError,
WithdrawFee, WithdrawFut, WithdrawRequest};
use async_trait::async_trait;
use bitcrypto::dhash160;
use chain::constants::SEQUENCE_FINAL;
Expand Down Expand Up @@ -1160,7 +1160,7 @@ impl MarketCoinOps for SlpToken {
)
}

fn tx_enum_from_bytes(&self, bytes: &[u8]) -> Result<TransactionEnum, MmError<TransactionErr>> {
fn tx_enum_from_bytes(&self, bytes: &[u8]) -> Result<TransactionEnum, MmError<TxMarshalingErr>> {
self.platform_coin.tx_enum_from_bytes(bytes)
}

Expand Down
19 changes: 12 additions & 7 deletions mm2src/coins/utxo/utxo_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ use crate::utxo::tx_cache::TxCacheResult;
use crate::utxo::utxo_withdraw::{InitUtxoWithdraw, StandardUtxoWithdraw, UtxoWithdraw};
use crate::{CanRefundHtlc, CoinBalance, CoinWithDerivationMethod, GetWithdrawSenderAddress, HDAddressId,
RawTransactionError, RawTransactionRequest, RawTransactionRes, SearchForSwapTxSpendInput, SignatureError,
SignatureResult, SwapOps, TradePreimageValue, TransactionFut, TxFeeDetails, ValidateAddressResult,
ValidatePaymentInput, VerificationError, VerificationResult, WithdrawFrom, WithdrawResult,
WithdrawSenderAddress};
SignatureResult, SwapOps, TradePreimageValue, TransactionFut, TxFeeDetails, TxMarshalingErr,
ValidateAddressResult, ValidatePaymentInput, VerificationError, VerificationResult, WithdrawFrom,
WithdrawResult, WithdrawSenderAddress};
use bitcrypto::dhash256;
pub use bitcrypto::{dhash160, sha256, ChecksumType};
use chain::constants::SEQUENCE_FINAL;
Expand Down Expand Up @@ -1822,11 +1822,16 @@ pub fn wait_for_output_spend(
Box::new(fut.boxed().compat())
}

pub fn tx_enum_from_bytes(coin: &UtxoCoinFields, bytes: &[u8]) -> Result<TransactionEnum, MmError<TransactionErr>> {
let mut transaction: UtxoTx = deserialize(bytes).map_to_mm(|e| TransactionErr::InvalidTx(e.to_string()))?;
pub fn tx_enum_from_bytes(coin: &UtxoCoinFields, bytes: &[u8]) -> Result<TransactionEnum, MmError<TxMarshalingErr>> {
let mut transaction: UtxoTx = deserialize(bytes).map_to_mm(|e| TxMarshalingErr::InvalidInput(e.to_string()))?;

if bytes.len() != transaction.tx_hex().len() {
return MmError::err(TransactionErr::InvalidTx("Transaction isn't valid.".to_string()));
let serialized_length = transaction.tx_hex().len();
if bytes.len() != serialized_length {
return MmError::err(TxMarshalingErr::CrossCheckFailed(format!(
"Expected '{}' lenght of the serialized transaction, found '{}'",
bytes.len(),
transaction.tx_hex().len()
)));
}

transaction.tx_hash_algo = coin.tx_hash_algo;
Expand Down
6 changes: 3 additions & 3 deletions mm2src/coins/utxo/utxo_standard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ use crate::rpc_command::init_withdraw::{InitWithdrawCoin, WithdrawTaskHandle};
use crate::utxo::utxo_builder::{UtxoArcBuilder, UtxoCoinBuilder};
use crate::{CanRefundHtlc, CoinBalance, CoinWithDerivationMethod, GetWithdrawSenderAddress,
NegotiateSwapContractAddrErr, PrivKeyBuildPolicy, SearchForSwapTxSpendInput, SignatureResult, SwapOps,
TradePreimageValue, TransactionFut, ValidateAddressResult, ValidatePaymentInput, VerificationResult,
WithdrawFut, WithdrawSenderAddress};
TradePreimageValue, TransactionFut, TxMarshalingErr, ValidateAddressResult, ValidatePaymentInput,
VerificationResult, WithdrawFut, WithdrawSenderAddress};
use crypto::trezor::utxo::TrezorUtxoCoin;
use crypto::Bip44Chain;
use futures::{FutureExt, TryFutureExt};
Expand Down Expand Up @@ -539,7 +539,7 @@ impl MarketCoinOps for UtxoStandardCoin {
)
}

fn tx_enum_from_bytes(&self, bytes: &[u8]) -> Result<TransactionEnum, MmError<TransactionErr>> {
fn tx_enum_from_bytes(&self, bytes: &[u8]) -> Result<TransactionEnum, MmError<TxMarshalingErr>> {
utxo_common::tx_enum_from_bytes(self.as_ref(), bytes)
}

Expand Down
6 changes: 3 additions & 3 deletions mm2src/coins/z_coin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::{BalanceError, BalanceFut, CoinBalance, FeeApproxStage, FoundSwapTxSp
MmCoin, NegotiateSwapContractAddrErr, NumConversError, PrivKeyActivationPolicy, RawTransactionFut,
RawTransactionRequest, SearchForSwapTxSpendInput, SignatureError, SignatureResult, SwapOps, TradeFee,
TradePreimageFut, TradePreimageResult, TradePreimageValue, TransactionDetails, TransactionEnum,
TransactionErr, TransactionFut, TxFeeDetails, UnexpectedDerivationMethod, ValidateAddressResult,
TransactionFut, TxFeeDetails, TxMarshalingErr, UnexpectedDerivationMethod, ValidateAddressResult,
ValidatePaymentInput, VerificationError, VerificationResult, WithdrawFut, WithdrawRequest};
use crate::{Transaction, WithdrawError};
use async_trait::async_trait;
Expand Down Expand Up @@ -983,10 +983,10 @@ impl MarketCoinOps for ZCoin {
)
}

fn tx_enum_from_bytes(&self, bytes: &[u8]) -> Result<TransactionEnum, MmError<TransactionErr>> {
fn tx_enum_from_bytes(&self, bytes: &[u8]) -> Result<TransactionEnum, MmError<TxMarshalingErr>> {
ZTransaction::read(bytes)
.map(TransactionEnum::from)
.map_to_mm(|e| TransactionErr::InvalidTx(e.to_string()))
.map_to_mm(|e| TxMarshalingErr::InvalidInput(e.to_string()))
}

fn current_block(&self) -> Box<dyn Future<Item = u64, Error = String> + Send> {
Expand Down
Loading

0 comments on commit 4ae28fb

Please sign in to comment.