In the bitcoin scripting language, how can I access other outputs of the transaction? Or how else can I limit how the coins may be spent?

1

Is there any way to add an opcode to a UTXO that prevents how the coins are spent?

For example, in order to to spend the output, a person must send X number of bitcoin to Y address within the accompanying transaction.

nick carraway

Posted 2019-03-30T00:12:44.977

Reputation: 215

Answers

4

There is no way to enforce a rule regarding the nature of an output when an input is spent. You will have to enforce this off chain in some manner, perhaps through multisig schemes where one key is held by a rule engine that will only sign the tx if your requirements are met.

Raghav Sood

Posted 2019-03-30T00:12:44.977

Reputation: 10 897

Is that what, "Incentivized finding of hash collisions" is ?https://en.bitcoin.it/wiki/Script

nick carraway 2019-03-30T00:22:31.920

No, that is a bounty people can claim if they are able to produce two values that hash to the same hash for some hash function in the script. For example, the bounty for sha1 was claimed after Google released a collision attack

Raghav Sood 2019-03-30T00:28:10.967

1The coins can still be sent anywhere, there is no restriction on the destinationRaghav Sood 2019-03-30T00:28:50.563

Thanks. I have found the best explanation: http://learnmeabitcoin.com/glossary/script

nick carraway 2019-03-30T01:42:18.600

Just wondering. Can't the user create a SIGHASH_ALL | ANYONECANPAY transaction consuming a M BTC input from UTXO, paying X BTC to address Y and M BTC to his own change address.Ugam Kamat 2019-03-30T08:06:36.103

3@UgamKamat That would on the condition that the final transaction incorporates that exact signed input. It does not allow you to set the condition from within a Bitcoin Script itself, and it does not prevent someone who has the key for that utxo M from sending it to any other address by simply signing a new tx input.Raghav Sood 2019-03-30T08:26:48.993

This would be detrimental to the system, as it could effectively limit the supply of bitcoins making some bitcoins more valuable than othersVinnie James 2019-03-30T14:04:30.927