Bitcoin Forum
May 03, 2024, 12:34:49 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: How to gain a deep understanding of transactions  (Read 14601 times)
malefice (OP)
Newbie
*
Offline Offline

Activity: 37
Merit: 0


View Profile
December 07, 2013, 09:20:16 AM
 #1

What is the best way to understand the protocol better?
1. how can I perform some testnet transactions, what are the best tools to create custom transactions? sx or what tool do you guys use for that?
2. to understand complex transactions my best source is https://en.bitcoin.it/wiki/Contracts, is there more documentation I should read?

If you want to be a moderator, report many posts with accuracy. You will be noticed.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714739689
Hero Member
*
Offline Offline

Posts: 1714739689

View Profile Personal Message (Offline)

Ignore
1714739689
Reply with quote  #2

1714739689
Report to moderator
piotr_n
Legendary
*
Offline Offline

Activity: 2053
Merit: 1354


aka tonikt


View Profile WWW
December 07, 2013, 01:27:32 PM
Last edit: December 07, 2013, 01:41:16 PM by piotr_n
 #2

Start here:
https://en.bitcoin.it/wiki/Protocol_specification#tx
https://en.bitcoin.it/wiki/Script
https://en.bitcoin.it/wiki/OP_CHECKSIG

Try to decode few raw transactions manually (from the hexdump) - that should give you a good start of what they are.

Also what is important and confuses many new people: each transaction (except of the coinbase/mining ones) refers to output scripts from its inputs, which are in previous transactions.
So validating a transaction involves executing a script that is a part of some previous transaction... same case for signing - just the opposite.

Check out gocoin - my original project of full bitcoin node & cold wallet written in Go.
PGP fingerprint: AB9E A551 E262 A87A 13BB  9059 1BE7 B545 CDF3 FD0E
nwbitcoin
Sr. Member
****
Offline Offline

Activity: 294
Merit: 250


You are a geek if you are too early to the party!


View Profile WWW
December 08, 2013, 02:22:19 PM
 #3

this is really useful - more people need to understand the mechanics of how Bitcoin works because they can then understand the potential!

*Image Removed*
I use Localbitcoins to sell bitcoins for GBP by bank transfer!
piotr_n
Legendary
*
Offline Offline

Activity: 2053
Merit: 1354


aka tonikt


View Profile WWW
December 08, 2013, 02:27:12 PM
 #4

this is really useful - more people need to understand the mechanics of how Bitcoin works because they can then understand the potential!
I couldn't agree more.

Reading some economical experts - e.g. like Bill Fleckenstein, it seems pretty obvious that they have no clue what bitcoin is and why its security is much stronger than any army can give. If the guy was really smart, as he pretends to be, he would have known that it is a solid money that builds an army and not the other way around... Smiley

Quote
Eric King:  “Bill, Bitcoin, do you have any thoughts on that?”

Fleckenstein:  “Yeah, it’s a giant chain-letter.  Everyone will lose all of their money that puts money in it.  It’s a complete joke.  Even a crappy currency has government taxing ability behind it, or some sort of a standing army or something like that.

Bitcoin is nothing.  It’s dot-com mania 3.0 just moved one step over, right?  People are so enamored with communication with their phones and online commerce and all of that.  Now they’ve invented what they call a currency to mess around with it, and people are speculating in it the same way they speculated in this other crap.  It’s not a currency at all, it’s a complete joke.”

http://kingworldnews.com/kingworldnews/KWN_DailyWeb/Entries/2013/12/6_Fleckentstein_-_Global_Meltdown_%26_Why_Bitcoin_Will_Go_To_Zero.html

Check out gocoin - my original project of full bitcoin node & cold wallet written in Go.
PGP fingerprint: AB9E A551 E262 A87A 13BB  9059 1BE7 B545 CDF3 FD0E
malefice (OP)
Newbie
*
Offline Offline

Activity: 37
Merit: 0


View Profile
December 08, 2013, 03:02:15 PM
 #5

Put aside the commentary of some financial entertainers, people are in the media to entertain not to seek the truth.
Some more questions about transactions:

Are there transactions that are somehow reserved? By 'reserved' I mean they are not spent, but I would not be able to spent the money at the address somewhere else.
For example if I have a crowdfunding tx with SIGHASH_ALL | SIGHASH_ANYONECANPAY on the input and Alice buys in, but then spends all the money on a shopping spree before I collected all the moneys, her crowdfunding contribution would simply be invalidated, right?
 
piotr_n
Legendary
*
Offline Offline

Activity: 2053
Merit: 1354


aka tonikt


View Profile WWW
December 08, 2013, 03:10:38 PM
 #6

Are there transactions that are somehow reserved? By 'reserved' I mean they are not spent, but I would not be able to spent the money at the address somewhere else.
For example if I have a crowdfunding tx with SIGHASH_ALL | SIGHASH_ANYONECANPAY on the input and Alice buys in, but then spends all the money on a shopping spree before I collected all the moneys, her crowdfunding contribution would simply be invalidated, right?
 

I am not sure if I understood the question but if I did...

Bitcoin transaction are not like credit cards - your girlfriend Alice cannot go on a shopping spree with your money if the money in her purse does not exist.
Using an analogy, it's more like a pre-paid card.
The only form of the money in her bitcoin purse is a set of a so-called "unspent outputs".

The way how an unspent output can be spent - that's a different topic. A pretty huge one, in fact..
You can for instance use the multisig transactions - so it would require e.g. 2 of 3 keys to spend the output and this way Alice would not be able to spend the money without a second signature.

It's probably not what you were asking for, but feel free to precise the question.

Check out gocoin - my original project of full bitcoin node & cold wallet written in Go.
PGP fingerprint: AB9E A551 E262 A87A 13BB  9059 1BE7 B545 CDF3 FD0E
genjix
Legendary
*
expert
Offline Offline

Activity: 1232
Merit: 1072


View Profile
December 08, 2013, 03:43:21 PM
 #7

http://sx.dyne.org/
malefice (OP)
Newbie
*
Offline Offline

Activity: 37
Merit: 0


View Profile
December 08, 2013, 04:26:18 PM
 #8

Are there transactions that are somehow reserved? By 'reserved' I mean they are not spent, but I would not be able to spent the money at the address somewhere else.
For example if I have a crowdfunding tx with SIGHASH_ALL | SIGHASH_ANYONECANPAY on the input and Alice buys in, but then spends all the money on a shopping spree before I collected all the moneys, her crowdfunding contribution would simply be invalidated, right?
 

It's probably not what you were asking for, but feel free to precise the question.

Thank you Piotr,
I look at the crowdfunding example "Assurance contracts" https://en.bitcoin.it/wiki/Contracts#Example_3:_Assurance_contracts
It is pretty clear to me how it works generally but I have some specific questions:
I am wondering if a person Alice that makes a pledge of 100 BTC in a 1000 BTC assurance contract can then still spent the 100 BTC?
Infact the output of the assurance tx is set to 1000 BTC, so until 1000 BTC are not collected the assurance tx remains unspent.
This leads to the matter that also Alices pledge is unspent? For her 100 BTC are an input into the assurance tx?
If so Alice could decide any time to spend the 100 BTC for something else. Is this correct?

Not that its a problem for me if Alice wants to do here shopping. I just wonder if bitcoin works that way, and if yes how you would make a "reservation" of the money, like with nTimelock but instead of spending the money only after a certain time, you reserve it for a certain amount of time.
piotr_n
Legendary
*
Offline Offline

Activity: 2053
Merit: 1354


aka tonikt


View Profile WWW
December 08, 2013, 04:33:27 PM
 #9

My pleasure, man.

Since I am just a regular bitcoins user, with no woman whatsoever, these kind of contracts are not my domain of interest Smiley
Though I am pretty sure that you can do all kind of a weird stuff with the bitcoin scripts.
Whether such transaction would be routed/mined or not - that's a different topic, but in theory the protocol is pretty open and you can mine whatever is not against it, as long as you find a miner which does not censor your script just because it is "non-standard" according to rules arbitrary defined by the bitcoin elite.

I know people around here have been working on solving all kind of strange contracts.
So if you ask patiently enough, eventually someone will show you the right way, not just pretend to know that he thinks there is one... Wink
You definitely ask a smart questions - that's why I don't want to give you a stupid answers.

Check out gocoin - my original project of full bitcoin node & cold wallet written in Go.
PGP fingerprint: AB9E A551 E262 A87A 13BB  9059 1BE7 B545 CDF3 FD0E
nwbitcoin
Sr. Member
****
Offline Offline

Activity: 294
Merit: 250


You are a geek if you are too early to the party!


View Profile WWW
December 08, 2013, 05:15:47 PM
 #10

Are there transactions that are somehow reserved? By 'reserved' I mean they are not spent, but I would not be able to spent the money at the address somewhere else.
For example if I have a crowdfunding tx with SIGHASH_ALL | SIGHASH_ANYONECANPAY on the input and Alice buys in, but then spends all the money on a shopping spree before I collected all the moneys, her crowdfunding contribution would simply be invalidated, right?
 

It's probably not what you were asking for, but feel free to precise the question.

Thank you Piotr,
I look at the crowdfunding example "Assurance contracts" https://en.bitcoin.it/wiki/Contracts#Example_3:_Assurance_contracts
It is pretty clear to me how it works generally but I have some specific questions:
I am wondering if a person Alice that makes a pledge of 100 BTC in a 1000 BTC assurance contract can then still spent the 100 BTC?
Infact the output of the assurance tx is set to 1000 BTC, so until 1000 BTC are not collected the assurance tx remains unspent.
This leads to the matter that also Alices pledge is unspent? For her 100 BTC are an input into the assurance tx?
If so Alice could decide any time to spend the 100 BTC for something else. Is this correct?

Not that its a problem for me if Alice wants to do here shopping. I just wonder if bitcoin works that way, and if yes how you would make a "reservation" of the money, like with nTimelock but instead of spending the money only after a certain time, you reserve it for a certain amount of time.

This is exactly what I've been looking at, and it seems it links to script contracts and bonds.

You can post date your transactions through contracts, and that does limit the spend as you can't transfer the bitcoin once you have assigned it to a future transfer.
However, you can use that value as part of a bond, where the bond assumes the value of the contract, and you are free to spend it, as long as you buy back the bond before your contract hits its time to transfer.

I am thinking it would be a fantastic way to create a community credit card which gives a credit union the facility that currently are only available through banks.

*Image Removed*
I use Localbitcoins to sell bitcoins for GBP by bank transfer!
vosovich
Newbie
*
Offline Offline

Activity: 28
Merit: 0


View Profile
December 08, 2013, 06:25:07 PM
 #11

I have found an excellent article which introduces the bitcoin protocol. It has filled many gaps in my understanding of the protocol.
malefice (OP)
Newbie
*
Offline Offline

Activity: 37
Merit: 0


View Profile
December 08, 2013, 06:27:18 PM
 #12


You can post date your transactions through contracts, and that does limit the spend as you can't transfer the bitcoin once you have assigned it to a future transfer.


Are you sure? My intuition is that Alice's transaction is not spent, and therefore she can spend another tx instead.
nwbitcoin
Sr. Member
****
Offline Offline

Activity: 294
Merit: 250


You are a geek if you are too early to the party!


View Profile WWW
December 08, 2013, 06:41:54 PM
 #13


You can post date your transactions through contracts, and that does limit the spend as you can't transfer the bitcoin once you have assigned it to a future transfer.


Are you sure? My intuition is that Alice's transaction is not spent, and therefore she can spend another tx instead.

If the contract is set up with a value to transfer at a future date, then its already spent, according to the script.

https://en.bitcoin.it/wiki/Script

This is not yet operational, but when it is, then the transaction goes through to the blockchain, with its post dated value transfer. the bitcoin will be recorded as being spent, but with no value, allocated, that will still show up in Alice's wallet.

This way Alice can't spend it either - think of it like a first confirmation delay that lasts the entire period of the contract!

A bond takes this transaction as its value and time stamp for existence - but this is where things start getting a bit complex because it starts following financial rules!






*Image Removed*
I use Localbitcoins to sell bitcoins for GBP by bank transfer!
malefice (OP)
Newbie
*
Offline Offline

Activity: 37
Merit: 0


View Profile
December 08, 2013, 07:21:52 PM
 #14

@nwbitcoin oh, you are referring to "A script is essentially a list of instructions recorded with each transaction that describe how the next person wanting to spend the Bitcoins being transferred can gain access to them."
So i have a tx with an output script and the transaction is over and out. But the next transaction can be done only after the timer.

The timer we are talking hereis not nLockTime, right? Because nLockTime says "Otherwise, the transaction may not be added to a block until after lock_time"
https://en.bitcoin.it/wiki/Protocol_specification#tx

So what is this disabled feature in the script you are talking about?

many thanks!



extro24
Sr. Member
****
Offline Offline

Activity: 481
Merit: 252


View Profile
December 08, 2013, 07:53:12 PM
 #15

@genjix:  Appreciate all your work on Bitcoin and libbitcoin, but is there a program to write and test Bitcoin Scripts?  A sort of Bitcoin Script IDE?  I think you need a little more than gforth.

malefice (OP)
Newbie
*
Offline Offline

Activity: 37
Merit: 0


View Profile
December 08, 2013, 07:54:02 PM
 #16

@vosovich: awsome, reading it right now!
extro24
Sr. Member
****
Offline Offline

Activity: 481
Merit: 252


View Profile
December 08, 2013, 07:54:26 PM
 #17

@vosovich:  You are right, that article is excellent.

nwbitcoin
Sr. Member
****
Offline Offline

Activity: 294
Merit: 250


You are a geek if you are too early to the party!


View Profile WWW
December 08, 2013, 10:09:19 PM
 #18

@nwbitcoin oh, you are referring to "A script is essentially a list of instructions recorded with each transaction that describe how the next person wanting to spend the Bitcoins being transferred can gain access to them."
So i have a tx with an output script and the transaction is over and out. But the next transaction can be done only after the timer.

The timer we are talking hereis not nLockTime, right? Because nLockTime says "Otherwise, the transaction may not be added to a block until after lock_time"
https://en.bitcoin.it/wiki/Protocol_specification#tx

So what is this disabled feature in the script you are talking about?

many thanks!





I think I understand the confusion, the instruction in the transaction script, includes an area where more complex script instructions can be placed.  Currently, that is limited to just one instruction, but it will be extended.

The articles in this thread might be useful to explain  - its where I asked a similar question and found my answers.

https://bitcointalk.org/index.php?topic=360087.0


*Image Removed*
I use Localbitcoins to sell bitcoins for GBP by bank transfer!
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!