Skip to content

Commit 291f5a1

Browse files
committed
fix comments
1 parent 2d3714e commit 291f5a1

File tree

16 files changed

+163
-140
lines changed

16 files changed

+163
-140
lines changed

wallet/src/account/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1446,7 +1446,7 @@ impl<K: AccountKeyChains> Account<K> {
14461446
)
14471447
}
14481448

1449-
pub fn create_stake_pool_tx_with_vrf_key(
1449+
pub fn create_stake_pool_with_vrf_key(
14501450
&mut self,
14511451
db_tx: &mut impl WalletStorageWriteUnlocked,
14521452
mut stake_pool_arguments: StakePoolCreationArguments,
@@ -1457,7 +1457,7 @@ impl<K: AccountKeyChains> Account<K> {
14571457
return Err(WalletError::VrfKeyMustBeProvided);
14581458
};
14591459

1460-
self.create_stake_pool_tx_impl(
1460+
self.create_stake_pool_impl(
14611461
stake_pool_arguments,
14621462
db_tx,
14631463
vrf_public_key,
@@ -1466,7 +1466,7 @@ impl<K: AccountKeyChains> Account<K> {
14661466
)
14671467
}
14681468

1469-
fn create_stake_pool_tx_impl(
1469+
fn create_stake_pool_impl(
14701470
&mut self,
14711471
stake_pool_arguments: StakePoolCreationArguments,
14721472
db_tx: &mut impl WalletStorageWriteUnlocked,
@@ -2493,7 +2493,7 @@ impl<K: AccountKeyChains + VRFAccountKeyChains> Account<K> {
24932493
Ok(data)
24942494
}
24952495

2496-
pub fn create_stake_pool_tx(
2496+
pub fn create_stake_pool(
24972497
&mut self,
24982498
db_tx: &mut impl WalletStorageWriteUnlocked,
24992499
mut stake_pool_arguments: StakePoolCreationArguments,
@@ -2504,7 +2504,7 @@ impl<K: AccountKeyChains + VRFAccountKeyChains> Account<K> {
25042504
Some(vrf_public_key) => vrf_public_key,
25052505
None => self.get_vrf_public_key(db_tx)?,
25062506
};
2507-
self.create_stake_pool_tx_impl(
2507+
self.create_stake_pool_impl(
25082508
stake_pool_arguments,
25092509
db_tx,
25102510
vrf_public_key,

wallet/src/wallet/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2018,7 +2018,7 @@ where
20182018
Ok((token_id, signed_transaction))
20192019
}
20202020

2021-
pub fn create_stake_pool_tx_with_vrf_key(
2021+
pub fn create_stake_pool_with_vrf_key(
20222022
&mut self,
20232023
account_index: U31,
20242024
current_fee_rate: FeeRate,
@@ -2030,7 +2030,7 @@ where
20302030
account_index,
20312031
TxAdditionalInfo::new(),
20322032
|account, db_tx| {
2033-
account.create_stake_pool_tx_with_vrf_key(
2033+
account.create_stake_pool_with_vrf_key(
20342034
db_tx,
20352035
stake_pool_arguments,
20362036
latest_median_time,
@@ -2515,7 +2515,7 @@ where
25152515
Ok(account.get_legacy_vrf_public_key())
25162516
}
25172517

2518-
pub fn create_stake_pool_tx(
2518+
pub fn create_stake_pool(
25192519
&mut self,
25202520
account_index: U31,
25212521
current_fee_rate: FeeRate,
@@ -2527,7 +2527,7 @@ where
25272527
account_index,
25282528
TxAdditionalInfo::new(),
25292529
|account, db_tx| {
2530-
account.create_stake_pool_tx(
2530+
account.create_stake_pool(
25312531
db_tx,
25322532
stake_pool_arguments,
25332533
latest_median_time,

wallet/src/wallet/tests.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1762,7 +1762,7 @@ fn create_stake_pool_and_list_pool_ids(#[case] seed: Seed) {
17621762
let decommission_key = Destination::PublicKey(standalone_pk);
17631763

17641764
let err = wallet
1765-
.create_stake_pool_tx_with_vrf_key(
1765+
.create_stake_pool_with_vrf_key(
17661766
DEFAULT_ACCOUNT_INDEX,
17671767
FeeRate::from_amount_per_kb(Amount::ZERO),
17681768
FeeRate::from_amount_per_kb(Amount::ZERO),
@@ -1779,7 +1779,7 @@ fn create_stake_pool_and_list_pool_ids(#[case] seed: Seed) {
17791779
assert_eq!(err, WalletError::VrfKeyMustBeProvided);
17801780

17811781
let stake_pool_transaction = wallet
1782-
.create_stake_pool_tx(
1782+
.create_stake_pool(
17831783
DEFAULT_ACCOUNT_INDEX,
17841784
FeeRate::from_amount_per_kb(Amount::ZERO),
17851785
FeeRate::from_amount_per_kb(Amount::ZERO),
@@ -1967,7 +1967,7 @@ fn create_stake_pool_for_different_wallet_and_list_pool_ids(#[case] seed: Seed)
19671967

19681968
// First, try to create the pool using staker_key_hash_dest as the staker address; this should fail.
19691969
let err = wallet1
1970-
.create_stake_pool_tx(
1970+
.create_stake_pool(
19711971
DEFAULT_ACCOUNT_INDEX,
19721972
FeeRate::from_amount_per_kb(Amount::ZERO),
19731973
FeeRate::from_amount_per_kb(Amount::ZERO),
@@ -1990,7 +1990,7 @@ fn create_stake_pool_for_different_wallet_and_list_pool_ids(#[case] seed: Seed)
19901990

19911991
// Now use staker_key_dest.
19921992
let stake_pool_transaction = wallet1
1993-
.create_stake_pool_tx(
1993+
.create_stake_pool(
19941994
DEFAULT_ACCOUNT_INDEX,
19951995
FeeRate::from_amount_per_kb(Amount::ZERO),
19961996
FeeRate::from_amount_per_kb(Amount::ZERO),
@@ -2008,7 +2008,7 @@ fn create_stake_pool_for_different_wallet_and_list_pool_ids(#[case] seed: Seed)
20082008
let stake_pool_transaction_id = stake_pool_transaction.transaction().get_id();
20092009

20102010
let stake_pool_transaction2 = wallet1
2011-
.create_stake_pool_tx_with_vrf_key(
2011+
.create_stake_pool_with_vrf_key(
20122012
DEFAULT_ACCOUNT_INDEX,
20132013
FeeRate::from_amount_per_kb(Amount::ZERO),
20142014
FeeRate::from_amount_per_kb(Amount::ZERO),
@@ -2211,7 +2211,7 @@ fn reset_keys_after_failed_transaction(#[case] seed: Seed) {
22112211
.unwrap()
22122212
.last_issued();
22132213

2214-
let result = wallet.create_stake_pool_tx(
2214+
let result = wallet.create_stake_pool(
22152215
DEFAULT_ACCOUNT_INDEX,
22162216
FeeRate::from_amount_per_kb(Amount::ZERO),
22172217
FeeRate::from_amount_per_kb(Amount::ZERO),
@@ -2426,7 +2426,7 @@ fn create_spend_from_delegations(#[case] seed: Seed) {
24262426
let pool_amount = chain_config.min_stake_pool_pledge();
24272427

24282428
let stake_pool_transaction = wallet
2429-
.create_stake_pool_tx(
2429+
.create_stake_pool(
24302430
DEFAULT_ACCOUNT_INDEX,
24312431
FeeRate::from_amount_per_kb(Amount::ZERO),
24322432
FeeRate::from_amount_per_kb(Amount::ZERO),
@@ -4727,7 +4727,7 @@ fn decommission_pool_wrong_account(#[case] seed: Seed) {
47274727
let decommission_key = wallet.get_new_address(acc_1_index).unwrap().1;
47284728

47294729
let stake_pool_transaction = wallet
4730-
.create_stake_pool_tx(
4730+
.create_stake_pool(
47314731
acc_0_index,
47324732
FeeRate::from_amount_per_kb(Amount::ZERO),
47334733
FeeRate::from_amount_per_kb(Amount::ZERO),
@@ -4824,7 +4824,7 @@ fn decommission_pool_request_wrong_account(#[case] seed: Seed) {
48244824
let decommission_key = wallet.get_new_address(acc_1_index).unwrap().1;
48254825

48264826
let stake_pool_transaction = wallet
4827-
.create_stake_pool_tx(
4827+
.create_stake_pool(
48284828
acc_0_index,
48294829
FeeRate::from_amount_per_kb(Amount::ZERO),
48304830
FeeRate::from_amount_per_kb(Amount::ZERO),
@@ -4914,7 +4914,7 @@ fn sign_decommission_pool_request_between_accounts(#[case] seed: Seed) {
49144914
let decommission_key = wallet.get_new_address(acc_1_index).unwrap().1;
49154915

49164916
let stake_pool_transaction = wallet
4917-
.create_stake_pool_tx(
4917+
.create_stake_pool(
49184918
acc_0_index,
49194919
FeeRate::from_amount_per_kb(Amount::ZERO),
49204920
FeeRate::from_amount_per_kb(Amount::ZERO),
@@ -5029,7 +5029,7 @@ fn sign_decommission_pool_request_cold_wallet(#[case] seed: Seed) {
50295029
assert_eq!(res, (U31::from_u32(1).unwrap(), Some("name".into())));
50305030

50315031
let stake_pool_transaction = hot_wallet
5032-
.create_stake_pool_tx(
5032+
.create_stake_pool(
50335033
DEFAULT_ACCOUNT_INDEX,
50345034
FeeRate::from_amount_per_kb(Amount::ZERO),
50355035
FeeRate::from_amount_per_kb(Amount::ZERO),
@@ -5127,7 +5127,7 @@ fn filter_pools(#[case] seed: Seed) {
51275127
let pool_amount = block1_amount;
51285128

51295129
let stake_pool_transaction = wallet1
5130-
.create_stake_pool_tx(
5130+
.create_stake_pool(
51315131
DEFAULT_ACCOUNT_INDEX,
51325132
FeeRate::from_amount_per_kb(Amount::ZERO),
51335133
FeeRate::from_amount_per_kb(Amount::ZERO),
@@ -6783,7 +6783,7 @@ fn conflicting_delegation_account_nonce(#[case] seed: Seed) {
67836783
let pool_amount = chain_config.min_stake_pool_pledge();
67846784

67856785
let stake_pool_transaction = wallet1
6786-
.create_stake_pool_tx(
6786+
.create_stake_pool(
67876787
DEFAULT_ACCOUNT_INDEX,
67886788
FeeRate::from_amount_per_kb(Amount::ZERO),
67896789
FeeRate::from_amount_per_kb(Amount::ZERO),
@@ -7076,7 +7076,7 @@ fn conflicting_delegation_account_nonce_same_wallet(#[case] seed: Seed) {
70767076
let pool_amount = chain_config.min_stake_pool_pledge();
70777077

70787078
let stake_pool_transaction = wallet
7079-
.create_stake_pool_tx(
7079+
.create_stake_pool(
70807080
DEFAULT_ACCOUNT_INDEX,
70817081
FeeRate::from_amount_per_kb(Amount::ZERO),
70827082
FeeRate::from_amount_per_kb(Amount::ZERO),
@@ -7590,7 +7590,7 @@ fn conflicting_delegation_account_nonce_multiple_inputs(#[case] seed: Seed) {
75907590
let pool_amount = chain_config.min_stake_pool_pledge();
75917591

75927592
let stake_pool_transaction = wallet
7593-
.create_stake_pool_tx(
7593+
.create_stake_pool(
75947594
DEFAULT_ACCOUNT_INDEX,
75957595
FeeRate::from_amount_per_kb(Amount::ZERO),
75967596
FeeRate::from_amount_per_kb(Amount::ZERO),
@@ -7865,7 +7865,7 @@ fn conflicting_delegation_account_with_reorg(#[case] seed: Seed) {
78657865
let pool_amount = chain_config.min_stake_pool_pledge();
78667866

78677867
let stake_pool_transaction = wallet
7868-
.create_stake_pool_tx(
7868+
.create_stake_pool(
78697869
DEFAULT_ACCOUNT_INDEX,
78707870
FeeRate::from_amount_per_kb(Amount::ZERO),
78717871
FeeRate::from_amount_per_kb(Amount::ZERO),

wallet/wallet-cli-commands/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -652,9 +652,9 @@ pub enum WalletCommand {
652652

653653
#[clap(name = "address-sweep-spendable")]
654654
/// Sweep all spendable coins or tokens from an address or addresses specified in `addresses`
655-
/// or all addresses from this account if all is set to true, to the given destination address.
656-
/// Either 1 or more addresses need to be specified in `addresses` without `all` being set, or
657-
/// `addresses` needs to be empty and --all being set.
655+
/// or all addresses from this account if `--all` is specified, to the given destination address.
656+
/// Either 1 or more addresses need to be specified in `addresses` without `--all` being set, or
657+
/// `addresses` needs to be empty and `--all` being set.
658658
///
659659
/// Spendable coins are any coins that are not locked, and tokens that are not frozen or locked.
660660
/// The wallet will automatically calculate the required fees

wallet/wallet-controller/src/runtime_wallet.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,22 +1037,22 @@ impl<B: storage::Backend + 'static> RuntimeWallet<B> {
10371037
}
10381038
}
10391039

1040-
pub fn create_stake_pool_tx(
1040+
pub fn create_stake_pool(
10411041
&mut self,
10421042
account_index: U31,
10431043
current_fee_rate: FeeRate,
10441044
consolidate_fee_rate: FeeRate,
10451045
stake_pool_arguments: StakePoolCreationArguments,
10461046
) -> WalletResult<SignedTxWithFees> {
10471047
match self {
1048-
RuntimeWallet::Software(w) => w.create_stake_pool_tx(
1048+
RuntimeWallet::Software(w) => w.create_stake_pool(
10491049
account_index,
10501050
current_fee_rate,
10511051
consolidate_fee_rate,
10521052
stake_pool_arguments,
10531053
),
10541054
#[cfg(feature = "trezor")]
1055-
RuntimeWallet::Trezor(w) => w.create_stake_pool_tx_with_vrf_key(
1055+
RuntimeWallet::Trezor(w) => w.create_stake_pool_with_vrf_key(
10561056
account_index,
10571057
current_fee_rate,
10581058
consolidate_fee_rate,

wallet/wallet-controller/src/synced_controller.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ use wallet_types::{
6868
use crate::{
6969
helpers::{fetch_token_info, fetch_utxo, into_balances, tx_to_partially_signed_tx},
7070
runtime_wallet::RuntimeWallet,
71-
types::{Balances, GenericCurrencyTransfer, NewTransaction, SweepFromAddresses},
71+
types::{
72+
Balances, GenericCurrencyTransfer, NewTransaction, PreparedTransaction, SweepFromAddresses,
73+
},
7274
ControllerConfig, ControllerError,
7375
};
7476

@@ -1016,7 +1018,7 @@ where
10161018
}
10171019

10181020
/// Creates a transaction that creates a new stake pool and broadcasts it to the mempool.
1019-
pub async fn create_stake_pool_tx(
1021+
pub async fn create_stake_pool(
10201022
&mut self,
10211023
amount: Amount,
10221024
decommission_key: Destination,
@@ -1030,7 +1032,7 @@ where
10301032
consolidate_fee_rate: FeeRate,
10311033
wallet: &mut RuntimeWallet<B>,
10321034
account_index: U31| {
1033-
wallet.create_stake_pool_tx(
1035+
wallet.create_stake_pool(
10341036
account_index,
10351037
current_fee_rate,
10361038
consolidate_fee_rate,
@@ -1113,7 +1115,7 @@ where
11131115
output_value: OutputValue,
11141116
htlc: HashedTimelockContract,
11151117
additional_info: TxAdditionalInfo,
1116-
) -> Result<NewTransaction, ControllerError<T>> {
1118+
) -> Result<PreparedTransaction, ControllerError<T>> {
11171119
let (current_fee_rate, consolidate_fee_rate) =
11181120
self.get_current_and_consolidation_fee_rate().await?;
11191121

@@ -1128,11 +1130,7 @@ where
11281130

11291131
let fees = into_balances(&self.rpc_client, self.chain_config, fees).await?;
11301132

1131-
Ok(NewTransaction {
1132-
tx,
1133-
fees,
1134-
broadcasted: false,
1135-
})
1133+
Ok(PreparedTransaction { tx, fees })
11361134
}
11371135

11381136
pub async fn create_order(

wallet/wallet-controller/src/types/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ use common::{
3838
pub use seed_phrase::SeedWithPassPhrase;
3939
pub use standalone_key::AccountStandaloneKeyDetails;
4040
pub use transaction::{
41-
InspectTransaction, NewTransaction, SignatureStats, TransactionToInspect, ValidatedSignatures,
41+
InspectTransaction, NewTransaction, PreparedTransaction, SignatureStats, TransactionToInspect,
42+
ValidatedSignatures,
4243
};
4344
use utils::ensure;
4445
use wallet::signer::trezor_signer::FoundDevice;

wallet/wallet-controller/src/types/transaction.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,9 @@ pub struct NewTransaction {
7575
pub fees: Balances,
7676
pub broadcasted: bool,
7777
}
78+
79+
/// Newly signed transaction with fees that is ready to be broadcasted to the mempool
80+
pub struct PreparedTransaction {
81+
pub tx: SignedTransaction,
82+
pub fees: Balances,
83+
}

wallet/wallet-rpc-client/src/handles_client/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ use wallet_rpc_lib::{
4545
NewDelegationTransaction, NewOrderTransaction, NewSubmittedTransaction,
4646
NewTokenTransaction, NftMetadata, NodeVersion, OpenedWallet, PoolInfo, PublicKeyInfo,
4747
RpcHashedTimelockContract, RpcInspectTransaction, RpcNewTransaction,
48-
RpcStandaloneAddresses, SendTokensFromMultisigAddressResult, StakePoolBalance,
49-
StakingStatus, StandaloneAddressWithDetails, TokenMetadata, TxOptionsOverrides, UtxoInfo,
50-
VrfPublicKeyInfo,
48+
RpcPreparedTransaction, RpcStandaloneAddresses, SendTokensFromMultisigAddressResult,
49+
StakePoolBalance, StakingStatus, StandaloneAddressWithDetails, TokenMetadata,
50+
TxOptionsOverrides, UtxoInfo, VrfPublicKeyInfo,
5151
},
5252
RpcError, WalletRpc,
5353
};
@@ -1095,7 +1095,7 @@ where
10951095
token_id: Option<String>,
10961096
htlc: RpcHashedTimelockContract,
10971097
config: ControllerConfig,
1098-
) -> Result<RpcNewTransaction, Self::Error> {
1098+
) -> Result<RpcPreparedTransaction, Self::Error> {
10991099
self.wallet_rpc
11001100
.create_htlc_transaction(
11011101
account_index,

0 commit comments

Comments
 (0)