How do I figure out whether this is a "spend" or "receive" transaction in relation to a given xpub and what is the associated address?
Let's use this result as an example:
"txs":[
{
"hash":"0202b8ba785d8befdbbeca1641a981d371ddfc2f5216a2d1fd78de7e8e460478",
"ver":2,
"vin_sz":2,
"vout_sz":1,
"size":335,
"weight":1340,
"fee":820,
"relayed_by":"0.0.0.0",
"lock_time":640369,
"tx_index":4222712286272463,
"double_spend":false,
"time":1595650444,
"block_index":640678,
"block_height":640678,
"inputs":[
.
.
.
],
"out":[
.
.
.
],
"result":-1820,
"balance":546
},
If the result is a negative value, that means that it's a "spend" transaction, "receive" if positive.
The associated address(es) are the "addr" in the "inputs" if it's a spend txn, in the "out" if it's a receive txn.