Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add destinations field to GotTransfer, Fix WalletClient::get_transfers() where Out=true #128

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,14 @@ impl<'de> Deserialize<'de> for TransferHeight {
}
}

/// Destinations for `GetTransferCategory::Out : true`
#[derive(Clone, Debug, Eq, PartialEq, Deserialize)]
pub struct Destination{
pub address: Address,
#[serde(with = "amount::serde::as_pico")]
pub amount: Amount,
}

/// Return type of wallet `get_transfer` and `get_transfers`.
#[derive(Clone, Debug, Eq, PartialEq, Deserialize)]
pub struct GotTransfer {
Expand All @@ -510,7 +518,9 @@ pub struct GotTransfer {
/// Height of the first block that confirmed this transfer (0 if not mined yet).
pub height: TransferHeight,
/// Note about this transfer.
pub note: String,
pub note: String,
/// Destinations for this transfer
pub destinations: Option<Vec<Destination>>,
/// Payment ID for this transfer.
pub payment_id: HashString<PaymentId>,
/// JSON object containing the major & minor subaddress index.
Expand Down Expand Up @@ -607,7 +617,7 @@ mod tests {
orphan_status: true,
prev_hash: HashString(BlockHash::repeat_byte(12)),
reward: Amount::from_pico(12),
timestamp: DateTime::<Utc>::from_utc(
timestamp: DateTime::from_naive_utc_and_offset(
NaiveDateTime::from_timestamp_opt(61, 0).unwrap(),
Utc,
),
Expand All @@ -626,7 +636,7 @@ mod tests {
orphan_status: true,
prev_hash: BlockHash::repeat_byte(12),
reward: Amount::from_pico(12),
timestamp: DateTime::<Utc>::from_utc(
timestamp: DateTime::from_naive_utc_and_offset(
NaiveDateTime::from_timestamp_opt(61, 0).unwrap(),
Utc,
),
Expand Down
16 changes: 12 additions & 4 deletions tests/clients_tests/all_clients_interaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ use monero::{
Address, Amount, Hash, KeyPair, Network, ViewPair,
};
use monero_rpc::{
BalanceData, BlockHeightFilter, GetTransfersCategory, GetTransfersSelector, GotTransfer,
HashString, IncomingTransfer, IncomingTransfers, KeyImageImportResponse, Payment,
PrivateKeyType, SubaddressBalanceData, SweepAllArgs, Transaction, TransactionsResponse,
TransferHeight, TransferOptions, TransferPriority, TransferType,
BalanceData, BlockHeightFilter, Destination, GetTransfersCategory, GetTransfersSelector,
GotTransfer, HashString, IncomingTransfer, IncomingTransfers, KeyImageImportResponse,
Payment, PrivateKeyType, SubaddressBalanceData, SweepAllArgs, Transaction,
TransactionsResponse, TransferHeight, TransferOptions, TransferPriority, TransferType
};

use super::helpers;
Expand Down Expand Up @@ -454,6 +454,14 @@ pub async fn run() {
txid: HashString(transfer_1_data.tx_hash.0.as_ref().to_vec()),
transfer_type: GetTransfersCategory::Pending,
unlock_time: 0,
destinations: Some(
transfer_1_destination.clone()
.into_iter()
.fold(vec![], |mut acc, x|{
acc.push(Destination{ address: x.0, amount: x.1 });
acc
})
),
});
helpers::wallet::get_transfer_assert_got_transfer(
&wallet,
Expand Down
Loading