Skip to content

How to check incoming transactions

Maciej Pilarczyk edited this page Apr 4, 2019 · 2 revisions

Abstract

This article aims to explain how an owner of a particular account could list and check incoming transactions.

Requirements

Blockchain network account

Every user of ADS blockchain needs an account to connect to the network. An account can be created by the node operator or Browser Wallet.

Address

The address is needed to indicate the transaction's sender. Every account has a unique address assigned during creation.

Secret key

The secret key is needed to sign the transaction. Secret key is private and should not be revealed to anyone.

IP address and port of node

Node's IP address and port must be known to connect to the network and send transaction.

Communication with the node

All the operations performed on the ADS blockchain are done using the ADS wallet program ads or JSON-RPC.

Collecting transactions' ids from account's log

To get the account's log user needs to call get_log function.

Function get_log takes one parameter: from. Parameter from is the earliest time of the log entry in seconds since epoch as a decimal number. If time is not provided (is equal zero) the full log will be returned.

Call with parameter from

{"run":"get_log","from":"1543247363"} #ads
{"jsonrpc":"2.0","id":"1","method":"get_log", "params":{"address":"0001-00000004-DBEB","from":1543247363}} #JSON-RPC

Below is a sample response. Account's events are in log array. Log array can be empty if there are no events in the selected period. Each event has time, date, type, and type_no fields. Different types of events have different structure.

{
	"current_block_time": "1543244800",
	"previous_block_time": "1543244288",
	"tx": {
		"data": "110200040000000100F05B",
		"signature": "029C4587D45DB0A5550E1155F6D4D3A159E2234C46290380FE28E80FCF5CF137467EC75928E9945102DA5F5916369F7ED16675F27D7363D0755090AB8CC8020A",
		"time": "1542455297",
		"account_msid": "0",
		"account_hashin": "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
		"account_hashout": "9909BA21378298A96B132C73BBCD17757559350FE81ACAA5246C3B1614A9A345",
		"deduct": "0.00000000000",
		"fee": "0.00000000000"
	},
	"account": {
		"address": "0002-00000004-3539",
		"node": "2",
		"id": "4",
		"msid": "64",
		"time": "1543230001",
		"date": "2018-11-26 12:00:01",
		"status": "0",
		"paired_node": "0",
		"paired_id": "0",
		"local_change": "1543229952",
		"remote_change": "1542197760",
		"balance": "1042.79299389909",
		"public_key": "860BB97F2E355C094CEFB63A7A1245C3D3073E535087FBACEF573C6EC48E17A9",
		"hash": "5D4D150853A7BBF2713EE23BA3774B88493A7C95990C9E5E506197E45D76362E"
	},
	"log": [{
			"time": "1542291341",
			"date": "2018-11-15 15:15:41",
			"type_no": "32768",
			"confirmed": "yes",
			"type": "node_started",
			"node_start_msid": "3189",
			"node_start_block": "1542290432",
			"account": {
				"balance": "1043.99939870000",
				"local_change": "1542290432",
				"remote_change": "1542197760",
				"hash_prefix_8": "177D7A31BF3F915C",
				"public_key_prefix_6": "860BB97F2E35",
				"status": "0",
				"msid": "14",
				"node": "0",
				"id": "0",
				"address": "0000-00000000-313E"
			},
			"dividend": "0.00000000000"
		}, {
			"time": "1542455298",
			"date": "2018-11-17 12:48:18",
			"type_no": "32784",
			"confirmed": "yes",
			"type": "dividend",
			"node_msid": "3320",
			"block_id": "5BF00000",
			"dividend": "-0.00020000000"
		},
        {
            "time": "1543248387",
            "date": "2018-11-26 17:06:27",
            "type_no": "32772",
            "confirmed": "no",
            "type": "send_one",
            "node": "1",
            "account": "4",
            "address": "0001-00000004-DBEB",
            "node_msid": "3744",
            "node_mpos": "1",
            "account_msid": "11",
            "amount": "1.00000000000",
            "sender_fee": "0.00100000000",
            "message": "000000000000000000000000000000002A3DBD3F9B1A4E41AED0A3C0732BC729",
            "inout": "in",
            "id": "0001:00000EA0:0001"
        }
    ]
}

To make a list of incoming transactions, a log must be filtered. Incoming transactions have field type equal send_one and field inout equal in.

For those events which match the filter field, id should be stored to process later.

Only one incoming transaction is present in the log example above. Its id is 0001:00000EA0:0001.

See more:

Validation of transactions' ids

If transaction id is known, it should be checked in ADS blockchain. Transaction checking is divided into two parts:

  • collecting block headers (required only when using ads program)
  • comparing transaction id with collected headers

Collecting block header

Collecting the block header should be done before checking transaction ids.

Collecting header depends on calling get_blocks function as long as all header will be updated.

{"run":"get_blocks"}

All headers are updated when a value of updated_blocks is equal 0. Below is sample response after a successful update.

{
    "current_block_time": "1543249408",
    "previous_block_time": "1543248896",
    "tx": {
        "data": "130200040000006E1EFC5B001EFC5B00000000",
        "signature": "C1201AA1EC8D8FD1DA31FB3F1AF59D3DF0AB431FC82657D18DCBD436EECD2D0D636755F7FA0F50AB529EED8AD56BCA9236B402DD9A44D1D51327A9027B802A07",
        "time": "1543249518"
    },
    "updated_blocks": "0"
}

See more:

Checking transaction id

Comparing transaction id with collected headers needs to call get_transaction function. It takes one required parameter txid - transaction id.

{"run":"get_transaction","txid":"0001:00000EA0:0001"} #ads
{"jsonrpc":"2.0","id":"1","method":"get_transaction", "params":{"txid":"0001:00000EA0:0001"}} #JSON-RPC

Below is sample response

{
    "current_block_time": "1543249408",
    "previous_block_time": "1543248896",
    "tx": {
        "data": "140200040000006E1FFC5B0100A00E00000100",
        "signature": "F8A1244D8C0FD364715A439585787DAD7854614DA91B3D1451F68314F1DCB14309526A84ED4AE771A8C75C61969054355CFC8E63743F4AE76DD6117B4C978E0D",
        "time": "1543249774",
        "account_msid": "0",
        "account_hashin": "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
        "account_hashout": "6B9F7E7D4EAD9292AE4273246CCA7E691DB595E01F66A0A6478C5841C8BC34F4",
        "deduct": "0.00000000000",
        "fee": "0.00000000000"
    },
    "network_tx": {
        "id": "0001:00000EA0:0001",
        "block_time": "1543247872",
        "block_id": "5BFC1800",
        "node": "1",
        "node_msid": "3744",
        "node_mpos": "1",
        "size": "125",
        "hashpath_size": "6",
        "data": "040100040000000B000000C118FC5B02000400000000E8764817000000000000000000000000000000000000002A3DBD3F9B1A4E41AED0A3C0732BC7291515D72AF2D0041D8F41727740F8B40A662BC1D7691A00E9B85FE8B15DC5A6C0B08AB898569F432531D89FC762B128962EABD895B3F1D41FB12851B15860E908",
        "hashpath": [
            "D35C5C427D59F0F461CAAE33D941CFF01A3A0F2BFB4A86E349408F45BB48AEBA",
            "807C957C867CA1FA190E1FCDD22A626685E9C554E2235B699142932DE96CE089",
            "BCF77DCB77AA3FB6328B35998DC5917F81F8EF96F82B5441B2FFDD0DBBFC8480",
            "3C90B8BCAE204C3479C45515D584D0F73061149A4427F2716F4E8026BCFA8536",
            "18340797415AF7E5F7B6A61815C210D7007635EA242800A805408BAFBFE76842",
            "F26A9BD1C882E83B865C6EFD82F789FD7548A6A40748BBF4C384B87DB86B8C7B"
        ]
    },
    "txn": {
        "type": "send_one",
        "node": "1",
        "user": "4",
        "msg_id": "11",
        "time": "1543248065",
        "target_node": "2",
        "target_user": "4",
        "sender_fee": "0.00100000000",
        "sender_address": "0001-00000004-DBEB",
        "target_address": "0002-00000004-3539",
        "amount": "1.00000000000",
        "message": "000000000000000000000000000000002A3DBD3F9B1A4E41AED0A3C0732BC729",
        "signature": "1515D72AF2D0041D8F41727740F8B40A662BC1D7691A00E9B85FE8B15DC5A6C0B08AB898569F432531D89FC762B128962EABD895B3F1D41FB12851B15860E908"
    }
}

Transaction details can be read from txn object. Especially:

  • sender address: txn.sender_address
  • transaction amount: txn.amount
  • transaction title (memo): txn.message

Warning! Field txn.time is insecure (it can be freely set by the user); use time of the message or the block instead.

See more:

You can’t perform that action at this time.