Bitcoin Forum
June 27, 2024, 04:28:52 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: retrieve blockchain.info network propagation percentage programmatically  (Read 491 times)
Time_DJ (OP)
Newbie
*
Offline Offline

Activity: 11
Merit: 0


View Profile
May 05, 2015, 08:01:55 AM
Last edit: May 05, 2015, 08:58:03 AM by Time_DJ
 #1

Hello im learning php here and i have a question about blockchain.info's wallet api.

so from my understanding network propagation is the amount of nodes a transaction hits before being confirmed.


Im using blockchain.info's wallet api and when a transaction has not had a confirmation yet, blockchain.info shows network propagation in the form of a percentage for any given unconfirmed transaction on their website.


How can i programmatically get this percentage for an unconfirmed transaction using php?..
 
Thanks in advance,
Time_Dj
virtualx
Hero Member
*****
Offline Offline

Activity: 672
Merit: 507


LOTEO


View Profile
May 05, 2015, 08:19:14 AM
 #2

Network propagation is the number of nodes (computers running a bitcoin client) that have heard about your transaction.
Not only transactions propagate in a network. Routing messages propagate too  Smiley

Propagation needs to happen before a confirmation can occur, if no miner knows about the transaction it cannot be confirmed.

To get the unconfirmed transactions:  https://blockchain.info/en/unconfirmed-transactions?format=json
Use a HTTP get to put the data into a variable ($data).  Then parse it with a JSON parser. Count the number of elements ($unconfirmedTotal). You can then calculate the percentage.
 
Do you want the percentage of uncofirmed transactions relative to all transactions or compared to recently confirmed?

...loteo...
DIGITAL ERA LOTTERY


r

▄▄███████████▄▄
▄███████████████████▄
▄███████████████████████▄
▄██████████████████████████▄
▄██  ███████▌ ▐██████████████▄
▐██▌ ▐█▀  ▀█    ▐█▀   ▀██▀  ▀██▌
▐██  █▌ █▌ ██  ██▌ ██▌ █▌ █▌ ██▌
▐█▌ ▐█ ▐█ ▐█▌ ▐██  ▄▄▄██ ▐█ ▐██▌
▐█  ██▄  ▄██    █▄    ██▄  ▄███▌
▀████████████████████████████▀
▀██████████████████████████▀
▀███████████████████████▀
▀███████████████████▀
▀▀███████████▀▀
r

RPLAY NOWR
BE A MOON VISITOR!
[/center]
Time_DJ (OP)
Newbie
*
Offline Offline

Activity: 11
Merit: 0


View Profile
May 05, 2015, 10:11:57 AM
Last edit: May 06, 2015, 08:12:05 AM by Time_DJ
 #3

Thanks for the reply & thanks for the explanation! Any chance you can give me an example?

Basically im following a tutorial online where first we generate a fresh bitcoin address that users can send btc to on page load using the wallet api. (code example below)  
That said i was trying to get the network propagation percentage for the "latest transaction" on the new address that just got generated.. ( $parseAddy )

Code:
// Generate new address 
$newAddy = json_decode(file_get_contents("https://blockchain.info/merchant/$ID/new_address?password=$PW"), true);

$parseAddy = $newAddy[address];

 

What i really want to do is determine if the network propagation percentage for the latest transaction on that address is low or high!


I was told when waiting for a confirmation, if the network propagation percentage for that transaction is high like 99%  then the chance of a double spend is really low and so it would be ok to accept the payment with a low confirmation number even 0 confirmations. ( items worth $20-$100)


That said im trying to put something together that checks the balance of the freshly created address and then checks the network propagation percentage of the latest transaction on that address and if it has a high percentage say greater than 97% than i want the transaction to immediately complete and forward the user to the product.

If the network propagation percentage for the latest transaction in that address is low, like 10% then i want the script to keep waiting for 2-3 confirmations instead of completing the transaction and forwarding the user.

 
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!