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

feat!: add scanned transaction handling for one-sided payments with callbacks #3794

Conversation

hansieodendaal
Copy link
Contributor

Description

  • Added separate statuses for scanned one-sided transactions to enable unique events and validation.
  • Added validation for one-sided payments updating their mined height and confirmations.
  • Added callbacks for scanned one-sided transactions (unconfirmed and confirmed)
  • Updated the wallet FFI with the callbacks.

Motivation and Context

Currently when a one-sided output is found by scanning the blockchain a Faux transaction is created for it with the Imported status, the same as for a manually imported output. Outputs found by scanning (for one-sided payments) should be handled differently to a manual import and their mined height and number confirmations should be validated.

How Has This Been Tested?

  • Unit tests
  • Cucumber tests
  • System level testing

Copy link
Contributor

@philipr-za philipr-za left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I feel like something is missing here. The scanned output faux transactions cannot be validated like normal transactions because we do not know their kernels. Their status needs to be driven by the status of the outputs, which for imported transaction was done using the check_imported_transactions task but I can't see anything similar for ScannedUnconfirmed outputs.

base_layer/common_types/src/transaction.rs Outdated Show resolved Hide resolved
base_layer/common_types/src/transaction.rs Outdated Show resolved Hide resolved
base_layer/wallet/src/wallet.rs Outdated Show resolved Hide resolved
base_layer/wallet/src/wallet.rs Outdated Show resolved Hide resolved
base_layer/wallet_ffi/src/callback_handler.rs Show resolved Hide resolved
base_layer/wallet_ffi/src/callback_handler.rs Outdated Show resolved Hide resolved
base_layer/wallet_ffi/src/callback_handler.rs Outdated Show resolved Hide resolved
@hansieodendaal hansieodendaal changed the title [WIP - adding tests] feat!: add scanned transaction handling for one-sided payments with callbacks [WIP] feat!: add scanned transaction handling for one-sided payments with callbacks Feb 8, 2022
- Added separate statuses for faux transactions to enable unique events and
  validation for scanned one-sided transactions.
- Added validation for one-sided payments updating the associated faux transaction
  mined height and confirmations.
- Added callbacks for faux transactions (unconfirmed and confirmed).
- Updated the wallet FFI with the callbacks.
@hansieodendaal hansieodendaal changed the title [WIP] feat!: add scanned transaction handling for one-sided payments with callbacks feat!: add scanned transaction handling for one-sided payments with callbacks Feb 9, 2022
Copy link
Contributor

@philipr-za philipr-za left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. My one comment is just a Nit so approving and going start a merge queue

Comment on lines +36 to +50
impl TransactionStatus {
pub fn is_faux(&self) -> bool {
match self {
TransactionStatus::Completed => false,
TransactionStatus::Broadcast => false,
TransactionStatus::MinedUnconfirmed => false,
TransactionStatus::Imported => true,
TransactionStatus::Pending => false,
TransactionStatus::Coinbase => false,
TransactionStatus::MinedConfirmed => false,
TransactionStatus::Rejected => false,
TransactionStatus::FauxUnconfirmed => true,
TransactionStatus::FauxConfirmed => true,
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
impl TransactionStatus {
pub fn is_faux(&self) -> bool {
match self {
TransactionStatus::Completed => false,
TransactionStatus::Broadcast => false,
TransactionStatus::MinedUnconfirmed => false,
TransactionStatus::Imported => true,
TransactionStatus::Pending => false,
TransactionStatus::Coinbase => false,
TransactionStatus::MinedConfirmed => false,
TransactionStatus::Rejected => false,
TransactionStatus::FauxUnconfirmed => true,
TransactionStatus::FauxConfirmed => true,
}
}
impl TransactionStatus {
pub fn is_faux(&self) -> bool {
match self {
TransactionStatus::Imported |
TransactionStatus::FauxUnconfirmed |
TransactionStatus::FauxConfirmed => true,
_ => false,
}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I will fix that as a side issue when I submit a new PR based on this merge.

@aviator-app aviator-app bot added mq-failed and removed mq-failed labels Feb 9, 2022
@aviator-app aviator-app bot removed the mq-failed label Feb 9, 2022
@aviator-app aviator-app bot merged commit 5453c9e into tari-project:development Feb 9, 2022
@hansieodendaal hansieodendaal deleted the ho_add_scanned_tx_handling branch February 10, 2022 05:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants