dcrwallet icon indicating copy to clipboard operation
dcrwallet copied to clipboard

Create listtickets json rpc method

Open kLkA opened this issue 6 years ago • 5 comments

kLkA avatar Jun 06 '18 20:06 kLkA

listtickets cmd produces an array of ticket information objects. Example

[
{
    "ticket": {
      "hash": "eda7d5738f741eada4dab771e8dd00bc6364c0914895484eb4269d911c7e7f41",
      "transaction": "01000000016a24f6e5de17b5e584c71f9ed952897f58a25c4ab7525ff4d8068ff61d8440011700000000ffffffff03204e00000000000000001aba76a9144ecfeff56944d17012052cd00389b3659633260c88ac00000000000000000000206a1ec37fdbc1d72106c04c558824832c4e84c3309aef50c30000000000000058000000000000000000001abd76a914000000000000000000000000000000000000000088ac000000000000000001ffffffffffffffff00000000ffffffff6b483045022100b2923a0ac6a5c94c46c9fedccad1d9617fedb7cc4b08339fcecf7a2e4d7b207102204ddea8d8379653dfd91be4a19096f7012b851478bb492d5d904d7f1c5cb84f8b01210231ffb5dcacfee9d2fdd11a52d13c429e5befe84059e995ee57bf14234c31590e",
      "my_inputs": [
        {
          "index": 0,
          "previous_account": 0,
          "previous_amount": 0.0005
        }
      ],
      "my_outputs": [
        {
          "index": 0,
          "account": 0,
          "internal": true,
          "amount": 0.0002,
          "address": {},
          "output_script": "ba76a9144ecfeff56944d17012052cd00389b3659633260c88ac"
        }
      ],
      "fee": 0.0003,
      "timestamp": 1528314256,
      "type": 2
    },
    "spender": {
      "hash": "0b2ff971ffea03994cc7308965069d3fcc0136a53d28ffaf67924e4d4970ba5a",
      "transaction": "01000000020000000000000000000000000000000000000000000000000000000000000000ffffffff00ffffffff417f7e1c919d26b44e48954891c06463bc00dde871b7daa4ad1e748f73d5a7ed0000000001ffffffff0300000000000000000000266a24f3a71549658df4e19aeb8013a87fdc6b361a6a4b3c1c819ac13ba58585a211799800000000000000000000000000086a06010006000000e5700bb10000000000001abb76a914c37fdbc1d72106c04c558824832c4e84c3309aef88ac000000000000000002c5220bb10000000000000000ffffffff04deadbeefffffffffffffffff00000000ffffffff6a473044022039a0e682f54cc83c37a8c7b919e931422d0ff98093c57568940773ce1adfc777022016e052d1870bed6bbab1decd39b46514b0fc8f2b13dd947b91d0d6601dcce4c2012102adc3e624cdfcdc422ce77a4451d240b4bfc099df2489cc2d6a186c7698886b9b",
      "my_inputs": [
        {
          "index": 1,
          "previous_account": 0,
          "previous_amount": 0.0002
        }
      ],
      "my_outputs": [
        {
          "index": 2,
          "account": 0,
          "internal": true,
          "amount": 29.70317029,
          "address": {},
          "output_script": "bb76a914c37fdbc1d72106c04c558824832c4e84c3309aef88ac"
        }
      ],
      "fee": 0,
      "timestamp": 1528315038,
      "type": 3
    },
    "status": "VOTED"
  }
]

kLkA avatar Jun 06 '18 21:06 kLkA

The numbers in "type": 2 and "type": 3 should be replaced with strings which indicate what the "type" actually is. Right now even I'm not sure what these are indicating, without first diving into the implementation.

Since this is the JSON-RPC API, and for this API we prefer to use account names rather than numbers (as the gRPC API does), both the previous and output accounts should be the account name.

How are you determining the input amount for ticket inputs? The first and only input in this transaction doesn't have any previous amount set.

Why is the value for the "address" field an empty JSON object?

Once again this will run into issues in SPV wallets, where the ticket status might be indeterminable without additional states to report.

jrick avatar Sep 24 '18 13:09 jrick

Did an update regarding SPV wallet implementation and applied changes corresponding to your remarks, example below:

Live ticket (default)

{                                                                                                                                                                                                                                                          [17/1334]
    "ticket": {                                                                                                                                                                                                                                                      
      "hash": "05d8f596b59e1612e5ec84fd7ef609c39833cd4d58cdd0630d7731f5ce802911",                                                                                                                                                                                    
      "transaction": "010000000171dc859320fdf63f320d439a15029e069ff019c0e1d9817fa581f33c854cc76b0800000000ffffffff03204e00000000000000001aba76a914d8bde14c5ab57ab9d814a8e1e38ed0d33eff895988ac00000000000000000000206a1e2c0f432588b17d3989debb15a5236c7df613fc9b88c20$
00000000000058000000000000000000001abd76a914000000000000000000000000000000000000000088ac00000000000000000188c200000000000000000000ffffffff6b483045022100bd94f8e56f363bb12f463d5a5461809c547a586644d1a3c1bc2be9d33dfe26c3022069d7c2eb853caa854e2f9af823c265ce110a09229$
1d79b3d6c30fbb1c9fee6b012102d4673d664536506cf61e787470dfe5131b0b74f2e410c50877dbf7a98900b340",                                                                                                                                                                       
      "myinputs": [                                                                                                                                                                                                                                                  
        {                                                                                                                                                                                                                                                            
          "index": 0,
          "previousaccount": "default",
          "previousamount": 0.000498
        }
      ],
      "myoutputs": [
        {
          "index": 0,
          "account": "default",
          "internal": false,
          "amount": 0.0002,
          "address": "Ssp7J7TUmi5iPhoQnWYNGQbeGhu6V3otJcS",
          "outputscript": "ba76a914d8bde14c5ab57ab9d814a8e1e38ed0d33eff895988ac"
        }
      ],
      "fee": 0.000298,
      "timestamp": 1539110379,
      "type": "TICKETPURCHASE"
    },
    "spender": null,
    "status": "LIVE"
  }

Live ticket (SPV mode)

{                                                                                                                                                                                                                                                                   
    "ticket": {                                                                                                                                                                                                                                                       
      "hash": "05d8f596b59e1612e5ec84fd7ef609c39833cd4d58cdd0630d7731f5ce802911",                                                                                                                                                                                     
      "transaction": "010000000171dc859320fdf63f320d439a15029e069ff019c0e1d9817fa581f33c854cc76b0800000000ffffffff03204e00000000000000001aba76a914d8bde14c5ab57ab9d814a8e1e38ed0d33eff895988ac00000000000000000000206a1e2c0f432588b17d3989debb15a5236c7df613fc9b88c20$
00000000000058000000000000000000001abd76a914000000000000000000000000000000000000000088ac00000000000000000188c200000000000000000000ffffffff6b483045022100bd94f8e56f363bb12f463d5a5461809c547a586644d1a3c1bc2be9d33dfe26c3022069d7c2eb853caa854e2f9af823c265ce110a09229$
1d79b3d6c30fbb1c9fee6b012102d4673d664536506cf61e787470dfe5131b0b74f2e410c50877dbf7a98900b340",                                                                                                                                                                        
      "myinputs": [                                                                                                                                                                                                                                                   
        {                                                                                                                                                                                                                                                             
          "index": 0,                                                                                                                                                                                                                                                 
          "previousaccount": "default",                                                                                                                                                                                                                               
          "previousamount": 0.000498                                                                                                                                                                                                                                  
        }                                                                                                                                                                                                                                                             
      ],
      "myoutputs": [
        {
          "index": 0,
          "account": "default",
          "internal": false,
          "amount": 0.0002,
          "address": "Ssp7J7TUmi5iPhoQnWYNGQbeGhu6V3otJcS",
          "outputscript": "ba76a914d8bde14c5ab57ab9d814a8e1e38ed0d33eff895988ac"
        }
      ],
      "fee": 0.000298,
      "timestamp": 1539110380,
      "type": "TICKETPURCHASE"
    },
    "spender": null,
    "status": "UNSPENT"
  }

Voted ticket (both modes)

{                                                                                                                                                                                                                                                                  
    "ticket": {                                                                                                                                                                                                                                                      
      "hash": "0957ca2b7c5371598393a565927b1aef91f8763028629e5c7212640557cdb871",                                                                                                                                                                                    
      "transaction": "010000000171dc859320fdf63f320d439a15029e069ff019c0e1d9817fa581f33c854cc76b0600000000ffffffff03204e00000000000000001aba76a914d8bde14c5ab57ab9d814a8e1e38ed0d33eff895988ac00000000000000000000206a1e2c2fe049caff028e838ff1a488a18f478c374e8588c20$
00000000000058000000000000000000001abd76a914000000000000000000000000000000000000000088ac00000000000000000188c200000000000000000000ffffffff6b483045022100a8a048e8e80b7546387fad9bb21689e06e088868662d5a7945633f4142b66633022047b6b017e2d5288677d34a03445335d5c1964b963$
ee7b372ccc21b477bf7cdf012102d4673d664536506cf61e787470dfe5131b0b74f2e410c50877dbf7a98900b340",                                                                                                                                                                       
      "myinputs": [                                                                                                                                                                                                                                                  
        {                                                                                                                                                                                                                                                            
          "index": 0,                                                                                                                                                                                                                                                
          "previousaccount": "default",                                                                                                                                                                                                                              
          "previousamount": 0.000498                                                                                                                                                                                                                                 
        }                                                                                                                                                                                                                                                            
      ],                                                                                                                                                                                                                                                             
      "myoutputs": [                                                                                                                                                                                                                                                 
        {                                                                                                                                                                                                                                                            
          "index": 0,                                                                                                                                                                                                                                                
          "account": "default",                                                                                                                                                                                                                                      
          "internal": false,                                                                                                                                                                                                                                         
          "amount": 0.0002,                                                                                                                                                                                                                                          
          "address": "Ssp7J7TUmi5iPhoQnWYNGQbeGhu6V3otJcS",                                                                                                                                                                                                          
          "outputscript": "ba76a914d8bde14c5ab57ab9d814a8e1e38ed0d33eff895988ac"                                                                                                                                                                                     
        }                                                                                                                                                                                                                                                            
      ],                                                                                                                                                                                                                                                             
      "fee": 0.000298,                                                                                                                                                                                                                                               
      "timestamp": 1539110380,                                                                                                                                                                                                                                       
      "type": "TICKETPURCHASE"                                                                                                                                                                                                                                       
    },                                                                                                                                                                                                                                                               
    "spender": {                                                                                                                                                                                                                                                     
      "hash": "91ff53aa435f6e3f86e43a9b672a7f8e5bf2459247c5fd21ea67a8b8c2a8167a",                                                                                                                                                                                    
      "transaction": "01000000020000000000000000000000000000000000000000000000000000000000000000ffffffff00ffffffff71b8cd57056412725c9e62283076f891ef1a7b9265a593835971537c2bca57090000000001ffffffff0300000000000000000000266a2450289e02f6f50450e26693b0bfd38e9194677$
76a8509ecb3cf41024d17200008f00000000000000000000000000086a06010006000000e5700bb10000000000001abb76a9142c2fe049caff028e838ff1a488a18f478c374e8588ac000000000000000002c5220bb10000000000000000ffffffff04deadbeef204e00000000000000000000ffffffff6b48304502210082c4ad2d1$
76b7a022eefd0837e8be912d9829112c97c5292f8b71d4b48e5c7302203ebcf52cff791a1f63672d6c9e9ab1bbcea92c3753997c1d9f446bdf96023cd40121023d206b0f7171ab012ce3860dc54c7705dd861cb822ac60eff6c1652e6a53e774",                                                                   
      "myinputs": [                                                                                                                                                                                                                                                  
        {                                                                                                                                                                                                                                                            
          "index": 1,                                                                                                                                                                                                                                                
          "previousaccount": "default",                                                                                                                                                                                                                              
          "previousamount": 0.0002                                                                                                                                                                                                                                   
        }                                                                                                                                                                                                                                                            
      ],                                                                                                                                                                                                                                                             
      "myoutputs": [                                                                                                                                                                                                                                                 
        {                                                                                                                                                                                                                                                            
          "index": 2,                                                                                                                                                                                                                                                
          "account": "default",                                                                                                                                                                                                                                      
          "internal": true,                                                                                                                                                                                                                                          
          "amount": 29.70317029,                                                                                                                                                                                                                                     
          "address": "SsYNumrZtVR7YkqwLMhcVuNqCb42Rp5qGe3",                                                                                                                                                                                                          
          "outputscript": "bb76a9142c2fe049caff028e838ff1a488a18f478c374e8588ac"                                                                                                                                                                                     
        }
      ],
      "fee": 0,
      "timestamp": 1539110487,
      "type": "VOTE"
    },
    "status": "VOTED"
  },

kLkA avatar Oct 09 '18 19:10 kLkA

Done

kLkA avatar Oct 11 '18 19:10 kLkA

I'll like to take this up

itswisdomagain avatar Aug 23 '19 01:08 itswisdomagain