Bitcoin Forum
June 14, 2024, 04:03:29 AM *
News: Voting for pizza day contest
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: How to get unconfirmed transactions?  (Read 156 times)
linuxqq (OP)
Jr. Member
*
Offline Offline

Activity: 34
Merit: 6


View Profile
December 14, 2020, 07:44:07 AM
Merited by Quickseller (1)
 #1

I have built a bitcoind node service. I want to quickly obtain unconfirmed transactions from the block and perform analysis. I read the vin and vout in the block and cannot know which are unconfirmed transactions. I need to build a btc Mining pool to quickly get unconfirmed transactions?
NotATether
Legendary
*
Offline Offline

Activity: 1638
Merit: 6896


bitcoincleanup.com / bitmixlist.org


View Profile WWW
December 14, 2020, 07:56:23 AM
Merited by Quickseller (3)
 #2

Use the getrawmempool RPC call to get a snapshot of the mempool. If you only want the transaction IDs inside the mempool, pass verbose=false as a parameter i.e. getrawmempool(false).

For each transaction you then call getrawtransaction to get the inputs, outputs and other stuff you need to get.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
ranochigo
Legendary
*
Offline Offline

Activity: 2982
Merit: 4193



View Profile
December 14, 2020, 08:00:21 AM
 #3

If the transaction is included in the block, then the transaction is already confirmed.

If you want to look at unconfirmed transaction (ie. transactions that has not yet been included in the block), you have to refer to your mempool. There is no perfect source of information for the unconfirmed transactions as mempool is just a representation of the transactions that has been relayed to you. It does not represent all the transactions that could be included in the next block, be it due to poor propagation or miner not broadcasting them to others.

█████████████████████████
████▐██▄█████████████████
████▐██████▄▄▄███████████
████▐████▄█████▄▄████████
████▐█████▀▀▀▀▀███▄██████
████▐███▀████████████████
████▐█████████▄█████▌████
████▐██▌█████▀██████▌████
████▐██████████▀████▌████
█████▀███▄█████▄███▀█████
███████▀█████████▀███████
██████████▀███▀██████████
█████████████████████████
.
BC.GAME
▄▄░░░▄▀▀▄████████
▄▄▄
██████████████
█████░░▄▄▄▄████████
▄▄▄▄▄▄▄▄▄██▄██████▄▄▄▄████
▄███▄█▄▄██████████▄████▄████
███████████████████████████▀███
▀████▄██▄██▄░░░░▄████████████
▀▀▀█████▄▄▄███████████▀██
███████████████████▀██
███████████████████▄██
▄███████████████████▄██
█████████████████████▀██
██████████████████████▄
.
..CASINO....SPORTS....RACING..
█░░░░░░█░░░░░░█
▀███▀░░▀███▀░░▀███▀
▀░▀░░░░▀░▀░░░░▀░▀
░░░░░░░░░░░░
▀██████████
░░░░░███░░░░
░░█░░░███▄█░░░
░░██▌░░███░▀░░██▌
░█░██░░███░░░█░██
░█▀▀▀█▌░███░░█▀▀▀█▌
▄█▄░░░██▄███▄█▄░░▄██▄
▄███▄
░░░░▀██▄▀


▄▄████▄▄
▄███▀▀███▄
██████████
▀███▄░▄██▀
▄▄████▄▄░▀█▀▄██▀▄▄████▄▄
▄███▀▀▀████▄▄██▀▄███▀▀███▄
███████▄▄▀▀████▄▄▀▀███████
▀███▄▄███▀░░░▀▀████▄▄▄███▀
▀▀████▀▀████████▀▀████▀▀
linuxqq (OP)
Jr. Member
*
Offline Offline

Activity: 34
Merit: 6


View Profile
December 14, 2020, 08:26:18 AM
 #4

Use the getrawmempool RPC call to get a snapshot of the mempool. If you only want the transaction IDs inside the mempool, pass verbose=false as a parameter i.e. getrawmempool(false).

For each transaction you then call getrawtransaction to get the inputs, outputs and other stuff you need to get.

Thank you, are all unconfirmed transactions in the memory pool? Will there be confirmed transactions in the memory pool?
ranochigo
Legendary
*
Offline Offline

Activity: 2982
Merit: 4193



View Profile
December 14, 2020, 08:27:43 AM
Merited by Quickseller (3)
 #5

Thank you, are all unconfirmed transactions in the memory pool?
Not all. See my response.
Will there be confirmed transactions in the memory pool?
No. Transactions are removed from mempool when they're in the block.

█████████████████████████
████▐██▄█████████████████
████▐██████▄▄▄███████████
████▐████▄█████▄▄████████
████▐█████▀▀▀▀▀███▄██████
████▐███▀████████████████
████▐█████████▄█████▌████
████▐██▌█████▀██████▌████
████▐██████████▀████▌████
█████▀███▄█████▄███▀█████
███████▀█████████▀███████
██████████▀███▀██████████
█████████████████████████
.
BC.GAME
▄▄░░░▄▀▀▄████████
▄▄▄
██████████████
█████░░▄▄▄▄████████
▄▄▄▄▄▄▄▄▄██▄██████▄▄▄▄████
▄███▄█▄▄██████████▄████▄████
███████████████████████████▀███
▀████▄██▄██▄░░░░▄████████████
▀▀▀█████▄▄▄███████████▀██
███████████████████▀██
███████████████████▄██
▄███████████████████▄██
█████████████████████▀██
██████████████████████▄
.
..CASINO....SPORTS....RACING..
█░░░░░░█░░░░░░█
▀███▀░░▀███▀░░▀███▀
▀░▀░░░░▀░▀░░░░▀░▀
░░░░░░░░░░░░
▀██████████
░░░░░███░░░░
░░█░░░███▄█░░░
░░██▌░░███░▀░░██▌
░█░██░░███░░░█░██
░█▀▀▀█▌░███░░█▀▀▀█▌
▄█▄░░░██▄███▄█▄░░▄██▄
▄███▄
░░░░▀██▄▀


▄▄████▄▄
▄███▀▀███▄
██████████
▀███▄░▄██▀
▄▄████▄▄░▀█▀▄██▀▄▄████▄▄
▄███▀▀▀████▄▄██▀▄███▀▀███▄
███████▄▄▀▀████▄▄▀▀███████
▀███▄▄███▀░░░▀▀████▄▄▄███▀
▀▀████▀▀████████▀▀████▀▀
linuxqq (OP)
Jr. Member
*
Offline Offline

Activity: 34
Merit: 6


View Profile
December 14, 2020, 08:38:23 AM
 #6

Thank you, are all unconfirmed transactions in the memory pool?
Not all. See my response.
Will there be confirmed transactions in the memory pool?
No. Transactions are removed from mempool when they're in the block.

thank you very much
NotATether
Legendary
*
Offline Offline

Activity: 1638
Merit: 6896


bitcoincleanup.com / bitmixlist.org


View Profile WWW
December 14, 2020, 08:39:00 AM
 #7

Thank you, are all unconfirmed transactions in the memory pool? Will there be confirmed transactions in the memory pool?

As ranochigo wrote, it'll only give you the mempool of the node you're querying, which is not complete and only has transactions it knows. But you can connect to several dozen different nodes, checking that the ones you're connecting to aren't peers of any others you're sampling, run getrawmempool on all of them and intersect all the transactions in a set to get the majority of the unconfirmed transactions.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
linuxqq (OP)
Jr. Member
*
Offline Offline

Activity: 34
Merit: 6


View Profile
December 14, 2020, 08:55:41 AM
 #8

Thank you, are all unconfirmed transactions in the memory pool? Will there be confirmed transactions in the memory pool?

As ranochigo wrote, it'll only give you the mempool of the node you're querying, which is not complete and only has transactions it knows. But you can connect to several dozen different nodes, checking that the ones you're connecting to aren't peers of any others you're sampling, run getrawmempool on all of them and intersect all the transactions in a set to get the majority of the unconfirmed transactions.

You mentioned connecting dozens of nodes here. Do I need to fill in these node addresses in the Bitcoind.conf configuration file? Or fill in many node addresses in my code? Thank you very much, I am a enthusiast who just participated in learning blockchain
ranochigo
Legendary
*
Offline Offline

Activity: 2982
Merit: 4193



View Profile
December 14, 2020, 09:30:18 AM
Merited by ABCbits (1)
 #9

You mentioned connecting dozens of nodes here. Do I need to fill in these node addresses in the Bitcoind.conf configuration file? Or fill in many node addresses in my code? Thank you very much, I am a enthusiast who just participated in learning blockchain
In Bitcoin.conf file, you should be able to add as many nodes as you want but there will be a restriction on the number of nodes your client will connect to. You can try opening port 8333 to allow other nodes to connect to you, the node count should increase gradually as your IP address gets relayed and propagated through addr messages within nodes.

Generally, the transactions that are non-standard, ie. valid transactions but are do not pass the standardness check[1] enforced by the nodes, will not be accepted by your node. They could still be accepted into a block however. Those are the kinds of transactions that you'll probably never see in the mempool, but only in blocks mined by miners.

By attempting to connect to as many node as possible, you could allow your bitcoind to potentially have more sources for the transactions to be relayed to you, deceasing the chances of certain transactions having low propagation (Txes with low relay fee, etc) but are otherwise standard and valid.

[1] https://github.com/bitcoin/bitcoin/blob/master/src/consensus/validation.h#L21

█████████████████████████
████▐██▄█████████████████
████▐██████▄▄▄███████████
████▐████▄█████▄▄████████
████▐█████▀▀▀▀▀███▄██████
████▐███▀████████████████
████▐█████████▄█████▌████
████▐██▌█████▀██████▌████
████▐██████████▀████▌████
█████▀███▄█████▄███▀█████
███████▀█████████▀███████
██████████▀███▀██████████
█████████████████████████
.
BC.GAME
▄▄░░░▄▀▀▄████████
▄▄▄
██████████████
█████░░▄▄▄▄████████
▄▄▄▄▄▄▄▄▄██▄██████▄▄▄▄████
▄███▄█▄▄██████████▄████▄████
███████████████████████████▀███
▀████▄██▄██▄░░░░▄████████████
▀▀▀█████▄▄▄███████████▀██
███████████████████▀██
███████████████████▄██
▄███████████████████▄██
█████████████████████▀██
██████████████████████▄
.
..CASINO....SPORTS....RACING..
█░░░░░░█░░░░░░█
▀███▀░░▀███▀░░▀███▀
▀░▀░░░░▀░▀░░░░▀░▀
░░░░░░░░░░░░
▀██████████
░░░░░███░░░░
░░█░░░███▄█░░░
░░██▌░░███░▀░░██▌
░█░██░░███░░░█░██
░█▀▀▀█▌░███░░█▀▀▀█▌
▄█▄░░░██▄███▄█▄░░▄██▄
▄███▄
░░░░▀██▄▀


▄▄████▄▄
▄███▀▀███▄
██████████
▀███▄░▄██▀
▄▄████▄▄░▀█▀▄██▀▄▄████▄▄
▄███▀▀▀████▄▄██▀▄███▀▀███▄
███████▄▄▀▀████▄▄▀▀███████
▀███▄▄███▀░░░▀▀████▄▄▄███▀
▀▀████▀▀████████▀▀████▀▀
linuxqq (OP)
Jr. Member
*
Offline Offline

Activity: 34
Merit: 6


View Profile
December 14, 2020, 09:45:32 AM
 #10

You mentioned connecting dozens of nodes here. Do I need to fill in these node addresses in the Bitcoind.conf configuration file? Or fill in many node addresses in my code? Thank you very much, I am a enthusiast who just participated in learning blockchain
In Bitcoin.conf file, you should be able to add as many nodes as you want but there will be a restriction on the number of nodes your client will connect to. You can try opening port 8333 to allow other nodes to connect to you, the node count should increase gradually as your IP address gets relayed and propagated through addr messages within nodes.

Generally, the transactions that are non-standard, ie. valid transactions but are do not pass the standardness check[1] enforced by the nodes, will not be accepted by your node. They could still be accepted into a block however. Those are the kinds of transactions that you'll probably never see in the mempool, but only in blocks mined by miners.

By attempting to connect to as many node as possible, you could allow your bitcoind to potentially have more sources for the transactions to be relayed to you, deceasing the chances of certain transactions having low propagation (Txes with low relay fee, etc) but are otherwise standard and valid.

[1] https://github.com/bitcoin/bitcoin/blob/master/src/consensus/validation.h#L21

Thank you very much
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!