Bitcoin Forum
May 11, 2024, 08:33:50 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: main() in bitcoin-tx.cpp  (Read 705 times)
victorkimba17 (OP)
Jr. Member
*
Offline Offline

Activity: 113
Merit: 5


View Profile
November 08, 2017, 01:58:01 PM
 #1

I notice that is a main() function in bitcoin-tx.cpp. This main() is not the main function of bitcoin core. Because the main function is in bitcoind.cpp

So why there is a main() in bitcoin-tx.cpp ?
1715416430
Hero Member
*
Offline Offline

Posts: 1715416430

View Profile Personal Message (Offline)

Ignore
1715416430
Reply with quote  #2

1715416430
Report to moderator
1715416430
Hero Member
*
Offline Offline

Posts: 1715416430

View Profile Personal Message (Offline)

Ignore
1715416430
Reply with quote  #2

1715416430
Report to moderator
1715416430
Hero Member
*
Offline Offline

Posts: 1715416430

View Profile Personal Message (Offline)

Ignore
1715416430
Reply with quote  #2

1715416430
Report to moderator
You can see the statistics of your reports to moderators on the "Report to moderator" pages.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715416430
Hero Member
*
Offline Offline

Posts: 1715416430

View Profile Personal Message (Offline)

Ignore
1715416430
Reply with quote  #2

1715416430
Report to moderator
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3388
Merit: 6635


Just writing some code


View Profile WWW
November 08, 2017, 03:12:21 PM
Merited by ABCbits (1)
 #2

There is a separate binary called bitcoin-tx which lets you do some transaction specific things without needing to run the full Bitcoin Core. It needs a main function for that binary to work.

Likewise, there are main functions in bitcoin-cli.cpp and qt/bitcoin.cpp as those are for separate binaries that need main functions too (bitcoin-cli and bitcoin-qt respectively).

victorkimba17 (OP)
Jr. Member
*
Offline Offline

Activity: 113
Merit: 5


View Profile
November 09, 2017, 12:50:30 AM
 #3

thank you. should have seen that
victorkimba17 (OP)
Jr. Member
*
Offline Offline

Activity: 113
Merit: 5


View Profile
November 10, 2017, 02:52:11 PM
 #4

There is a separate binary called bitcoin-tx which lets you do some transaction specific things without needing to run the full Bitcoin Core. It needs a main function for that binary to work.

It looks like bitcoin-tx.cpp is never built into the bincoind binary of Bitcoin core, isn't  it?
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3388
Merit: 6635


Just writing some code


View Profile WWW
November 12, 2017, 02:05:47 AM
 #5

It looks like bitcoin-tx.cpp is never built into the bincoind binary of Bitcoin core, isn't  it?
No, it is not. bitcoin-tx.cpp is for bitcoin-tx, a completely separate binary. It only exists to provide the separate bitcoin-tx binary.

victorkimba17 (OP)
Jr. Member
*
Offline Offline

Activity: 113
Merit: 5


View Profile
November 12, 2017, 02:22:41 AM
 #6

Thank you. Now I use the bitcoin-tx binary.

bitcoin-tx -create in=0fb9df5614be8b33be0434ce4062750d83f1b7ce05cc1296604f82eb9abf802b:0 outscript=0.00159999:"DUP HASH160 0x14 0x6793a38f79b8cd51dbb6face6dc75a4af5c1bf29 EQUALVERIFY CHECKSIG"

and got the return value
02000000012b80bf9aeb824f609612cc05ceb7f1830d756240ce3404be338bbe1456dfb90f00000 00000ffffffff01ff700200000000001976a9146793a38f
79b8cd51dbb6face6dc75a4af5c1bf2988ac00000000

i understand the outscript format. 0.00159999 is the value to be spent. What about the in format ? what is 0fb9df56..... ? It is previous tx or scriptSig?
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3388
Merit: 6635


Just writing some code


View Profile WWW
November 12, 2017, 05:14:09 AM
 #7

What about the in format ? what is 0fb9df56..... ? It is previous tx or scriptSig?
Read https://bitcoin.org/en/developer-reference#raw-transaction-format

victorkimba17 (OP)
Jr. Member
*
Offline Offline

Activity: 113
Merit: 5


View Profile
November 12, 2017, 01:40:31 PM
 #8

What about the in format ? what is 0fb9df56..... ? It is previous tx or scriptSig?
Read https://bitcoin.org/en/developer-reference#raw-transaction-format

I read the link about raw transaction format. It says raw transaction has version, tx_in count, Tx_in, TX_out count, Tx_out and lock time.

I can't relate this format to the hex value in the input part.
byteball
Member
**
Offline Offline

Activity: 266
Merit: 42

The rising tide lifts all boats


View Profile
November 12, 2017, 06:14:28 PM
 #9

Code:
in=0fb9df5614be8b33be0434ce4062750d83f1b7ce05cc1296604f82eb9abf802b:0

TxIn (transaction input) structure consists of prevOut, scriptSig and sequence.
In bitcoind code prevOut has type COutPoint which consists of txid and output number.
So the "in=" you quoted means the transaction will spend the output with index 0 from transaction with id 0fb9df5614be8b33be0434ce4062750d83f1b7ce05cc1296604f82eb9abf802b, if the signature in scriptSig will be correct for
the corresponding TxOut's pk_script.

I guess the signature is generated from a key in your wallet file, if it can sign this input.

Ceterum censeo Civitatem Profunda esse delendam
victorkimba17 (OP)
Jr. Member
*
Offline Offline

Activity: 113
Merit: 5


View Profile
November 13, 2017, 05:19:18 AM
Last edit: November 13, 2017, 12:41:07 PM by victorkimba17
 #10

So in "bitcoin-tx -create in=0fb9df5614be8b33be0434ce4062750d83f1b7ce05cc1296604f82eb9abf802b:0 ...."
The 0fb9df5614be8b33be0434ce4062750d83f1b7ce05cc1296604f82eb9abf802b is the txid.

Thank you.

We can use the command "bitcoin-tx -create --help"  to see the explanation of the options in the command.
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!