Bitcoin Forum
June 23, 2018, 04:32:08 PM *
News: Latest stable version of Bitcoin Core: 0.16.1  [Torrent]. (New!)
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: main() in bitcoin-tx.cpp  (Read 622 times)
victorkimba17
Jr. Member
*
Offline Offline

Activity: 84
Merit: 1


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 ?
The World's Betting Exchange

Bet with play money. Win real Bitcoin. 5BTC Prize Fund for World Cup 2018.

Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1529771528
Hero Member
*
Offline Offline

Posts: 1529771528

View Profile Personal Message (Offline)

Ignore
1529771528
Reply with quote  #2

1529771528
Report to moderator
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 1442
Merit: 1352


3F1Y9yquzvY6RWvKbw2n2zeo9V5mvBhADU


View Profile WWW
November 08, 2017, 03:12:21 PM
 #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
Jr. Member
*
Offline Offline

Activity: 84
Merit: 1


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

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

Activity: 84
Merit: 1


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: 1442
Merit: 1352


3F1Y9yquzvY6RWvKbw2n2zeo9V5mvBhADU


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
Jr. Member
*
Offline Offline

Activity: 84
Merit: 1


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: 1442
Merit: 1352


3F1Y9yquzvY6RWvKbw2n2zeo9V5mvBhADU


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
Jr. Member
*
Offline Offline

Activity: 84
Merit: 1


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: 112
Merit: 10


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.
victorkimba17
Jr. Member
*
Offline Offline

Activity: 84
Merit: 1


View Profile
November 13, 2017, 05:19:18 AM
 #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:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!