All Projects → square → Beancounter

square / Beancounter

Licence: apache-2.0
Utility to audit the balance of Hierarchical Deterministic (HD) wallets. Supports multisig + segwit wallets.

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to Beancounter

Peatiocryptoexchange
An open-source Crypto-Currency exchange. Peatio v3.0 Coming Soon !
Stars: ✭ 141 (+29.36%)
Mutual labels:  bitcoin, cryptocurrency, wallet, crypto
Multicurrencywallet
Bitcoin, Ethereum, ERC20 crypto wallets with Atomic Swap exchange. Release announce: https://twitter.com/SwapOnlineTeam/status/1321844352369500160
Stars: ✭ 136 (+24.77%)
Mutual labels:  bitcoin, cryptocurrency, wallet, crypto
Etherwalletkit
Ethereum Wallet Toolkit for iOS - You can implement an Ethereum wallet without a server and blockchain knowledge.
Stars: ✭ 96 (-11.93%)
Mutual labels:  cryptocurrency, wallet, crypto
Cryptex
Gemini, GDAX, Bitfinex, Poloniex, Binance, Kraken, Cryptopia, Koinex, BitGrail and CoinMarketCap cryptocurrency exchange API clients in Swift / iOS SDK. Check prices and account balances using Sample iOS app.
Stars: ✭ 51 (-53.21%)
Mutual labels:  bitcoin, cryptocurrency, crypto
Bitcoinaddress
Bitcoin Wallet Address Generator
Stars: ✭ 52 (-52.29%)
Mutual labels:  bitcoin, cryptocurrency, wallet
Currencyviewer
Short python framework that dynamically displays and converts the cryptocurrencies in your Kraken wallet into equivalents fiat money.
Stars: ✭ 13 (-88.07%)
Mutual labels:  bitcoin, cryptocurrency, wallet
Siis
Trading bot including terminal, for crypto and traditionals markets. Assisted or fully automated strategy.
Stars: ✭ 45 (-58.72%)
Mutual labels:  bitcoin, cryptocurrency, crypto
Esteem Surfer
Ecency desktop formerly known as Esteem Surfer - reimagined desktop social wallet, contribute and get rewarded (for Windows, Mac, Linux)
Stars: ✭ 100 (-8.26%)
Mutual labels:  cryptocurrency, wallet, crypto
Hth Legacy Old Chain
Old Binaries and source code for HTH. Deprecated.
Stars: ✭ 22 (-79.82%)
Mutual labels:  bitcoin, cryptocurrency, crypto
Airgap Wallet
The AirGap Wallet is installed on an everyday smartphone. This app has only access to public information.
Stars: ✭ 78 (-28.44%)
Mutual labels:  bitcoin, cryptocurrency, wallet
The Journal Of Blockchain
区块链自媒体、专注区块链技术学习和实践、IPFS/Filecoin、Bitcoin、Ethereum、EOS、Cosmos、区块链、白皮书、Coinmarketcap、Coindesk、Safe Network、Telegram、Docker、社会治理、经济激励
Stars: ✭ 63 (-42.2%)
Mutual labels:  bitcoin, cryptocurrency, crypto
Cated
CATEd - Cryptocurrency Analytics and Trading Engine for Django
Stars: ✭ 84 (-22.94%)
Mutual labels:  bitcoin, cryptocurrency, wallet
Lightning App
An easy-to-use cross-platform Lightning wallet
Stars: ✭ 872 (+700%)
Mutual labels:  bitcoin, cryptocurrency, wallet
Crypto Supplies
Cryptocurrency circulating, maximum and total supplies
Stars: ✭ 26 (-76.15%)
Mutual labels:  bitcoin, cryptocurrency, crypto
Paymint
The Paymint Wallet is a secure and user friendly Bitcoin wallet
Stars: ✭ 48 (-55.96%)
Mutual labels:  bitcoin, cryptocurrency, wallet
Aeternity
æternity: solving scalability problems by making sense of state-channels
Stars: ✭ 923 (+746.79%)
Mutual labels:  bitcoin, cryptocurrency, crypto
Jesse
An advanced crypto trading bot written in Python
Stars: ✭ 1,038 (+852.29%)
Mutual labels:  bitcoin, cryptocurrency, crypto
Ccxt.net
CCXT.NET – CryptoCurrency eXchange Trading Library for .NET
Stars: ✭ 89 (-18.35%)
Mutual labels:  bitcoin, cryptocurrency, crypto
Awesome Blockchain
Curated list of blockchain services and exchanges 🔥🏦🔥🏦🔥🏦🔥
Stars: ✭ 604 (+454.13%)
Mutual labels:  bitcoin, cryptocurrency, crypto
Wallet Core
Cross-platform, cross-blockchain wallet library.
Stars: ✭ 657 (+502.75%)
Mutual labels:  bitcoin, cryptocurrency, crypto

Beancounter

license travis coverage report

Beancounter is a command line utility to audit the balance of Hierarchical Deterministic (HD) wallets at a given point in time (or block height). The tool is designed to scale and work for wallets with a large number of addresses or a large number of transactions, with support ranging from simple watch wallets to more complicated multisig + segwit. If you're curious, here's why we decided to write Beancounter in the first place.

Beancounter currently supports two types of backends to query the blockchain:

  1. Electrum public servers. When using these servers, Beancounter behaves in a similar fashion to an Electrum client wallet. The servers are queried for transaction history for specific addresses. Using Electrum servers is easiest but requires trusting public servers to return accurate information. There is also potential privacy exposure.

  2. Private Btcd node. Btcd is a Bitcoin full node which implements transaction indexes. Setting up a Btcd node can take some time (the initial sync takes ~7 days) and requires maintaining the node up-to-date. The benefit is however a higher level of guarantee that the transaction history is accurate.

logo

Getting Started

Installing

Requires Go 1.11 or higher.

$ git clone https://github.com/square/beancounter/
$ cd beancounter
$ go build -mod=vendor

Deriving the child pubkey

Let's imagine we want to track the balance of tpubD8L6UhrL8ML9... and the derivation being used is m/1'/1234/change/index.

We need to manually perform the 1234 derivation:

$ ./beancounter keytree 1234
Enter pubkey #1 out of #1:
tpubD8L6UhrL8ML9Ao47k4pmdvUoiA6QUJVzrJ9BXLgU9idRKnvdRFGgjcxmVxojWGvCcjMi6QWCp8uMpCwWdSFRDNJ7utizxLy27sVWXQT4Jz7
Child pubkey #1: tpubDBrCAXucLxvjC9n9nZGGcYS8pk4X1N97YJmUgdDSwG2p36gbSqeRuytHYCHe2dHxLsV2EchX9ePaFdRwp7cNLrSpnr3PsoPLUQqbvLBDWvh

We can then use tpubDBrCAXucLxvj... to compute the balance.

Compute balance of a HD wallet (using Electrum)

$ ./beancounter compute-balance --type multisig --block-height 1438791
Enter pubkey #1 out of #1:
tpubDBrCAXucLxvjC9n9nZGGcYS8pk4X1N97YJmUgdDSwG2p36gbSqeRuytHYCHe2dHxLsV2EchX9ePaFdRwp7cNLrSpnr3PsoPLUQqbvLBDWvh
...
Balance: 267893477

Compute balance of a single address (using Electrum)

$ ./beancounter compute-balance --type single-address --lookahead 1 --block-height 1438791
Enter single address:
mzoeuyGqMudyvKbkNx5dtNBNN59oKEAsPn
...
Balance: 111168038

Compute balance of a HD wallet (using Btcd)

https://github.com/btcsuite/btcd contains information on how to setup a node.

Beancounter requires addrindex=1, txindex=1, and notls=1. If your node is on a remote server, we recommend tunneling the RPC traffic over ssh or some other secure tunnel.

rpcuser=mia
rpcpass=ilovebrownies
rpclisten=127.0.0.1:8334
notls=1

blocksonly=1
addrindex=1
txindex=1

Once the Btcd is up and running, you can do:

$ ./beancounter compute-balance --type multisig --block-height 1438791 --backend btcd --addr localhost:8334 --rpcuser mia --rpcpass ilovebrownies
Enter pubkey #1 out of #1:
tpubDBrCAXucLxvjC9n9nZGGcYS8pk4X1N97YJmUgdDSwG2p36gbSqeRuytHYCHe2dHxLsV2EchX9ePaFdRwp7cNLrSpnr3PsoPLUQqbvLBDWvh
...
Balance: 267893477

Details

Beancounter is implemented in Go. We picked Go because we wanted an easy build and distribution process. We appreciate the ability to cross-compile and distribute static binaries which don't have external dependencies.

We use the following process to determine a deterministic wallet's balance at a given block height:

  1. Derive external (receive) and internal (change) addresses.
  2. For each address, query the backend for a list of transactions. We keep deriving additional addresses until we find a large number of unused addresses.
  3. Prune the transaction list to remove transactions newer than the block height.
  4. For each transaction, query the backend for the raw transaction.
  5. For each transaction, track whether the output belongs to the wallet and whether it got spent.
  6. Iterate over the transactions and compute the final balance.

Contributing

We appreciate any pull request which fixes bugs or adds features!

If you need ideas on how to contribute, we would enjoy a 3rd backend (Bitcoin-core based, processing each block by streaming the entire blockchain) as well as additional wallet types (e.g. multisig non-segwit).

Additional unittests and improvements to comments/docs are also always welcome.

License

Copyright 2018 Square, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].