OdyseeTeam / chainquery

Chainquery parses and syncs the LBRY blockchain data into structured SQL
https://lbry.tech
MIT License
2.26k stars 42 forks source link

store purchase information in transaction data (new table) #138

Open tzarebczan opened 4 years ago

tzarebczan commented 4 years ago

We should store content purchases in chainquery - would this go in the transaction data or a new table?

A purchase tx looks like this: https://explorer.lbry.com/tx/9a6829c34c850d5c6104b215543cb35624ee158cce0f72f8eb3d21e63c0b5e15


  ],
  "vout": [
    {
      "value": 1.00000000,
      "n": 0,
      "scriptPubKey": {
        "asm": "OP_DUP OP_HASH160 ced311ef2411f89ea678e0d69be93a3750e01eb6 OP_EQUALVERIFY OP_CHECKSIG",
        "hex": "76a914ced311ef2411f89ea678e0d69be93a3750e01eb688ac",
        "reqSigs": 1,
        "type": "pubkeyhash",
        "addresses": [
          "bXark9nmwzYuGD5XepqUbfwREQ6u7VEjHE"
        ]
      }
    },
    {
      "value": 0.00000000,
      "n": 1,
      "scriptPubKey": {
        "asm": "OP_RETURN 500a14d55dfc23482a3269b606c56119e754dc7e2ccf83",
        "hex": "6a17500a14d55dfc23482a3269b606c56119e754dc7e2ccf83",
        "type": "nulldata"
      }
    },
    {
      "value": 48.88847050,
      "n": 2,
      "scriptPubKey": {
        "asm": "OP_DUP OP_HASH160 5f421acc6d6cd9eb31ec568055e361e371527992 OP_EQUALVERIFY OP_CHECKSIG",
        "hex": "76a9145f421acc6d6cd9eb31ec568055e361e37152799288ac",
        "reqSigs": 1,
        "type": "pubkeyhash",
        "addresses": [
          "bMQx5VHQRyuDdjbsnzzAFRWkDiwi1unQmV"
        ]
      }
    }
  ]```
tiger5226 commented 4 years ago

How do I know this is a purchase transaction vs any other transaction where LBC changes hands ?

tzarebczan commented 4 years ago

You'll have an op return and that will decode to the claim id of the purchase, https://explorer.lbry.com/claims/83cf2c7edc54e71961c506b669322a4823fc5dd5 in this case.

tiger5226 commented 4 years ago
tzarebczan commented 4 years ago

The first vout will have the claim address and amount. We are not supporting ones with more than 1 per transaction at this time.