user151: We are trying to figure out how to identify the sender (source address) of a given transaction retrieved using cardano-wallet.
Here is an example datastructure from the api. Be aware the field values are randomized (not real):
{
  inserted_at: {
    height: { quantity: 4263, unit: "block" },
    time: "2021-11-21T18:00:39Z",
    epoch_number: 190,
    absolute_slot_number: 4323,
    slot_number: 132423,
  },
  status: "in_ledger",
  withdrawals: [],
  amount: { quantity: 2000000, unit: "lovelace" },
  inputs: [
    {
      id: "80b4ab2773da9bccdb62d8bbf22f339bf041f0ff082f34acc6614f6a759e58e",
      index: 0,
    },
  ],
  direction: "incoming",
  fee: { quantity: 0, unit: "lovelace" },
  outputs: [
    {
      amount: { quantity: 2000000, unit: "lovelace" },
      address:
        "addr_test1qzwtzc4vrase42ytaj8nqam6z4322x5dx08gj2gxtjqy05wl5feqsw9lgy9askcyzjemw4d8x94n25nq204j6kqfpmhsn64us7",
      assets: [],
    },
    {
      amount: { quantity: 56, unit: "lovelace" },
      address: "addr_test1vqd00tpc537seq9hy64pupcu7s88x5w9jdln4lqyfees3swgmk",
      assets: [],
    },
  ],
  metadata: None,
  depth: { quantity: 370, unit: "block" },
  id: "d6c29eb3a8865b1e79d5cf2beb4d04b6685145a2c73d910d70e8f80080384",
  deposit: { quantity: 0, unit: "lovelace" },
  collateral: [],
  mint: [],
};

Now, the source address is listed in one of the outputs, since the transaction must send the remainder of the balance to it. However, this isn't a great way to identify the source address because it might not be there if there is no remainder, or there may be 3 or more outputs.
I expected the inputs to contain the address, but it just has an id.
I see no other mentions of the source address. How does one figure out who sent a transaction?

user5167: You all are way over complicating this.. It's as easy as:
def get_return_address_from_utxo(utxo):
try:
    r = requests.get(f"https://cardanoscan.io/transaction/{utxo}")

    content = r.content.decode("utf-8").split(
        'FROM ADDRESSES (INPUTS)</span></div></div><div class=mt-4><div class="d-flex flex-row '
        'justify-content-between px-3"><div><strong>Address</strong></div><div><strong>Amount</strong></div></div><hr class=darkHR><div data-simplebar><div class="d-flex flex-row justify-content-between px-2"><div class=addressField><div class="row align-items-center"><div class=col-auto>')
    sub = content[1].split("span")
    address = sub[0]
    address = address.replace("<a href=/address/", "").replace("><", "")
    return address
except requests.exceptions.RequestException as e:
    return ''
except IndexError as e:
    return ''


151: <p>We are trying to figure out how to identify the sender (source address) of a given transaction retrieved using <code>cardano-wallet</code>.</p>
<p>Here is an example datastructure from the api. Be aware the field values are randomized (not real):</p>
<pre><code>{
  inserted_at: {
    height: { quantity: 4263, unit: &quot;block&quot; },
    time: &quot;2021-11-21T18:00:39Z&quot;,
    epoch_number: 190,
    absolute_slot_number: 4323,
    slot_number: 132423,
  },
  status: &quot;in_ledger&quot;,
  withdrawals: [],
  amount: { quantity: 2000000, unit: &quot;lovelace&quot; },
  inputs: [
    {
      id: &quot;80b4ab2773da9bccdb62d8bbf22f339bf041f0ff082f34acc6614f6a759e58e&quot;,
      index: 0,
    },
  ],
  direction: &quot;incoming&quot;,
  fee: { quantity: 0, unit: &quot;lovelace&quot; },
  outputs: [
    {
      amount: { quantity: 2000000, unit: &quot;lovelace&quot; },
      address:
        &quot;addr_test1qzwtzc4vrase42ytaj8nqam6z4322x5dx08gj2gxtjqy05wl5feqsw9lgy9askcyzjemw4d8x94n25nq204j6kqfpmhsn64us7&quot;,
      assets: [],
    },
    {
      amount: { quantity: 56, unit: &quot;lovelace&quot; },
      address: &quot;addr_test1vqd00tpc537seq9hy64pupcu7s88x5w9jdln4lqyfees3swgmk&quot;,
      assets: [],
    },
  ],
  metadata: None,
  depth: { quantity: 370, unit: &quot;block&quot; },
  id: &quot;d6c29eb3a8865b1e79d5cf2beb4d04b6685145a2c73d910d70e8f80080384&quot;,
  deposit: { quantity: 0, unit: &quot;lovelace&quot; },
  collateral: [],
  mint: [],
};
</code></pre>
<p>Now, the source address is listed in one of the outputs, since the transaction must send the remainder of the balance to it. However, this isn't a great way to identify the source address because it might not be there if there is no remainder, or there may be 3 or more outputs.</p>
<p>I expected the <code>inputs</code> to contain the address, but it just has an id.</p>
<p>I see no other mentions of the source address. How does one figure out who sent a transaction?</p>
 5167: <p>You all are way over complicating this.. It's as easy as:</p>
<pre><code>def get_return_address_from_utxo(utxo):
try:
    r = requests.get(f&quot;https://cardanoscan.io/transaction/{utxo}&quot;)

    content = r.content.decode(&quot;utf-8&quot;).split(
        'FROM ADDRESSES (INPUTS)&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=mt-4&gt;&lt;div class=&quot;d-flex flex-row '
        'justify-content-between px-3&quot;&gt;&lt;div&gt;&lt;strong&gt;Address&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;&lt;strong&gt;Amount&lt;/strong&gt;&lt;/div&gt;&lt;/div&gt;&lt;hr class=darkHR&gt;&lt;div data-simplebar&gt;&lt;div class=&quot;d-flex flex-row justify-content-between px-2&quot;&gt;&lt;div class=addressField&gt;&lt;div class=&quot;row align-items-center&quot;&gt;&lt;div class=col-auto&gt;')
    sub = content[1].split(&quot;span&quot;)
    address = sub[0]
    address = address.replace(&quot;&lt;a href=/address/&quot;, &quot;&quot;).replace(&quot;&gt;&lt;&quot;, &quot;&quot;)
    return address
except requests.exceptions.RequestException as e:
    return ''
except IndexError as e:
    return ''
</code></pre>
