Skip to content

Commit cfef054

Browse files
authored
Merge pull request #3175 from nervosnetwork/rc/v0.116.1
2 parents 3373f2d + e823210 commit cfef054

File tree

7 files changed

+79
-6
lines changed

7 files changed

+79
-6
lines changed

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
# 0.116.1 (2024-05-28)
2+
3+
### CKB Node & Light Client
4+
5+
- [CKB@v0.116.1](https://github.com/nervosnetwork/ckb/releases/tag/v0.116.1) was released on May. 11st, 2024. This version of CKB node is now bundled and preconfigured in Neuron.
6+
- [CKB Light Client@v0.3.7](https://github.com/nervosnetwork/ckb-light-client/releases/tag/v0.3.7) was released on Apr. 13th, 2024. This version of CKB Light Client is now bundled and preconfigured in Neuron
7+
8+
### Assumed valid target
9+
10+
Block before `0x6dd077b407d019a0bce0cbad8c34e69a524ae4b2599b9feda2c7491f3559d32c`(at height `13,007,704`) will be skipped in validation.(https://github.com/nervosnetwork/neuron/pull/3157)
11+
12+
---
13+
14+
## Bug fixes
15+
16+
- 3173: Fix importing an account from a hardware wallet.(@yanguoyu)
17+
18+
**Full Changelog**: https://github.com/nervosnetwork/neuron/compare/v0.116.0...v0.116.1
19+
120
# 0.116.0 (2024-05-24)
221

322
### CKB Node & Light Client

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"packages": ["packages/*"],
3-
"version": "0.116.0",
3+
"version": "0.116.1",
44
"npmClient": "yarn",
55
"$schema": "node_modules/lerna/schemas/lerna-schema.json"
66
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "neuron",
33
"productName": "Neuron",
44
"description": "CKB Neuron Wallet",
5-
"version": "0.116.0",
5+
"version": "0.116.1",
66
"private": true,
77
"author": {
88
"name": "Nervos Core Dev",

packages/neuron-ui/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "neuron-ui",
3-
"version": "0.116.0",
3+
"version": "0.116.1",
44
"private": true,
55
"author": {
66
"name": "Nervos Core Dev",

packages/neuron-wallet/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"productName": "Neuron",
44
"description": "CKB Neuron Wallet",
55
"homepage": "https://www.nervos.org/",
6-
"version": "0.116.0",
6+
"version": "0.116.1",
77
"private": true,
88
"author": {
99
"name": "Nervos Core Dev",
@@ -97,7 +97,7 @@
9797
"electron-builder": "24.9.1",
9898
"electron-devtools-installer": "3.2.0",
9999
"jest-when": "3.6.0",
100-
"neuron-ui": "0.116.0",
100+
"neuron-ui": "0.116.1",
101101
"typescript": "5.3.3"
102102
}
103103
}

packages/neuron-wallet/src/services/hardware/ledger.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,20 @@ import logger from '../../utils/logger'
1212
import NetworksService from '../../services/networks'
1313
import { generateRPC } from '../../utils/ckb-rpc'
1414

15+
const UNCOMPRESSED_KEY_LENGTH = 130
16+
const compressPublicKey = (key: string) => {
17+
if (key.length !== UNCOMPRESSED_KEY_LENGTH) {
18+
return key
19+
}
20+
21+
const publicKey = Buffer.from(key, 'hex')
22+
const compressedPublicKey = Buffer.alloc(33)
23+
// '03' for odd value, '02' for even value
24+
.fill(publicKey[64] & 1 ? '03' : '02', 0, 1, 'hex')
25+
.fill(publicKey.subarray(1, 33), 1, 33)
26+
return compressedPublicKey.toString('hex')
27+
}
28+
1529
export default class Ledger extends Hardware {
1630
private ledgerCKB: LedgerCKB | null = null
1731
private transport: Transport | null = null
@@ -41,8 +55,9 @@ export default class Ledger extends Hardware {
4155

4256
public async getExtendedPublicKey(): Promise<ExtendedPublicKey> {
4357
const { public_key, chain_code } = await this.ledgerCKB!.getWalletExtendedPublicKey(this.defaultPath)
58+
// The ledger wallet's public key is unzipped, so zip it to 33 bytes https://en.bitcoin.it/wiki/BIP_0032 serializes the coordinate pair P
4459
return {
45-
publicKey: public_key,
60+
publicKey: compressPublicKey(public_key),
4661
chainCode: chain_code,
4762
}
4863
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import Ledger from '../../../src/services/hardware/ledger'
2+
3+
const getWalletExtendedPublicKeyMock = jest.fn()
4+
5+
jest.mock('hw-app-ckb', () => {
6+
return function () {
7+
return {
8+
getWalletExtendedPublicKey: getWalletExtendedPublicKeyMock,
9+
}
10+
}
11+
})
12+
13+
jest.mock('@ledgerhq/hw-transport-node-hid', () => ({
14+
open: jest.fn(),
15+
}))
16+
17+
const pk =
18+
'04d061e9c5891f579fd548cfd22ff29f5c642714cc7e7a9215f0071ef5a5723f691757b28e31be71f09f24673eed52348e58d53bcfd26f4d96ec6bf1489eab429d'
19+
const zipPk = '03d061e9c5891f579fd548cfd22ff29f5c642714cc7e7a9215f0071ef5a5723f69'
20+
21+
describe('test for ledger', () => {
22+
describe('test getExtendedPublicKey', () => {
23+
it('if the return pk is unzip', async () => {
24+
getWalletExtendedPublicKeyMock.mockResolvedValueOnce({ public_key: pk, chain_code: '0x' })
25+
const ledger = new Ledger({} as any)
26+
await ledger.connect()
27+
const res = await ledger.getExtendedPublicKey()
28+
expect(res.publicKey).toBe(zipPk)
29+
})
30+
31+
it('if the return pk is zip', async () => {
32+
getWalletExtendedPublicKeyMock.mockResolvedValueOnce({ public_key: zipPk, chain_code: '0x' })
33+
const ledger = new Ledger({} as any)
34+
await ledger.connect()
35+
const res = await ledger.getExtendedPublicKey()
36+
expect(res.publicKey).toBe(zipPk)
37+
})
38+
})
39+
})

0 commit comments

Comments
 (0)