This does not answer to the question: "how to know how much an address own" or at least "how to know the source of a transaction".
It only gives you the sum of all the BTC spent by an address (in the case of the 'addr' command)
I think you're a little confused as to what
scantxoutset is showing. It is scanning the UTXO set... which is the set of all
unspent transaction outputs. It returns the UTXOs currently controlled by the descriptors that you provide... in other words "how much the address own".
My example address (as of 2021-02-04 23:20 UTC):
Is that not exactly what you're after?
If I do the math on a real wallet, the total_amount is the sum of all VOUT which is not what is left unspent in the wallet, but what was spent (out) of the wallet.
No... those "vout"'s are the vout's from the txid's that created that particular UTXO... which sent it
to that address
(They're not vout's spending
from the address)
Note listunspent "address" will list all the unspent UTXO from the wallet. Can be entered into the console. Sum of them will give the total of the unspent UTXO available.
Note that
listunspent only works on addresses that are "in" your wallet.dat... it will not work for "external" (aka "random") addresses.