how to use wallet_get_pretty_transaction in json rpc call?

Started by sbwdlihao, July 10, 2014, 08:39:59 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

HackFisher

Anything said on these forums does not constitute an intent to create a legal obligation or contract between myself and anyone else.   These are merely my opinions and I reserve the right to change them at any time.

HackFisher

Transaction ID seems not return in the rpc result, trx confirmation might need to be refactored to provide the transfer trx ID to the rpc call later.

Quoteand i am coufused, beacuse i counldn't find transaction_id_type in the result of wallet_transfer

The ID is not returned because it is always calculated by digest in signed_transaction, we might need to change the rpc call return type to include the trx id.
Anything said on these forums does not constitute an intent to create a legal obligation or contract between myself and anyone else.   These are merely my opinions and I reserve the right to change them at any time.

sbwdlihao

i have called wallet_transfer successfully in php
try{
$tx = $rpc->wallet_transfer(12, "XTS", "acc-51btc", "lihao-test1");
}catch(Exception $e){
echo sprintf("error %s\n", $e->getMessage());
};


and the result is
Array [4]   
   expiration   (string:15) 20140710T102525   
   delegate_slate_id   null   
   operations   Array [2]   
      0   Array [2]   
         type   (string:16) withdraw_op_type   
         data   Array [3]   
            balance_id   (string:36) XTSNWJpomfWVhvd7PM8QMMxnbmc8rNNg6C86   
            amount   (int) 1210000   
            claim_input_data   (string:0)    
      1   Array [2]   
         type   (string:15) deposit_op_type   
         data   Array [2]   
            amount   (int) 1200000   
            condition   Array [4]   
               asset_id   (int) 0   
               delegate_slate_id   (int) 0   
               type   (string:23) withdraw_signature_type   
               data   Array [2]   
                  owner   (string:36) XTSJL1fTtNg8LQbLPw33LKrHJKRpEsayNCG4   
                  memo   Array [2]   
                     one_time_key   (string:53) XTS7sxksh6uXuELNAaawFsC7V2Qu5Kt7dWj51KnCrLmzcJi4gbvu7   
                     encrypted_memo_data   (string:128) 6279c02e653b21d7c25d7a818a1f2badfe36861ff73fa53e9d3396416e9493a3ca539c0528d2353ef62692cd33a9043694adc57429f8e5081152b5ad94d6ab4f   
   signatures   Array [1]   
      0   (string:130) 207343a0001159d526f358caca89cc32a935ec84c5ee2c3a873a2cffa1b94998f15b7fadd940e84dc2902f7c774682bd5f6c4accaed87934da9de2292504e9e894   

i don't find the tx id, so i think i could use wallet_get_pretty_transaction to parse the result to get tx id

this is the wallet_transfer introduction
{
        "method_name": "wallet_transfer",
        "description": "Sends given amount to the given address, assumes shares in DAC.  This transfer will occur in a single transaction and will be cheaper, but may reduce your privacy.",
        "return_type": "signed_transaction",
        "parameters" :
          [
            {
              "name" : "amount_to_transfer",
              "type" : "real_amount",
              "description" : "the amount of shares to transfer"
            },
            {
              "name" : "asset_symbol",
              "type" : "asset_symbol",
              "description" : "the asset to transfer"
            },
            {
              "name" : "from_account_name",
              "type" : "sending_account_name",
              "description" : "the source account(s) to draw the shares from"
            },
            {
              "name" : "to_account_name",
              "type" : "receive_account_name",
              "description" : "the account to transfer the shares to"
            },
            {
              "name" : "memo_message",
              "type" : "string",
              "description" : "a memo to store with the transaction",
              "default_value" : ""
            }
          ],
        "prerequisites" : ["wallet_unlocked"],
        "aliases" : ["transfer"]
      },


and wallet_get_pretty_transaction introduction
{
        "method_name": "wallet_get_pretty_transaction",
        "description": "Return a pretty JSON representation of a transaction",
        "return_type": "pretty_transaction",
        "parameters" :
          [
            {
              "name" : "transaction",
              "type" : "signed_transaction",
              "description" : "the transaction to pretty-print"
            }
          ],
        "is_const" : true,
        "prerequisites" : ["json_authenticated"]
      }


so, i tried
$r = $rpc->wallet_get_pretty_transaction($tx);
and
$r = $rpc->wallet_get_pretty_transaction(json_encode($tx));
both failed

i find signed_transaction structure in transaction.hpp
struct signed_transaction : public transaction
   {
      transaction_id_type                     id()const;
      size_t                                  data_size()const;
      void                                    sign( const fc::ecc::private_key& signer, const digest_type& chain_id );

      vector<fc::ecc::compact_signature> signatures;
   };

and i am coufused, beacuse i counldn't find transaction_id_type in the result of wallet_transfer

can any one help me with this problem please?how to get tx id from the result of wallet_transfer?