- 新增 tools/fisco-realnode/:真链实证期用过的 Python SDK 发送器 (fj-sdk/)、Java JNI 独立交叉验证探针 (jni/)、TARS 编解码辅助 (tars/), 作为审计轨迹留档,便于回看签名口径根因。 - 新增 example.chain.json(非密钥,可入库)与 README.md 索引:明确 规范入口 (selftest-fisco-contract.py 主门禁第22条) 与审计轨迹的分工、 复现所需环境变量、下载项、密钥与诚实边界。 - .gitignore 屏蔽私钥 (*.pem/*.key)、下载型二进制 (jar/tar.gz) 与大证据 blob,防止密钥或体积大的文件进 git 历史。
32 lines
1.3 KiB
Java
32 lines
1.3 KiB
Java
import org.fisco.bcos.sdk.jni.common.JniLibLoader;
|
|
import org.fisco.bcos.sdk.jni.utilities.tx.TransactionStructBuilderJniObj;
|
|
import org.fisco.bcos.sdk.jni.utilities.tx.Transaction;
|
|
|
|
/**
|
|
* 用官方 JNI 解码我构造的交易 TARS 字节,输出官方视角的 JSON。
|
|
*
|
|
* 用法: java -cp bcos-sdk-jni.jar Decode <txHexFile>
|
|
*/
|
|
public class Decode {
|
|
public static void main(String[] args) throws Exception {
|
|
JniLibLoader.loadJniLibrary();
|
|
String hex = new String(java.nio.file.Files.readAllBytes(
|
|
java.nio.file.Paths.get(args[0])), "utf-8").trim();
|
|
if (hex.startsWith("0x")) hex = hex.substring(2);
|
|
|
|
Transaction tx = TransactionStructBuilderJniObj.decodeTransactionStruct(hex);
|
|
String json = TransactionStructBuilderJniObj.encodeTransactionStructToJson(tx);
|
|
System.out.println("OFFICIAL_JSON=" + json);
|
|
|
|
byte[] dh = tx.getDataHash();
|
|
StringBuilder sb = new StringBuilder();
|
|
for (byte b : dh) sb.append(String.format("%02x", b));
|
|
System.out.println("OFFICIAL_DECODED_HASH=" + sb);
|
|
|
|
byte[] sg = tx.getSignature();
|
|
StringBuilder sb2 = new StringBuilder();
|
|
for (byte b : sg) sb2.append(String.format("%02x", b));
|
|
System.out.println("OFFICIAL_DECODED_SIG=" + sb2);
|
|
}
|
|
}
|