Author Topic: Get Block number from transaction  (Read 1973 times)

0 Members and 1 Guest are viewing this topic.

Offline madforstrength

Get Block number from transaction
« on: May 25, 2016, 06:54:04 am »
Hi [member=120]xeroc[/member] ,

Is there any way I can get block number from transaction?

I am getting this:

Code: [Select]
{
  "ref_block_num": 58752,
  "ref_block_prefix": 3236012376,
  "expiration": "2016-05-25T06:54:00",
  "operations": [[
      0,{
        "fee": {
          "amount": 264174,
          "asset_id": "1.3.0"
        },
        "from": "1.2.98834",
        "to": "1.2.101520",
        "amount": {
          "amount": 10000,
          "asset_id": "1.3.0"
        },
        "extensions": []
      }
    ]
  ],
  "extensions": [],
  "signatures": [
    "1f24ed1f4e129dbba3973406aea2c6c7443eab11f85d7daeb66e7992273ca959b80c98ddc2704bcd21c679d8b4d4011951f05b4ea41ac934c4d6b9429106ad1c8c"
  ]
}

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12915
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: xeroc
Re: Get Block number from transaction
« Reply #1 on: May 25, 2016, 08:56:48 am »
That is a signed transcation .. if you put this as argument of "get_transaction_id" you will get a transaction id ..
Then there is "get_recent_transaction_by_id"
https://bitshares.org/doxygen/classgraphene_1_1app_1_1database__api.html#ac1475ae15f2b5398a08a68d067051e92
not sure if it tells you the  blocknumber though ..
Give BitShares a try! Use the http://testnet.bitshares.eu provided by http://bitshares.eu powered by ChainSquad GmbH

Offline madforstrength

Re: Get Block number from transaction
« Reply #2 on: May 25, 2016, 10:25:57 am »
Hello [member=120]xeroc[/member],

Thanks for your reply, well "get_recent_transaction_by_id" also does not return block number :(

In the mobile wallet of bitshares they are somehow getting blocknumber and transaction id after transaction is included in the blockchain. (TransactionConfirmStore.js) Do you have any idea how they are getting it?

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12915
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: xeroc
Re: Get Block number from transaction
« Reply #3 on: May 25, 2016, 11:27:04 am »
Maybe @svk can figure that out
Give BitShares a try! Use the http://testnet.bitshares.eu provided by http://bitshares.eu powered by ChainSquad GmbH

Offline madforstrength

Re: Get Block number from transaction
« Reply #4 on: May 27, 2016, 07:30:39 am »
Hi [member=120]xeroc[/member],

I found that they are using "broadcast_transaction_with_callback" to get the block number.

I have tried to call this using python graphenelib the transaction was broadcasted but it returned none. So I think I need to somehow add listener for callback.
This is what I have tried:
Code: [Select]
client1.setObjectCallbacks({"registered-network-broadcast": config.trx_callback})
print(client1.ws.broadcast_transaction_with_callback(0,res, api="network_broadcast"))

Can you help me out in this?

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12915
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: xeroc
Re: Get Block number from transaction
« Reply #5 on: May 27, 2016, 07:35:32 am »
Hi [member=120]xeroc[/member],

I found that they are using "broadcast_transaction_with_callback" to get the block number.

I have tried to call this using python graphenelib the transaction was broadcasted but it returned none. So I think I need to somehow add listener for callback.
This is what I have tried:
Code: [Select]
client1.setObjectCallbacks({"registered-network-broadcast": config.trx_callback})
print(client1.ws.broadcast_transaction_with_callback(0,res, api="network_broadcast"))

Can you help me out in this?

"broadcast_transaction_with_callback" is a call that requires websockets for the callback .. you can't use it via RPC easily unfortunatelly :(
Give BitShares a try! Use the http://testnet.bitshares.eu provided by http://bitshares.eu powered by ChainSquad GmbH