Bitcoin Forum
May 24, 2024, 03:26:46 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Lock funds in transaction A until transaction B?  (Read 547 times)
andrewdb (OP)
Newbie
*
Offline Offline

Activity: 2
Merit: 1


View Profile
March 13, 2016, 05:55:57 PM
Merited by ABCbits (1)
 #1

I am learning about Bitcoin script, and wondering if something like the following is possible:

Is there a way to create a transaction which will lock funds until another transaction from someone else with a certain metadata exists?

achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3402
Merit: 6648


Just writing some code


View Profile WWW
March 13, 2016, 05:58:27 PM
Merited by ABCbits (2)
 #2

I am learning about Bitcoin script, and wondering if something like the following is possible:

Is there a way to create a transaction which will lock funds until another transaction from someone else with a certain metadata exists?


You cannot lock them until a certain transaction exists. However, what you can do is have a script can only be spent from when a certain secret is known. That secret could be published in another transaction.

You can also lock to a certain date or block height.

andrewdb (OP)
Newbie
*
Offline Offline

Activity: 2
Merit: 1


View Profile
March 13, 2016, 06:07:36 PM
 #3

You cannot lock them until a certain transaction exists. However, what you can do is have a script can only be spent from when a certain secret is known. That secret could be published in another transaction.

Interesting.

Which opcodes are involved in this "lock-until-secret-published" strategy? Is this P2SH?

I'd love to learn more about this.
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3402
Merit: 6648


Just writing some code


View Profile WWW
March 13, 2016, 06:24:12 PM
Merited by ABCbits (3)
 #4

You cannot lock them until a certain transaction exists. However, what you can do is have a script can only be spent from when a certain secret is known. That secret could be published in another transaction.

Interesting.

Which opcodes are involved in this "lock-until-secret-published" strategy? Is this P2SH?

I'd love to learn more about this.
The address to lock the coins in is a p2sh address.

The script itself may look something like:
Code:
OP_SHA256 <sha256(secret)> OP_EQUALVERIFY
<pubkey> OP_CHECKSIG
This would mean that the person who is spending it must own the private key for the <pubkey> and must know the secret so that when the secret is put through the SHA256 hash, you get <sha256(secret)>.

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!