retrieve all the transaction between two addresses

1

I've used this query to try to get all the transaction between two addresses:

https://blockchain.info/multiaddr?active=1EipJdYVJbqsTSQhj1icK424AkMbyjvgBm|1LWwLvKWbcpiZYqCcwfuQ3gjjNJkxftmEJ

but the thing is- according to my wallet there are many more transactions that aren't appearing in the json result here.

Why is that?

How can I see actually all of the transactions?

I though maybe blockexplorer would be better than blockchain.info, but actually- not so.

They have it as this:

https://blockexplorer.com/api/addrs/1EipJdYVJbqsTSQhj1icK424AkMbyjvgBm,1LWwLvKWbcpiZYqCcwfuQ3gjjNJkxftmEJ/txs?from=0&to=50

perhaps it would be better to just query by txid?

smatthewenglish

Posted 2016-12-13T14:23:32.813

Reputation: 1 063

When you say "all the transactions between two addresses" do you mean you only want transactions where both addresses were involved, or do you just want all transactions from both addresses?m1xolyd1an 2016-12-13T16:56:49.607

the ones between then, but- also those that are not just bi-directional, but that also include maybe like- 1 to many others as well- but- at least those twosmatthewenglish 2016-12-13T20:16:02.450

Answers

1

I don't believe you can do this with just a single API call. I'd return all the transactions from one of the addresses, and cycle through all the inputs and outputs and if they match the other address then show the tx data.

Not sure which language you're using but the logic should be the same.

<?php
$addr1 = "1EipJdYVJbqsTSQhj1icK424AkMbyjvgBm";
$addr2 = "1LWwLvKWbcpiZYqCcwfuQ3gjjNJkxftmEJ";

$url = "https://blockchain.info/address/".$addr1."?format=json";
$fgc = json_decode(file_get_contents($url), true);

//num of txs
$txs = count($fgc["txs"]);

//loop through all txs
for($i=0;$i<$txs;$i++){
    //check all inputs & outputs for the other address
    //inputs
    $numinputs = count($fgc["txs"][$i]["inputs"]);
    for($ii=0;$ii<$numinputs;$ii++){
        if($fgc["txs"][$i]["inputs"][$ii]["prev_out"]["addr"] == $addr2){
            //found a corresponding tx
            print_r($fgc["txs"][$i]);
        }
    }//end inputs loop

    $numoutputs = count($fgc["txs"][$i]["out"]);
    for($iii=0;$iii<$numoutputs;$iii++){
        if($fgc["txs"][$i]["out"][$iii]["addr"] == $addr2){
            //found a corresponding tx
            print_r($fgc["txs"][$i]);
        }
    }//end outputs loop
}

?>

http://phpfiddle.org/main/code/8imw-ardy

m1xolyd1an

Posted 2016-12-13T14:23:32.813

Reputation: 3 356

why is it so that this is not an easy thing to query?smatthewenglish 2016-12-14T09:50:50.877

0

Scott Lewis

Posted 2016-12-13T14:23:32.813

Reputation: 1