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

Meta tx #142

Open
wants to merge 6 commits into
base: sigma
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
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions cli/src/extensions/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ impl TransactionTypeExtension for TransactionKind {
match self {
TransactionKind::Incoming => style(s).green().to_string(),
TransactionKind::Outgoing => style(s).red().to_string(),
TransactionKind::Meta => style(s).dim().to_string(),
TransactionKind::External => style(s).red().to_string(),
TransactionKind::Batch => style(s).dim().to_string(),
TransactionKind::Reorg => style(s).dim().to_string(),
Expand Down Expand Up @@ -153,6 +154,7 @@ impl TransactionExtension for TransactionRecord {
}
}
TransactionData::Outgoing { fees, aggregate_input_value, transaction, payment_value, change_value, .. }
| TransactionData::Meta { fees, aggregate_input_value, transaction, payment_value, change_value, .. }
| TransactionData::Batch { fees, aggregate_input_value, transaction, payment_value, change_value, .. }
| TransactionData::TransferIncoming { fees, aggregate_input_value, transaction, payment_value, change_value, .. }
| TransactionData::TransferOutgoing { fees, aggregate_input_value, transaction, payment_value, change_value, .. } => {
Expand Down
2 changes: 1 addition & 1 deletion cli/src/modules/pskb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ impl Pskb {
}
let pskb = Self::parse_input_pskb(argv.first().unwrap().as_str())?;
let account = ctx.wallet().account()?;
match account.pskb_broadcast(&pskb).await {
match account.pskb_broadcast(&pskb, false).await {
Ok(sent) => tprintln!(ctx, "Sent transactions {:?}", sent),
Err(e) => terrorln!(ctx, "Send error {:?}", e),
}
Expand Down
1 change: 1 addition & 0 deletions wallet/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ workflow-node.workspace = true
workflow-rpc.workspace = true
workflow-store.workspace = true
workflow-wasm.workspace = true
workflow-http.workspace = true
xxhash-rust.workspace = true
zeroize.workspace = true
indexed_db_futures.workspace = true
Expand Down
15 changes: 8 additions & 7 deletions wallet/core/src/account/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ pub trait Account: AnySync + Send + Sync + 'static {
let mut ids = vec![];
while let Some(transaction) = stream.try_next().await? {
transaction.try_sign()?;
ids.push(transaction.try_submit(&self.wallet().rpc_api()).await?);
ids.push(transaction.try_submit(&self.wallet().rpc_api(), false).await?);

if let Some(notifier) = notifier.as_ref() {
notifier(&transaction);
Expand Down Expand Up @@ -370,7 +370,7 @@ pub trait Account: AnySync + Send + Sync + 'static {
let mut ids = vec![];
while let Some(transaction) = stream.try_next().await? {
transaction.try_sign()?;
ids.push(transaction.try_submit(&self.wallet().rpc_api()).await?);
ids.push(transaction.try_submit(&self.wallet().rpc_api(), false).await?);

if let Some(notifier) = notifier.as_ref() {
notifier(&transaction);
Expand Down Expand Up @@ -476,16 +476,17 @@ pub trait Account: AnySync + Send + Sync + 'static {
}
}

async fn pskb_broadcast(self: Arc<Self>, bundle: &Bundle) -> Result<Vec<Hash>, Error> {
async fn pskb_broadcast(self: Arc<Self>, bundle: &Bundle, is_meta_tx: bool) -> Result<Vec<Hash>, Error> {
let mut ids = Vec::new();
let mut stream = bundle_to_finalizer_stream(bundle);

while let Some(result) = stream.next().await {
match result {
Ok(pskt) => {
let change = self.change_address()?;
let transaction = pskt_to_pending_transaction(pskt, self.wallet().network_id()?, change)?;
ids.push(transaction.try_submit(&self.wallet().rpc_api()).await?);
let transaction =
pskt_to_pending_transaction(pskt, self.wallet().network_id()?, change, self.utxo_context().clone().into())?;
ids.push(transaction.try_submit(&self.wallet().rpc_api(), is_meta_tx).await?);
}
Err(e) => {
eprintln!("Error processing a PSKT from bundle: {:?}", e);
Expand Down Expand Up @@ -536,7 +537,7 @@ pub trait Account: AnySync + Send + Sync + 'static {
let mut ids = vec![];
while let Some(transaction) = stream.try_next().await? {
transaction.try_sign()?;
ids.push(transaction.try_submit(&self.wallet().rpc_api()).await?);
ids.push(transaction.try_submit(&self.wallet().rpc_api(), false).await?);

if let Some(notifier) = notifier.as_ref() {
notifier(&transaction);
Expand Down Expand Up @@ -714,7 +715,7 @@ pub trait DerivationCapableAccount: Account {
let mut stream = generator.stream();
while let Some(transaction) = stream.try_next().await? {
transaction.try_sign_with_keys(&keys, None)?;
let id = transaction.try_submit(&rpc).await?;
let id = transaction.try_submit(&rpc, false).await?;
if let Some(notifier) = notifier {
notifier(index, aggregate_utxo_count, balance, Some(id));
}
Expand Down
4 changes: 3 additions & 1 deletion wallet/core/src/account/pskb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ pub fn pskt_to_pending_transaction(
finalized_pskt: PSKT<Finalizer>,
network_id: NetworkId,
change_address: Address,
source_utxo_context: Option<UtxoContext>,
) -> Result<PendingTransaction, Error> {
let mass = 10;
let (signed_tx, _) = match finalized_pskt.clone().extractor() {
Expand Down Expand Up @@ -341,7 +342,7 @@ pub fn pskt_to_pending_transaction(
change_address,
utxo_iterator,
priority_utxo_entries: None,
source_utxo_context: None,
source_utxo_context,
destination_utxo_context: None,
fee_rate: None,
final_transaction_priority_fee: fee_u.into(),
Expand Down Expand Up @@ -491,6 +492,7 @@ pub async fn commit_reveal_batch_bundle(
pskt_finalizer.clone(),
network_id,
account.clone().as_derivation_capable()?.change_address()?,
account.utxo_context().clone().into(),
) {
Ok(tx) => Ok(tx.id()),
Err(e) => Err(e),
Expand Down
5 changes: 3 additions & 2 deletions wallet/core/src/api/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -603,14 +603,15 @@ pub struct FeeRatePollerDisableResponse {}
pub struct TransactionsDataGetRequest {
pub account_id: AccountId,
pub network_id: NetworkId,
pub filter: Option<Vec<TransactionKind>>,
pub kind_filter: Option<Vec<TransactionKind>>,
pub group_filter: Option<Vec<TransactionGroup>>,
pub start: u64,
pub end: u64,
}

impl TransactionsDataGetRequest {
pub fn with_range(account_id: AccountId, network_id: NetworkId, range: std::ops::Range<u64>) -> Self {
Self { account_id, network_id, filter: None, start: range.start, end: range.end }
Self { account_id, network_id, kind_filter: None, group_filter: None, start: range.start, end: range.end }
}
}

Expand Down
3 changes: 2 additions & 1 deletion wallet/core/src/storage/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ pub trait TransactionRecordStore: Send + Sync {
&self,
binding: &Binding,
network_id: &NetworkId,
filter: Option<Vec<TransactionKind>>,
kind_filter: Option<Vec<TransactionKind>>,
group_filter: Option<Vec<TransactionGroup>>,
range: std::ops::Range<usize>,
) -> Result<TransactionRangeResult>;

Expand Down
27 changes: 25 additions & 2 deletions wallet/core/src/storage/local/transaction/fsio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,37 @@ impl TransactionRecordStore for TransactionStore {
&self,
binding: &Binding,
network_id: &NetworkId,
filter: Option<Vec<TransactionKind>>,
kind_filter: Option<Vec<TransactionKind>>,
group_filter: Option<Vec<TransactionGroup>>,
range: std::ops::Range<usize>,
) -> Result<TransactionRangeResult> {
let folder = self.ensure_folder(binding, network_id).await?;
let ids = self.enumerate(binding, network_id).await?;
let mut transactions = vec![];
let total = if let Some(group_filter) = group_filter {
let mut located = 0;

for id in ids {
let path = folder.join(id.to_hex());

match read(&path, None).await {
Ok(tx) => {
if group_filter.contains(&tx.kind().into()) {
if located >= range.start && located < range.end {
transactions.push(Arc::new(tx));
}

let total = if let Some(filter) = filter {
located += 1;
}
}
Err(err) => {
log_error!("Error loading transaction {id}: {:?}", err);
}
}
}

located
} else if let Some(filter) = kind_filter {
let mut located = 0;

for id in ids {
Expand Down
Loading
Loading