Skip to content

sirpillage/stellar-downloader

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stellar Downloader

Download trades and payment data from the Stellar blockchain network as a CSV file for accounting purposes.

Table of Contents

How it Works

Stellar Downloader uses Node and the Stellar Javascript SDK to pull payments and effects from Horizon.

It uses the /effects endpoint to get all payments and trades, ordering them by the paging_token in ascending order.

It uses the /payments endpoint to fill in data that is unavailable from the /effects endpoint such as the initial funder of an account or the counterparty of a payment.

Everytime it encounters a new trustline, it adds it to the list of headers and prints out the headers to stdout. From that point on, it always prints the cumulative balance of that asset in a new column on the right. In this manner, you will always have the latest balance for all assets on each row in CSV format.

Note: This script will not include any fees paid by the account, and as such, balances for XLM may be slightly off.

Output

This is what the script outputs:

  • trades and payments to stdout in CSV format.
  • column headers to stdout in CSV format. It prefixes headers with - so it can be removed using grep in the bash script. See the How to Run (Advanced) section for more details.
  • new accounts to stderr.

Note: This script will not include any path_payments made by the account at this point in time, although you can easily update the script to include this.

Note: This script will not include any fees paid by the account, and as such, balances for XLM may be slightly off.

Getting Started

Set Up

  1. You can clone the repo by running the following command:
    git clone git@github.com:nikhilsaraf/stellar-downloader.git
  2. Make sure you install Node.js
  3. Set up the Stellar Javascript SDK by installing it from npm:
    npm install --save stellar-sdk

How to Run (Basic)

Run the trades.js script for your account (replace GA... with your account):

node trades.js GA...

You can redirect stdout and stderr to files as desired. See the How to Run (Advanced) section below for more details.

How to Run (Advanced)

This process will allow you to spider an account, i.e. you can pull data from the initial account as well as all accounts created by the initial account. This will create N files, 1 per account. Note the script will modify your input file, so be careful if you run it more than once.

  1. create a new file called newAccounts.txt with the initial account you want to start with on the first line as follows (replace GA... with your account):
    new account: GA....
    
  2. run the bash script runForAccounts.sh as follows:
    ./runForAccounts.sh newAccounts.txt

Questions

Please feel free to ask questions by opening an issue or to contribute to the code using a Pull Request.

About

Download data from the Stellar network

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 86.7%
  • Shell 13.3%