diff --git a/genesis-builder/src/lib.rs b/genesis-builder/src/lib.rs index b84fd0edd6..306363e71b 100644 --- a/genesis-builder/src/lib.rs +++ b/genesis-builder/src/lib.rs @@ -403,7 +403,7 @@ impl GenesisBuilder { parent_election_hash, interlink: Some(vec![]), seed, - extra_data: supply.serialize_to_vec(), + extra_data: u64::from(supply).to_be_bytes().to_vec(), state_root, body_root, diff_root: TreeProof::empty().root_hash(), diff --git a/mempool/tests/mod.rs b/mempool/tests/mod.rs index 75d54eeb73..892564b050 100644 --- a/mempool/tests/mod.rs +++ b/mempool/tests/mod.rs @@ -780,8 +780,8 @@ async fn mempool_tps() { let mut prev_txn = txns.first().expect("Is vector empty?").clone(); for txn in txns { assert!( - prev_txn.fee >= txn.fee, - "Transactions in mempool are not ordered by fee" + prev_txn.fee_per_byte() >= txn.fee_per_byte(), + "Transactions in mempool are not ordered by fee per byte" ); prev_txn = txn.clone(); } diff --git a/primitives/account/src/account/vesting_contract.rs b/primitives/account/src/account/vesting_contract.rs index dfd6263e37..f93603aac7 100644 --- a/primitives/account/src/account/vesting_contract.rs +++ b/primitives/account/src/account/vesting_contract.rs @@ -95,8 +95,8 @@ impl AccountTransactionInteraction for VestingContract { owner: data.owner.clone(), start_time: data.start_time, time_step: data.time_step, - step_amount: data.step_amount, - total_amount: data.total_amount, + step_amount: data.step_amount.into(), + total_amount: data.total_amount.into(), }); Ok(Account::Vesting(VestingContract { @@ -104,8 +104,8 @@ impl AccountTransactionInteraction for VestingContract { owner: data.owner, start_time: data.start_time, time_step: data.time_step, - step_amount: data.step_amount, - total_amount: data.total_amount, + step_amount: data.step_amount.into(), + total_amount: data.total_amount.into(), })) } diff --git a/primitives/account/tests/htlc_contract.rs b/primitives/account/tests/htlc_contract.rs index eb260552f4..3099591549 100644 --- a/primitives/account/tests/htlc_contract.rs +++ b/primitives/account/tests/htlc_contract.rs @@ -24,7 +24,7 @@ use nimiq_transaction::{ SignatureProof, Transaction, }; -const HTLC: &str = "00000000000000001b215589344cf570d36bec770825eae30b73213924786862babbdb05e7c4430612135eb2a836812303daebe368963c60d22098a5e9f1ebcb8e54d0b7beca942a2a0a9d95391804fe8f0100000000000296350000000000000001"; +const HTLC: &str = "001b215589344cf570d36bec770825eae30b73213924786862babbdb05e7c4430612135eb2a836812303daebe368963c60d22098a5e9f1ebcb8e54d0b7beca942a2a0a9d95391804fe8f01000000000002963501"; fn prepare_outgoing_transaction() -> ( HashedTimeLockedContract, diff --git a/primitives/account/tests/vesting_contract.rs b/primitives/account/tests/vesting_contract.rs index bb9b4c6e4c..2136d9f29d 100644 --- a/primitives/account/tests/vesting_contract.rs +++ b/primitives/account/tests/vesting_contract.rs @@ -8,7 +8,7 @@ use nimiq_database::traits::Database; use nimiq_keys::{Address, KeyPair}; use nimiq_primitives::{ account::{AccountError, AccountType}, - coin::Coin, + coin::{Coin, CoinBe}, networks::NetworkId, transaction::TransactionError, }; @@ -18,7 +18,7 @@ use nimiq_test_utils::{accounts_revert::TestCommitRevert, test_rng::test_rng}; use nimiq_transaction::{SignatureProof, Transaction}; use nimiq_utils::key_rng::SecureGenerate; -const CONTRACT: &str = "00002fbf9bd9c800fd34ab7265a0e48c454ccbf4c9c61dfdf68f9a220000000000000001000000000003f480000002632e314a0000002fbf9bd9c800"; +const CONTRACT: &str = "8090e7def9f70bfd34ab7265a0e48c454ccbf4c9c61dfdf68f9a220000000000000001000000000003f4808094c5f1b24c8090e7def9f70b"; fn init_tree() -> (TestCommitRevert, VestingContract, KeyPair, KeyPair) { let mut rng = test_rng(true); @@ -172,7 +172,7 @@ fn it_can_create_contract_from_transaction() { Serialize::serialize_to_writer(&owner, &mut data); Serialize::serialize_to_writer(&0u64.to_be_bytes(), &mut data); Serialize::serialize_to_writer(&100u64.to_be_bytes(), &mut data); - Serialize::serialize_to_writer(&Coin::try_from(50).unwrap(), &mut data); + Serialize::serialize_to_writer(&CoinBe::from(Coin::try_from(50).unwrap()), &mut data); tx.recipient_data = data; tx.recipient = tx.contract_creation_address(); @@ -206,8 +206,8 @@ fn it_can_create_contract_from_transaction() { Serialize::serialize_to_writer(&owner, &mut data); Serialize::serialize_to_writer(&0u64.to_be_bytes(), &mut data); Serialize::serialize_to_writer(&100u64.to_be_bytes(), &mut data); - Serialize::serialize_to_writer(&Coin::try_from(50).unwrap(), &mut data); - Serialize::serialize_to_writer(&Coin::try_from(150).unwrap(), &mut data); + Serialize::serialize_to_writer(&CoinBe::from(Coin::try_from(50).unwrap()), &mut data); + Serialize::serialize_to_writer(&CoinBe::from(Coin::try_from(150).unwrap()), &mut data); tx.recipient_data = data; tx.recipient = tx.contract_creation_address(); diff --git a/primitives/src/coin.rs b/primitives/src/coin.rs index 813d85a2ae..36aac99888 100644 --- a/primitives/src/coin.rs +++ b/primitives/src/coin.rs @@ -259,7 +259,7 @@ impl FromStr for Coin { #[cfg(feature = "serde-derive")] mod serialization { - use nimiq_serde::SerializedSize; + use nimiq_serde::SerializedMaxSize; use serde::{ de::{Error as DeError, Unexpected}, ser::Error as SerError, @@ -268,8 +268,10 @@ mod serialization { use super::*; - impl SerializedSize for Coin { - const SIZE: usize = 8; + impl SerializedMaxSize for Coin { + // u64::MAX takes up 10 bytes, but Coin is limited to Javascript's Number.MAX_SAFE_INTEGER, + // which only takes up 8 bytes. + const MAX_SIZE: usize = 8; } impl Serialize for Coin { @@ -278,11 +280,7 @@ mod serialization { S: Serializer, { if self.0 <= Coin::MAX_SAFE_VALUE { - if serializer.is_human_readable() { - self.0.serialize(serializer) - } else { - nimiq_serde::fixint::be::serialize(&self.0, serializer) - } + self.0.serialize(serializer) } else { Err(S::Error::custom("Overflow detected for a Coin value")) } @@ -294,13 +292,7 @@ mod serialization { where D: Deserializer<'de>, { - let value: u64 = if deserializer.is_human_readable() { - Deserialize::deserialize(deserializer)? - } else { - // No need to fuzz, it just delegates to - // `nimiq_serde::fixint::be` and `Coin::try_from` looks sane. - nimiq_serde::fixint::be::deserialize(deserializer)? - }; + let value: u64 = Deserialize::deserialize(deserializer)?; Coin::try_from(value).map_err(|_| { D::Error::invalid_value( Unexpected::Unsigned(value), @@ -322,3 +314,83 @@ mod serialization { } } } + +/// A newtype around [`Coin`] that serializes as a fixed-size integer in big-endian order. +#[derive(Debug, Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Default, Hash)] +pub struct CoinBe(Coin); + +#[cfg(feature = "serde-derive")] +mod serialization_fixint_be { + use nimiq_serde::SerializedSize; + use serde::{ + de::{Error as DeError, Unexpected}, + ser::Error as SerError, + Deserialize, Deserializer, Serialize, Serializer, + }; + + use super::*; + + impl SerializedSize for CoinBe { + const SIZE: usize = 8; + } + + impl Serialize for CoinBe { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + if serializer.is_human_readable() { + self.0.serialize(serializer) + } else if self.0 .0 <= Coin::MAX_SAFE_VALUE { + nimiq_serde::fixint::be::serialize(&self.0 .0, serializer) + } else { + Err(S::Error::custom("Overflow detected for a Coin value")) + } + } + } + + impl<'de> Deserialize<'de> for CoinBe { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let coin: Coin = if deserializer.is_human_readable() { + Deserialize::deserialize(deserializer)? + } else { + let value: u64 = nimiq_serde::fixint::be::deserialize(deserializer)?; + Coin::try_from(value).map_err(|_| { + D::Error::invalid_value( + Unexpected::Unsigned(value), + &"An u64 below the Coin maximum value", + ) + })? + }; + Ok(CoinBe(coin)) + } + } + + // Test must live here as we cannot create an out-of-range `CoinBe` from the + // outside. + #[test] + fn test_serialize_out_of_bounds() { + let mut vec = Vec::with_capacity(8); + let res = + nimiq_serde::Serialize::serialize_to_writer(&CoinBe(Coin(9007199254740992)), &mut vec); + match res { + Ok(_) => panic!("Didn't fail"), + Err(err) => assert_eq!(err.kind(), std::io::ErrorKind::Other), + } + } +} + +impl From for CoinBe { + fn from(coin: Coin) -> Self { + CoinBe(coin) + } +} + +impl From for Coin { + fn from(coin_be: CoinBe) -> Self { + coin_be.0 + } +} diff --git a/primitives/tests/coin/mod.rs b/primitives/tests/coin/mod.rs index a90540b5c8..7f7910c8bf 100644 --- a/primitives/tests/coin/mod.rs +++ b/primitives/tests/coin/mod.rs @@ -20,13 +20,13 @@ impl NonFailingTest { } static NON_FAILING_TESTS: [NonFailingTest; 7] = [ - NonFailingTest::new("0000000000000000", 0u64), - NonFailingTest::new("0000000000000001", 1u64), - NonFailingTest::new("0000000000000005", 5u64), - NonFailingTest::new("0000000100000005", 4294967301), - NonFailingTest::new("000000000001e240", 123456u64), - NonFailingTest::new("0000001234561234", 78187467316u64), - NonFailingTest::new("001fffffffffffff", Coin::MAX_SAFE_VALUE), + NonFailingTest::new("00", 0u64), + NonFailingTest::new("01", 1u64), + NonFailingTest::new("05", 5u64), + NonFailingTest::new("8580808010", 4294967301), + NonFailingTest::new("c0c407", 123456u64), + NonFailingTest::new("b4a4d8a2a302", 78187467316u64), + NonFailingTest::new("ffffffffffffff0f", Coin::MAX_SAFE_VALUE), ]; #[test] @@ -45,7 +45,7 @@ fn test_non_failing() { fn test_deserialize_out_of_bounds() { use nimiq_serde::DeserializeError; - match Coin::deserialize_from_vec(&hex::decode("0020000000000000").unwrap()) { + match Coin::deserialize_from_vec(&hex::decode("8080808080808010").unwrap()) { Ok(coin) => panic!("Instead of failing, got {}", coin), Err(err) => assert_eq!(err, DeserializeError::serde_custom()), } diff --git a/primitives/transaction/src/account/vesting_contract.rs b/primitives/transaction/src/account/vesting_contract.rs index aea461adef..3325bc1baf 100644 --- a/primitives/transaction/src/account/vesting_contract.rs +++ b/primitives/transaction/src/account/vesting_contract.rs @@ -1,5 +1,8 @@ use nimiq_keys::Address; -use nimiq_primitives::{account::AccountType, coin::Coin}; +use nimiq_primitives::{ + account::AccountType, + coin::{Coin, CoinBe}, +}; use nimiq_serde::{Deserialize, Serialize, SerializedSize}; use crate::{ @@ -77,9 +80,9 @@ pub struct CreationTransactionData { /// The frequency at which funds are released. pub time_step: u64, /// The amount released at each [`time_step`](Self::time_step). - pub step_amount: Coin, + pub step_amount: CoinBe, /// Initially locked balance. - pub total_amount: Coin, + pub total_amount: CoinBe, } #[derive(Deserialize, Serialize, SerializedSize)] @@ -98,7 +101,7 @@ struct CreationTransactionData24 { #[serde(with = "nimiq_serde::fixint::be")] #[serialize_size(fixed_size)] pub time_step: u64, - pub step_amount: Coin, + pub step_amount: CoinBe, } #[derive(Deserialize, Serialize, SerializedSize)] struct CreationTransactionData32 { @@ -109,8 +112,8 @@ struct CreationTransactionData32 { #[serde(with = "nimiq_serde::fixint::be")] #[serialize_size(fixed_size)] pub time_step: u64, - pub step_amount: Coin, - pub total_amount: Coin, + pub step_amount: CoinBe, + pub total_amount: CoinBe, } impl CreationTransactionData { @@ -124,8 +127,8 @@ impl CreationTransactionData { owner, start_time: 0, time_step, - step_amount: tx_value, - total_amount: tx_value, + step_amount: tx_value.into(), + total_amount: tx_value.into(), } } CreationTransactionData24::SIZE => { @@ -140,7 +143,7 @@ impl CreationTransactionData { start_time, time_step, step_amount, - total_amount: tx_value, + total_amount: tx_value.into(), } } CreationTransactionData32::SIZE => { diff --git a/primitives/transaction/src/lib.rs b/primitives/transaction/src/lib.rs index aed63af8cb..9eea258568 100644 --- a/primitives/transaction/src/lib.rs +++ b/primitives/transaction/src/lib.rs @@ -14,7 +14,10 @@ use nimiq_hash::{Blake2bHash, Hash, SerializeContent}; use nimiq_keys::{Address, PublicKey}; use nimiq_network_interface::network::Topic; use nimiq_primitives::{ - account::AccountType, coin::Coin, networks::NetworkId, policy::Policy, + account::AccountType, + coin::{Coin, CoinBe}, + networks::NetworkId, + policy::Policy, transaction::TransactionError, }; use nimiq_serde::{Deserialize, Serialize}; @@ -591,8 +594,8 @@ impl SerializeContent for Transaction { self.sender_type.serialize_to_writer(writer)?; self.recipient.serialize_to_writer(writer)?; self.recipient_type.serialize_to_writer(writer)?; - self.value.serialize_to_writer(writer)?; - self.fee.serialize_to_writer(writer)?; + CoinBe::from(self.value).serialize_to_writer(writer)?; + CoinBe::from(self.fee).serialize_to_writer(writer)?; writer.write_all(&self.validity_start_height.to_be_bytes())?; self.network_id.serialize_to_writer(writer)?; self.flags.serialize_to_writer(writer)?; diff --git a/primitives/transaction/src/reward.rs b/primitives/transaction/src/reward.rs index cb23150780..c4ba96c5ed 100644 --- a/primitives/transaction/src/reward.rs +++ b/primitives/transaction/src/reward.rs @@ -1,8 +1,8 @@ use nimiq_keys::Address; use nimiq_primitives::coin::Coin; -use nimiq_serde::{Deserialize, Serialize, SerializedSize}; +use nimiq_serde::{Deserialize, Serialize, SerializedMaxSize}; -#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, SerializedSize)] +#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, SerializedMaxSize)] pub struct RewardTransaction { /// The validator address of the rewarded validator. pub validator_address: Address, diff --git a/primitives/transaction/tests/serialization.rs b/primitives/transaction/tests/serialization.rs index 52862bf148..0d0d067ea7 100644 --- a/primitives/transaction/tests/serialization.rs +++ b/primitives/transaction/tests/serialization.rs @@ -9,9 +9,9 @@ use nimiq_test_log::test; use nimiq_transaction::*; use nimiq_utils::merkle::MerklePath; -const EXTENDED_TRANSACTION: &str = "014a88aaad038f9b8248865c4b9249efc554960e160000ad25610feb43d75307763d3f010822a757027429000000000746a52880000000000000000000000136c32a00e2010e4712ea5b1703873529dd195b2b8f014c295ab352a12e3332d8f30cfc2db9680480c77af04feb0d89bdb5d5d9432d4ca17866abf3b4d6c1a05fa0fbdaed056181eaff68db063c759a0964bceb5f262f7335ed97c5471e773429926c106eae50881b998c516581e6d93933bb92feb2edcdbdb1b118fc000f8f1df8715538840b79e74721c631efe0f9977ccd88773b022a07b3935f2e8546e20ed7f7e1a0c77da7a7e1737bf0625170610846792ea16bc0f6d8cf9ded8a9da1d467f4191a3a97d5fc17d08d699dfa486787f70eb09e2cdbd5b63fd1a8357e1cd24cd37aa2f3408400"; -const BASIC_TRANSACTION: &str = "00000222666efadc937148a6d61589ce6d4aeecca97fda4c32348d294eab582f14a0754d1260f15bea0e8fb07ab18f45301483599e34000000000000c350000000000000008a00019640023fecb82d3aef4be76853d5c5b263754b7d495d9838f6ae5df60cf3addd3512a82988db0056059c7a52ae15285983ef0db8229ae446c004559147686d28f0a30a"; -const INVALID_EXTENDED_TRANSACTION: &str = "014a88aaad038f9b8248865c4b9249efc554960e16000000ad25610feb43d75307763d3f010822a75702742900000000000746a52880000000000000000000000136c32a0500e20e4712ea5b1703873529dd195b2b8f014c295ab352a12e3332d8f30cfc2db9680480c77af04feb0d89bdb5d5d9432d4ca17866abf3b4d6c1a05fa0fbdaed056181eaff68db063c759a0964bceb5f262f7335ed97c5471e773429926c106eae50881b998c516581e6d93933bb92feb2edcdbdb1b118fc000f8f1df8715538840b79e74721c631efe0f9977ccd88773b022a07b3935f2e8546e20ed7f7e1a0c77da7a7e1737bf0625170610846792ea16bc0f6d8cf9ded8a9da1d467f4191a3a97d5fc17d08d699dfa486787f70eb09e2cdbd5b63fd1a8357e1cd24cd37aa2f3408400"; +const EXTENDED_TRANSACTION: &str = "014a88aaad038f9b8248865c4b9249efc554960e160000ad25610feb43d75307763d3f010822a75702742900008080a2a9eae80100000136c32a00e2010e4712ea5b1703873529dd195b2b8f014c295ab352a12e3332d8f30cfc2db9680480c77af04feb0d89bdb5d5d9432d4ca17866abf3b4d6c1a05fa0fbdaed056181eaff68db063c759a0964bceb5f262f7335ed97c5471e773429926c106eae50881b998c516581e6d93933bb92feb2edcdbdb1b118fc000f8f1df8715538840b79e74721c631efe0f9977ccd88773b022a07b3935f2e8546e20ed7f7e1a0c77da7a7e1737bf0625170610846792ea16bc0f6d8cf9ded8a9da1d467f4191a3a97d5fc17d08d699dfa486787f70eb09e2cdbd5b63fd1a8357e1cd24cd37aa2f3408400"; +const BASIC_TRANSACTION: &str = "00000222666efadc937148a6d61589ce6d4aeecca97fda4c32348d294eab582f14a0754d1260f15bea0e8fb07ab18f45301483599e34d086038a0100019640023fecb82d3aef4be76853d5c5b263754b7d495d9838f6ae5df60cf3addd3512a82988db0056059c7a52ae15285983ef0db8229ae446c004559147686d28f0a30a"; +const INVALID_EXTENDED_TRANSACTION: &str = "014a88aaad038f9b8248865c4b9249efc554960e16000000ad25610feb43d75307763d3f010822a7570274290000008080a2a9eae80100000136c32a0500e20e4712ea5b1703873529dd195b2b8f014c295ab352a12e3332d8f30cfc2db9680480c77af04feb0d89bdb5d5d9432d4ca17866abf3b4d6c1a05fa0fbdaed056181eaff68db063c759a0964bceb5f262f7335ed97c5471e773429926c106eae50881b998c516581e6d93933bb92feb2edcdbdb1b118fc000f8f1df8715538840b79e74721c631efe0f9977ccd88773b022a07b3935f2e8546e20ed7f7e1a0c77da7a7e1737bf0625170610846792ea16bc0f6d8cf9ded8a9da1d467f4191a3a97d5fc17d08d699dfa486787f70eb09e2cdbd5b63fd1a8357e1cd24cd37aa2f3408400"; #[test] fn it_can_deserialize_historic_transaction() { diff --git a/primitives/transaction/tests/staking_contract_verify.rs b/primitives/transaction/tests/staking_contract_verify.rs index 92f611ca4a..f642bee25f 100644 --- a/primitives/transaction/tests/staking_contract_verify.rs +++ b/primitives/transaction/tests/staking_contract_verify.rs @@ -94,8 +94,8 @@ fn create_validator() { None, ); - let tx_hex = "018c551fabc6e6e00c609c3f0313257ad7e835643c0000000000000000000000000000000000000000000103b40400b300481ddd7af6be3cf5c123b7af2c21f87f4ac808c8b0e622eb85826124a844713c60858b5c72adcf8b72b4dbea959d042769dcc93a0190e4b8aec92283548138833950aa214d920c17d3d19de27f6176d9fb21620edae76ad398670e17d5eba2f494b9b6901d457592ea68f9d35380c857ba44856ae037aff272ad6c1900442b426dde0bc53431e9ce5807f7ec4a05e71ce4a1e7e7b2511891521c4d3fd975764e3031ef646d48fa881ad88240813d40e533788f0dac2bc4d4c25db7b108c67dd28b7ec4c240cdc044badcaed7860a5d3da42ef860ed25a6db9c07be000a7f504f6d1b24ac81642206d5996b20749a156d7b39f851e60f228b19eef3fb3547469f03fc9764f5f68bc88e187ffee0f43f169acde847c78ea88029cdb19b91dd9562d60b607dd0347d67a0e33286c8908e4e9579a42685da95f06a92010303030303030303030303030303030303030303010000000000000000000000000000000000000000000000000000000000000000b7561c15e53da2c482bfafddbf404f28b14ee2743e5cfe451c860da378b2ac23a651b574183d1287e2cea109943a34c44a7df9eb2fe5067c70f1c02bde900828c232a3d7736a278e0e8ac679bc2a1669f660c3810980526b7890f6e1708381007451b039e2f3fcafc3be7c6bd9e01fbc072c956a2b95a335cfb3cd3702335b530079dbb852cfc6b9571b4bbed6f0f302d8f1deef55640998c2145b56aed007fc1b92222a2778ed3b562f59b23570e6fd1dfb7af07cf08cd6e58f401aa7dba7c70d00000002540be40000000000000000640000000107006200b3adb13fe6887f6cdcb8c82c429f718fcdbbb27b2a19df7c1ea9814f19cd910500614003ac99ddcb92b8af398ff1b554d3b664f033a27b04fe9d265ac426d1fde1b2ea9fbee26bf0c8e62b89f273a984806d79de67e836c9fcec3455639b58480a"; - let tx_size = 731; + let tx_hex = "018c551fabc6e6e00c609c3f0313257ad7e835643c0000000000000000000000000000000000000000000103b40400b300481ddd7af6be3cf5c123b7af2c21f87f4ac808c8b0e622eb85826124a844713c60858b5c72adcf8b72b4dbea959d042769dcc93a0190e4b8aec92283548138833950aa214d920c17d3d19de27f6176d9fb21620edae76ad398670e17d5eba2f494b9b6901d457592ea68f9d35380c857ba44856ae037aff272ad6c1900442b426dde0bc53431e9ce5807f7ec4a05e71ce4a1e7e7b2511891521c4d3fd975764e3031ef646d48fa881ad88240813d40e533788f0dac2bc4d4c25db7b108c67dd28b7ec4c240cdc044badcaed7860a5d3da42ef860ed25a6db9c07be000a7f504f6d1b24ac81642206d5996b20749a156d7b39f851e60f228b19eef3fb3547469f03fc9764f5f68bc88e187ffee0f43f169acde847c78ea88029cdb19b91dd9562d60b607dd0347d67a0e33286c8908e4e9579a42685da95f06a92010303030303030303030303030303030303030303010000000000000000000000000000000000000000000000000000000000000000b7561c15e53da2c482bfafddbf404f28b14ee2743e5cfe451c860da378b2ac23a651b574183d1287e2cea109943a34c44a7df9eb2fe5067c70f1c02bde900828c232a3d7736a278e0e8ac679bc2a1669f660c3810980526b7890f6e1708381007451b039e2f3fcafc3be7c6bd9e01fbc072c956a2b95a335cfb3cd3702335b530079dbb852cfc6b9571b4bbed6f0f302d8f1deef55640998c2145b56aed007fc1b92222a2778ed3b562f59b23570e6fd1dfb7af07cf08cd6e58f401aa7dba7c70d80c8afa025640000000107006200b3adb13fe6887f6cdcb8c82c429f718fcdbbb27b2a19df7c1ea9814f19cd910500614003ac99ddcb92b8af398ff1b554d3b664f033a27b04fe9d265ac426d1fde1b2ea9fbee26bf0c8e62b89f273a984806d79de67e836c9fcec3455639b58480a"; + let tx_size = 721; let mut ser_tx: Vec = Vec::with_capacity(tx_size); assert_eq!(tx_size, tx.serialized_size()); @@ -204,8 +204,8 @@ fn update_validator() { None, ); - let tx_hex = "018c551fabc6e6e00c609c3f0313257ad7e835643c0000000000000000000000000000000000000000000103b9040101b300481ddd7af6be3cf5c123b7af2c21f87f4ac808c8b0e622eb85826124a84401713c60858b5c72adcf8b72b4dbea959d042769dcc93a0190e4b8aec92283548138833950aa214d920c17d3d19de27f6176d9fb21620edae76ad398670e17d5eba2f494b9b6901d457592ea68f9d35380c857ba44856ae037aff272ad6c1900442b426dde0bc53431e9ce5807f7ec4a05e71ce4a1e7e7b2511891521c4d3fd975764e3031ef646d48fa881ad88240813d40e533788f0dac2bc4d4c25db7b108c67dd28b7ec4c240cdc044badcaed7860a5d3da42ef860ed25a6db9c07be000a7f504f6d1b24ac81642206d5996b20749a156d7b39f851e60f228b19eef3fb3547469f03fc9764f5f68bc88e187ffee0f43f169acde847c78ea88029cdb19b91dd9562d60b607dd0347d67a0e33286c8908e4e9579a42685da95f06a92010103030303030303030303030303030303030303030101000000000000000000000000000000000000000000000000000000000000000001b7561c15e53da2c482bfafddbf404f28b14ee2743e5cfe451c860da378b2ac23a651b574183d1287e2cea109943a34c44a7df9eb2fe5067c70f1c02bde900828c232a3d7736a278e0e8ac679bc2a1669f660c3810980526b7890f6e1708381007451b039e2f3fcafc3be7c6bd9e01fbc072c956a2b95a335cfb3cd3702335b5300ff327a38d36a5a3aa0052a3c761fd4f820b4289f19522a299004c747676e364522b24317a332bd65f9dcee8a207e7ef5096f7a09c15155a9f3159ca623226306000000000000000000000000000000640000000107026200b3adb13fe6887f6cdcb8c82c429f718fcdbbb27b2a19df7c1ea9814f19cd910500da1106e3cc1137a33b7a34101d6a15ad12357280b5d8e1de39702f2890e9f0d597f2e14b2f0e5b45dd6f5fbe9a3e9112b8d3463f1fdd79f77a468386ff916b0a"; - let tx_size = 736; + let tx_hex = "018c551fabc6e6e00c609c3f0313257ad7e835643c0000000000000000000000000000000000000000000103b9040101b300481ddd7af6be3cf5c123b7af2c21f87f4ac808c8b0e622eb85826124a84401713c60858b5c72adcf8b72b4dbea959d042769dcc93a0190e4b8aec92283548138833950aa214d920c17d3d19de27f6176d9fb21620edae76ad398670e17d5eba2f494b9b6901d457592ea68f9d35380c857ba44856ae037aff272ad6c1900442b426dde0bc53431e9ce5807f7ec4a05e71ce4a1e7e7b2511891521c4d3fd975764e3031ef646d48fa881ad88240813d40e533788f0dac2bc4d4c25db7b108c67dd28b7ec4c240cdc044badcaed7860a5d3da42ef860ed25a6db9c07be000a7f504f6d1b24ac81642206d5996b20749a156d7b39f851e60f228b19eef3fb3547469f03fc9764f5f68bc88e187ffee0f43f169acde847c78ea88029cdb19b91dd9562d60b607dd0347d67a0e33286c8908e4e9579a42685da95f06a92010103030303030303030303030303030303030303030101000000000000000000000000000000000000000000000000000000000000000001b7561c15e53da2c482bfafddbf404f28b14ee2743e5cfe451c860da378b2ac23a651b574183d1287e2cea109943a34c44a7df9eb2fe5067c70f1c02bde900828c232a3d7736a278e0e8ac679bc2a1669f660c3810980526b7890f6e1708381007451b039e2f3fcafc3be7c6bd9e01fbc072c956a2b95a335cfb3cd3702335b5300ff327a38d36a5a3aa0052a3c761fd4f820b4289f19522a299004c747676e364522b24317a332bd65f9dcee8a207e7ef5096f7a09c15155a9f3159ca62322630600640000000107026200b3adb13fe6887f6cdcb8c82c429f718fcdbbb27b2a19df7c1ea9814f19cd910500da1106e3cc1137a33b7a34101d6a15ad12357280b5d8e1de39702f2890e9f0d597f2e14b2f0e5b45dd6f5fbe9a3e9112b8d3463f1fdd79f77a468386ff916b0a"; + let tx_size = 722; let mut ser_tx: Vec = Vec::with_capacity(tx_size); assert_eq!(tx_size, tx.serialized_size()); @@ -312,8 +312,8 @@ fn deactivate_validator() { None, ); - let tx_hex = "018c551fabc6e6e00c609c3f0313257ad7e835643c0000000000000000000000000000000000000000000103770283fa05dbe31f85e719f4c4fd67ebdba2e444d9f800b300481ddd7af6be3cf5c123b7af2c21f87f4ac808c8b0e622eb85826124a84400ba13522884a716f0688ceeeaabf37e91cbee9798d05ff5f03d3eb2f0ff280f20f83c1327d1f2a908fcecebdfa194283150dde38627c0b91e2c5175c2bef98102000000000000000000000000000000640000000107026200b3adb13fe6887f6cdcb8c82c429f718fcdbbb27b2a19df7c1ea9814f19cd910500cc3d26a7c19aca652c22aadb2fee3f104b35dff438d4a4ae3d46f44e762027c3fad96ed24a35460d14be9c5a17eb9b120560ce58a002724ccc2b9dd49c6d510c"; - let tx_size = 285; + let tx_hex = "018c551fabc6e6e00c609c3f0313257ad7e835643c0000000000000000000000000000000000000000000103770283fa05dbe31f85e719f4c4fd67ebdba2e444d9f800b300481ddd7af6be3cf5c123b7af2c21f87f4ac808c8b0e622eb85826124a84400ba13522884a716f0688ceeeaabf37e91cbee9798d05ff5f03d3eb2f0ff280f20f83c1327d1f2a908fcecebdfa194283150dde38627c0b91e2c5175c2bef9810200640000000107026200b3adb13fe6887f6cdcb8c82c429f718fcdbbb27b2a19df7c1ea9814f19cd910500cc3d26a7c19aca652c22aadb2fee3f104b35dff438d4a4ae3d46f44e762027c3fad96ed24a35460d14be9c5a17eb9b120560ce58a002724ccc2b9dd49c6d510c"; + let tx_size = 271; let mut ser_tx: Vec = Vec::with_capacity(tx_size); assert_eq!(tx_size, tx.serialized_size()); @@ -369,8 +369,8 @@ fn reactivate_validator() { None, ); - let tx_hex = "018c551fabc6e6e00c609c3f0313257ad7e835643c0000000000000000000000000000000000000000000103770383fa05dbe31f85e719f4c4fd67ebdba2e444d9f800b300481ddd7af6be3cf5c123b7af2c21f87f4ac808c8b0e622eb85826124a844005fe2ead749549fb7d329ef9f99bf5693c87977fd3253400581a8b832d2bef6a705d6fe76ba1e875ade5f0185396cde41622497a9761959adf7ccfca99bcfff07000000000000000000000000000000640000000107026200b3adb13fe6887f6cdcb8c82c429f718fcdbbb27b2a19df7c1ea9814f19cd91050000f1a9c7bc1883df69d8dab50661ea56a22b64764b0206fef6f533a47504d924c6574f493f591519ea633e5c7a24fa79f13384d571e5c466c6ca7b0fe8b3100f"; - let tx_size = 285; + let tx_hex = "018c551fabc6e6e00c609c3f0313257ad7e835643c0000000000000000000000000000000000000000000103770383fa05dbe31f85e719f4c4fd67ebdba2e444d9f800b300481ddd7af6be3cf5c123b7af2c21f87f4ac808c8b0e622eb85826124a844005fe2ead749549fb7d329ef9f99bf5693c87977fd3253400581a8b832d2bef6a705d6fe76ba1e875ade5f0185396cde41622497a9761959adf7ccfca99bcfff0700640000000107026200b3adb13fe6887f6cdcb8c82c429f718fcdbbb27b2a19df7c1ea9814f19cd91050000f1a9c7bc1883df69d8dab50661ea56a22b64764b0206fef6f533a47504d924c6574f493f591519ea633e5c7a24fa79f13384d571e5c466c6ca7b0fe8b3100f"; + let tx_size = 271; let mut ser_tx: Vec = Vec::with_capacity(tx_size); assert_eq!(tx_size, tx.serialized_size()); @@ -425,8 +425,8 @@ fn retire_validator() { None, ); - let tx_hex = "018c551fabc6e6e00c609c3f0313257ad7e835643c0000000000000000000000000000000000000000000103630400b300481ddd7af6be3cf5c123b7af2c21f87f4ac808c8b0e622eb85826124a84400fd7e470f62d7d89158109c0440c2815a6829a962ee838b02fb69840a5b8e6b8b58fe830981328064a45053b28b9abe7ace71838f60c5881b3d352c02f2067908000000000000000000000000000000640000000107026200b3adb13fe6887f6cdcb8c82c429f718fcdbbb27b2a19df7c1ea9814f19cd9105003a86c09bd9dc35a226f2444c4c5ce564fda1958571682aaf7548b210d41969c4b2c85b662f5769b9c5916e5abd3b841355fd011ae7b19b7553693621ba76f805"; - let tx_size = 265; + let tx_hex = "018c551fabc6e6e00c609c3f0313257ad7e835643c0000000000000000000000000000000000000000000103630400b300481ddd7af6be3cf5c123b7af2c21f87f4ac808c8b0e622eb85826124a84400fd7e470f62d7d89158109c0440c2815a6829a962ee838b02fb69840a5b8e6b8b58fe830981328064a45053b28b9abe7ace71838f60c5881b3d352c02f206790800640000000107026200b3adb13fe6887f6cdcb8c82c429f718fcdbbb27b2a19df7c1ea9814f19cd9105003a86c09bd9dc35a226f2444c4c5ce564fda1958571682aaf7548b210d41969c4b2c85b662f5769b9c5916e5abd3b841355fd011ae7b19b7553693621ba76f805"; + let tx_size = 251; let mut ser_tx: Vec = Vec::with_capacity(tx_size); assert_eq!(tx_size, tx.serialized_size()); @@ -481,8 +481,8 @@ fn create_staker() { None, ); - let tx_hex = "018c551fabc6e6e00c609c3f0313257ad7e835643c000000000000000000000000000000000000000000010378050183fa05dbe31f85e719f4c4fd67ebdba2e444d9f800b3adb13fe6887f6cdcb8c82c429f718fcdbbb27b2a19df7c1ea9814f19cd91050078848bb51c29e0cfa5ef76c851f65366dc788e9f9b8c1cba28972eb9aaa4a2464bb43262985ef0703568865f765460a83e8694b25665f0bc249de3096464df0b000000000098968000000000000000640000000107006200b3adb13fe6887f6cdcb8c82c429f718fcdbbb27b2a19df7c1ea9814f19cd91050032e29c914094d23a4ce65921041227208820b24551b97e72703c8bcc8f3084ba4680e9e8fd926462f021c4a54dce5f864ba2112ba032afcb68a82935cc402503"; - let tx_size = 286; + let tx_hex = "018c551fabc6e6e00c609c3f0313257ad7e835643c000000000000000000000000000000000000000000010378050183fa05dbe31f85e719f4c4fd67ebdba2e444d9f800b3adb13fe6887f6cdcb8c82c429f718fcdbbb27b2a19df7c1ea9814f19cd91050078848bb51c29e0cfa5ef76c851f65366dc788e9f9b8c1cba28972eb9aaa4a2464bb43262985ef0703568865f765460a83e8694b25665f0bc249de3096464df0b80ade204640000000107006200b3adb13fe6887f6cdcb8c82c429f718fcdbbb27b2a19df7c1ea9814f19cd91050032e29c914094d23a4ce65921041227208820b24551b97e72703c8bcc8f3084ba4680e9e8fd926462f021c4a54dce5f864ba2112ba032afcb68a82935cc402503"; + let tx_size = 275; let mut ser_tx: Vec = Vec::with_capacity(tx_size); assert_eq!(tx_size, tx.serialized_size()); @@ -536,8 +536,8 @@ fn stake() { None, ); - let tx_hex = "018c551fabc6e6e00c609c3f0313257ad7e835643c000000000000000000000000000000000000000000010315068c551fabc6e6e00c609c3f0313257ad7e835643c000000000000006400000000000000640000000107006200b3adb13fe6887f6cdcb8c82c429f718fcdbbb27b2a19df7c1ea9814f19cd910500f5d801f531117483118108b30cd606301a424ba63147f3f0a2e085bd655fd15c8eafb971a39883fc9da3711d7ac474cd6047eed7791ec6e00c6ed1a464fddb01"; - let tx_size = 187; + let tx_hex = "018c551fabc6e6e00c609c3f0313257ad7e835643c000000000000000000000000000000000000000000010315068c551fabc6e6e00c609c3f0313257ad7e835643c64640000000107006200b3adb13fe6887f6cdcb8c82c429f718fcdbbb27b2a19df7c1ea9814f19cd910500f5d801f531117483118108b30cd606301a424ba63147f3f0a2e085bd655fd15c8eafb971a39883fc9da3711d7ac474cd6047eed7791ec6e00c6ed1a464fddb01"; + let tx_size = 173; let mut ser_tx: Vec = Vec::with_capacity(tx_size); assert_eq!(tx_size, tx.serialized_size()); @@ -568,8 +568,8 @@ fn update_staker() { None, ); - let tx_hex = "018c551fabc6e6e00c609c3f0313257ad7e835643c000000000000000000000000000000000000000000010379070183fa05dbe31f85e719f4c4fd67ebdba2e444d9f80000b3adb13fe6887f6cdcb8c82c429f718fcdbbb27b2a19df7c1ea9814f19cd91050086b3e9305b69d7228967569082a4b870c9dea0ea5e83c4e1f2866f492bc2c974ecc92ea595e23825b3ea7846a85af397c38c32689c3e38c5de244845a2f68b0b000000000000000000000000000000640000000107026200b3adb13fe6887f6cdcb8c82c429f718fcdbbb27b2a19df7c1ea9814f19cd910500aad587075d132f1b28335360fa5fed46c9fafd56119606981891cf7f9eec58dcdaebb55bb52a253e9c0cc5e14bb83977b99f4a15f15f48ecce8399796c618606"; - let tx_size = 287; + let tx_hex = "018c551fabc6e6e00c609c3f0313257ad7e835643c000000000000000000000000000000000000000000010379070183fa05dbe31f85e719f4c4fd67ebdba2e444d9f80000b3adb13fe6887f6cdcb8c82c429f718fcdbbb27b2a19df7c1ea9814f19cd91050086b3e9305b69d7228967569082a4b870c9dea0ea5e83c4e1f2866f492bc2c974ecc92ea595e23825b3ea7846a85af397c38c32689c3e38c5de244845a2f68b0b00640000000107026200b3adb13fe6887f6cdcb8c82c429f718fcdbbb27b2a19df7c1ea9814f19cd910500aad587075d132f1b28335360fa5fed46c9fafd56119606981891cf7f9eec58dcdaebb55bb52a253e9c0cc5e14bb83977b99f4a15f15f48ecce8399796c618606"; + let tx_size = 273; let mut ser_tx: Vec = Vec::with_capacity(tx_size); assert_eq!(tx_size, tx.serialized_size()); @@ -615,8 +615,8 @@ fn delete_validator() { // Test serialization and deserialization. let tx = make_delete_validator_tx(Policy::VALIDATOR_DEPOSIT - 100, false); - let tx_hex = "0100000000000000000000000000000000000000010301008c551fabc6e6e00c609c3f0313257ad7e835643c000000000002540be39c000000000000006400000001070062007451b039e2f3fcafc3be7c6bd9e01fbc072c956a2b95a335cfb3cd3702335b53001450cfe0a974b19c7564411fa9d075d28170a76a8f9f40158be8fa86bfd391e389a7f49e243680947006569dff74dcc09721dd861b8977cf66343a4c6c9fab06"; - let tx_size = 167; + let tx_hex = "0100000000000000000000000000000000000000010301008c551fabc6e6e00c609c3f0313257ad7e835643c00009cc7afa0256400000001070062007451b039e2f3fcafc3be7c6bd9e01fbc072c956a2b95a335cfb3cd3702335b53001450cfe0a974b19c7564411fa9d075d28170a76a8f9f40158be8fa86bfd391e389a7f49e243680947006569dff74dcc09721dd861b8977cf66343a4c6c9fab06"; + let tx_size = 157; let mut ser_tx: Vec = Vec::with_capacity(tx_size); assert_eq!(tx_size, tx.serialized_size()); @@ -653,8 +653,8 @@ fn remove_stake() { // Test serialization and deserialization. let tx = make_remove_stake_tx(false); - let tx_hex = "0100000000000000000000000000000000000000010301018c551fabc6e6e00c609c3f0313257ad7e835643c000000000000000003e8000000000000006400000001070062007451b039e2f3fcafc3be7c6bd9e01fbc072c956a2b95a335cfb3cd3702335b5300cdb476051adbdb069a880d475aefc327f91e760abd588317bc801b2b17292e26197bfb980afcd3d3351d21a48c5e6edd00a215cff9d4bd9b881099b4749ee100"; - let tx_size = 167; + let tx_hex = "0100000000000000000000000000000000000000010301018c551fabc6e6e00c609c3f0313257ad7e835643c0000e8076400000001070062007451b039e2f3fcafc3be7c6bd9e01fbc072c956a2b95a335cfb3cd3702335b5300cdb476051adbdb069a880d475aefc327f91e760abd588317bc801b2b17292e26197bfb980afcd3d3351d21a48c5e6edd00a215cff9d4bd9b881099b4749ee100"; + let tx_size = 154; let mut ser_tx: Vec = Vec::with_capacity(tx_size); assert_eq!(tx_size, tx.serialized_size()); diff --git a/primitives/transaction/tests/vesting_contract_verify.rs b/primitives/transaction/tests/vesting_contract_verify.rs index 3060dffb4f..90345e779e 100644 --- a/primitives/transaction/tests/vesting_contract_verify.rs +++ b/primitives/transaction/tests/vesting_contract_verify.rs @@ -1,6 +1,9 @@ use nimiq_keys::{Address, KeyPair, PrivateKey}; use nimiq_primitives::{ - account::AccountType, coin::Coin, networks::NetworkId, transaction::TransactionError, + account::AccountType, + coin::{Coin, CoinBe}, + networks::NetworkId, + transaction::TransactionError, }; use nimiq_serde::{Deserialize, DeserializeError, Serialize}; use nimiq_transaction::{ @@ -69,7 +72,7 @@ fn it_can_verify_creation_transaction() { Serialize::serialize_to_writer(&sender, &mut data); Serialize::serialize_to_writer(&100u64.to_be_bytes(), &mut data); Serialize::serialize_to_writer(&100u64.to_be_bytes(), &mut data); - Serialize::serialize_to_writer(&Coin::try_from(100).unwrap(), &mut data); + Serialize::serialize_to_writer(&CoinBe::from(Coin::try_from(100).unwrap()), &mut data); transaction.recipient_data = data; transaction.recipient = transaction.contract_creation_address(); assert_eq!( @@ -83,8 +86,8 @@ fn it_can_verify_creation_transaction() { Serialize::serialize_to_writer(&sender, &mut data); Serialize::serialize_to_writer(&100u64.to_be_bytes(), &mut data); Serialize::serialize_to_writer(&100u64.to_be_bytes(), &mut data); - Serialize::serialize_to_writer(&Coin::try_from(100).unwrap(), &mut data); - Serialize::serialize_to_writer(&Coin::try_from(100).unwrap(), &mut data); + Serialize::serialize_to_writer(&CoinBe::from(Coin::try_from(100).unwrap()), &mut data); + Serialize::serialize_to_writer(&CoinBe::from(Coin::try_from(100).unwrap()), &mut data); transaction.recipient_data = data; transaction.recipient = transaction.contract_creation_address(); assert_eq!( @@ -97,8 +100,8 @@ fn it_can_verify_creation_transaction() { owner: Address::from([0u8; 20]), start_time: 100, time_step: 0, - step_amount: Coin::try_from(1000).unwrap(), - total_amount: Coin::try_from(100).unwrap(), + step_amount: Coin::try_from(1000).unwrap().into(), + total_amount: Coin::try_from(100).unwrap().into(), }; transaction.recipient_data = data.to_tx_data(); transaction.recipient = transaction.contract_creation_address(); diff --git a/test-utils/src/transactions.rs b/test-utils/src/transactions.rs index d8cb01d585..f05e3aa3cd 100644 --- a/test-utils/src/transactions.rs +++ b/test-utils/src/transactions.rs @@ -567,8 +567,8 @@ impl TransactionsGenerator { owner: Address(self.rng.gen()), start_time: 0, time_step: 1, - step_amount: balance, - total_amount: balance, + step_amount: balance.into(), + total_amount: balance.into(), }, }, IncomingType::CreateHTLC => IncomingAccountData::Htlc { diff --git a/transaction-builder/src/recipient/vesting_contract.rs b/transaction-builder/src/recipient/vesting_contract.rs index 96a136d031..2af00e6eab 100644 --- a/transaction-builder/src/recipient/vesting_contract.rs +++ b/transaction-builder/src/recipient/vesting_contract.rs @@ -174,10 +174,12 @@ impl VestingRecipientBuilder { .ok_or(VestingRecipientBuilderError::NoTimeStep)?, step_amount: self .step_amount - .ok_or(VestingRecipientBuilderError::NoStepAmount)?, + .ok_or(VestingRecipientBuilderError::NoStepAmount)? + .into(), total_amount: self .total_amount - .ok_or(VestingRecipientBuilderError::NoTotalAmount)?, + .ok_or(VestingRecipientBuilderError::NoTotalAmount)? + .into(), }, }) } diff --git a/transaction-builder/tests/vesting_contract.rs b/transaction-builder/tests/vesting_contract.rs index 1c593a7d16..d1d8d0ec0f 100644 --- a/transaction-builder/tests/vesting_contract.rs +++ b/transaction-builder/tests/vesting_contract.rs @@ -1,7 +1,11 @@ use std::convert::{TryFrom, TryInto}; use nimiq_keys::{Address, KeyPair, PrivateKey}; -use nimiq_primitives::{account::AccountType, coin::Coin, networks::NetworkId}; +use nimiq_primitives::{ + account::AccountType, + coin::{Coin, CoinBe}, + networks::NetworkId, +}; use nimiq_serde::{Deserialize, Serialize}; use nimiq_test_log::test; use nimiq_transaction::{SignatureProof, Transaction}; @@ -51,7 +55,7 @@ fn it_can_create_creation_transaction() { Serialize::serialize_to_writer(&sender.address(), &mut data); Serialize::serialize_to_writer(&100u64.to_be_bytes(), &mut data); Serialize::serialize_to_writer(&100u64.to_be_bytes(), &mut data); - Serialize::serialize_to_writer(&Coin::try_from(100).unwrap(), &mut data); + Serialize::serialize_to_writer(&CoinBe::from(Coin::try_from(100).unwrap()), &mut data); transaction.recipient_data = data; transaction.recipient = transaction.contract_creation_address(); @@ -80,8 +84,8 @@ fn it_can_create_creation_transaction() { Serialize::serialize_to_writer(&sender.address(), &mut data); Serialize::serialize_to_writer(&100u64.to_be_bytes(), &mut data); Serialize::serialize_to_writer(&100u64.to_be_bytes(), &mut data); - Serialize::serialize_to_writer(&Coin::try_from(100).unwrap(), &mut data); - Serialize::serialize_to_writer(&Coin::try_from(101).unwrap(), &mut data); + Serialize::serialize_to_writer(&CoinBe::from(Coin::try_from(100).unwrap()), &mut data); + Serialize::serialize_to_writer(&CoinBe::from(Coin::try_from(101).unwrap()), &mut data); transaction.recipient_data = data; transaction.recipient = transaction.contract_creation_address(); diff --git a/web-client/src/transaction.rs b/web-client/src/transaction.rs index 2e79446b49..012d884562 100644 --- a/web-client/src/transaction.rs +++ b/web-client/src/transaction.rs @@ -586,7 +586,7 @@ impl Transaction { raw: hex::encode(self.recipient_data()), owner: data.owner.to_user_friendly_address(), start_time: data.start_time, - step_amount: data.step_amount.into(), + step_amount: Into::::into(data.step_amount).into(), time_step: data.time_step, }) } else if self.inner.recipient_type == AccountType::HTLC {