<p>hmmm, yes, this accounting system within bitcoin :-) bitcoin.SE is full of questions according to the balance on accounts.</p>

<p>The "-17" would indicate, that funds left from a known address in your wallet to an "external" target address. And if fees is 20, then yes, you have "outgoing" 37 coins. Btw: what system are you playing on? Addresses starting with "GPP"...?</p>

<p>When I was playing with the regtest env, I discovered that only "gettxout" provides reliable info, which tx might have funds. See also the <a href="https://bitcoin.stackexchange.com/questions/48504/how-to-check-if-an-output-has-been-spent">thread here</a>.</p>

<p>Here a short linux shell script, to fetch the idea. It needs to get updated to cope with many inputs, so one would need to iterate through the VINs... </p>

<pre><code>  b_cli="bitcoind -regtest"
  FUNDING_TXID=3dda59bf9801f88...5498dd7fd1c3f9577963b94

  TX_PREV_VOUT=$( $b_cli gettransaction $FUNDING_TXID | \
                  awk '/vout/ {  print $2; exit }'    | tr -d "," )

  $b_cli gettxout $FUNDING_TXID $TX_PREV_VOUT

  # as per Pieter's comment, spendable VINs return "something"...
  if [ ${#ret_val} -gt 0 ]; then
    echo " ## This tx has spendable funds"
  else
    echo " ## no spendable funds on $FUNDING_TXID"
  fi
</code></pre>

<p>Adding up all the parts, which have spendable funds, would then be "your" balance. And you could check "in" and "out" going funds in your wallet.</p>

CC BY-SA 3.0
2018-03-26T08:55:30.117Z
So this is not from bitcoin it is a wallet from an alternative POS coin but the CLI is almost identical to the bitcoin-cli. Either way, I looked into other transactions where I sent out money and the "fee" value was negative. Knowing that I ran the number and my net is actually "amount" + "fee" so this tx was a net gain of 3. After some reading I realized this was a staking reward.
LoganHenderson
CC BY-SA 3.0
2018-03-26T08:52:13.763Z
2018-03-26T08:52:13.763Z
pebwindkraft
<p>I have a TXid in my wallet that contains multiple transactions (multiple sends and receives). From what I read these are transactions the network creates facilitate splitting/combining multiple inputs/outputs etc. When I <code>gettransaction</code> in the wallet I have I see</p>

<pre><code>gettransaction 3dda59bf9801f88...5498dd7fd1c3f9577963b94
{
  "amount": -17.00000000,
  "fee": 20.00000000,

  "details": [
    {
      "account": "",
      "category": "send",
      "amount": 0.00000000,
      "vout": 0,
      "fee": 20.00000000
    },
    {
      "account": "",
      "address": "GPP7ic67...9TgitCB21r",
      "category": "send",
      "amount": -20.00000000,
      "vout": 1,
      "fee": 20.00000000
    },
    {
      "account": "",
      "address": "GPP7ic67...9TgitCB21r",
      "category": "send",
      "amount": -17.00000000,
      "vout": 2,
      "fee": 20.00000000
    },
    {
      "account": "TestWallet",
      "address": "GPP7ic67...9TgitCB21r",
      "category": "receive",
      "amount": 20.00000000,
      "vout": 1
    }
  ],
</code></pre>

<p>So, I'm trying to figure out what the net result of this transaction is. I received -17 and I had 20 fee. Does that mean I net loss 37? </p>

<bitcoin-core><bitcoind><bitcoin-cli>
Transaction net gain/loss
LoganHenderson
# Transaction net gain/loss

(Asked by: username_0 on 2018-03-23)

I have a TXid in my wallet that contains multiple transactions (multiple sends and receives). From what I read these are transactions the network creates facilitate splitting/combining multiple inputs/outputs etc. When I `gettransaction` in the wallet I have I see

```
gettransaction 3dda59bf9801f88...5498dd7fd1c3f9577963b94
{
  "amount": -17.00000000,
  "fee": 20.00000000,

  "details": [
    {
      "account": "",
      "category": "send",
      "amount": 0.00000000,
      "vout": 0,
      "fee": 20.00000000
    },
    {
      "account": "",
      "address": "GPP7ic67...9TgitCB21r",
      "category": "send",
      "amount": -20.00000000,
      "vout": 1,
      "fee": 20.00000000
    },
    {
      "account": "",
      "address": "GPP7ic67...9TgitCB21r",
      "category": "send",
      "amount": -17.00000000,
      "vout": 2,
      "fee": 20.00000000
    },
    {
      "account": "TestWallet",
      "address": "GPP7ic67...9TgitCB21r",
      "category": "receive",
      "amount": 20.00000000,
      "vout": 1
    }
  ],

```

So, I'm trying to figure out what the net result of this transaction is. I received -17 and I had 20 fee. Does that mean I net loss 37?

**Tags:** bitcoin-core, bitcoind, bitcoin-cli


---

## 1 answers

### Answer by username_1 on 2018-03-26. Score: 0

hmmm, yes, this accounting system within bitcoin :-) bitcoin.SE is full of questions according to the balance on accounts.

The "-17" would indicate, that funds left from a known address in your wallet to an "external" target address. And if fees is 20, then yes, you have "outgoing" 37 coins. Btw: what system are you playing on? Addresses starting with "GPP"...?

When I was playing with the regtest env, I discovered that only "gettxout" provides reliable info, which tx might have funds. See also the [thread here](https://bitcoin.stackexchange.com/questions/48504/how-to-check-if-an-output-has-been-spent).

Here a short linux shell script, to fetch the idea. It needs to get updated to cope with many inputs, so one would need to iterate through the VINs...

```
  b_cli="bitcoind -regtest"
  FUNDING_TXID=3dda59bf9801f88...5498dd7fd1c3f9577963b94

  TX_PREV_VOUT=$( $b_cli gettransaction $FUNDING_TXID | \
                  awk '/vout/ {  print $2; exit }'    | tr -d "," )

  $b_cli gettxout $FUNDING_TXID $TX_PREV_VOUT

  # as per Pieter's comment, spendable VINs return "something"...
  if [ ${#ret_val} -gt 0 ]; then
    echo " ## This tx has spendable funds"
  else
    echo " ## no spendable funds on $FUNDING_TXID"
  fi

```

Adding up all the parts, which have spendable funds, would then be "your" balance. And you could check "in" and "out" going funds in your wallet.

> **Comments:**
> **username_0**: So this is not from bitcoin it is a wallet from an alternative POS coin but the CLI is almost identical to the bitcoin-cli. Either way, I looked into other transactions where I sent out money and the "fee" value was negative. Knowing that I ran the number and my net is actually "amount" + "fee" so this tx was a net gain of 3. After some reading I realized this was a staking reward.  

---

