Skip to content

Commit 4c742da

Browse files
authored
Merge pull request #1900 from mintlayer/feature/wallet-show-change-address
Add option to list change addresses in the wallet
2 parents 24c4e14 + 2fd7d66 commit 4c742da

File tree

22 files changed

+397
-143
lines changed

22 files changed

+397
-143
lines changed

node-gui/backend/src/backend_impl.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ impl Backend {
223223
.flatten();
224224

225225
let addresses = controller
226-
.get_issued_addresses(account_index)
226+
.get_issued_addresses(account_index, false)
227227
.await
228228
.map_err(|e| BackendError::WalletError(e.to_string()))?
229229
.into_iter()
@@ -1244,7 +1244,7 @@ impl Backend {
12441244
}
12451245
};
12461246

1247-
match controller.get_issued_addresses(account_id.account_index()).await {
1247+
match controller.get_issued_addresses(account_id.account_index(), false).await {
12481248
Ok(addresses) => {
12491249
for info in addresses {
12501250
Self::send_event(

test/functional/test_framework/wallet_cli_controller.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -430,14 +430,14 @@ async def submit_transaction(self, transaction: str, do_not_store: bool = False)
430430

431431
async def list_pool_ids(self) -> List[PoolData]:
432432
output = await self._write_command("staking-list-pools\n", can_be_empty=True)
433-
self.log.info(f"pools: {output}");
433+
self.log.info(f"pools: {output}")
434434
pattern = r"Pool Id: ([a-zA-Z0-9]+), Pledge: (\d+[.]?\d+), Balance: (\d+[.]?\d+), Creation Block Height: (\d+), Creation block timestamp: (\d+), Staker: ([a-zA-Z0-9]+), Decommission Key: ([a-zA-Z0-9]+), VRF Public Key: ([a-zA-Z0-9]+)"
435435
matches = re.findall(pattern, output)
436436
return [PoolData(pool_id, pledge, balance, int(height), timestamp, staker, decommission_key, vrf_public_key) for pool_id, pledge, balance, height, timestamp, staker, decommission_key, vrf_public_key in matches]
437437

438438
async def list_pools_for_decommission(self) -> List[PoolData]:
439439
output = await self._write_command("staking-list-owned-pools-for-decommission\n", can_be_empty=True)
440-
self.log.info(f"pools: {output}");
440+
self.log.info(f"pools: {output}")
441441
pattern = r"Pool Id: ([a-zA-Z0-9]+), Pledge: (\d+[.]?\d+), Balance: (\d+[.]?\d+), Creation Block Height: (\d+), Creation block timestamp: (\d+), Staker: ([a-zA-Z0-9]+), Decommission Key: ([a-zA-Z0-9]+), VRF Public Key: ([a-zA-Z0-9]+)"
442442
matches = re.findall(pattern, output)
443443
return [PoolData(pool_id, pledge, balance, int(height), timestamp, staker, decommission_key, vrf_public_key) for pool_id, pledge, balance, height, timestamp, staker, decommission_key, vrf_public_key in matches]
@@ -477,15 +477,15 @@ async def rescan(self) -> str:
477477
return await self._write_command("wallet-rescan\n")
478478

479479
async def start_staking(self) -> str:
480-
return await self._write_command(f"staking-start\n")
480+
return await self._write_command("staking-start\n")
481481

482482
async def stop_staking(self) -> str:
483-
return await self._write_command(f"staking-stop\n")
483+
return await self._write_command("staking-stop\n")
484484

485485
async def staking_status(self) -> str:
486-
return await self._write_command(f"staking-status\n")
486+
return await self._write_command("staking-status\n")
487487

488-
async def generate_block(self, transactions: [str]) -> str:
488+
async def generate_block(self, transactions: List[str]) -> str:
489489
return await self._write_command(f"generate-block {transactions}\n")
490490

491491
async def get_standalone_addresses(self) -> str:
@@ -494,8 +494,9 @@ async def get_standalone_addresses(self) -> str:
494494
async def get_standalone_address_details(self, address: str) -> str:
495495
return await self._write_command(f"standalone-address-details {address}\n")
496496

497-
async def get_addresses_usage(self) -> str:
498-
return await self._write_command("address-show\n")
497+
async def get_addresses_usage(self, with_change: bool = False) -> str:
498+
include_change = "--include-change" if with_change else ""
499+
return await self._write_command(f"address-show {include_change}\n")
499500

500501
async def get_vrf_addresses_usage(self) -> str:
501502
return await self._write_command("staking-show-vrf-public-keys\n")
@@ -515,7 +516,7 @@ async def get_balance(self, with_locked: str = 'unlocked', utxo_states: List[str
515516
return await self._write_command(f"account-balance {with_locked} {' '.join(utxo_states)}\n")
516517

517518
async def list_pending_transactions(self) -> List[str]:
518-
output = await self._write_command(f"transaction-list-pending\n")
519+
output = await self._write_command("transaction-list-pending\n")
519520
pattern = r'Id<Transaction>\{([^}]*)\}'
520521
return re.findall(pattern, output)
521522

test/functional/test_framework/wallet_rpc_controller.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -238,14 +238,14 @@ async def reveal_public_key_as_hex(self, address: Optional[str] = None) -> str:
238238
return self._write_command("address_reveal_public_key", [self.account, address])['result']['public_key_hex']
239239

240240
async def new_address(self) -> str:
241-
return self._write_command(f"address_new", [self.account])['result']['address']
241+
return self._write_command("address_new", [self.account])['result']['address']
242242

243243
async def add_standalone_multisig_address(self, min_required_signatures: int, pub_keys: List[str], label: Optional[str] = None) -> str:
244244
return self._write_command("standalone_add_multisig", [self.account, min_required_signatures, pub_keys, label, None])['result']
245245

246246
async def list_utxos(self, utxo_types: str = '', with_locked: str = '', utxo_states: List[str] = []) -> List[UtxoOutpoint]:
247247
outputs = self._write_command("account_utxos", [self.account, utxo_types, with_locked, ''.join(utxo_states)])['result']
248-
return [UtxoOutpoint(tx_id=match["outpoint"]["source_id"]["content"]['tx_id'], index=int(match["outpoint"]['index'])) for match in outputs]
248+
return [UtxoOutpoint(id=match["outpoint"]["source_id"]["content"]['tx_id'], index=int(match["outpoint"]['index'])) for match in outputs]
249249

250250
async def get_transaction(self, tx_id: str) -> str:
251251
return self._write_command("transaction_get", [self.account, tx_id])['result']
@@ -270,12 +270,12 @@ async def issue_new_token(self,
270270
number_of_decimals: int,
271271
metadata_uri: str,
272272
destination_address: str,
273-
token_supply: Optional[int] = None,
273+
token_supply_fixed: Optional[int] = None,
274274
is_freezable: bool = True):
275-
if token_supply is None:
275+
if token_supply_fixed is None:
276276
token_supply = { "type": "Lockable" }
277277
else:
278-
token_supply = { "type": "Fixed", "content": {'decimal': str(token_supply)} }
278+
token_supply = { "type": "Fixed", "content": {'decimal': str(token_supply_fixed)} }
279279

280280
result = self._write_command('token_issue_new', [
281281
self.account,
@@ -375,7 +375,7 @@ async def decommission_stake_pool(self, pool_id: str, address: str) -> str:
375375
return "The transaction was submitted successfully"
376376

377377
async def submit_transaction(self, transaction: str, do_not_store: bool = False) -> str:
378-
result = self._write_command(f"node_submit_transaction", [transaction, do_not_store, {}])
378+
result = self._write_command("node_submit_transaction", [transaction, do_not_store, {}])
379379
if 'result' in result:
380380
return f"The transaction was submitted successfully\n\n{result['result']['tx_id']}"
381381
else:
@@ -397,7 +397,7 @@ async def create_delegation(self, address: str, pool_id: str) -> Optional[str]:
397397
return self._write_command("delegation_create", [self.account, address, pool_id, {'in_top_x_mb': 5}])['result']['delegation_id']
398398

399399
async def stake_delegation(self, amount: int, delegation_id: str) -> str:
400-
self._write_command(f"delegation_stake", [self.account, {'decimal': str(amount)}, delegation_id, {'in_top_x_mb': 5}])['result']
400+
self._write_command("delegation_stake", [self.account, {'decimal': str(amount)}, delegation_id, {'in_top_x_mb': 5}])['result']
401401
return "Success"
402402

403403
async def list_delegation_ids(self) -> List[DelegationData]:
@@ -412,22 +412,22 @@ async def sync(self) -> str:
412412
return "Success"
413413

414414
async def start_staking(self) -> str:
415-
self._write_command(f"staking_start", [self.account])['result']
415+
self._write_command("staking_start", [self.account])['result']
416416
return "Staking started successfully"
417417

418418
async def stop_staking(self) -> str:
419-
self._write_command(f"staking_stop", [self.account])['result']
419+
self._write_command("staking_stop", [self.account])['result']
420420
return "Success"
421421

422422
async def staking_status(self) -> str:
423-
result = self._write_command(f"staking_status", [self.account])['result']
423+
result = self._write_command("staking_status", [self.account])['result']
424424
if result == "Staking":
425425
return "Staking"
426426
else:
427427
return "Not staking"
428428

429-
async def get_addresses_usage(self) -> str:
430-
return self._write_command("address_show", [self.account])['result']
429+
async def get_addresses_usage(self, with_change: bool = False) -> str:
430+
return self._write_command("address_show", [self.account, with_change])['result']
431431

432432
async def get_balance(self, with_locked: str = 'unlocked', utxo_states: List[str] = ['confirmed']) -> str:
433433
with_locked = with_locked.capitalize()

0 commit comments

Comments
 (0)