11import { StaticChangeAddressResolver , roundRobinRandomImprove } from '@cardano-sdk/input-selection' ;
22
3+ import { Bip32Account , SignTransactionContext , util } from '@cardano-sdk/key-management' ;
34import { Cardano , Serialization } from '@cardano-sdk/core' ;
5+ import { Ed25519KeyHashHex } from '@cardano-sdk/crypto' ;
46import { GreedyTxEvaluator } from './GreedyTxEvaluator' ;
57import { InitializeTxProps , InitializeTxResult } from '../types' ;
68import { RedeemersByType , defaultSelectionConstraints } from '../input-selection' ;
79import { TxBuilderDependencies } from './types' ;
810import { createPreInputSelectionTxBody , includeChangeAndInputs } from '../createTransactionInternals' ;
911import { ensureValidityInterval } from '../ensureValidityInterval' ;
10- import { util } from '@cardano-sdk/key-management' ;
12+
13+ const dRepPublicKeyHash = async ( addressManager ?: Bip32Account ) : Promise < Ed25519KeyHashHex | undefined > =>
14+ addressManager && ( await ( await addressManager . derivePublicKey ( util . DREP_KEY_DERIVATION_PATH ) ) . hash ( ) ) . hex ( ) ;
1115
1216export const initializeTx = async (
1317 props : InitializeTxProps ,
@@ -72,9 +76,7 @@ export const initializeTx = async (
7276 witness : props . witness as Cardano . Witness
7377 } ) ;
7478
75- const dRepPublicKey = addressManager
76- ? ( await addressManager . derivePublicKey ( util . DREP_KEY_DERIVATION_PATH ) ) . hex ( )
77- : undefined ;
79+ const dRepKeyHashHex = await dRepPublicKeyHash ( addressManager ) ;
7880
7981 const transaction = new Serialization . Transaction (
8082 Serialization . TransactionBody . fromCore ( unwitnessedTx . body ) ,
@@ -84,8 +86,8 @@ export const initializeTx = async (
8486 auxiliaryData ? Serialization . AuxiliaryData . fromCore ( auxiliaryData ) : undefined
8587 ) ;
8688
87- const signingContext = {
88- dRepPublicKey ,
89+ const signingContext : SignTransactionContext = {
90+ ... ( dRepKeyHashHex && { dRepKeyHashHex } ) ,
8991 handleResolutions : props . handleResolutions ?? [ ] ,
9092 knownAddresses : addresses ,
9193 txInKeyPathMap : await util . createTxInKeyPathMap ( unwitnessedTx . body , addresses , inputResolver )
0 commit comments