BitShares Forum

Main => General Discussion => Topic started by: BTSdac on December 20, 2015, 03:49:03 am

Title: what do a transfer include in BTS
Post by: BTSdac on December 20, 2015, 03:49:03 am
there is lack technical documents to explain what does a transfer and operation contain?
I understand from code 
a transfer should contain
1.chain ID ,sender ,receiver ,amount, asset symbol . and digest of them
2. signature of required keys
what is more ?  there have identification information/ that prove sender how to gain the sending coin,  I don`t know if have similar in btc?
Title: Re: what do a transfer include in BTS
Post by: pc on December 20, 2015, 09:13:39 am
This is what a transaction with a single transfer operation without a memo looks like:

Code: [Select]
{
      "ref_block_num": 65534,
      "ref_block_prefix": 878476643,
      "expiration": "2015-11-07T21:12:09",
      "operations": [[
          0,{
            "fee": {
              "amount": 4000000,
              "asset_id": "1.3.0"
            },
            "from": "1.2.28788",
            "to": "1.2.97102",
            "amount": {
              "amount": 10000000,
              "asset_id": "1.3.0"
            },
            "extensions": []
          }
        ]
      ],
      "extensions": [],
      "signatures": [
        "1f4a55c5ae64ba8084d20583697a45e73f54abebe72d11bf388a9258e6125859956356e9021c51f015b68885b5023f6b3a2d9f733c3f79ad10331e658fdd872b64"
      ],
      "operation_results": [[
          0,{}
        ]
      ]
    }

The identification information of sender and receiver is the account ids in the "from" and "to" fields.
Note that "coins" are handled differently from Bitcoin in that BitShares keeps an internal ledger of accounts and balances, whereas Bitcoin uses unspent transaction outputs.
Title: Re: what do a transfer include in BTS
Post by: BTSdac on December 20, 2015, 01:44:57 pm
This is what a transaction with a single transfer operation without a memo looks like:

Code: [Select]
{
      "ref_block_num": 65534,
      "ref_block_prefix": 878476643,
      "expiration": "2015-11-07T21:12:09",
      "operations": [[
          0,{
            "fee": {
              "amount": 4000000,
              "asset_id": "1.3.0"
            },
            "from": "1.2.28788",
            "to": "1.2.97102",
            "amount": {
              "amount": 10000000,
              "asset_id": "1.3.0"
            },
            "extensions": []
          }
        ]
      ],
      "extensions": [],
      "signatures": [
        "1f4a55c5ae64ba8084d20583697a45e73f54abebe72d11bf388a9258e6125859956356e9021c51f015b68885b5023f6b3a2d9f733c3f79ad10331e658fdd872b64"
      ],
      "operation_results": [[
          0,{}
        ]
      ]
    }

The identification information of sender and receiver is the account ids in the "from" and "to" fields.
Note that "coins" are handled differently from Bitcoin in that BitShares keeps an internal ledger of accounts and balances, whereas Bitcoin uses unspent transaction outputs.
do you know the detail of internal ledger of accounts and balances
it seems that a sender cannot send a same amount of asset to same receiver  in one block that would make same  "ref_block_num" ,"ref_block_prefix" and "expiration"?
Code: [Select]
FC_ASSERT( (skip & skip_transaction_dupe_check) ||
              trx_idx.indices().get<by_trx_id>().find(trx_id) == trx_idx.indices().get<by_trx_id>().end() );
   transaction_evaluation_state eval_state(this);
Title: Re: what do a transfer include in BTS
Post by: pc on December 20, 2015, 02:40:18 pm
Is there anything specific that you want to know?

The internal database of a full node can be queried with a few simple commands in the cli_wallet, for example

Code: [Select]
locked >>> get_account 1.2.28788
get_account 1.2.28788
{
  "id": "1.2.28788",
...
  "name": "cyrano",
...
}

Edit: the ref_block_num and ref_block_prefix is only to prove that the creator of the transaction has seen the given block with the given prefix. So the same transaction couldn't be used in a different fork of the chain that doesn't include that particular block. These values have nothing to do with the transfer operation.