Skip to content

Commit 2990883

Browse files
tomislavhoracekMarcin Mazurek
andauthored
[DDW-1217] Change voting registration reward address to a payment address (#3131)
* [DDW-1217] Introduce a reward address change from staking to payment address for SW and HW Ledger * [DDW-1217] Fix types * [DDW-1217] Change Trezor voting reward address to payment address * [DDW-1217] CHANGELOG update --------- Co-authored-by: Marcin Mazurek <[email protected]>
1 parent 8d31311 commit 2990883

File tree

6 files changed

+38
-26
lines changed

6 files changed

+38
-26
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
### Chores
1414

15+
- Changed voting reward address to a payment address ([PR 3131](https://github.com/input-output-hk/daedalus/pull/3131))
1516
- Updated @trezor/connect to v9.0.8 ([PR 3127](https://github.com/input-output-hk/daedalus/pull/3127))
1617
- Add members of Cardano Wallet team to the "About Daedalus" screen ([PR 3092](https://github.com/input-output-hk/daedalus/pull/3092))
1718
- Removed Chromatic from project ([PR 3126](https://github.com/input-output-hk/daedalus/pull/3126))

source/renderer/app/api/transactions/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,10 @@ export type VotingMetadataType = Record<
272272
VotingMetaRegistrationType
273273
>;
274274
export type VotingDataType = {
275+
address: {
276+
id: string;
277+
spendingPath: string;
278+
};
275279
stakeAddress: string;
276280
stakeAddressHex: string;
277281
votingKey: string;

source/renderer/app/stores/HardwareWalletsStore.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2251,19 +2251,20 @@ export default class HardwareWalletsStore extends Store {
22512251
let auxiliaryData = null;
22522252

22532253
if (this.votingData) {
2254-
const { stakeAddress, stakeKey, votingKey, nonce } = this.votingData;
2254+
const { address, stakeKey, votingKey, nonce } = this.votingData;
22552255
unsignedTxAuxiliaryData = {
22562256
nonce,
22572257
// unique increaseable number e.g. current epoch number or absolute slot number ( identifies unique tx / vote registration )
22582258
rewardDestinationAddress: {
2259-
address: stakeAddress,
2259+
address,
22602260
stakingPath: [2147485500, 2147485463, 2147483648, 2, 0],
22612261
},
22622262
stakePubKey: stakeKey,
22632263
type: CATALYST_VOTING_REGISTRATION_TYPE,
22642264
votingPubKey: votingKey,
22652265
};
22662266
auxiliaryData = prepareTrezorAuxiliaryData({
2267+
address,
22672268
votingKey,
22682269
nonce: nonce.toString(),
22692270
});
@@ -2575,12 +2576,12 @@ export default class HardwareWalletsStore extends Store {
25752576
let unsignedTxAuxiliaryData = null;
25762577

25772578
if (this.votingData) {
2578-
const { stakeAddress, stakeKey, votingKey, nonce } = this.votingData;
2579+
const { address, stakeKey, votingKey, nonce } = this.votingData;
25792580
unsignedTxAuxiliaryData = {
25802581
nonce,
25812582
// unique increasable number e.g. current epoch number or absolute slot number ( identifies unique tx / vote registration )
25822583
rewardDestinationAddress: {
2583-
address: stakeAddress,
2584+
address,
25842585
stakingPath: [2147485500, 2147485463, 2147483648, 2, 0],
25852586
},
25862587
stakePubKey: stakeKey,

source/renderer/app/stores/VotingStore.ts

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ export type VotingRegistrationKeyType = {
3232
public: (...args: Array<any>) => any;
3333
};
3434
export type VotingDataType = {
35-
stakeAddress: string;
36-
stakeAddressHex: string;
35+
addressHex: string;
3736
votingKey: string;
3837
stakeKey: string;
3938
role: PathRoleIdentityType;
@@ -214,9 +213,10 @@ export default class VotingStore extends Store {
214213
};
215214
prepareVotingData = async ({ walletId }: { walletId: string }) => {
216215
try {
217-
const { stakeAddresses } = this.stores.addresses;
218-
const stakeAddress = stakeAddresses[walletId];
219-
const stakeAddressHex = await this._getHexFromBech32(stakeAddress);
216+
const [address] = await this.stores.addresses.getAddressesByWalletId(
217+
walletId
218+
);
219+
const addressHex = await this._getHexFromBech32(address.id);
220220
await this._generateVotingRegistrationKey();
221221
if (!this.votingRegistrationKey)
222222
throw new Error('Failed to generate voting registration key.');
@@ -255,7 +255,7 @@ export default class VotingStore extends Store {
255255
int: 3,
256256
},
257257
v: {
258-
bytes: stakeAddressHex,
258+
bytes: addressHex,
259259
},
260260
},
261261
{
@@ -283,8 +283,8 @@ export default class VotingStore extends Store {
283283
},
284284
};
285285
const votingData = {
286-
stakeAddress,
287-
stakeAddressHex,
286+
address,
287+
addressHex,
288288
votingKey,
289289
stakeKey,
290290
role: 'mutable_account',
@@ -337,16 +337,10 @@ export default class VotingStore extends Store {
337337
const votingData = await this.prepareVotingData({
338338
walletId,
339339
});
340-
const {
341-
stakeAddressHex,
342-
votingKey,
343-
stakeKey,
344-
role,
345-
index,
346-
} = votingData;
340+
const { addressHex, votingKey, stakeKey, role, index } = votingData;
347341
// @ts-ignore ts-migrate(1320) FIXME: Type of 'await' operand must either be a valid pro... Remove this comment to see the full error message
348342
const signature = await this.signMetadataRequest.execute({
349-
addressHex: stakeAddressHex,
343+
addressHex,
350344
walletId,
351345
passphrase,
352346
votingKey,
@@ -359,7 +353,7 @@ export default class VotingStore extends Store {
359353
// @ts-ignore ts-migrate(1320) FIXME: Type of 'await' operand must either be a valid pro... Remove this comment to see the full error message
360354
await this.createVotingRegistrationTransactionRequest.execute({
361355
address: address.id,
362-
addressHex: stakeAddressHex,
356+
addressHex,
363357
amount,
364358
passphrase,
365359
walletId,

source/renderer/app/utils/shelleyLedger.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,10 @@ export type TxAuxiliaryData = {
8686
votingPubKey: string;
8787
};
8888
export type RewardDestinationAddressType = {
89-
address: string;
89+
address: {
90+
id: string;
91+
spendingPath: string;
92+
};
9093
// type of "address.id"
9194
stakingPath: BIP32Path;
9295
};
@@ -484,9 +487,12 @@ export const prepareLedgerAuxiliaryData = (
484487
paymentDestination: {
485488
type: TxOutputDestinationType.DEVICE_OWNED,
486489
params: {
487-
type: AddressType.REWARD_KEY,
490+
type: AddressType.BASE_PAYMENT_KEY_STAKE_KEY,
488491
params: {
489492
stakingPath: rewardDestinationAddress.stakingPath,
493+
spendingPath: str_to_path(
494+
rewardDestinationAddress.address.spendingPath
495+
),
490496
},
491497
},
492498
},
@@ -513,7 +519,7 @@ export const cborizeTxVotingRegistration = ({
513519
new Map<number, Buffer | number>([
514520
[1, Buffer.from(votingPubKey, 'hex')],
515521
[2, Buffer.from(stakePubKey, 'hex')],
516-
[3, utils.bech32_decodeAddress(rewardDestinationAddress.address)],
522+
[3, utils.bech32_decodeAddress(rewardDestinationAddress.address.id)],
517523
[4, Number(nonce)],
518524
]),
519525
];

source/renderer/app/utils/shelleyTrezor.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,20 +75,26 @@ export const prepareTrezorWithdrawal = (
7575
};
7676
};
7777
export type TrezorVotingDataType = {
78+
address: {
79+
id: string;
80+
spendingPath: string;
81+
};
7882
votingKey: string;
7983
nonce: string;
8084
};
8185

8286
export const prepareTrezorAuxiliaryData = ({
87+
address,
8388
votingKey,
8489
nonce,
8590
}: TrezorVotingDataType) => ({
8691
cVoteRegistrationParameters: {
8792
votePublicKey: votingKey,
8893
stakingPath: "m/1852'/1815'/0'/2/0",
8994
paymentAddressParameters: {
90-
addressType: Messages.CardanoAddressType.REWARD,
91-
path: "m/1852'/1815'/0'/2/0",
95+
addressType: Messages.CardanoAddressType.BASE,
96+
path: `m/${address.spendingPath}`,
97+
stakingPath: "m/1852'/1815'/0'/2/0",
9298
},
9399
nonce,
94100
format: Messages.CardanoCVoteRegistrationFormat.CIP15, // Catalyst voting format

0 commit comments

Comments
 (0)