-
Notifications
You must be signed in to change notification settings - Fork 48
Blockchain Operations
Gets the amount of currency currently assiciated with a cryptocurrency address.
examples:
$ moneywagon address-balance --crypto=doge --address=D8ZXs3JDdLuyRjG3wDtRQE2PMT4YQWELfZ
99405.6048377
Also you can include a --verbose
flag to get more output:
$ moneywagon address-balance vtc --address=Va3LcDhwrcwGtG366jeP6EJzWnKT4yMDxs --verbose
* Trying: <Service: ThisIsVTC (0 in cache)>
URL: http://explorer.thisisvtc.com/api/addr/Va3LcDhwrcwGtG366jeP6EJzWnKT4yMDxs/balance
99.5
An additional parameter, --paranoid=n
can be added to crosscheck multiple services.
The number n
corresponds to how many services to check:
$ moneywagon address-balance btc --address=1HWpyFJ7N6rvFkq3ZCMiFnqM6hviNFmG5X --paranoid=5 --verbose
* Trying: <Service: Toshi (0 in cache)>
URL: https://bitcoin.toshi.io/api/v0/addresses/1HWpyFJ7N6rvFkq3ZCMiFnqM6hviNFmG5X
* Trying: <Service: BlockCypher (0 in cache)>
URL: http://api.blockcypher.com/v1/btc/main/addrs/1HWpyFJ7N6rvFkq3ZCMiFnqM6hviNFmG5X
* Trying: <Service: Blockr (0 in cache)>
URL: http://btc.blockr.io/api/v1/address/info/1HWpyFJ7N6rvFkq3ZCMiFnqM6hviNFmG5X
* Trying: <Service: BlockStrap (0 in cache)>
URL: http://api.blockstrap.com/v0/btc/address/id/1HWpyFJ7N6rvFkq3ZCMiFnqM6hviNFmG5X
* Trying: <Service: ChainSo (0 in cache)>
URL: https://chain.so/api/v2/get_address_balance/btc/1HWpyFJ7N6rvFkq3ZCMiFnqM6hviNFmG5X/1
0.00132132
$ moneywagon single-transaction ppc 6dddc4deb0806d987844b429e73b20ce5f0355407cce220130b5eac8fa13970e | python -mjson.tool
{
"block_number": 117284,
"confirmations": 115918,
"fee": 0.02,
"inputs": [
{
"address": "PJyL5yc5Zk2EDC2p4Tu5fAfU5NP59hDn88",
"amount": 1.001288
},
{
"address": "PJopCzzaHC1Kb1CV7iDLs1o4gXpssG1czj",
"amount": 0.010604
},
{
"address": "PGBnz34C79DahgY5pEN5zdSwkkeEZBH7n2",
"amount": 0.010862
},
{
"address": "PGXvsTrer2neCnhwCk9FwMJxHTcfznoYKk",
"amount": 100.01
},
{
"address": "PJyL5yc5Zk2EDC2p4Tu5fAfU5NP59hDn88",
"amount": 1.137068
},
{
"address": "PJyL5yc5Zk2EDC2p4Tu5fAfU5NP59hDn88",
"amount": 1.056389
},
{
"address": "PDsudZAz7F7XvB6x5h5oyoNT35uLRXuwrf",
"amount": 0.78484
}
],
"outputs": [
{
"address": "PEWcuiycc1vaSqAVBC5bpGq2mMF7Gs4ixp",
"amount": 0.011051
},
{
"address": "PVoei4A3TozCSK8W9VvS55fABdTZ1BCwfj",
"amount": 103.98
}
],
"time": "2014-06-16T00:07:10+00:00",
"total_in": 104.01105100000001,
"total_out": 103.991051,
"txid": "6dddc4deb0806d987844b429e73b20ce5f0355407cce220130b5eac8fa13970e"
}
Gets the block, according to either block number, block hash or get by latest.
example:
$ moneywagon get-block btc --latest --paranoid=2 | python -m json.tool
{
"block_number": 368900,
"confirmations": 1,
"hash": "0000000000000000043ab9d01e2e88ff460b6205b43cf3508ddeb8461bddc2fd",
"merkle_root": "7205cd649ffe5645e1841ef2ba19d7c48166dc9a6f15584aa24d4af61236d96e",
"mining_difficulty": 52278304845.59181,
"next_hash": null,
"previous_hash": "00000000000000000f3a1d9508d69a1310a1ed41e18025f143f28c8ea5f5575e",
"sent_value": 8762.56646775,
"size": 219868,
"time": "2015-08-08T05:55:01+00:00",
"total_fees": 0.07663532,
"txids": [
"da8812c9c7e02d4c159bc2c9978aa50dd295d88fe14f10e07101c729e771510e",
"ce6c456ecf46be306eb65eb9ac8210466d6aacd0e44b8dfdeaf100d9aaadca47",
...
]
}
$ moneywagon get-block ltc --block_number=242 | python -m json.tool
{
"block_number": 242,
"confirmations": 829724,
"hash": "3849a1aabc09d147d815652cadee10b55f8eddf63efe4174479dba7e74d76cf1",
"merkle_root": "30a914ec415904b0dac0cf9bf5eed275b721cbb87a757878bc6d425817c52027",
"mining_difficulty": 0.00024414,
"next_hash": "1f427c34e3d98d7d0eb205be0881ea15d49c5e41f3d783e345f30747d2baad3b",
"previous_hash": "a6af6882076ece122753d12c134815f33b2b3f3d9e8feeeb5529f6ec5ef3b31c",
"sent_value": 50.0,
"size": 215,
"time": "2011-10-13T03:13:40+00:00",
"total_fees": 0.0,
"txids": [
"da8812c9c7e02d4c159bc2c9978aa50dd295d88fe14f10e07101c729e771510e",
"ce6c456ecf46be306eb65eb9ac8210466d6aacd0e44b8dfdeaf100d9aaadca47",
...
]
}
Send all funds associated with private_key
and send them to to_address
.
Optionally specify what fee you would like to include. Can either be an integer
in satoshis, or the string 'optimal'. Returned is the txid of the broadcasted
transaction.
Use --password
if your private key is encoded with a BIP38 password.
moneywagon moneywagon sweep btc 812b... 1Coq3qrShpWQNZ7yGCREo6EqUCdem4EdtJ --fee=optimal --verbose
['02491bdced5e48734de7c922547f1e73b4706d3747143ed01934d75313161c42']
Gets a list of all transactions sent and received by the passed in cryptocurrency address. The resulting output is always valid json. The most recent transaction is always at the top.
$ moneywagon historical-transactions doge D8ZXs3JDdLuyRjG3wDtRQE2PMT4YQWELfZ | python -m json.tool
[
{
"amount": 66.72788462,
"confirmations": 248634,
"date": "2015-02-07T18:04:05+00:00",
"txid": "a7cfe62ad255cb1e77762ab196455eae974fb9010023f60761fc8a25b1a9f8ec"
},
{
"amount": 67.96625,
"confirmations": 256753,
"date": "2015-02-01T19:36:39+00:00",
"txid": "fb371d55ce172ee015e110fa7896c8920af64aa3befe01b2596b99bbff35e5f7"
},
{
"amount": 68.02740385,
"confirmations": 256753,
"date": "2015-02-01T19:36:39+00:00",
"txid": "a04454ed38f9a587cc6c6d4730758fe38c60aca8153f2b0890b9163baf343f49"
},
{
"amount": 68.01211538,
"confirmations": 256753,
"date": "2015-02-01T19:36:39+00:00",
"txid": "7999040a76978d32c7dae5acbbccd1e899027595dba172b7458d9763b0cb3855"
},
{
"amount": 69.17061567,
"confirmations": 274609,
"date": "2015-01-19T18:39:16+00:00",
"txid": "ecd6a0c21873d307639be35d029347583a645d0ce0a924e75524b26b27904dd1"
},
{
"amount": 70.70056818,
"confirmations": 275074,
"date": "2015-01-19T10:30:05+00:00",
"txid": "3fe38e89f25c9fb424970ae8c763064adaa15af357ecf49602f73e5912845f27"
},
{
"amount": 98995.0,
"confirmations": 561926,
"date": "2014-06-15T23:48:44+00:00",
"txid": "b6bd31a9d4db7a6d54a64086a0a51432336fb18338bece3f8382faa79728fbfc"
}
]
This command also supports the --verbose
and --paranoid=n
flags (see above).
Get the fiat total of a group of cryptocurrency addresses from a "csv wallet" file.
The --async
option will do all the price and blockchain fetches asynchronously
so the operation finishes much faster. The --collapse
option will sum all balances
of the same currency to the same line on output.
example:
$ cat ~/wallets.csv
doge,D8ZXs3JDdLuyRjG3wDtRQE2PMT4YQWELfZ
btc,1HWpyFJ7N6rvFkq3ZCMiFnqM6hviNFmG5X
$ moneywagon wallet-balance ~/wallets.csv usd
doge (16.43 USD) == 99405.6048377 x 0.00016531 (cryptonator)
btc (1.06 USD) == 0.00379546 x 279.58 (bitstamp)
Total amount of all crypto: 17.49 USD
Some services have a web interface for viewing blockchain data in a web browser. To get a list of all block explorer urls, use the following API:
$ moneywagon explorer-urls btc --address=1HWpyFJ7N6rvFkq3ZCMiFnqM6hviNFmG5X
http://blockr.io/address/info/1HWpyFJ7N6rvFkq3ZCMiFnqM6hviNFmG5X https://chain.so/address/btc/1HWpyFJ7N6rvFkq3ZCMiFnqM6hviNFmG5X https://www.biteasy.com/blockchain/addresses/1HWpyFJ7N6rvFkq3ZCMiFnqM6hviNFmG5X https://www.smartbit.com.au/address/1HWpyFJ7N6rvFkq3ZCMiFnqM6hviNFmG5X https://blockchain.info/address/1HWpyFJ7N6rvFkq3ZCMiFnqM6hviNFmG5X https://insight.bitpay.com/address/1HWpyFJ7N6rvFkq3ZCMiFnqM6hviNFmG5X
You can pipe these URLs directly into a browser:
$ moneywagon explorer-urls btc --address=1HWpyFJ7N6rvFkq3ZCMiFnqM6hviNFmG5X | xargs firefox -new-tab -url "$line"
Or through python:
>>> from moneywagon import get_explorer_url
>>> get_explorer_url('btc', address='1HWpyFJ7N6rvFkq3ZCMiFnqM6hviNFmG5X')
[
"http://blockr.io/address/info/1HWpyFJ7N6rvFkq3ZCMiFnqM6hviNFmG5X",
"https://chain.so/address/btc/1HWpyFJ7N6rvFkq3ZCMiFnqM6hviNFmG5X",
"https://www.biteasy.com/blockchain/addresses/1HWpyFJ7N6rvFkq3ZCMiFnqM6hviNFmG5X",
"https://www.smartbit.com.au/address/1HWpyFJ7N6rvFkq3ZCMiFnqM6hviNFmG5X",
"https://blockchain.info/address/1HWpyFJ7N6rvFkq3ZCMiFnqM6hviNFmG5X",
"https://insight.bitpay.com/address/1HWpyFJ7N6rvFkq3ZCMiFnqM6hviNFmG5X"
]