锯齿交易有效载荷解码

时间:2018-09-19 07:47:43

标签: hyperledger blockchain hyperledger-sawtooth

我在锯齿上开了一笔交易。我可以使用API​​查看交易数据。我的问题是如何解码事务负载。

{
      "header": {
        "batcher_public_key": "03d58421f80cf7f2d51efd7f4fc28fd07a81de146f7d01acc70c9e5dcfdf2cc20f",
        "dependencies": [],
        "family_name": "document",
        "family_version": "1.0",
        "inputs": [
          "7d5acb"
        ],
        "nonce": "",
        "outputs": [
          "7d5acb"
        ],
        "payload_sha512": "9be6b4029768c2dda71b86eed2b1ba441442ec56714b863993f12aeab09242ef84087bc53b0cfadb93bbf99bcc7cdb8e03d71b1158887c8c3735abafb9765a43",
        "signer_public_key": "03d58421f80cf7f2d51efd7f4fc28fd07a81de146f7d01acc70c9e5dcfdf2cc20f"
      },
      "header_signature": "e4379a4a4f66c52677df299ddc136a968efb64fba9de30acdf230a719442cdc56c2cf55953c14bbc5cc68991a8bef156df3d32fcf6c37f201c279f6ad7065cab",
      "payload": "o2RWZXJiY3NldGROYW1leCBlZjlkMThjZGIwYjNkZDNmNWU1ZWE2MDliZjY3MDhmOWVWYWx1ZWA="
    }

我要解码有效载荷”:"o2RWZXJiY3NldGROYW1leCBlZjlkMThjZGIwYjNkZDNmNWU1ZWE2MDliZjY3MDhmOWVWYWx1ZWA=".
任何人都可以指导。

1 个答案:

答案 0 :(得分:5)

sawtooth rest-api返回base64编码的数据,首先,您必须解码您的数据,

    import base64
    decoded = base64.b64decode("o2RWZXJiY3NldGROYW1leCBlZjlkMThjZGIwYjNkZDNmNWU1ZWE2MDliZjY3MDhmOWVWYWx1ZWA=")

现在,这实际上取决于您如何编码数据,对cbor,protobuf等使用反序列化。