Monday, 16 December 2019

Application of Bitcoin Script

Application of Bitcoin Script:

Now you all know about Bitcoin Structure. If you don't know then please read about the structure of Bitcoin, please. Now we'll talk about applications of Bitcoin script.
There are five applications
  • Escrow transaction
  • Green addresses
  • Efficient micro-payment
  • Lock time
  • Smart contracts

Escrow Transaction:

First of all, we need to understand that what is escrow? So according to wikipedia, ESCROW is a contract between two parties with the help of trusted third party. This third party receive and pay money for the primary parites with plentiful terms and conditions.
Excrow transaction is useful in following situation:
  • Alice wants to buy some things from Bob.
  • She wants to pay with Bitcoins and Bob has to send physical goods to Alice.
  • Alice doesn't want to pay until she receives it. And Bob doesn't want to send it, until he has received the payment
There is a cool solution in bitcoin.
  • Alice creates a multi-signature, which is type of digital signature that makes it possible for two or more user to sign a document and verify it, named MULTISIG transaction that requires Alice, Bob And Third Party to sign in order to redeem the bitcoins.We can say that this third party is Huzaifa. Huzaifa is a judge, whose role stat when there is disagreement from any of them
  • Alice signs the transaction if he had coins to send. These coins are held an escrow between Alice, Bob, and Huzaifa.
  • At this point, Bob can safely send the goods to Alice and sign the transaction. After this bitcoin structure releases money to Bob.
  • If the goods arrive and goods was same as Alice expected, she can release the money towards Bob signing the transaction. The money will be sent to Bob without the need of Huzaifa.
  • This happens if both are honest.
  • Otherwise Alice could ask for her money back. And maybe Bob doesn't agree to sign the transactions that releases the money towards Alice.
  • So, now it's Huzaifa's turn to decide who's right and sign the transaction that releases money either towards Alice or Bob. In both cases, since only two signatures are required. After this the money will be sent to one of them

Green Addresses:


​If Alice wants to pay Bob, and Bob’s offline. Or due to some issues, Bob can’t go and look at the block chain and wait for the transactions to be confirmed. It's take some time like one hour for confirmation of transaction. But for some merchandise such as food, Bob can’t wait an hour before delivering and Alice will not wait for one hour for food.
To solve this problem, there is a app;ication named Green Addresses. We have to introduce another third party, which we’ll call the bank (for the easiness of you). Alice is going to talk to her bank, and confirm her identity and say that i want to make some transaction to Bob. And the bank will say, "Sure. I’m going to deduct some money out of your account. And draw up a transaction from one of my green addresses over to Bob."

So when Bob sees that this transaction is signed by the bank, which he trusts, he can accept money which will be his when it’s confirmed in the block chain.

Efficient Micro-Payments:


If Alice is a customer who wants to continually pay Bob small amounts of money for some service that Bob provides. For example, Bob may be Alice’s wireless service provider, and requires her to pay a small fee for every minute that she talks on her phone. 
Creating a Bitcoin transaction for every minute that Alice speaks on the phone won’t work. That will create too many transactions, and the transaction fees add up. If the value of each one of these transactions is on the order of what the transaction fees are, Alice is going to be paying a high cost to do this. 
The best way is combine all these small payments into one big payment at the end. We start with a MULTISIG, which we discussed before, transaction that pays the maximum amount Alice which is equal to the service which alice needs, requiring both Alice and Bob to sign to release the coins. Now, after the first minute that Alice has used the service and signs a transaction spending those coins that were sent to the MULTISIG address, sending one unit of payment to Bob. After the next minute of using the service, Alice signs another transaction, this time paying two units to Bob. Notice these are signed only by Alice, and haven’t been signed by Bob yet, nor are they being published to the block chain. Alice will keep sending these transactions to Bob every minute that she uses the service. When Alice will finish using the service, and tells Bob, "I’m done." At this point Alice will stop signing additional transactions. After this, Bob will say "Great. I’ll disconnect your service, and I’ll take that last transaction that you sent me, sign it, and publish that to the block chain."

Lock Time:

​If, before the micro-payment protocol can even start, Alice and Bob will both sign a transaction which refunds all of Alice’s money back to her, but the refund is “locked” until some time in the future. So after Alice signs, but before she broadcasts, the first MULTISIG transaction that puts her funds into escrow, she’ll want to get this refund transaction from Bob and hold on to it. That guarantees that if she makes it to time t ​and Bob hasn’t signed any of the small transactions that Alice has sent, Alice can publish this transaction which refunds all of the money directly to her. 
What does it mean that it’s locked until time t​? Recall when we looked at the metadata in Bitcoin transactions (please see, blockchain structure), that there was this lock_time parameter. The way it works is that if you specify any value other than zero for the lock time, it tells miners not to publish the transaction until the specified lock time. The transaction will be invalid before this time, based on the timestamps that are put into blocks. So this is a way of preparing a transaction that can only be spent in the future if it isn’t already spent by then. It works quite nicely in the micro-payment protocol as a safety valve for Alice to know that if Bob never signs, eventually she’ll be able to get her money back.

Smart Contracts:

These all applications are based on smart contracts. These are contracts for which we have some degree of technical enforcement in Bitcoin. We can use scripts, miners, and transaction validation to realize the escrow protocol or the micro-payment protocol without needing a centralized authority.