Title: Where are functions: Add transaction, Sign transaction, Check transaction ... Post by: skylord56 on May 22, 2018, 03:59:33 PM Hi,
I need to know where are the functions responsible to: - Add transaction - Sign the transaction by private key - Check the transaction by nodes - Add to mempool In the bitcoin code please ? What is the function reponsible to check if transaction can be added to block by all nodes, and if it's correct ? Thank's Title: Re: Where are functions: Add transaction, Sign transaction, Check transaction ... Post by: achow101 on May 22, 2018, 07:22:17 PM - Add transaction Add transaction to what?- Sign the transaction by private key The code for the RPC command signrawtransactionwithwallet can be found here (https://github.com/bitcoin/bitcoin/blob/master/src/wallet/rpcwallet.cpp#L3453). Follow the code and it will take you to where transactions are actually signed. Starting with this command shows you the whole process.- Check the transaction by nodes Checking a transaction is done when it is being added to the mempool (the same functions are used for checking transactions in blocks). Just follow the code for AcceptToMemoryPool (https://github.com/bitcoin/bitcoin/blob/master/src/validation.cpp#L1018)- Add to mempool Title: Re: Where are functions: Add transaction, Sign transaction, Check transaction ... Post by: skylord56 on May 22, 2018, 07:32:48 PM - Add transaction Add transaction to what?- Sign the transaction by private key The code for the RPC command signrawtransactionwithwallet can be found here (https://github.com/bitcoin/bitcoin/blob/master/src/wallet/rpcwallet.cpp#L3453). Follow the code and it will take you to where transactions are actually signed. Starting with this command shows you the whole process.- Check the transaction by nodes Checking a transaction is done when it is being added to the mempool (the same functions are used for checking transactions in blocks). Just follow the code for AcceptToMemoryPool (https://github.com/bitcoin/bitcoin/blob/master/src/validation.cpp#L1018)- Add to mempool By Add Transaction i mean: Create a new transaction. Transaction is checked first and added to Mempool waiting for miners no ? Many thank's Title: Re: Where are functions: Add transaction, Sign transaction, Check transaction ... Post by: achow101 on May 22, 2018, 07:36:11 PM By Add Transaction i mean: Create a new transaction. Follow the code for createrawtransaction (https://github.com/bitcoin/bitcoin/blob/master/src/rpc/rawtransaction.cpp#L336). If you are interested in how the wallet works, then follow the code for sendtoaddress (https://github.com/bitcoin/bitcoin/blob/master/src/wallet/rpcwallet.cpp#L488)Transaction is checked first and added to Mempool waiting for miners no ? Yes. However the checking and adding to mempool are done as part of the same function. The AddToMemoryPool function will call the various checking functions for checking a transaction and then add it to the mempool at the end. It also performs its own checks for the additional conditions of adding a transaction to the mempool (e.g. conflicts, replacement, transaction fee, etc.).Title: Re: Where are functions: Add transaction, Sign transaction, Check transaction ... Post by: skylord56 on May 22, 2018, 07:39:11 PM By Add Transaction i mean: Create a new transaction. Follow the code for createrawtransaction (https://github.com/bitcoin/bitcoin/blob/master/src/rpc/rawtransaction.cpp#L336). If you are interested in how the wallet works, then follow the code for sendtoaddress (https://github.com/bitcoin/bitcoin/blob/master/src/wallet/rpcwallet.cpp#L488)Transaction is checked first and added to Mempool waiting for miners no ? Yes. However the checking and adding to mempool are done as part of the same function. The AddToMemoryPool function will call the various checking functions for checking a transaction and then add it to the mempool at the end. It also performs its own checks for the additional conditions of adding a transaction to the mempool (e.g. conflicts, replacement, transaction fee, etc.).First thank you for the explaignation, really appreciated :) SignSignature is the one that sign a transaction with private key no ? Title: Re: Where are functions: Add transaction, Sign transaction, Check transaction ... Post by: achow101 on May 22, 2018, 07:50:40 PM SignSignature is the one that sign a transaction with private key no ? No, ProduceSignature is. SignSignature is not actually used outside of tests. |