This publish was first revealed on Medium. Learn Half 2 here.
Beforehand, we’ve launched two methods to delegate the suitable to spend one’s bitcoin: one at Script level, the opposite at transaction level.
We generalize the previous to delegate to any script/smart contract, as an alternative of a public key solely. It permits one to authorize arbitrary sensible contract to spend one’s bitcoin.
The complete code is proven beneath:
Line 9 checks the delegated script is signed and thus authorized by the proprietor. Line 12 and 13 make sure the delegated script goes into the spending transaction’s output as the brand new locking script utilizing OP_PUSH_TX, much like the emulation of Pay to Script Hash (P2SH).
Watch: CoinGeek New York presentation, The Path to BitCoin Adoption: How you can Flip the Total Internet into Bitcoin Apps
New to Bitcoin? Try CoinGeek’s Bitcoin for Beginners part, the final word useful resource information to be taught extra about Bitcoin—as initially envisioned by Satoshi Nakamoto—and blockchain.