update transaction

api calls throughout
This commit is contained in:
Yeastplume
2022-11-22 13:25:44 +00:00
parent 746c1831c5
commit cd3203be23
20 changed files with 188 additions and 85 deletions
+1
View File
@@ -82,6 +82,7 @@ where
&mut *w,
None,
Some(ret_slate.id),
None,
Some(&parent_key_id),
use_test_rng,
)?;
+11 -2
View File
@@ -334,7 +334,14 @@ where
wallet_lock!(wallet_inst, w);
let parent_key_id = w.parent_key_id();
let txs = updater::retrieve_txs(&mut **w, tx_id, tx_slate_id, Some(&parent_key_id), false)?;
let txs = updater::retrieve_txs(
&mut **w,
tx_id,
tx_slate_id,
query_args,
Some(&parent_key_id),
false,
)?;
Ok((validated, txs))
}
@@ -405,6 +412,7 @@ where
refresh_from_node,
tx_id,
tx_slate_id,
None,
)?;
if txs.1.len() != 1 {
return Err(Error::PaymentProofRetrieval(
@@ -663,6 +671,7 @@ where
&mut *w,
None,
Some(ret_slate.id),
None,
Some(&parent_key_id),
use_test_rng,
)?;
@@ -1123,7 +1132,7 @@ where
// Step 2: Update outstanding transactions with no change outputs by kernel
let mut txs = {
wallet_lock!(wallet_inst, w);
updater::retrieve_txs(&mut **w, None, None, Some(&parent_key_id), true)?
updater::retrieve_txs(&mut **w, None, None, None, Some(&parent_key_id), true)?
};
result = update_txs_via_kernel(wallet_inst.clone(), keychain_mask, &mut txs)?;
if !result {
+59 -1
View File
@@ -23,6 +23,7 @@ use crate::slate_versions::SlateVersion;
use crate::types::OutputData;
use crate::SlatepackAddress;
use chrono::prelude::*;
use ed25519_dalek::Signature as DalekSignature;
/// Type for storing amounts (in nanogrins).
@@ -148,6 +149,32 @@ impl Default for IssueInvoiceTxArgs {
}
}
/// Sort tx retrieval order
#[derive(Clone, Serialize, Deserialize)]
pub enum RetrieveTxQuerySortOrder {
/// Ascending
Asc,
/// Descending
Desc,
}
/// Valid sort fields for a transaction list retrieval query
#[derive(Clone, Serialize, Deserialize)]
pub enum RetrieveTxQuerySortField {
/// Transaction Id
Id,
/// Creation Timestamp
CreationTimestamp,
/// Confirmation Timestamp
ConfirmationTimestamp,
/// TotalAmount (AmountCredited-AmountDebited)
TotalAmount,
/// Amount Credited
AmountCredited,
/// Amount Debited
AmountDebited,
}
/// Retrieve Transaction List Pagination Arguments
#[derive(Clone, Serialize, Deserialize)]
pub struct RetrieveTxQueryArgs {
@@ -163,6 +190,27 @@ pub struct RetrieveTxQueryArgs {
pub limit: Option<u32>,
/// whether to include cancelled transactions in the returned set
pub include_cancelled: Option<bool>,
/// whether to only consider non-cancelled, outstanding transactions
pub include_outstanding_only: Option<bool>,
/// whether to only consider confirmed-only transactions
pub include_confirmed_only: Option<bool>,
/// lower bound on the total amount (amount_credited - amount_debited), inclusive
pub min_amount_inc: Option<u64>,
/// higher bound on the total amount (amount_credited - amount_debited), inclusive
pub max_amount_inc: Option<u64>,
/// lower bound on the creation timestamp, inclusive
pub min_creation_timestamp_inc: Option<DateTime<Utc>>,
/// higher bound on on the creation timestamp, inclusive
pub max_creation_timestamp_inc: Option<DateTime<Utc>>,
/// lower bound on the confirmation timestamp, inclusive
pub min_confirmed_timestamp_inc: Option<DateTime<Utc>>,
/// higher bound on the confirmation timestamp, inclusive
pub max_confirmed_timestamp_inc: Option<DateTime<Utc>>,
/// Field within the tranasction list on which to sort
/// defaults to ID if not present
pub sort_field: Option<RetrieveTxQuerySortField>,
/// Sort order, defaults to DESC if not present (most recent is first)
pub sort_order: Option<RetrieveTxQuerySortOrder>,
}
impl Default for RetrieveTxQueryArgs {
@@ -171,7 +219,17 @@ impl Default for RetrieveTxQueryArgs {
before_id_inc: None,
after_id_inc: None,
limit: None,
include_cancelled: None,
include_cancelled: Some(true),
include_outstanding_only: Some(false),
include_confirmed_only: Some(false),
min_amount_inc: None,
max_amount_inc: None,
min_creation_timestamp_inc: None,
max_creation_timestamp_inc: None,
min_confirmed_timestamp_inc: None,
max_confirmed_timestamp_inc: None,
sort_field: Some(RetrieveTxQuerySortField::Id),
sort_order: Some(RetrieveTxQuerySortOrder::Desc),
}
}
}