@@ -215,7 +215,12 @@ export class AdaService extends Service {
215215 return utxo ;
216216 }
217217
218- private getStakeKeyHash ( stakeKey : string ) {
218+ /**
219+ * Get
220+ * @param stakeKey
221+ * @private
222+ */
223+ private getStakeKeyHash ( stakeKey : string ) : Uint8Array | undefined {
219224 const rewardAddress = RewardAddress . from_address ( Address . from_bech32 ( stakeKey ) ) ;
220225 const paymentCred = rewardAddress ?. payment_cred ( ) ;
221226 const hash = paymentCred ?. to_keyhash ( ) ;
@@ -287,61 +292,4 @@ export class AdaService extends Service {
287292 }
288293 }
289294 }
290-
291- private harden ( num : number ) : number {
292- return 0x80000000 + num ;
293- } ;
294-
295- private deriveAddressPrvKey (
296- bipPrvKey : CardanoWasm . Bip32PrivateKey ,
297- testnet : boolean ,
298- ) : {
299- signKey : CardanoWasm . PrivateKey ;
300- address : string ;
301- } {
302- const networkId = testnet
303- ? CardanoWasm . NetworkInfo . testnet ( ) . network_id ( )
304- : CardanoWasm . NetworkInfo . mainnet ( ) . network_id ( ) ;
305- const accountIndex = 0 ;
306- const addressIndex = 0 ;
307-
308- const accountKey = bipPrvKey
309- . derive ( this . harden ( 1852 ) ) // purpose
310- . derive ( this . harden ( 1815 ) ) // coin type
311- . derive ( this . harden ( accountIndex ) ) ; // account #
312-
313- const utxoKey = accountKey
314- . derive ( 0 ) // external
315- . derive ( addressIndex ) ;
316-
317- const stakeKey = accountKey
318- . derive ( 2 ) // chimeric
319- . derive ( 0 )
320- . to_public ( ) ;
321-
322- const baseAddress = CardanoWasm . BaseAddress . new (
323- networkId ,
324- CardanoWasm . StakeCredential . from_keyhash (
325- utxoKey . to_public ( ) . to_raw_key ( ) . hash ( ) ,
326- ) ,
327- CardanoWasm . StakeCredential . from_keyhash ( stakeKey . to_raw_key ( ) . hash ( ) ) ,
328- ) ;
329-
330- const address = baseAddress . to_address ( ) . to_bech32 ( ) ;
331-
332- return { signKey : utxoKey . to_raw_key ( ) , address : address } ;
333- } ;
334-
335- private mnemonicToPrivateKey (
336- mnemonic : string ,
337- ) : CardanoWasm . Bip32PrivateKey {
338- const entropy = mnemonicToEntropy ( mnemonic ) ;
339-
340- const rootKey = CardanoWasm . Bip32PrivateKey . from_bip39_entropy (
341- Buffer . from ( entropy , 'hex' ) ,
342- Buffer . from ( '' ) ,
343- ) ;
344-
345- return rootKey ;
346- } ;
347295}
0 commit comments