Skip to content

Commit 343af80

Browse files
authored
improve response (#12)
1 parent 124875f commit 343af80

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/index.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,18 @@ function processGetAddrResponse(response: Buffer) {
6969
partialResponse = partialResponse.slice(1 + PKLEN)
7070

7171
let hash: Buffer | undefined
72+
let address: string;
73+
7274
if(PKLEN != ED25519_PK_SIZE) {
7375
hash = Buffer.from(partialResponse.slice(0, 20))
74-
}
7576

76-
//"advance" buffer
77-
partialResponse = partialResponse.slice(20)
78-
79-
const address = Buffer.from(partialResponse.subarray(0, -2)).toString()
77+
//"advance" buffer
78+
partialResponse = partialResponse.slice(20)
79+
address = Buffer.from(partialResponse.subarray(0, -2)).toString()
80+
} else {
81+
// ED25519: Convert raw bytes to hex string
82+
address = partialResponse.subarray(0, -2).toString('hex');
83+
}
8084

8185
return {
8286
publicKey,

0 commit comments

Comments
 (0)