2

我在 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=".
任何人都可以请指导。

4

1 回答 1

5

锯齿rest-api返回base64编码数据,首先你必须解码你的数据,

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

现在它真的取决于你如何编码你的数据,对 cbor、protobuf 等使用反序列化。

于 2018-09-19T09:00:27.950 回答