Bitcoin Forum
March 28, 2024, 01:34:07 PM *
News: Latest Bitcoin Core release: 26.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: I want to get started with bitcoin script, what are some good resources?  (Read 238 times)
BoofBitcoin (OP)
Newbie
*
Offline Offline

Activity: 12
Merit: 25


View Profile
April 02, 2020, 09:09:45 PM
Merited by Quickseller (2), ABCbits (2), hugeblack (1), o_e_l_e_o (1)
 #1

I have been researching bitcoin script and to my surprise its not as difficult as I first assumed. The problem is every resource I have seen so far from googling around and looking at youtube videos only seem to cover the fundamentals but never really touches on other things like what is the process of serializing and executing my script as a transaction on the blockchain? Most guides cover stuff like what is a stack and how does Alice send bob bitcoin and what that transaction type look like. Suppose I create a timelocked script or multisig script, how do I execute that script live or on the testnet? Also, are there any development "best practices" I should be aware of, or a development environment that can streamline or optimize the process of development, debugging, and deployment?
1711632847
Hero Member
*
Offline Offline

Posts: 1711632847

View Profile Personal Message (Offline)

Ignore
1711632847
Reply with quote  #2

1711632847
Report to moderator
1711632847
Hero Member
*
Offline Offline

Posts: 1711632847

View Profile Personal Message (Offline)

Ignore
1711632847
Reply with quote  #2

1711632847
Report to moderator
1711632847
Hero Member
*
Offline Offline

Posts: 1711632847

View Profile Personal Message (Offline)

Ignore
1711632847
Reply with quote  #2

1711632847
Report to moderator
Activity + Trust + Earned Merit == The Most Recognized Users on Bitcointalk
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1711632847
Hero Member
*
Offline Offline

Posts: 1711632847

View Profile Personal Message (Offline)

Ignore
1711632847
Reply with quote  #2

1711632847
Report to moderator
1711632847
Hero Member
*
Offline Offline

Posts: 1711632847

View Profile Personal Message (Offline)

Ignore
1711632847
Reply with quote  #2

1711632847
Report to moderator
1711632847
Hero Member
*
Offline Offline

Posts: 1711632847

View Profile Personal Message (Offline)

Ignore
1711632847
Reply with quote  #2

1711632847
Report to moderator
Coding Enthusiast
Legendary
*
Offline Offline

Activity: 1039
Merit: 2783


Bitcoin and C♯ Enthusiast


View Profile WWW
April 03, 2020, 03:34:15 AM
Merited by Quickseller (3), hugeblack (2), ABCbits (1), o_e_l_e_o (1)
 #2

I'm in the same boat. The basics of bitcoin script language are pretty easy, the problem I've faced is the special cases and undocumented exceptions. Unfortunately the only way to fully understand scripts your only option is to look at the bitcoin core source code (C++ code), start here.

Suppose I create a timelocked script or multisig script, how do I execute that script live or on the testnet?
This answer by me may help you get started on pay to (witness) script hash script types: https://bitcoin.stackexchange.com/a/93733/87716

Projects List+Suggestion box
Donate: 1Q9s or bc1q
|
|
|
FinderOuter(0.19.1)Ann-git
Denovo(0.7.0)Ann-git
Bitcoin.Net(0.26.0)Ann-git
|
|
|
BitcoinTransactionTool(0.11.0)Ann-git
WatchOnlyBitcoinWallet(3.2.1)Ann-git
SharpPusher(0.12.0)Ann-git
HCP
Legendary
*
Offline Offline

Activity: 2086
Merit: 4315

<insert witty quote here>


View Profile
April 03, 2020, 10:04:09 AM
 #3

My end goal is I want to learn to create a script that can handle an escrow like service, where 2 parties can agree or disagree that the agreement is to satisfaction and if there is a disagreement then a third party can step in and mediate.
Not wanting to dull your thirst for knowledge... but isn't that sort of escrow scenario already handled by a simple 2-of-3 multisig wallet setup? Huh

..JAMBLER.io..Create Your Bitcoin Mixing
Business Now for   F R E E 
▄█████████████████████████████
█████████████████████████
████▀████████████████████
███▀█████▄█▀███▀▀▀██████
██▀█████▄█▄██████████████
██▄▄████▀▄▄▄▀▀▀▀▀▄▄██████
█████▄▄▄██████████▀▄████
█████▀▄█▄██████▀█▄█████
███████▀▄█▀█▄██▀█▄███████
█████████▄█▀▄█▀▄█████████
█████████████████████████
█████████████████████████
▀█████████████████████████████
█████████████████████████████████████████████████
.
      OUR      
PARTNERS

.
█████████████████████████████████████████████████
████▄
██
██
██
██
██
██
██
██
██
██
██
████▀
▄█████████████████████████████
████████▀▀█████▀▀████████
█████▀█████████████▀█████
████████████████████████
███████████████▄█████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████▀█████████
████████████████████████
█████▄█████████████▄█████
████████▄▄█████▄▄████████
▀█████████████████████████████
█████████████████████████████████████████████████
.
   INVEST   
BITCOIN

.
█████████████████████████████████████████████████
████▄
██
██
██
██
██
██
██
██
██
██
██
████▀
aliashraf
Legendary
*
Offline Offline

Activity: 1456
Merit: 1174

Always remember the cause!


View Profile WWW
April 03, 2020, 06:16:47 PM
Last edit: April 03, 2020, 07:29:44 PM by aliashraf
Merited by HCP (10), ABCbits (9), Quickseller (2), Coding Enthusiast (2), mocacinno (1), o_e_l_e_o (1)
 #4

OP,
For mastering bitcoin scripting language you need to check resources like this: https://github.com/bitcoinbook/bitcoinbook/blob/develop/ch07.asciidoc

But for creating actual scripts tailored to your needs (like the hypothetical one @ETFbitcoin suggested) without coding it you have two options:

1)lame option: Ignore the mastering phase and just storyboard your requirements right here, waiting for someone to write down a script for you.

2)Try writing down simple scripts tailored to your need and incrementally add more twists to it

In either case, you will come with something like this:
Code:
 IF
    IF
      2
    ELSE
      <60 days> CHECKSEQUENCEVERIFY DROP
      <MyPubkey> CHECKSIGVERIFY
      1
    ENDIF
    <Pubkey1> <Pubkey2> <Pubkey3> 3 CHECKMULTISIG
  ELSE
    <90 days> CHECKSEQUENCEVERIFY DROP
    <MyPubkey> CHECKSIG
  ENDIF
In this 'simple' script, I send funds to an address which is redeemable with 2 of 3 authorized members of a directing board or something, however, after  60 days if the board doesn't reach required 2 votes, one authorized member can join me to reclaim the funds and after 90 days I can do it by myself.

Now that the script is ready, you need the public keys to put in the placeholders and a map. What map? One that tells you the value of each opcode presented in the script. here you could find one: https://en.bitcoin.it/wiki/Script
After replacing public keys in the script you might decide to calculate its sha256 hash and ripemd160.

You can use libbitcoin-explorer (bx) to get rid of mapping and doing both hashes.  as follows:
Code:
echo {SCRIPT}| bx script-encode | bx sha256 | bx ripemd160
The result would be the hash of your script and it can be used as the destination of a simple P2SH transaction but you and other people who wish to access the funds in the future should have access to the original script. reclaiming complex scripts is another story.


Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!