0

I'm trying to get the wallet id from scriptSing and ScriptPubKey. When I decode the scriptSig, the result does not contain the address address. But when I decode the scriptPubKey, it contains the address.

Why the scriptSig does not contain the address?

If it does not contain the wallet id, does it contain any references to previous transaction output? if yes, what is the property inside the RPC response that contains the reference to previous output?

This is the documentation reference bitcoin core

2

Bitcoin does not actually use addresses internally. Addresses are just a way for us humans to specify what scriptPubKey we want the wallet software to create. When a transaction output is spent, the address is not included anywhere because it is not needed.

Bitcoin Core's decoding RPCs will include more information than is actually present in the transaction, block, or script. This is because it can infer and display the information present in different ways.

Since an address describes a scriptPubKey, it is typically possible to take a scriptPubKey and compute an address that corresponds to it. This is not always possible because not all scriptPubKeys correspond to addresses. But usually they do, and so the decoder will show you that.

However scriptSigs do not have corresponding addresses. You cannot get a scriptSig from an address and vice versa. In fact, the idea that you send from an address is really not true; that's just a simpler way to describe things to people. It isn't how Bitcoin actually works.

The reference to the previous output is done by explicitly referencing it, not referencing some address. Every output is uniquely identified by the transaction it is included in, and its index in the array of outputs in that transaction. Bitcoin Core displays this to you as the txid and vout fields for each input.

Bitcoin really does not have wallet ids. Contrary to popular belief, addresses are not wallet ids, nor are public keys.

  • So, the reference to previous output is the type Outpoint inside the Transaction input? so the hash inside the outpoint is the hash of the Previous Transaction output? – vincenzopalazzo Aug 5 at 15:44
  • 2
    Yes. The hash is the txid of the previous transaction, no the hash of the previous transaction output. It tells you what transaction to look up. The vout is the index of the transaction output in the array of transaction outputs in the previous transaction. It tells you where exactly in that transaction is the output being spent. – Andrew Chow Aug 5 at 17:12
  • Thank so much, so for get the previus txout I could decodeRawTransaction(outpoinHasTx) -> access the transactionOutoput where vout = nOutpoint -> decode the scriptPubKeys – vincenzopalazzo Aug 6 at 11:18
  • Yes. That is how you would get the address for an input. – Andrew Chow Aug 6 at 17:27
  • Thanks for your help – vincenzopalazzo Aug 6 at 18:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.