File tree Expand file tree Collapse file tree 5 files changed +13
-8
lines changed
Expand file tree Collapse file tree 5 files changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -234,7 +234,7 @@ export class OceanP2P extends EventEmitter {
234234 P2P_LOGGER . info ( `Starting P2P Node with peerID: ${ this . _publicAddress } ` )
235235
236236 this . _publicKey = config . keys . publicKey
237- this . _privateKey = config . keys . privateKey
237+ this . _privateKey = config . keys . privateKey . raw
238238 /** @type {import('libp2p').Libp2pOptions } */
239239 // start with some default, overwrite based on config later
240240 const bindInterfaces = [ ]
@@ -341,7 +341,7 @@ export class OceanP2P extends EventEmitter {
341341
342342 let options = {
343343 addresses,
344- peerId : config . keys . peerId ,
344+ privateKey : config . keys . privateKey ,
345345 transports,
346346 streamMuxers : [ yamux ( ) ] ,
347347 connectionEncryption : [
Original file line number Diff line number Diff line change @@ -108,7 +108,7 @@ export async function handleDownloadUrlCommand(
108108 // we parse the string into the object again
109109 const encryptedObject = ethCrypto . cipher . parse ( task . aes_encrypted_key )
110110 // get the key from configuration
111- const nodePrivateKey = Buffer . from ( config . keys . privateKey ) . toString ( 'hex' )
111+ const nodePrivateKey = Buffer . from ( config . keys . privateKey . raw ) . toString ( 'hex' )
112112 const decrypted = await ethCrypto . decryptWithPrivateKey (
113113 nodePrivateKey ,
114114 encryptedObject
Original file line number Diff line number Diff line change @@ -452,15 +452,15 @@ export async function checkFee(
452452 */
453453export async function getProviderWallet ( chainId ?: string ) : Promise < ethers . Wallet > {
454454 return new ethers . Wallet (
455- Buffer . from ( ( await getConfiguration ( ) ) . keys . privateKey ) . toString ( 'hex' )
455+ Buffer . from ( ( await getConfiguration ( ) ) . keys . privateKey . raw ) . toString ( 'hex' )
456456 )
457457}
458458export async function getProviderWalletAddress ( ) : Promise < string > {
459459 return ( await getProviderWallet ( ) ) . address
460460}
461461
462462export async function getProviderKey ( ) : Promise < string > {
463- return Buffer . from ( ( await getConfiguration ( ) ) . keys . privateKey ) . toString ( 'hex' )
463+ return Buffer . from ( ( await getConfiguration ( ) ) . keys . privateKey . raw ) . toString ( 'hex' )
464464}
465465
466466/**
Original file line number Diff line number Diff line change @@ -9,12 +9,13 @@ import {
99 setupEnvironment ,
1010 tearDownEnvironment
1111} from '../utils/utils.js'
12+ import { OceanNodeConfig } from '../../@types/OceanNode.js'
1213
1314describe ( 'OceanP2P Test' , ( ) => {
1415 let node1 : OceanP2P
1516 let node2 : OceanP2P
16- let config1 : any
17- let config2 : any
17+ let config1 : OceanNodeConfig
18+ let config2 : OceanNodeConfig
1819 const mDNSInterval : number = 1
1920
2021 const envOverrides = buildEnvOverrideConfig (
@@ -67,6 +68,10 @@ describe('OceanP2P Test', () => {
6768 assert ( node2 , 'Failed to create P2P Node instance' )
6869 } )
6970 it ( 'Start check peerID of each node' , ( ) => {
71+ console . log ( config1 . keys . peerId . toString ( ) )
72+ console . log ( node1 . _libp2p . peerId . toString ( ) )
73+ console . log ( config2 . keys . peerId . toString ( ) )
74+ console . log ( node2 . _libp2p . peerId . toString ( ) )
7075 assert (
7176 config1 . keys . peerId . toString ( ) === node1 . _libp2p . peerId . toString ( ) ,
7277 'Peer missmatch for node1'
Original file line number Diff line number Diff line change @@ -90,7 +90,7 @@ export function getPeerIdFromPrivateKey(privateKey: string): OceanNodeKeys {
9090 return {
9191 peerId : peerIdFromPrivateKey ( key ) ,
9292 publicKey : key . publicKey . raw ,
93- privateKey : key . raw ,
93+ privateKey : key ,
9494 ethAddress : new Wallet ( privateKey . substring ( 2 ) ) . address
9595 }
9696}
You can’t perform that action at this time.
0 commit comments