Skip to content

Commit

Permalink
Merge pull request #385 from nervosnetwork/serialize-signed-witnesses
Browse files Browse the repository at this point in the history
[ᚬmaster] fix(core): serialize the witnesses after it's signed
  • Loading branch information
Keith-CY authored Nov 8, 2019
2 parents 17cd05f + 08b5c1d commit 893e4ef
Show file tree
Hide file tree
Showing 13 changed files with 189 additions and 43 deletions.
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,28 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [0.24.2](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.24.1...v0.24.2) (2019-11-08)


### Bug Fixes

* **core:** serialize the witnesses after it's signed ([6d4bcdc](https://github.com/nervosnetwork/ckb-sdk-js/commit/6d4bcdca2f5076449ea4f75611ec4f3bcd467662))





## [0.24.1](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.24.0...v0.24.1) (2019-11-07)


### Bug Fixes

* **utils:** fix the precision-lost in toHexInLittleEndian ([9658a76](https://github.com/nervosnetwork/ckb-sdk-js/commit/9658a769e34344617c64d832322d8c85b72daea7))





# [0.24.0](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.23.1...v0.24.0) (2019-11-02)


Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"packages": [
"packages/*"
],
"version": "0.24.0"
"version": "0.24.2"
}
19 changes: 19 additions & 0 deletions packages/ckb-sdk-core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,25 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [0.24.2](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.24.1...v0.24.2) (2019-11-08)


### Bug Fixes

* **core:** serialize the witnesses after it's signed ([6d4bcdc](https://github.com/nervosnetwork/ckb-sdk-js/commit/6d4bcdca2f5076449ea4f75611ec4f3bcd467662))





## [0.24.1](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.24.0...v0.24.1) (2019-11-07)

**Note:** Version bump only for package @nervosnetwork/ckb-sdk-core





# [0.24.0](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.23.1...v0.24.0) (2019-11-02)


Expand Down
102 changes: 76 additions & 26 deletions packages/ckb-sdk-core/__tests__/fixtures.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,60 @@
},
"signTransaction": {
"basic transaction": {
"privateKey": "0xe79f3207ea4980b7fed79956d5934249ceac4751a4fae01a0f7c4a96884bc4e3",
"privateKey": "0xdcec27d0d975b0378471183a03f7071dea8532aaf968be796719ecd20af6988f",
"transaction": {
"cellDeps": [],
"cellDeps": [
{
"outPoint": {
"txHash": "0xbd864a269201d7052d4eb3f753f49f7c68b8edc386afc8bb6ef3e15a05facca2",
"index": "0x0"
},
"depType": "depGroup"
}
],
"headerDeps": [],
"inputs": [
{
"since": "0x0",
"previousOutput": {
"txHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"index": "0xffffffff"
},
"since": "0x0"
"txHash": "0x001748c1b5749af9636b940ae7d8d56d12a3de83f9020e765a5e108ca87873fa",
"index": "0x0"
}
},
{
"since": "0x0",
"previousOutput": {
"txHash": "0x00317da41f64a75f7cb0bd0238857e1dc75d50fae3f8bbab1e20e18840df024c",
"index": "0x0"
}
}
],
"outputs": [
{
"capacity": "0x48c27395000",
"capacity": "0x189640200",
"lock": {
"args": "0x",
"codeHash": "0x0000000000000000000000000000000000000000000000000000000000000001",
"hashType": "data"
},
"type": null
"args": "0x3cb5366451256c3c9f8d4e2fc2e2aa8fa5774756",
"codeHash": "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8",
"hashType": "type"
}
},
{
"capacity": "0x31eb37587",
"lock": {
"args": "0xc11d75be4531c9c0cca7531bab077f9a1710c87c",
"codeHash": "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8",
"hashType": "type"
}
}
],
"outputsData": ["0x"],
"outputsData": ["0x", "0x"],
"version": "0x0",
"witnesses": [
{
"lock": "",
"inputType": "",
"outputType": ""
},
{
"lock": "",
"inputType": "",
Expand All @@ -46,32 +73,55 @@
]
},
"expected": {
"cellDeps": [],
"cellDeps": [
{
"outPoint": {
"txHash": "0xbd864a269201d7052d4eb3f753f49f7c68b8edc386afc8bb6ef3e15a05facca2",
"index": "0x0"
},
"depType": "depGroup"
}
],
"headerDeps": [],
"inputs": [
{
"since": "0x0",
"previousOutput": {
"txHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"index": "0xffffffff"
},
"since": "0x0"
"txHash": "0x001748c1b5749af9636b940ae7d8d56d12a3de83f9020e765a5e108ca87873fa",
"index": "0x0"
}
},
{
"since": "0x0",
"previousOutput": {
"txHash": "0x00317da41f64a75f7cb0bd0238857e1dc75d50fae3f8bbab1e20e18840df024c",
"index": "0x0"
}
}
],
"outputs": [
{
"capacity": "0x48c27395000",
"capacity": "0x189640200",
"lock": {
"args": "0x",
"codeHash": "0x0000000000000000000000000000000000000000000000000000000000000001",
"hashType": "data"
},
"type": null
"args": "0x3cb5366451256c3c9f8d4e2fc2e2aa8fa5774756",
"codeHash": "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8",
"hashType": "type"
}
},
{
"capacity": "0x31eb37587",
"lock": {
"args": "0xc11d75be4531c9c0cca7531bab077f9a1710c87c",
"codeHash": "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8",
"hashType": "type"
}
}
],
"outputsData": ["0x"],
"outputsData": ["0x", "0x"],
"version": "0x0",
"witnesses": [
"0x5500000010000000550000005500000041000000e601e96d81b868b0f7feed9b23f48f0ff3d0206b055f77880d8408fd469d61b24c251969f69aa28fb17e2729457d7ff27e4e262fabc669240a7a6bff60f2ab0e01"
"0x55000000100000005500000055000000410000005bc073bf55db333d5680ddf36e4814b9ce2118cfe4504f95c7d3e9a7548e16886cf1a1481fd80ce70d5e19108a43fd17fa32aad0d46c30c3410001ed2934ad2f00",
"0x10000000100000001000000010000000"
]
}
},
Expand Down
10 changes: 5 additions & 5 deletions packages/ckb-sdk-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nervosnetwork/ckb-sdk-core",
"version": "0.24.0",
"version": "0.24.2",
"description": "JavaScript SDK for Nervos Network CKB Project",
"author": "Nervos <[email protected]>",
"homepage": "https://github.com/nervosnetwork/ckb-sdk-js#readme",
Expand Down Expand Up @@ -30,9 +30,9 @@
"url": "https://github.com/nervosnetwork/ckb-sdk-js/issues"
},
"dependencies": {
"@nervosnetwork/ckb-sdk-rpc": "0.24.0",
"@nervosnetwork/ckb-sdk-utils": "0.24.0",
"@nervosnetwork/ckb-types": "0.24.0"
"@nervosnetwork/ckb-sdk-rpc": "0.24.2",
"@nervosnetwork/ckb-sdk-utils": "0.24.2",
"@nervosnetwork/ckb-types": "0.24.2"
},
"gitHead": "4e76ada0c7315887acbf4eee27d264722a8d36e6"
"gitHead": "942872f4bfcf795bf516593a7d96126f058378db"
}
6 changes: 5 additions & 1 deletion packages/ckb-sdk-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,11 @@ class Core {
})
return {
...transaction,
witnesses: signedWitnesses,
witnesses: signedWitnesses.map(
witness => (
typeof witness === 'string' ? witness : this.utils.serializeWitnessArgs(witness)
)
),
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/ckb-sdk-core/src/signWitnessGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const signWitnessGroup = (
s.update(serializedEmptyWitnessBytes)

witnessGroup.slice(1).forEach(w => {
const bytes = typeof w === 'string' ? hexToBytes(w) : serializeWitnessArgs(w)
const bytes = hexToBytes(typeof w === 'string' ? w : serializeWitnessArgs(w))
s.update(hexToBytes(toHexInLittleEndian(bytes.length, 8)))
s.update(bytes)
})
Expand Down
16 changes: 16 additions & 0 deletions packages/ckb-sdk-rpc/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [0.24.2](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.24.1...v0.24.2) (2019-11-08)

**Note:** Version bump only for package @nervosnetwork/ckb-sdk-rpc





## [0.24.1](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.24.0...v0.24.1) (2019-11-07)

**Note:** Version bump only for package @nervosnetwork/ckb-sdk-rpc





# [0.24.0](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.23.1...v0.24.0) (2019-11-02)


Expand Down
8 changes: 4 additions & 4 deletions packages/ckb-sdk-rpc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nervosnetwork/ckb-sdk-rpc",
"version": "0.24.0",
"version": "0.24.2",
"description": "RPC module of @nervosnetwork/ckb-sdk-core",
"author": "Nervos <[email protected]>",
"homepage": "https://github.com/nervosnetwork/ckb-sdk-js/packages/ckb-rpc#readme",
Expand Down Expand Up @@ -32,12 +32,12 @@
"url": "https://github.com/nervosnetwork/ckb-sdk-js/issues"
},
"dependencies": {
"@nervosnetwork/ckb-sdk-utils": "0.24.0",
"@nervosnetwork/ckb-sdk-utils": "0.24.2",
"axios": "0.19.0"
},
"devDependencies": {
"@nervosnetwork/ckb-types": "0.24.0",
"@nervosnetwork/ckb-types": "0.24.2",
"dotenv": "8.1.0"
},
"gitHead": "4e76ada0c7315887acbf4eee27d264722a8d36e6"
"gitHead": "942872f4bfcf795bf516593a7d96126f058378db"
}
19 changes: 19 additions & 0 deletions packages/ckb-sdk-utils/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,25 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [0.24.2](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.24.1...v0.24.2) (2019-11-08)

**Note:** Version bump only for package @nervosnetwork/ckb-sdk-utils





## [0.24.1](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.24.0...v0.24.1) (2019-11-07)


### Bug Fixes

* **utils:** fix the precision-lost in toHexInLittleEndian ([9658a76](https://github.com/nervosnetwork/ckb-sdk-js/commit/9658a769e34344617c64d832322d8c85b72daea7))





# [0.24.0](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.23.1...v0.24.0) (2019-11-02)

**Note:** Version bump only for package @nervosnetwork/ckb-sdk-utils
Expand Down
6 changes: 3 additions & 3 deletions packages/ckb-sdk-utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nervosnetwork/ckb-sdk-utils",
"version": "0.24.0",
"version": "0.24.2",
"description": "Utils module of @nervosnetwork/ckb-sdk-core",
"author": "Nervos <[email protected]>",
"homepage": "https://github.com/nervosnetwork/ckb-sdk-js#readme",
Expand Down Expand Up @@ -30,7 +30,7 @@
"url": "https://github.com/nervosnetwork/ckb-sdk-js/issues"
},
"dependencies": {
"@nervosnetwork/ckb-types": "0.24.0",
"@nervosnetwork/ckb-types": "0.24.2",
"blake2b-wasm": "1.1.7",
"elliptic": "6.5.1"
},
Expand All @@ -39,5 +39,5 @@
"@types/elliptic": "6.4.8",
"@types/utf8": "2.1.6"
},
"gitHead": "4e76ada0c7315887acbf4eee27d264722a8d36e6"
"gitHead": "942872f4bfcf795bf516593a7d96126f058378db"
}
16 changes: 16 additions & 0 deletions packages/ckb-types/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [0.24.2](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.24.1...v0.24.2) (2019-11-08)

**Note:** Version bump only for package @nervosnetwork/ckb-types





## [0.24.1](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.24.0...v0.24.1) (2019-11-07)

**Note:** Version bump only for package @nervosnetwork/ckb-types





# [0.24.0](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.23.1...v0.24.0) (2019-11-02)


Expand Down
4 changes: 2 additions & 2 deletions packages/ckb-types/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nervosnetwork/ckb-types",
"version": "0.24.0",
"version": "0.24.2",
"description": "Type module of @nervosnetwork/ckb-sdk-core",
"author": "Nervos <[email protected]>",
"homepage": "https://github.com/nervosnetwork/ckb-sdk-js#readme",
Expand All @@ -23,5 +23,5 @@
"scripts": {
"doc": "../../node_modules/.bin/typedoc --out docs ./index.d.ts --mode modules --includeDeclarations --excludeExternals --ignoreCompilerErrors --theme default --readme README.md"
},
"gitHead": "4e76ada0c7315887acbf4eee27d264722a8d36e6"
"gitHead": "942872f4bfcf795bf516593a7d96126f058378db"
}

0 comments on commit 893e4ef

Please sign in to comment.