Task: Bitcoin Trackdown

Tags

Script, Blockchain, API, Internet Access

Description

Recently a horrible hack event happens with Binance the exchange. Over 7000 BTC was hacked and transferred away. As a bitcoin enthusiast, you're super interested to find out where those money went.

Given a BTC address source. Can you write a program to find out a list of addresses, that historically, there's BTC coming out of source and going into these addresses. Sort them by the total amount of BTC, and only output top 10, and their corresponding outgoing number of BTC value in satoshi.

Specification

Given a BTC address, find all the outgoing transactions from that address. Count the number of BTCs going into those output address, and sort them by the total number of BTCs. Output top 10 with the BTC amount in satoshi, as a JSON array.

Note that, you don't have to worry about any of the following:

  • Time fluctuation: A transaction happens while the test is running
  • Calculate everything in satoshi, to avoid floating point errors.
  • Each test case will query at most 10 addresses.
  • Non-standard transactions: Multi-sig and other weird cases. Only P2PKH (starting with 1) and P2SH (starting with 3) addresses will be tested.
  • Only consider transactions that has a single input of the querying address.
  • Each address will have at most 100 transactions.

Example

When running your program, we'll feed in one BTC address per line, and the program should output the top 10 as a JSON array, in a single line.

Note, we provide the input through stdin and not args. You'll need to loop through stdin for multiple inputs.

$ ./your-prog
3NK9pxgHedLTsrgq1Wkwvx61h9hPt8VrNP
[["3Ercgcpbyyrxy7TAVzhoPbeFAGN9tJ8Q4x", 998156], ["3JCVow7NNhAfMFEGLSaEKEUqJPA2AMV2Gf", 12000]]
157Bb1npdTvuzth7e4z6mBqzPANKd7QZHB
[]

Let us know if this example doesn't work anymore, since a lot is happening in the BTC world!

Instructions
Get started
My Submissions

Submit to see your result!

Leaderboard

Nobody here yet, solve it now to get on the board!