-
Notifications
You must be signed in to change notification settings - Fork 258
feat: add offline one-sided transaction signing cucumber test #7743
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
base: development
Are you sure you want to change the base?
Changes from 1 commit
3ef3cb8
9889080
d77db94
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| # Copyright 2025 The Tari Project | ||
| # SPDX-License-Identifier: BSD-3-Clause | ||
|
|
||
| @offline-signing @wallet | ||
| Feature: Offline One-Sided Transaction Signing | ||
|
|
||
| @critical | ||
| Scenario: Full offline signing flow via gRPC | ||
| # Set up infrastructure | ||
| Given I have a seed node NODE | ||
| When I have wallet WALLET_SENDER connected to all seed nodes | ||
| When I have wallet WALLET_RECEIVER connected to all seed nodes | ||
| When I have SHA3X mining node MINER connected to base node NODE and wallet WALLET_SENDER | ||
| # Fund the sender wallet | ||
| When mining node MINER mines 4 blocks | ||
| Then all nodes are at height 4 | ||
| When I wait for wallet WALLET_SENDER to have at least 1002000 uT | ||
| # Export sender keys so we can create a view-only wallet and sign offline | ||
| Then I export wallet WALLET_SENDER view and spend keys as SENDER_KEYS | ||
| # Create view-only wallet from exported keys | ||
| Then I create view wallet VIEW_WALLET from view and spend keys SENDER_KEYS on node NODE | ||
| # Wait for view wallet to discover UTXOs via chain scan | ||
| When I wait for wallet VIEW_WALLET to have at least 1002000 uT | ||
| # Step 1: View-only wallet prepares transaction for offline signing via gRPC | ||
| When I prepare an offline one-sided transaction of 100000 uT from wallet VIEW_WALLET to wallet WALLET_RECEIVER at fee 20 | ||
| # Step 2: Sign the prepared transaction offline using the exported spend key | ||
| Then I sign the prepared transaction offline using keys SENDER_KEYS | ||
|
||
| # Step 3: Broadcast the signed transaction back via the view-only wallet | ||
| When I broadcast the signed transaction via wallet VIEW_WALLET | ||
| # Mine blocks to confirm | ||
| When mining node MINER mines 5 blocks | ||
| Then all nodes are at height 9 | ||
| # Step 4: Verify receiving wallet has confirmed funds | ||
| When I wait for wallet WALLET_RECEIVER to have at least 100000 uT | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,177 @@ | ||||||
| // Copyright 2025. The Tari Project | ||||||
| // | ||||||
| // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the | ||||||
| // following conditions are met: | ||||||
| // | ||||||
| // 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following | ||||||
| // disclaimer. | ||||||
| // | ||||||
| // 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the | ||||||
| // following disclaimer in the documentation and/or other materials provided with the distribution. | ||||||
| // | ||||||
| // 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote | ||||||
| // products derived from this software without specific prior written permission. | ||||||
| // | ||||||
| // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, | ||||||
| // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||||||
| // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||||||
| // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||||||
| // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | ||||||
| // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE | ||||||
| // USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||||
|
|
||||||
| use cucumber::{then, when}; | ||||||
| use minotari_app_grpc::tari_rpc as grpc; | ||||||
| use grpc::PaymentRecipient; | ||||||
| use tari_common::configuration::Network; | ||||||
| use tari_common_types::types::PrivateKey; | ||||||
| use tari_integration_tests::{TariWorld, wallet_process::create_wallet_client}; | ||||||
| use tari_transaction_components::{ | ||||||
| consensus::ConsensusManager, | ||||||
| key_manager::{ | ||||||
| KeyManager, | ||||||
| wallet_types::{SpendWallet, WalletType}, | ||||||
| }, | ||||||
| offline_signing::{ | ||||||
| models::{PrepareOneSidedTransactionForSigningResult, SignedOneSidedTransactionResult, TransactionResult}, | ||||||
| sign_locked_transaction, | ||||||
| }, | ||||||
| transaction_components::memo_field::{MemoField, TxType}, | ||||||
| }; | ||||||
| use tari_utilities::hex::Hex; | ||||||
|
|
||||||
| #[when(expr = "I prepare an offline one-sided transaction of {int} uT from wallet {word} to wallet {word} at fee {int}")] | ||||||
| async fn prepare_offline_transaction( | ||||||
| world: &mut TariWorld, | ||||||
| amount: u64, | ||||||
| sender: String, | ||||||
| receiver: String, | ||||||
| fee: u64, | ||||||
| ) { | ||||||
| let mut sender_client = create_wallet_client(world, sender.clone()).await.unwrap(); | ||||||
| let receiver_wallet_address = world.get_wallet_address(&receiver).await.unwrap(); | ||||||
|
|
||||||
| let payment_id = MemoField::new_open_from_string( | ||||||
| &format!("Offline one-sided {} uT from {} to {}", amount, sender, receiver), | ||||||
| TxType::PaymentToOther, | ||||||
| ) | ||||||
| .unwrap(); | ||||||
|
|
||||||
| let recipient = PaymentRecipient { | ||||||
| address: receiver_wallet_address, | ||||||
| amount, | ||||||
| fee_per_gram: fee, | ||||||
| payment_type: 2, // ONE_SIDED_TO_STEALTH_ADDRESS | ||||||
|
||||||
| payment_type: 2, // ONE_SIDED_TO_STEALTH_ADDRESS | |
| payment_type: grpc::payment_recipient::PaymentType::OneSidedToStealthAddress as i32, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a public key, not private, it wont work
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need to use the wallet cli to sign this, not the struct, we need to test the complete cycle
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
Debugimplementation forTariWorld(lines 117-138) should be updated to include the newoffline_signing_preparedandoffline_signing_signedfields. This ensures that the state of offline signing is visible when the world is printed for debugging purposes.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this