Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: ggbtctalk000 on September 07, 2017, 04:33:11 PM



Title: How to get hands-on with bitcoin script development
Post by: ggbtctalk000 on September 07, 2017, 04:33:11 PM
I covered and had basic fundamental understanding of how the scripting (lock or formerly ScriptPubKey and unlock or formerl ScriptSig). The "mastering bitcoin" had fairly good coverage on how scripting works and what purpose it does. However there are faily large number of script op codes available in the appendix, so I am wondering what are good way to get hands-on and write a script and deploy it on live platform?
My wild guess, is most bitcoin wallets will only work with a Pay-to-public-key hash, i imagine one has to develop the proprietary wallet that can send and received bitcoin based on signing of custom scripts. I am going to take another shot at it by saying existing wallets that can send/receive bitcoin using P2SH (pay-to-script-hash) will work. But I believe one still has to write the script and some integrate with the wallet. 
Thanks!


Title: Re: How to get hands-on with bitcoin script development
Post by: BitcoinsGreat on September 11, 2017, 05:20:38 PM
I covered and had basic fundamental understanding of how the scripting (lock or formerly ScriptPubKey and unlock or formerl ScriptSig). The "mastering bitcoin" had fairly good coverage on how scripting works and what purpose it does. However there are faily large number of script op codes available in the appendix, so I am wondering what are good way to get hands-on and write a script and deploy it on live platform?
My wild guess, is most bitcoin wallets will only work with a Pay-to-public-key hash, i imagine one has to develop the proprietary wallet that can send and received bitcoin based on signing of custom scripts. I am going to take another shot at it by saying existing wallets that can send/receive bitcoin using P2SH (pay-to-script-hash) will work. But I believe one still has to write the script and some integrate with the wallet. 
Thanks!

Are you trying to get info on writing these in yourself or looking for pre-existing examples? You can try looking at what is happening in the background of something like NXT or ETH.


Title: Re: How to get hands-on with bitcoin script development
Post by: mrayazgul on September 11, 2017, 05:57:32 PM
Not many people have touched what you are talking about because there is really no market for it right now, but you can play away. I would say to grab a copy of core and use the testnet and a small private network and see what you can do that will get the public interest and show them the possibilities and that might make more action in the coding world, you never know.


Title: Re: How to get hands-on with bitcoin script development
Post by: pebwindkraft on September 12, 2017, 05:05:56 PM
yup, and Andreas' book is great!
There are lots of OpCodes not used, or their combinations creates transactions, which are not forwarded.
I think this is a protection of the network, to avoid loops in scripts and similiar. But the experts need to confirm.
When trying to play with scripts, there is lot of history here, maybe a bit longer ago, but search the forum (maybe the keywords like "OpCode" and "bitcoin contracts").
And when you have an idea, try it on testnet first, then go to live net. I had a lot of help here: http://bitcoin-script-debugger.visvirial.com/

p.s.:
found the reference here in the forum: https://bitcointalk.org/index.php?topic=1840303.0


Title: Re: How to get hands-on with bitcoin script development
Post by: Kogs on September 13, 2017, 07:20:55 AM
Somewhere I heard that at the moment some nodes only allow some predefined scripts.
But I don't know if this is true or not.

The idea behind this was, that you don't burn your coins with some "experimental" scripts where you are not able to spend them anymore.

There are several problems with homemade scripts
  • Possibility, that the coins will get burned if script has an error
  • Possiblility of unintended behaviour. The script could do what you expect, but it could possible also do something you did not expect when it is used with a different set of parameters for example. Maybe someone who use the script differently could steal coins from this script if you don't think of all possiblities (As happend with the Ethereum DAO hack).

To minimize the risk of having such troubles, you should test your scripts always in testnet and also show the script to some experienced people who may find some vulnerabilities before releasing it to the main net.


Title: Re: How to get hands-on with bitcoin script development
Post by: ggbtctalk000 on September 15, 2017, 09:58:48 PM
ok, it is purely for edu purposes to get hands-on with scripts and op-codes. I may spend few satoshis but not planning to do any trading or gain here.


Title: Re: How to get hands-on with bitcoin script development
Post by: jasondrey13 on March 05, 2019, 03:23:21 AM
I've been looking for a tool to experiment with bitcoin script for a while now, and I finally finished developing one myself: https://bitauth.com/ide/

BitAuth IDE is an open source project for designing advanced scripts for bitcoin and bitcoin-like cryptocurrencies. It’s both a learning sandbox and a tool for designing new kinds of wallets.

It includes a live-updating, interactive, line-by-line debugger, which visualizes that state of the stack over the entire execution of the program. There's also an entity and variable system for automatically generating private keys, public keys, and correct signatures across locking and unlocking scripts.

See here for a more detailed tour and a video walkthrough:
https://blog.bitjson.com/bitauth-ide-write-and-debug-custom-bitcoin-scripts-aad51f6e3f44

And the source is on GitHub: https://github.com/bitauth/bitauth-ide


Title: Re: How to get hands-on with bitcoin script development
Post by: darosior on March 05, 2019, 09:24:44 PM
I covered and had basic fundamental understanding of how the scripting (lock or formerly ScriptPubKey and unlock or formerl ScriptSig). The "mastering bitcoin" had fairly good coverage on how scripting works and what purpose it does. However there are faily large number of script op codes available in the appendix, so I am wondering what are good way to get hands-on and write a script and deploy it on live platform?
My wild guess, is most bitcoin wallets will only work with a Pay-to-public-key hash, i imagine one has to develop the proprietary wallet that can send and received bitcoin based on signing of custom scripts. I am going to take another shot at it by saying existing wallets that can send/receive bitcoin using P2SH (pay-to-script-hash) will work. But I believe one still has to write the script and some integrate with the wallet.  
Thanks!
Hi,

I made this in Python to experiment (basic, but still powerful) raw Bitcoin transactions and scripting : https://github.com/darosior/raw-transactions . Modify `gen_rawtx.py` with your script. Since there is no README, feel free to ask me questions.
EDIT : Here is a blog post related to the code, it might help you getting around it : https://medium.com/@darosior/bitcoin-raw-transactions-the-hard-way-f139615f195b .