Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: yampi on April 23, 2015, 08:32:19 PM



Title: Questions about p2sh addresses
Post by: yampi on April 23, 2015, 08:32:19 PM
If I generated a p2sh address from a raw transaction, would I be able to spend it?
Or is p2sh only for multi signature transactions?


Title: Re: Questions about p2sh addresses
Post by: DannyHamilton on April 23, 2015, 08:44:18 PM
If I generated a p2sh address from a raw transaction, would I be able to spend it?

That depends on the particular script that you choose to create.

P2SH just means "Pay To Script Hash"  So, until you define what script is being hashed, it isn't possible to determine if the output will be spendable.

Or is p2sh only for multi signature transactions?

Nope.  P2SH can be used for any valid bitcoin output script.  Multi-sig is just a common and convenient use.


Title: Re: Questions about p2sh addresses
Post by: Cryddit on April 24, 2015, 09:40:47 PM
If I generated a p2sh address from a raw transaction, would I be able to spend it?
Or is p2sh only for multi signature transactions?

You can certainly create a p2sh address that you can spend.  p2sh is for any script, not just multi-signature scripts.

Of course, you can also create a p2sh address which cannot be spent because there is no script that both hashes to that value and succeeds when checked. 

IOW, anyone can write a script that says, in effect,

if (false) then
   the output may be spent.

and put funds in a p2sh transaction having a hash that corresponds to that script.  It's just not a very useful script.  There's already 1BitcoinEaterAddressDontSendf59kuE, which does the same thing.  But people don't usually create such scripts (which can't be spent) on purpose.