Skip to content

Commit 33f6016

Browse files
authored
Merge pull request #356 from tronprotocol/develop-evan-blocksign
block witness signature need not to base64
2 parents 10d9c5a + b170542 commit 33f6016

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/main/java/org/tron/core/capsule/BlockCapsule.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ public void sign(byte[] privateKey) {
184184
// TODO private_key == null
185185
ECKey ecKey = ECKey.fromPrivate(privateKey);
186186
ECDSASignature signature = ecKey.sign(getRawHash().getBytes());
187-
ByteString sig = ByteString.copyFrom(signature.toBase64().getBytes());
187+
ByteString sig = ByteString.copyFrom(signature.toByteArray());
188188

189189
BlockHeader blockHeader = this.block.getBlockHeader().toBuilder().setWitnessSignature(sig)
190190
.build();
@@ -201,7 +201,8 @@ public boolean validateSignature() throws ValidateSignatureException {
201201
try {
202202
return Arrays
203203
.equals(ECKey.signatureToAddress(getRawHash().getBytes(),
204-
block.getBlockHeader().getWitnessSignature().toStringUtf8()),
204+
TransactionCapsule
205+
.getBase64FromByteString(block.getBlockHeader().getWitnessSignature())),
205206
block.getBlockHeader().getRawData().getWitnessAddress().toByteArray());
206207
} catch (SignatureException e) {
207208
throw new ValidateSignatureException(e.getMessage());
@@ -228,9 +229,9 @@ public Sha256Hash calcMerkleRoot() {
228229
}
229230

230231
Vector<Sha256Hash> ids = transactionsList.stream()
231-
.map(TransactionCapsule::new)
232-
.map(TransactionCapsule::getHash)
233-
.collect(Collectors.toCollection(Vector::new));
232+
.map(TransactionCapsule::new)
233+
.map(TransactionCapsule::getHash)
234+
.collect(Collectors.toCollection(Vector::new));
234235

235236
return MerkleTree.getInstance().createTree(ids).getRoot().getHash();
236237
}

0 commit comments

Comments
 (0)