Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: MakFrogz on May 28, 2019, 12:20:40 PM



Title: How to get fee from incoming transaction?
Post by: MakFrogz on May 28, 2019, 12:20:40 PM
Hi!


How to get fee from incoming transaction because incoming object hasn`t this parameter?


Title: Re: How to get fee from incoming transaction?
Post by: o_e_l_e_o on May 28, 2019, 01:34:50 PM
Your question isn't entirely clear.

If you are looking to see what fee someone has used on an unconfirmed transaction you are waiting to receive, then enter the transaction in to a block explorer such as or https://blockstream.info/ and look for the fee in sats per vByte.

If you are look to set a fee for an incoming transaction, for example it you are creating a QR code to request a specific amount to be sent to an address, then you can't do that. Setting the fee is entirely dependent on the person sending the transaction.


Title: Re: How to get fee from incoming transaction?
Post by: MakFrogz on May 28, 2019, 02:41:48 PM
Ok, look


For example, i send from faucet to my wallet! After that i get transaction id and use command "gettransaction" and see object like this
Code:
{
  "amount": 0.01000000,
  "confirmations": 1,
  "blockhash": "00000000000360708fb414b90b0eccaaf8eb12352fc0f59c81b0de15c81f7bb4",
  "blockindex": 279,
  "blocktime": 1559045534,
  "txid": "232871a92c8ba56f043c43c5c663e7cdd832667a12b4a2e13e09fb1997a7563e",
  "walletconflicts": [
  ],
  "time": 1559044936,
  "timereceived": 1559044936,
  "bip125-replaceable": "no",
  "details": [
    {
      "account": "acc = c01278ba-e83c-4230-b492-da5d1f075e62",
      "address": "2NFWv3z97yK3EnAuvve1eomwRqX5YWEpL1M",
      "category": "receive",
      "amount": 0.01000000,
      "label": "acc = c01278ba-e83c-4230-b492-da5d1f075e62",
      "vout": 1
    }
  ],
  "hex": "02000000000101df760e0882e4d8d35ff237d0098604f8bd2fcc9cea17f5508dd7094c6177d999000000001716001456f001f6e6a2761bb89f4707470f88d8e159b022feffffff02012143000000000017a91425d06c996cddafef75d57ed68fea977885a1e82b8740420f000000000017a914f44a7344dd4b58b6fdbcf401bfcb9cefcd0d224a8702473044022002cb69388d3b496b51106fef58c4aa75b75983101fd009c04b264424a06f9f59022021670487a423764625b04ddb7531f3d5d0bd056401077c51bdee51ecdc26775e012102f3984576609def6d6ec2c1813ce7cbecd57207844b93148d044c85e40bac49258c2c1700"
}

but i haven`t fee


Title: Re: How to get fee from incoming transaction?
Post by: ranochigo on May 28, 2019, 02:46:54 PM
The transaction doesn't actually explicitly contain the transaction fees that is included in the transaction. The only parameters that has the amount of Bitcoins is the inputs and the outputs. The network automatically consider any amount that is not included in the output as a fee.

ie. If a transaction has a 0.01 BTC input and a 0.009 BTC output, the fee will be 0.001.

Most of the wallet's interface allows the users to indicate the fee so as to simplify things.


Title: Re: How to get fee from incoming transaction?
Post by: o_e_l_e_o on May 28, 2019, 02:51:35 PM
So in that case you can take the string of letters and numbers following "txid" and paste it in to a blockchain explorer. Since that is a testnet transaction rather than a real bitcoin transaction, you will have to use a specific testnet explorer. For example: https://blockstream.info/testnet/tx/232871a92c8ba56f043c43c5c663e7cdd832667a12b4a2e13e09fb1997a7563e

As you can see from that page, the fee for that transaction is 1 sat/vByte.