Transaction internal structure


#1

I'm trying to understand the inner workings of zcash. If I look at transaction 1f87d128efbe29a751117ede4b7977697a5f85ba4d16733cdb0f82cc9cda7733 with zcash-cli getrawtransaction 1f87d128efbe29a751117ede4b7977697a5f85ba4d16733cdb0f82cc9cda7733 1 I get the following:

{
    "hex" : "0200000....d6fb9207",
    "txid" : "1f87d128efbe29a751117ede4b7977697a5f85ba4d16733cdb0f82cc9cda7733",
    "version" : 2,
    "locktime" : 0,
    "vin" : [
        {
            "txid" : "37186c97ae98294b17ff6a3731b1a8e2db8054226f0761a49952a5199028148a",
            "vout" : 0,
            "scriptSig" : {
                "asm" : "304402207ce7a63adf38c35d846f06e3452151e939e0ede513fca15763140e772c546219022027d25c1e85ae6d018e7883d77db579c7d4ca2fb240eb9f6093691ab5acda5d5b01 03aba319c5aca2a1916919121a882dd9bbaab0a8ea7b5b0b5d95dc48ea616c340f",
                "hex" : "47304402207ce7a63adf38c35d846f06e3452151e939e0ede513fca15763140e772c546219022027d25c1e85ae6d018e7883d77db579c7d4ca2fb240eb9f6093691ab5acda5d5b012103aba319c5aca2a1916919121a882dd9bbaab0a8ea7b5b0b5d95dc48ea616c340f"
            },
            "sequence" : 4294967295
        }
    ],
    "vout" : [
    ],
    "vjoinsplit" : [
        {
            "anchor" : "8aa07978e5f7e3046033fda41bbaafea8aa3c4d9319add934d31ff8c43747ebf",
            "nullifiers" : [
                "761112ba12e2822bfca6275e5df2f1d0f13826a5d7c52d6d1200a4f77c7fac77",
                "9307557e3bffaeae7776476363f5175c2f648a1364e8decb734fc00b91da8fa6"
            ],
            "commitments" : [
                "3b24c81628203ba9d3cb77b10ce210b938b8878aa0405d1379a329105fe7048a",
                "f94910d68a1f7e589e8d40a93d9e5dddd533f5f4538a417c1f95060cdfcf26b5"
            ],
            "macs" : [
                "236363ce454dbf7a74cb9e48bb4618201094c8495629fabd62707be8bb0fa55c",
                "f8ec3f444637e6e070f3e69f01da0ea9bf8d841e47606f59c04a6c7acdb78634"
            ],
            "vpub_old" : 0.00224536,
            "vpub_new" : 0.00000000
        }
    ],
    "blockhash" : "0000000455715d0627fd0a13edb4086ea64ed1ceeb7c8e3dd5a3d5f67003e683",
    "confirmations" : 2391,
    "time" : 1477887298,
    "blocktime" : 1477887298
}
  • 1) What does version mean, and what's the difference between the different version values (I've seen 1 and 2 and maybe 5 (?) so far)?

  • 2) What does locktime: 0 mean?

  • 3) I can see that this transaction has no public outputs (empty vout) and uses a JoinSplit. That single JoinSplit's amount is vpub_old - vpub_new, i.e. initial balance - remaining balance = 0.00224536. Correct?

  • 4) The source of this transaction appears to be another transaction, namely 37186c97ae98294b17ff6a3731b1a8e2db8054226f0761a49952a5199028148a. If I look that up with zcash-cli getrawtransaction 37186c97ae98294b17ff6a3731b1a8e2db8054226f0761a49952a5199028148a 1 I get:

{
    "hex" : "0100000002....40000",
    "txid" : "37186c97ae98294b17ff6a3731b1a8e2db8054226f0761a49952a5199028148a",
    "version" : 1,
    "locktime" : 1107,
    "vin" : [
        {
            "txid" : "01cfc290106651094cd8b8569db614e9b01a425b1b4b71df6342171a13402174",
            "vout" : 0,
            "scriptSig" : {
                "asm" : "30440220017edc9a2db3cfd4b22673629402d161d1f8e5099076393fbcde165c9d11fe25022016a731abb21e72693ed99340672271096153b35f633b6e7eef97eb412345caa201 03a880d5b390506805ac05c05d9021f4657c79a753847623a0bd61b670450ee69c",
                "hex" : "4730440220017edc9a2db3cfd4b22673629402d161d1f8e5099076393fbcde165c9d11fe25022016a731abb21e72693ed99340672271096153b35f633b6e7eef97eb412345caa2012103a880d5b390506805ac05c05d9021f4657c79a753847623a0bd61b670450ee69c"
            },
            "sequence" : 4294967294
        },
        {
            "txid" : "caec905a05bd4293f4034427cfa914d9ae30db1dcf8f9465b393772659983c2c",
            "vout" : 0,
            "scriptSig" : {
                "asm" : "304502210080df125310ff82739d2735326767a8f44c1bb93461c7793441eaa3c04508e29302200b3828bd5ce418b0e0cd7598058c922aa8e9eeb185f968e2ce61b4ecb8d814d301 03a880d5b390506805ac05c05d9021f4657c79a753847623a0bd61b670450ee69c",
                "hex" : "48304502210080df125310ff82739d2735326767a8f44c1bb93461c7793441eaa3c04508e29302200b3828bd5ce418b0e0cd7598058c922aa8e9eeb185f968e2ce61b4ecb8d814d3012103a880d5b390506805ac05c05d9021f4657c79a753847623a0bd61b670450ee69c"
            },
            "sequence" : 4294967294
        }
    ],
    "vout" : [
        {
            "value" : 0.00234536,
            "n" : 0,
            "scriptPubKey" : {
                "asm" : "OP_DUP OP_HASH160 43ed97ecee51e1bd28b44815b9c0fa6657e83e88 OP_EQUALVERIFY OP_CHECKSIG",
                "hex" : "76a91443ed97ecee51e1bd28b44815b9c0fa6657e83e8888ac",
                "reqSigs" : 1,
                "type" : "pubkeyhash",
                "addresses" : [
                    "t1Q4muUHEUMG1qRnY2H9GWMZUKenpc9oVh3"
                ]
            }
        },
        {
            "value" : 0.00539998,
            "n" : 1,
            "scriptPubKey" : {
                "asm" : "OP_DUP OP_HASH160 4e4aed57beb456d8a1e6ec0aa0a35a5b002d0bce OP_EQUALVERIFY OP_CHECKSIG",
                "hex" : "76a9144e4aed57beb456d8a1e6ec0aa0a35a5b002d0bce88ac",
                "reqSigs" : 1,
                "type" : "pubkeyhash",
                "addresses" : [
                    "t1R1aUKrfcB1zmhL25sEde8LvV8u9mzNYPi"
                ]
            }
        }
    ],
    "vjoinsplit" : [
    ],
    "blockhash" : "0000000adb3f7348293808fb4180fd7bed6a8c62ed37733ea2ad3cf30bedf397",
    "confirmations" : 3186,
    "time" : 1477768138,
    "blocktime" : 1477768138
}

so it appears to me that the source of the first (version=2) transaction is another transaction (version=1) which in turn has to other transactions as input. I tried going down that rabbit hole, but to no avail. Even more puzzling to me is that the second transaction has two inputs, and two outputs. I see that only one of these has the proper amount, but theoretically both amounts could be equal and then I wouldn't know which belongs to which... So how do I find out which "address" (or "account"?) was the input to the first transaction?

  • 5) Does the verbose output from above contain all information, or do I need to encode e.g. vin[0].scriptSig.hex (first transaction) or vin[0].scriptSig.hex (second transaction)?