2

when somebody send me BTCs I recognize that by seeing a transaction output is equal to my address. But how can I be sure that it's really me and only me who can spend the output?

I can check, I can unlock the output. But consider I'm an evil, I sell BTCs to somebody. But I create a multisign-script wich unblocks the transaction output also by my private key and when I receive $ I take my BTCs back.

Is there a protection against this? Do wallets check the output scripts somehow before claiming the balance?

1 Answer 1

3

Wallets will only consider outputs to be theirs if it is something that it can spend from. This usually entails checking the output script against the set of scripts that your addresses will be used to generate. So even if you can sign for something, if the script does not match any of the scripts stored in your wallet, then it will not consider that output to be yours.

If the output was a P2SH output, then you would need to have the redeemScript in order to spend from it, so unless the sender shared that with you (and if they did, you could check for any nastiness), your wallet won't even know that you could spend that P2SH output.

Also, there is no "claiming the balance" or claiming of any sort except when you spend an output.

2
  • so, there is something like set of acceptable script templates which could be used for addr to addr transfer?
    – smrt28
    Dec 8, 2017 at 7:52
  • Yes. There are script templates, and most wallets will only watch those script templates. There is no need to try every single output to see if you could spend it; that would be extremely computationally expensive and open up several DoS vectors.
    – Ava Chow
    Dec 8, 2017 at 7:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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