├── .gitignore ├── .travis.yml ├── COPYING ├── Changelog ├── README.md ├── dist-tools └── changelog.sh ├── doc ├── _sources │ ├── apireference.txt │ ├── examples.txt │ ├── gettingstarted.txt │ ├── index.txt │ ├── introduction.txt │ ├── usage.txt │ ├── vergerpc.config.txt │ ├── vergerpc.connection.txt │ ├── vergerpc.data.txt │ ├── vergerpc.exceptions.txt │ ├── vergerpc.txt │ └── vergerpc.util.txt ├── _static │ ├── ajax-loader.gif │ ├── basic.css │ ├── comment-bright.png │ ├── comment-close.png │ ├── comment.png │ ├── default.css │ ├── doctools.js │ ├── down-pressed.png │ ├── down.png │ ├── file.png │ ├── jquery.js │ ├── minus.png │ ├── plus.png │ ├── pygments.css │ ├── searchtools.js │ ├── sidebar.js │ ├── underscore.js │ ├── up-pressed.png │ ├── up.png │ └── websupport.js ├── apireference.html ├── examples.html ├── genindex.html ├── gettingstarted.html ├── index.html ├── introduction.html ├── objects.inv ├── py-modindex.html ├── search.html ├── searchindex.js ├── usage.html ├── vergerpc.config.html ├── vergerpc.connection.html ├── vergerpc.data.html ├── vergerpc.exceptions.html ├── vergerpc.html └── vergerpc.util.html ├── release_process.txt ├── setup.py ├── sphinx ├── Makefile ├── make.bat └── source │ ├── apireference.rst │ ├── conf.py │ ├── examples.rst │ ├── gettingstarted.rst │ ├── index.rst │ ├── introduction.rst │ ├── usage.rst │ ├── vergerpc.config.rst │ ├── vergerpc.connection.rst │ ├── vergerpc.data.rst │ ├── vergerpc.exceptions.rst │ ├── vergerpc.rst │ └── vergerpc.util.rst ├── src └── vergerpc │ ├── __init__.py │ ├── config.py │ ├── connection.py │ ├── data.py │ ├── exceptions.py │ ├── proxy.py │ └── util.py └── tests └── test.py /.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | *~ 3 | sphinx/build 4 | build 5 | dist 6 | src/verge_python.egg-info 7 | 8 | # IDE 9 | .idea 10 | out/ -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | python: 3 | - 2.7 4 | install: 5 | - if [[ $TRAVIS_PYTHON_VERSION < '2.7' ]]; then pip install -q --use-mirrors argparse; fi 6 | - python setup.py install -q 7 | script: python tests/test.py --envconfig 8 | notifications: 9 | irc: 10 | skip_join: true 11 | on_success: change 12 | on_failure: change 13 | channels: 14 | - irc.freenode.org#verge 15 | email: 16 | on_success: never 17 | on_failure: change 18 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | Copyright (c) 2010-2011 Bitcoin-Python developers 2 | Copyright (c) 2016 VERGE-Python developers 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in 12 | all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /Changelog: -------------------------------------------------------------------------------- 1 | 2014-03-02 17:55:05 -0600 Naveen Garg 2 | 3 | * add importprivkey method 4 | 5 | 2014-02-26 15:34:39 -0800 Peter Harrington 6 | 7 | * Update config.py 8 | 9 | 2014-01-28 19:58:26 +0100 Jean-Christophe Saad-Dupuy 10 | 11 | * updated changelog 12 | 13 | 2014-01-28 19:26:06 +0100 Jean-Christophe Saad-Dupuy 14 | 15 | * Version bump (tag: v0.1.2) 16 | 17 | 2014-01-28 11:31:13 -0600 benfbat 18 | 19 | * Update config.py 20 | 21 | 2014-01-27 23:08:33 +0100 Jean-Christophe Saad-Dupuy 22 | 23 | * Added support for loading verge.conf under windows 24 | 25 | 2014-01-26 23:00:57 +0100 jcsaaddupuy 26 | 27 | * Update README.rst 28 | 29 | 2014-01-26 23:06:44 +0100 Jean-Christophe Saad-Dupuy 30 | 31 | * markdown 32 | 33 | 2014-01-26 23:05:31 +0100 Jean-Christophe Saad-Dupuy 34 | 35 | * updated verge-qt connection instructions 36 | 37 | 2014-01-22 02:26:02 +0100 Jean-Christophe Saad-Dupuy 38 | 39 | * fixed markdown 40 | 41 | 2014-01-22 02:24:44 +0100 Jean-Christophe Saad-Dupuy 42 | 43 | * Added instruction for connection with verge-t 44 | 45 | 2014-01-21 18:51:36 +0100 Jean-Christophe Saad-Dupuy 46 | 47 | * Updated documentation link 48 | 49 | 2014-01-21 18:41:36 +0100 Jean-Christophe Saad-Dupuy 50 | 51 | * Updated changelog (tag: v0.1.1) 52 | 53 | 2014-01-21 18:41:09 +0100 Jean-Christophe Saad-Dupuy 54 | 55 | * updated version in documentation 56 | 57 | 2014-01-21 09:55:38 +0100 jcsaaddupuy 58 | 59 | * Update README.rst 60 | 61 | 2014-01-20 21:17:42 +0100 Jean-Christophe Saad-Dupuy 62 | 63 | * Removed pip instructions 64 | 65 | 2014-01-20 20:52:44 +0100 Jean-Christophe Saad-Dupuy 66 | 67 | * bump version 68 | 69 | 2014-01-20 20:52:18 +0100 Jean-Christophe Saad-Dupuy 70 | 71 | * Removed uggly print 72 | 73 | 2014-01-20 20:43:03 +0100 jcsaaddupuy 74 | 75 | * Update README.rst 76 | 77 | 2014-01-20 20:35:00 +0100 Jean-Christophe Saad-Dupuy 78 | 79 | * Updated tests 80 | 81 | 2014-01-20 20:31:26 +0100 Jean-Christophe Saad-Dupuy 82 | 83 | * Fixed markdown typo 84 | 85 | 2014-01-20 20:27:42 +0100 Jean-Christophe Saad-Dupuy 86 | 87 | * version reset (dogedev) 88 | 89 | 2014-01-20 20:26:08 +0100 Jean-Christophe Saad-Dupuy 90 | 91 | * Updated documentation 92 | 93 | 2014-01-20 19:58:38 +0100 Jean-Christophe Saad-Dupuy 94 | 95 | * changed default rpc port 96 | 97 | 2014-01-20 19:41:43 +0100 Jean-Christophe Saad-Dupuy 98 | 99 | * Migration bitcoin -> verge 100 | 101 | 2014-01-20 19:12:31 +0100 Jean-Christophe Saad-Dupuy 102 | 103 | * Changed bitcoin -> verge 104 | 105 | 2013-12-26 10:33:05 +0100 Wladimir J. van der Laan 106 | 107 | * fix documentation for sendtoaddress 108 | 109 | 2013-12-01 01:05:30 -0500 jon 110 | 111 | * Changed iterkeys() to keys() to make the code python3 compatible. The method keys() exists in both python 2 and 3 but keysiter() does not exist in python 3 since keys() by defaults returns an iterator. 112 | 113 | 2013-10-29 12:02:27 -0200 Leandro Boscariol 114 | 115 | * Made sure the code will raise InsufficientFunds or stop 116 | 117 | 2013-10-29 11:14:15 -0200 Leandro Boscariol 118 | 119 | * Work around to raise InsufficientFunds exception when needed 120 | 121 | 2013-09-27 15:49:55 +0200 Nicolas Kuttler 122 | 123 | * Add signmessage and verifymessage support 124 | 125 | 2013-09-27 14:29:31 +0200 Nicolas Kuttler 126 | 127 | * Add --noremote option 128 | 129 | 2013-09-27 13:08:17 +0200 Nicolas Kuttler 130 | 131 | * Make the test runs configurable 132 | 133 | 2013-09-11 18:16:59 +0200 mUniKeS 134 | 135 | * Add gettxout function 136 | 137 | 2013-09-02 19:46:04 +0200 Wladimir J. van der Laan 138 | 139 | * connect_to_local: check cfg for None 140 | 141 | 2013-05-30 17:59:03 +0200 Oliver Gasser 142 | 143 | * Add dumpprivkey() function. 144 | 145 | 2013-05-30 16:48:03 +0200 Oliver Gasser 146 | 147 | * Use items() instead of iteritems(). 148 | 149 | 2013-04-25 08:27:27 +0300 Aviad Reich 150 | 151 | * pep8 styling conventions 152 | 153 | 2013-04-24 22:39:24 -0600 Jeff Cook 154 | 155 | * Raise a TransportException on HTTP 403. 156 | 157 | 2013-04-24 22:39:06 -0600 Jeff Cook 158 | 159 | * Define TransportException exception class. 160 | 161 | 2013-04-22 14:05:03 +0400 Nikolay Belikov 162 | 163 | * + Added exception wrapper into AuthServiceProxy 164 | 165 | 2013-04-21 08:56:40 -0600 Jeff Cook 166 | 167 | * Inform user when 403 Forbidden is sent by bitcoind. 168 | 169 | 2013-04-21 13:07:59 +0300 Aviad Reich 170 | 171 | * add tests for connect_to_remote. SSL is Faulty 172 | 173 | 2013-04-17 12:49:35 +0400 Nikolay Belikov 174 | 175 | * ! Minor code style fixes 176 | 177 | 2013-04-16 18:46:46 +0400 Nikolay Belikov 178 | 179 | * Major overhaul of AuthServiceProxy 180 | 181 | 2013-04-14 21:35:38 -0500 Jason Kölker 182 | 183 | * Allow getbalance default account with minconf=0 184 | 185 | 2013-03-30 16:32:59 +0100 Wladimir J. van der Laan 186 | 187 | * bump version number to 0.3 (tag: v0.3) 188 | 189 | 2013-03-30 16:13:06 +0100 Aviad Reich 190 | 191 | * add keypoolrefill method 192 | 193 | 2013-03-20 00:33:59 +0200 Aviad Reich 194 | 195 | * raw transaction support added 196 | 197 | 2013-03-21 14:41:33 +0200 Aviad Reich 198 | 199 | * cherry pick to fix dont_raise so it only blocks the correct exceptions to return a boolean (origin/wallet_locking) 200 | 201 | 2013-03-29 10:15:09 +0300 Aviad Reich 202 | 203 | * ignore dist and python_egg 204 | 205 | 2013-03-23 19:08:46 +0000 Aviad Reich 206 | 207 | * deprecated getblocknumber - use getblockcount instead 208 | 209 | 2013-03-19 23:01:18 +0200 Aviad Reich 210 | 211 | * add wallet locking/unlocking support 212 | 213 | 2013-03-19 14:42:26 +0200 Aviad Reich 214 | 215 | * in listtransactions, iterate all accounts if account is None (origin/listtransactions) 216 | 217 | 2013-03-19 11:16:38 +0200 Aviad Reich 218 | 219 | * listaccounts can return a dictionary from account names to their balance if the param as_dict is True, update tests. (origin/listaccounts) 220 | 221 | 2013-03-19 09:44:20 +0200 Aviad Reich 222 | 223 | * add tests for listunspent and getmininginfo 224 | 225 | 2013-03-18 08:18:23 +0200 Aviad Reich 226 | 227 | * refactor __repr__ 228 | 229 | 2013-03-17 09:43:44 +0200 Aviad Reich 230 | 231 | * flake8 style conventions fixes 232 | 233 | 2013-03-18 00:13:42 +0200 Aviad Reich 234 | 235 | * add listunspent method 236 | 237 | 2013-03-17 23:46:44 +0200 Aviad Reich 238 | 239 | * add support for getmininginfo 240 | 241 | 2013-03-17 16:37:09 +0200 Aviad Reich 242 | 243 | * Issue #15: add from parameter to listtransactions 244 | 245 | 2013-03-15 22:14:10 +0100 David Barton 246 | 247 | * Fixed usage.rst broken links 248 | 249 | 2013-03-14 09:26:23 +0200 Aviad Reich 250 | 251 | * connect_to_local(): use default testnet port, when the config file has testnet=x 252 | 253 | 2013-02-10 17:35:14 +0100 Adrian 254 | 255 | * Add getrawtransaction method 256 | 257 | 2013-01-16 03:28:11 +0100 Thomas Steen Rasmussen 258 | 259 | * fix bug when rpc reply error is null in json 260 | 261 | 2012-12-12 00:14:34 +0100 Benoît HERVIER 262 | 263 | * There isn't always an error key in resp dict 264 | 265 | 2012-12-12 00:12:40 +0100 Benoît HERVIER 266 | 267 | * There isn't always an error key in resp dict 268 | 269 | 2012-12-12 00:10:41 +0100 Benoît HERVIER 270 | 271 | * Allow use of https 272 | 273 | 2012-12-12 00:09:38 +0100 Benoît HERVIER 274 | 275 | * Allow use of https 276 | 277 | 2012-10-29 16:46:18 +0100 Harald Schilly 278 | 279 | * assert that we are really in the testnet 280 | 281 | 2012-10-28 23:25:25 +0100 Harald Schilly 282 | 283 | * optionally allow to pass in the path to the bitcoin.conf file if it is at a non-standard path 284 | 285 | 2012-10-28 21:52:48 +0100 Harald Schilly 286 | 287 | * fixing tests 288 | 289 | 2012-10-23 02:57:40 +0200 Thomas Steen Rasmussen 290 | 291 | * Add support for the 'verifymessage' RPC command 292 | 293 | 2012-10-05 18:45:50 +0200 Wladimir J. van der Laan 294 | 295 | * Switch to jgarzik's jsonrpc implementation 296 | 297 | 2012-10-05 18:32:23 +0200 Wladimir J. van der Laan 298 | 299 | * Use RPC error codes from bitcoin core source 300 | 301 | 2012-07-15 12:07:53 +0400 Alexander Petrovich 302 | 303 | * Added listsinceblock, getblock, getblockhash 304 | 305 | 2011-09-04 15:17:44 +0200 Jure Vrscaj 306 | 307 | * Added sendmany command. 308 | 309 | 2011-08-24 17:28:14 +0000 toomanysecrets0 310 | 311 | * Edited README.rst via GitHub 312 | 313 | 2011-08-24 16:57:01 +0000 toomanysecrets0 314 | 315 | * under new management 316 | 317 | 2011-08-24 14:56:22 +0200 Wladimir J. van der Laan 318 | 319 | * update changelog 320 | 321 | 2011-08-24 14:53:53 +0200 Wladimir J. van der Laan 322 | 323 | * allow listtransactions() (default to '' account), add test for gettransaction 324 | 325 | 2011-08-24 11:20:43 +0200 Wladimir J. van der Laan 326 | 327 | * add license (MIT) (tag: v0.2) 328 | 329 | 2011-08-24 23:00:01 +0300 Wladimir J. van der Laan 330 | 331 | * mention cheeseshop page 332 | 333 | 2011-08-24 10:16:46 +0200 Wladimir J. van der Laan 334 | 335 | * link to new doc 336 | 337 | 2011-08-24 10:09:12 +0200 Wladimir J. van der Laan 338 | 339 | * rename package to 'bitcoinrpc' 340 | 341 | 2011-08-24 09:42:34 +0200 Wladimir J. van der Laan 342 | 343 | * add neccesary metadata 344 | 345 | 2011-08-24 09:22:43 +0200 Witchspace 346 | 347 | * Version bump 348 | 349 | 2011-08-20 09:00:18 +0400 Alexander Petrovich 350 | 351 | * Edited src/bitcoin/connection.py via GitHub 352 | 353 | 2011-07-04 13:52:17 +0100 Greg Hughes 354 | 355 | * Look in correct location for bitcoin.conf on Mac OS X 356 | 357 | 2011-06-06 15:48:41 +0200 Daniel Poelzleithner 358 | 359 | * add minconf to getbalance 360 | 361 | 2011-06-06 15:47:39 +0200 Daniel Poelzleithner 362 | 363 | * add listtransactions address filter 364 | 365 | 2011-06-06 15:46:30 +0200 Daniel Poelzleithner 366 | 367 | * fix bug in listreceivedbyaddress 368 | 369 | 2011-05-18 21:10:47 +0200 Witchspace 370 | 371 | * add TODOs 372 | 373 | 2011-05-18 21:10:11 +0200 Witchspace 374 | 375 | * add TODOs 376 | 377 | 2011-05-18 20:54:47 +0200 Witchspace 378 | 379 | * default rpcuser to '' 380 | 381 | 2011-05-16 17:43:04 -0300 Carlos da Costa 382 | 383 | * Ignore comments in the read_config_file. Ignore lines without '='. 384 | 385 | 2011-03-29 15:06:10 +0200 Jure Vrscaj 386 | 387 | * Added "listaccounts" command. 388 | 389 | 2010-12-20 18:29:30 -0800 Stephen 390 | 391 | * Add import BitcoinConnection to connect_to_remote() 392 | 393 | 2010-12-20 18:29:30 -0800 Stephen 394 | 395 | * Add import BitcoinConnection to connect_to_remote() 396 | 397 | 2010-12-11 20:13:00 +0100 Witchspace 398 | 399 | * initial commit (tag: v0.1.0) 400 | 401 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ``` 2 | ____ _________________________ ________ ___________ 3 | \ \ / /\_ _____/\______ \ / _____/ \_ _____/ 4 | \ Y / | __)_ | _// \ ___ | __)_ 5 | \ / | \ | | \\ \_\ \ | \ 2018 VERGE 6 | \___/ /_______ / |____|_ / \______ //_______ / 7 | \/ \/ \/ \/ 8 | ``` 9 | # A Python library for the VERGE Client 10 | It is a set of Python libraries that allows easy access to the 11 | VERGE peer-to-peer cryptocurrency client API. 12 | 13 | 14 | Installation instructions 15 | =========================== 16 | 17 | verge-python uses setuptools for the install script. There are no dependencies apart from Python itself. 18 | 19 | :: 20 | 21 | $ python setup.py build 22 | $ python setup.py install 23 | 24 | 25 | Pypi / Cheeseshop 26 | ================== 27 | 28 | It is possible to install the package through Pypi (cheeseshop), see http://pypi.python.org/pypi?:action=display&name=verge-python 29 | :: 30 | $ pip install verge-python 31 | # if not working, try 32 | $ pip install --pre verge-python 33 | 34 | Connection to verge-qt 35 | ========================= 36 | 37 | If you want to connect to verge-qt, add server=1 in your VERGE.conf 38 | :: 39 | 40 | rpcuser=vergerpcuser 41 | rpcpassword=A RANDOM GENERATED PASSWORD 42 | server=1 43 | 44 | TODO 45 | ====== 46 | These things still have to be added: 47 | 48 | - SSL support (including certificate verification) for managing remote verge daemons. 49 | 50 | verge-python is a fork of bitcoin-python : https://github.com/laanwj/bitcoin-python 51 | 52 | 53 | -------------------------------------------------------------------------------- /dist-tools/changelog.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | git --no-pager log --no-merges --format="%ai %aN %n%n%x09* %s%d%n" 3 | -------------------------------------------------------------------------------- /doc/_sources/apireference.txt: -------------------------------------------------------------------------------- 1 | ================= 2 | API reference 3 | ================= 4 | 5 | .. toctree:: 6 | :maxdepth: 2 7 | 8 | vergerpc.rst 9 | vergerpc.connection.rst 10 | vergerpc.exceptions.rst 11 | vergerpc.data.rst 12 | vergerpc.config.rst 13 | 14 | -------------------------------------------------------------------------------- /doc/_sources/examples.txt: -------------------------------------------------------------------------------- 1 | **************************** 2 | Examples 3 | **************************** 4 | 5 | A basic program that uses ``python-verge`` looks like this: 6 | 7 | First, import the library and exceptions. 8 | 9 | :: 10 | 11 | import vergerpc 12 | from vergerpc.exceptions import InsufficientFunds 13 | 14 | Then, we connect to the currently running ``verge`` instance of the current user on the local machine 15 | with one call to 16 | :func:`~vergerpc.connect_to_local`. This returns a :class:`~vergerpc.connection.VERGEConnection` objects: 17 | 18 | :: 19 | 20 | conn = vergerpc.connect_to_local() 21 | 22 | Try to move one verge from account ``testaccount`` to account ``testaccount2`` using 23 | :func:`~vergerpc.connection.VERGEConnection.move`. Catch the :class:`~vergerpc.exceptions.InsufficientFunds` 24 | exception in the case the originating account is broke: 25 | 26 | :: 27 | 28 | try: 29 | conn.move("testaccount", "testaccount2", 1.0) 30 | except InsufficientFunds,e: 31 | print "Account does not have enough funds available!" 32 | 33 | 34 | Retrieve general server information with :func:`~vergerpc.connection.VERGEConnection.getinfo` and print some statistics: 35 | 36 | :: 37 | 38 | info = conn.getinfo() 39 | print "Blocks: %i" % info.blocks 40 | print "Connections: %i" % info.connections 41 | print "Difficulty: %f" % info.difficulty 42 | 43 | 44 | -------------------------------------------------------------------------------- /doc/_sources/gettingstarted.txt: -------------------------------------------------------------------------------- 1 | ================= 2 | Getting Started 3 | ================= 4 | 5 | .. toctree:: 6 | :maxdepth: 2 7 | 8 | introduction.rst 9 | usage.rst 10 | examples.rst 11 | 12 | -------------------------------------------------------------------------------- /doc/_sources/index.txt: -------------------------------------------------------------------------------- 1 | ================================================== 2 | verge-python - Easy-to-use VERGE API client. 3 | ================================================== 4 | 5 | ``verge-python`` is a set of Python libraries that allows easy access to the 6 | verge_ peer-to-peer cryptocurrency client API. 7 | 8 | Contents: 9 | 10 | .. toctree:: 11 | :maxdepth: 2 12 | 13 | gettingstarted.rst 14 | apireference.rst 15 | 16 | Indices and tables 17 | ================== 18 | 19 | * :ref:`genindex` 20 | * :ref:`modindex` 21 | * :ref:`search` 22 | 23 | .. _verge: http://vergecurrency.com/ 24 | 25 | -------------------------------------------------------------------------------- /doc/_sources/introduction.txt: -------------------------------------------------------------------------------- 1 | **************************** 2 | Introduction 3 | **************************** 4 | 5 | The goal of this library is to make it easier for: 6 | 7 | - Payment gateways to support VERGE 8 | - Merchant sites to integrate VERGE payments directly 9 | - Other services that require (micro-)payments to use VERGE 10 | 11 | In this initial release it implements a thin wrapper around the 12 | VERGE JSON-RPC API. Using this API from Python directly is conceptually very simple, 13 | here is the example from the API 14 | documentation page: 15 | 16 | :: 17 | 18 | from jsonrpc import ServiceProxy 19 | 20 | access = ServiceProxy("http://user:password@127.0.0.1:20102") 21 | access.getinfo() 22 | access.listreceivedbyaddress(6) 23 | access.sendtoaddress("D1yEmxiMso2RsFVfBcCa616npBvGgxiBX", 1000) 24 | 25 | However, this approach has some disadvantages, one thing is that error handling is complex, as it 26 | requires manually checking the contents of :const:`JSONException` objects. 27 | 28 | ``verge-python`` attempts to create an even more friendly interface by wrapping the JSON-RPC API. The major advantages 29 | compared to a raw ``jsonrpc`` based approach are: 30 | 31 | - Better exception handling. Exceptions are converted to subclasses of :class:`~vergerpc.exceptions.VERGEException`. 32 | 33 | - Automatic verge configuration loading. In case the ``verge -server`` or ``verged`` program runs on the same 34 | machine as the client script, and as the same user, the configuration file can automatically be parsed. This 35 | makes it unneccesary to explicitly specify a *username* and *password*. Of course, this is still possible. 36 | 37 | - Documentation in Pythonish format. You are reading this right now. 38 | 39 | - The functions 40 | :func:`~vergerpc.connection.VERGEConnection.getinfo`, :func:`~vergerpc.connection.VERGEConnection.listreceivedbyaccount`, 41 | :func:`~vergerpc.connection.VERGEConnection.listreceivedbyaddress`, 42 | :func:`~vergerpc.connection.VERGEConnection.listtransactions` and more return actual Python objects, instead of simply 43 | dictionaries. This makes for cleaner code, as the fields can simply be addressed with ``x.foo`` instead of 44 | ``x['foo']``. 45 | 46 | The plan for future releases is to add a more high-level interface on top of this. 47 | 48 | -------------------------------------------------------------------------------- /doc/_sources/usage.txt: -------------------------------------------------------------------------------- 1 | ================= 2 | Usage 3 | ================= 4 | 5 | See also the `main verge documentation`_ for details and background on setting up and 6 | using verged remotely. 7 | 8 | Setting up verge for remote control 9 | ------------------------------------- 10 | 11 | If you run VERGE with the ``-server`` argument, or if you run ``verged``, it can be controlled 12 | either by sending it HTTP-JSON-RPC commands. 13 | 14 | However, beginning with VERGE 0.3.3 you must create a ``verge.conf`` file in the VERGE data directory 15 | (default ``$HOME/.dogeconf``) and set an RPC password: 16 | 17 | :: 18 | 19 | rpcuser=anything 20 | rpcpassword=anything 21 | 22 | Once that is done, the easiest way to check whether VERGE accepts remote commands is by running 23 | VERGE again, with the command (and any parameters) as arguments. For example: 24 | 25 | :: 26 | 27 | $ verged getinfo 28 | 29 | Connecting to the wallet from Python 30 | ------------------------------------- 31 | 32 | There are two functions for this: 33 | 34 | *Connecting to local verge instance* 35 | Use the function :func:`~vergerpc.connect_to_local`. This automagically 36 | sorts out the connection to a verge process running on the current machine, 37 | for the current user. 38 | 39 | :: 40 | 41 | conn = vergerpc.connect_to_local() 42 | 43 | *Connecting to a remote verge instance* 44 | Use the function :func:`~vergerpc.connect_to_remote`. For this function 45 | it is neccesary to explicitly specify a hostname and port to connect to, and 46 | to provide user credentials for logging in. 47 | 48 | :: 49 | 50 | conn = vergerpc.connect_to_remote('foo', 'bar', host='payments.yoyodyne.com', port=20102) 51 | 52 | 53 | How to use the API 54 | ------------------------------------- 55 | 56 | For basic sending and receiving of payments, the four most important methods are 57 | 58 | *Getting the current balance* 59 | Use the method :func:`~vergerpc.connection.VERGEConnection.getbalance` to get the current server balance. 60 | 61 | :: 62 | 63 | print "Your balance is %f" % (conn.getbalance(),) 64 | 65 | *Check a customer address for validity and get information about it* 66 | This can be done with the method :func:`~vergerpc.connection.VERGEConnection.validateaddress`. 67 | 68 | :: 69 | 70 | rv = conn.validateaddress(foo) 71 | if rv.isvalid: 72 | print "The address that you provided is valid" 73 | else: 74 | print "The address that you provided is invalid, please correct" 75 | 76 | *Sending payments* 77 | The method :func:`~vergerpc.connection.VERGEConnection.sendtoaddress` sends a specified 78 | amount of coins to a specified address. 79 | 80 | :: 81 | 82 | conn.sendtoaddress("DsTGAm1ApjEJfsWfAaRVaZHRm26mv5GL73", 20000.0) 83 | 84 | *Get a new address for accepting payments* 85 | To accept payments, use the method :func:`~vergerpc.connection.VERGEConnection.getnewaddress` 86 | to generate a new address. Give this address to the customer and store it in a safe place, to be able to check 87 | when the payment to this address has been made. 88 | 89 | :: 90 | 91 | pay_to = conn.getnewaddress() 92 | print "We will ship the pirate sandwidth after payment of 20000 coins to ", pay_to 93 | 94 | *Check how much has been received at a certain address* 95 | The method :func:`~vergerpc.connection.VERGEConnection.getreceivedbyaddress` 96 | returns how many verges have been received at a certain address. Together with the 97 | previous function, this can be used to check whether a payment has been made 98 | by the customer. 99 | 100 | :: 101 | 102 | amount = conn.getreceivedbyaddress(pay_to) 103 | if amount > 20000.0: 104 | print "Thanks, your sandwidth will be prepared and shipped." 105 | 106 | 107 | 108 | 109 | The account API 110 | ------------------------------------- 111 | More advanced usage of verge allows multiple accounts within one wallet. This 112 | can be useful if you are writing software for a bank, or 113 | simply want to have a clear separation between customers payments. 114 | 115 | For this, see the `Account API`_ documentation. 116 | 117 | .. _main bitcoin documentation: https://en.bitcoin.it/wiki/Main_Page 118 | .. _account API: https://en.bitcoin.it/wiki/Accounts_explained 119 | 120 | 121 | -------------------------------------------------------------------------------- /doc/_sources/vergerpc.config.txt: -------------------------------------------------------------------------------- 1 | :mod:`vergerpc.config` --- Utilities for reading verge configuration files 2 | ==================================================================================== 3 | 4 | .. automodule:: vergerpc.config 5 | :members: 6 | :show-inheritance: 7 | 8 | -------------------------------------------------------------------------------- /doc/_sources/vergerpc.connection.txt: -------------------------------------------------------------------------------- 1 | :mod:`vergerpc.connection` --- Connect to VERGE server via JSON-RPC 2 | ==================================================================================== 3 | 4 | .. automodule:: vergerpc.connection 5 | :members: 6 | :show-inheritance: 7 | 8 | 9 | -------------------------------------------------------------------------------- /doc/_sources/vergerpc.data.txt: -------------------------------------------------------------------------------- 1 | :mod:`vergerpc.data` --- VERGE RPC service, data objects 2 | ==================================================================================== 3 | 4 | .. automodule:: vergerpc.data 5 | :members: 6 | :show-inheritance: 7 | 8 | -------------------------------------------------------------------------------- /doc/_sources/vergerpc.exceptions.txt: -------------------------------------------------------------------------------- 1 | :mod:`vergerpc.exceptions` --- Exception definitions 2 | ==================================================================================== 3 | 4 | .. automodule:: vergerpc.exceptions 5 | :members: 6 | :show-inheritance: 7 | 8 | -------------------------------------------------------------------------------- /doc/_sources/vergerpc.txt: -------------------------------------------------------------------------------- 1 | :mod:`vergerpc` --- Convenience functions 2 | ==================================================================================== 3 | 4 | .. automodule:: vergerpc 5 | :members: 6 | :show-inheritance: 7 | 8 | -------------------------------------------------------------------------------- /doc/_sources/vergerpc.util.txt: -------------------------------------------------------------------------------- 1 | :mod:`vergerpc.util` --- Generic utilities used by verge client library 2 | ==================================================================================== 3 | 4 | .. automodule:: vergerpc.util 5 | :members: 6 | :show-inheritance: 7 | 8 | -------------------------------------------------------------------------------- /doc/_static/ajax-loader.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vergecurrency/verge-python/8b05f1589ec944f429e25299fb2f5d6e7641c141/doc/_static/ajax-loader.gif -------------------------------------------------------------------------------- /doc/_static/basic.css: -------------------------------------------------------------------------------- 1 | /* 2 | * basic.css 3 | * ~~~~~~~~~ 4 | * 5 | * Sphinx stylesheet -- basic theme. 6 | * 7 | * :copyright: Copyright 2007-2013 by the Sphinx team, see AUTHORS. 8 | * :license: BSD, see LICENSE for details. 9 | * 10 | */ 11 | 12 | /* -- main layout ----------------------------------------------------------- */ 13 | 14 | div.clearer { 15 | clear: both; 16 | } 17 | 18 | /* -- relbar ---------------------------------------------------------------- */ 19 | 20 | div.related { 21 | width: 100%; 22 | font-size: 90%; 23 | } 24 | 25 | div.related h3 { 26 | display: none; 27 | } 28 | 29 | div.related ul { 30 | margin: 0; 31 | padding: 0 0 0 10px; 32 | list-style: none; 33 | } 34 | 35 | div.related li { 36 | display: inline; 37 | } 38 | 39 | div.related li.right { 40 | float: right; 41 | margin-right: 5px; 42 | } 43 | 44 | /* -- sidebar --------------------------------------------------------------- */ 45 | 46 | div.sphinxsidebarwrapper { 47 | padding: 10px 5px 0 10px; 48 | } 49 | 50 | div.sphinxsidebar { 51 | float: left; 52 | width: 230px; 53 | margin-left: -100%; 54 | font-size: 90%; 55 | } 56 | 57 | div.sphinxsidebar ul { 58 | list-style: none; 59 | } 60 | 61 | div.sphinxsidebar ul ul, 62 | div.sphinxsidebar ul.want-points { 63 | margin-left: 20px; 64 | list-style: square; 65 | } 66 | 67 | div.sphinxsidebar ul ul { 68 | margin-top: 0; 69 | margin-bottom: 0; 70 | } 71 | 72 | div.sphinxsidebar form { 73 | margin-top: 10px; 74 | } 75 | 76 | div.sphinxsidebar input { 77 | border: 1px solid #98dbcc; 78 | font-family: sans-serif; 79 | font-size: 1em; 80 | } 81 | 82 | div.sphinxsidebar #searchbox input[type="text"] { 83 | width: 170px; 84 | } 85 | 86 | div.sphinxsidebar #searchbox input[type="submit"] { 87 | width: 30px; 88 | } 89 | 90 | img { 91 | border: 0; 92 | max-width: 100%; 93 | } 94 | 95 | /* -- search page ----------------------------------------------------------- */ 96 | 97 | ul.search { 98 | margin: 10px 0 0 20px; 99 | padding: 0; 100 | } 101 | 102 | ul.search li { 103 | padding: 5px 0 5px 20px; 104 | background-image: url(file.png); 105 | background-repeat: no-repeat; 106 | background-position: 0 7px; 107 | } 108 | 109 | ul.search li a { 110 | font-weight: bold; 111 | } 112 | 113 | ul.search li div.context { 114 | color: #888; 115 | margin: 2px 0 0 30px; 116 | text-align: left; 117 | } 118 | 119 | ul.keywordmatches li.goodmatch a { 120 | font-weight: bold; 121 | } 122 | 123 | /* -- index page ------------------------------------------------------------ */ 124 | 125 | table.contentstable { 126 | width: 90%; 127 | } 128 | 129 | table.contentstable p.biglink { 130 | line-height: 150%; 131 | } 132 | 133 | a.biglink { 134 | font-size: 1.3em; 135 | } 136 | 137 | span.linkdescr { 138 | font-style: italic; 139 | padding-top: 5px; 140 | font-size: 90%; 141 | } 142 | 143 | /* -- general index --------------------------------------------------------- */ 144 | 145 | table.indextable { 146 | width: 100%; 147 | } 148 | 149 | table.indextable td { 150 | text-align: left; 151 | vertical-align: top; 152 | } 153 | 154 | table.indextable dl, table.indextable dd { 155 | margin-top: 0; 156 | margin-bottom: 0; 157 | } 158 | 159 | table.indextable tr.pcap { 160 | height: 10px; 161 | } 162 | 163 | table.indextable tr.cap { 164 | margin-top: 10px; 165 | background-color: #f2f2f2; 166 | } 167 | 168 | img.toggler { 169 | margin-right: 3px; 170 | margin-top: 3px; 171 | cursor: pointer; 172 | } 173 | 174 | div.modindex-jumpbox { 175 | border-top: 1px solid #ddd; 176 | border-bottom: 1px solid #ddd; 177 | margin: 1em 0 1em 0; 178 | padding: 0.4em; 179 | } 180 | 181 | div.genindex-jumpbox { 182 | border-top: 1px solid #ddd; 183 | border-bottom: 1px solid #ddd; 184 | margin: 1em 0 1em 0; 185 | padding: 0.4em; 186 | } 187 | 188 | /* -- general body styles --------------------------------------------------- */ 189 | 190 | a.headerlink { 191 | visibility: hidden; 192 | } 193 | 194 | h1:hover > a.headerlink, 195 | h2:hover > a.headerlink, 196 | h3:hover > a.headerlink, 197 | h4:hover > a.headerlink, 198 | h5:hover > a.headerlink, 199 | h6:hover > a.headerlink, 200 | dt:hover > a.headerlink { 201 | visibility: visible; 202 | } 203 | 204 | div.body p.caption { 205 | text-align: inherit; 206 | } 207 | 208 | div.body td { 209 | text-align: left; 210 | } 211 | 212 | .field-list ul { 213 | padding-left: 1em; 214 | } 215 | 216 | .first { 217 | margin-top: 0 !important; 218 | } 219 | 220 | p.rubric { 221 | margin-top: 30px; 222 | font-weight: bold; 223 | } 224 | 225 | img.align-left, .figure.align-left, object.align-left { 226 | clear: left; 227 | float: left; 228 | margin-right: 1em; 229 | } 230 | 231 | img.align-right, .figure.align-right, object.align-right { 232 | clear: right; 233 | float: right; 234 | margin-left: 1em; 235 | } 236 | 237 | img.align-center, .figure.align-center, object.align-center { 238 | display: block; 239 | margin-left: auto; 240 | margin-right: auto; 241 | } 242 | 243 | .align-left { 244 | text-align: left; 245 | } 246 | 247 | .align-center { 248 | text-align: center; 249 | } 250 | 251 | .align-right { 252 | text-align: right; 253 | } 254 | 255 | /* -- sidebars -------------------------------------------------------------- */ 256 | 257 | div.sidebar { 258 | margin: 0 0 0.5em 1em; 259 | border: 1px solid #ddb; 260 | padding: 7px 7px 0 7px; 261 | background-color: #ffe; 262 | width: 40%; 263 | float: right; 264 | } 265 | 266 | p.sidebar-title { 267 | font-weight: bold; 268 | } 269 | 270 | /* -- topics ---------------------------------------------------------------- */ 271 | 272 | div.topic { 273 | border: 1px solid #ccc; 274 | padding: 7px 7px 0 7px; 275 | margin: 10px 0 10px 0; 276 | } 277 | 278 | p.topic-title { 279 | font-size: 1.1em; 280 | font-weight: bold; 281 | margin-top: 10px; 282 | } 283 | 284 | /* -- admonitions ----------------------------------------------------------- */ 285 | 286 | div.admonition { 287 | margin-top: 10px; 288 | margin-bottom: 10px; 289 | padding: 7px; 290 | } 291 | 292 | div.admonition dt { 293 | font-weight: bold; 294 | } 295 | 296 | div.admonition dl { 297 | margin-bottom: 0; 298 | } 299 | 300 | p.admonition-title { 301 | margin: 0px 10px 5px 0px; 302 | font-weight: bold; 303 | } 304 | 305 | div.body p.centered { 306 | text-align: center; 307 | margin-top: 25px; 308 | } 309 | 310 | /* -- tables ---------------------------------------------------------------- */ 311 | 312 | table.docutils { 313 | border: 0; 314 | border-collapse: collapse; 315 | } 316 | 317 | table.docutils td, table.docutils th { 318 | padding: 1px 8px 1px 5px; 319 | border-top: 0; 320 | border-left: 0; 321 | border-right: 0; 322 | border-bottom: 1px solid #aaa; 323 | } 324 | 325 | table.field-list td, table.field-list th { 326 | border: 0 !important; 327 | } 328 | 329 | table.footnote td, table.footnote th { 330 | border: 0 !important; 331 | } 332 | 333 | th { 334 | text-align: left; 335 | padding-right: 5px; 336 | } 337 | 338 | table.citation { 339 | border-left: solid 1px gray; 340 | margin-left: 1px; 341 | } 342 | 343 | table.citation td { 344 | border-bottom: none; 345 | } 346 | 347 | /* -- other body styles ----------------------------------------------------- */ 348 | 349 | ol.arabic { 350 | list-style: decimal; 351 | } 352 | 353 | ol.loweralpha { 354 | list-style: lower-alpha; 355 | } 356 | 357 | ol.upperalpha { 358 | list-style: upper-alpha; 359 | } 360 | 361 | ol.lowerroman { 362 | list-style: lower-roman; 363 | } 364 | 365 | ol.upperroman { 366 | list-style: upper-roman; 367 | } 368 | 369 | dl { 370 | margin-bottom: 15px; 371 | } 372 | 373 | dd p { 374 | margin-top: 0px; 375 | } 376 | 377 | dd ul, dd table { 378 | margin-bottom: 10px; 379 | } 380 | 381 | dd { 382 | margin-top: 3px; 383 | margin-bottom: 10px; 384 | margin-left: 30px; 385 | } 386 | 387 | dt:target, .highlighted { 388 | background-color: #fbe54e; 389 | } 390 | 391 | dl.glossary dt { 392 | font-weight: bold; 393 | font-size: 1.1em; 394 | } 395 | 396 | .field-list ul { 397 | margin: 0; 398 | padding-left: 1em; 399 | } 400 | 401 | .field-list p { 402 | margin: 0; 403 | } 404 | 405 | .optional { 406 | font-size: 1.3em; 407 | } 408 | 409 | .versionmodified { 410 | font-style: italic; 411 | } 412 | 413 | .system-message { 414 | background-color: #fda; 415 | padding: 5px; 416 | border: 3px solid red; 417 | } 418 | 419 | .footnote:target { 420 | background-color: #ffa; 421 | } 422 | 423 | .line-block { 424 | display: block; 425 | margin-top: 1em; 426 | margin-bottom: 1em; 427 | } 428 | 429 | .line-block .line-block { 430 | margin-top: 0; 431 | margin-bottom: 0; 432 | margin-left: 1.5em; 433 | } 434 | 435 | .guilabel, .menuselection { 436 | font-family: sans-serif; 437 | } 438 | 439 | .accelerator { 440 | text-decoration: underline; 441 | } 442 | 443 | .classifier { 444 | font-style: oblique; 445 | } 446 | 447 | abbr, acronym { 448 | border-bottom: dotted 1px; 449 | cursor: help; 450 | } 451 | 452 | /* -- code displays --------------------------------------------------------- */ 453 | 454 | pre { 455 | overflow: auto; 456 | overflow-y: hidden; /* fixes display issues on Chrome browsers */ 457 | } 458 | 459 | td.linenos pre { 460 | padding: 5px 0px; 461 | border: 0; 462 | background-color: transparent; 463 | color: #aaa; 464 | } 465 | 466 | table.highlighttable { 467 | margin-left: 0.5em; 468 | } 469 | 470 | table.highlighttable td { 471 | padding: 0 0.5em 0 0.5em; 472 | } 473 | 474 | tt.descname { 475 | background-color: transparent; 476 | font-weight: bold; 477 | font-size: 1.2em; 478 | } 479 | 480 | tt.descclassname { 481 | background-color: transparent; 482 | } 483 | 484 | tt.xref, a tt { 485 | background-color: transparent; 486 | font-weight: bold; 487 | } 488 | 489 | h1 tt, h2 tt, h3 tt, h4 tt, h5 tt, h6 tt { 490 | background-color: transparent; 491 | } 492 | 493 | .viewcode-link { 494 | float: right; 495 | } 496 | 497 | .viewcode-back { 498 | float: right; 499 | font-family: sans-serif; 500 | } 501 | 502 | div.viewcode-block:target { 503 | margin: -1px -10px; 504 | padding: 0 10px; 505 | } 506 | 507 | /* -- math display ---------------------------------------------------------- */ 508 | 509 | img.math { 510 | vertical-align: middle; 511 | } 512 | 513 | div.body div.math p { 514 | text-align: center; 515 | } 516 | 517 | span.eqno { 518 | float: right; 519 | } 520 | 521 | /* -- printout stylesheet --------------------------------------------------- */ 522 | 523 | @media print { 524 | div.document, 525 | div.documentwrapper, 526 | div.bodywrapper { 527 | margin: 0 !important; 528 | width: 100%; 529 | } 530 | 531 | div.sphinxsidebar, 532 | div.related, 533 | div.footer, 534 | #top-link { 535 | display: none; 536 | } 537 | } -------------------------------------------------------------------------------- /doc/_static/comment-bright.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vergecurrency/verge-python/8b05f1589ec944f429e25299fb2f5d6e7641c141/doc/_static/comment-bright.png -------------------------------------------------------------------------------- /doc/_static/comment-close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vergecurrency/verge-python/8b05f1589ec944f429e25299fb2f5d6e7641c141/doc/_static/comment-close.png -------------------------------------------------------------------------------- /doc/_static/comment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vergecurrency/verge-python/8b05f1589ec944f429e25299fb2f5d6e7641c141/doc/_static/comment.png -------------------------------------------------------------------------------- /doc/_static/default.css: -------------------------------------------------------------------------------- 1 | /* 2 | * default.css_t 3 | * ~~~~~~~~~~~~~ 4 | * 5 | * Sphinx stylesheet -- default theme. 6 | * 7 | * :copyright: Copyright 2007-2013 by the Sphinx team, see AUTHORS. 8 | * :license: BSD, see LICENSE for details. 9 | * 10 | */ 11 | 12 | @import url("basic.css"); 13 | 14 | /* -- page layout ----------------------------------------------------------- */ 15 | 16 | body { 17 | font-family: sans-serif; 18 | font-size: 100%; 19 | background-color: #11303d; 20 | color: #000; 21 | margin: 0; 22 | padding: 0; 23 | } 24 | 25 | div.document { 26 | background-color: #1c4e63; 27 | } 28 | 29 | div.documentwrapper { 30 | float: left; 31 | width: 100%; 32 | } 33 | 34 | div.bodywrapper { 35 | margin: 0 0 0 230px; 36 | } 37 | 38 | div.body { 39 | background-color: #ffffff; 40 | color: #000000; 41 | padding: 0 20px 30px 20px; 42 | } 43 | 44 | div.footer { 45 | color: #ffffff; 46 | width: 100%; 47 | padding: 9px 0 9px 0; 48 | text-align: center; 49 | font-size: 75%; 50 | } 51 | 52 | div.footer a { 53 | color: #ffffff; 54 | text-decoration: underline; 55 | } 56 | 57 | div.related { 58 | background-color: #133f52; 59 | line-height: 30px; 60 | color: #ffffff; 61 | } 62 | 63 | div.related a { 64 | color: #ffffff; 65 | } 66 | 67 | div.sphinxsidebar { 68 | } 69 | 70 | div.sphinxsidebar h3 { 71 | font-family: 'Trebuchet MS', sans-serif; 72 | color: #ffffff; 73 | font-size: 1.4em; 74 | font-weight: normal; 75 | margin: 0; 76 | padding: 0; 77 | } 78 | 79 | div.sphinxsidebar h3 a { 80 | color: #ffffff; 81 | } 82 | 83 | div.sphinxsidebar h4 { 84 | font-family: 'Trebuchet MS', sans-serif; 85 | color: #ffffff; 86 | font-size: 1.3em; 87 | font-weight: normal; 88 | margin: 5px 0 0 0; 89 | padding: 0; 90 | } 91 | 92 | div.sphinxsidebar p { 93 | color: #ffffff; 94 | } 95 | 96 | div.sphinxsidebar p.topless { 97 | margin: 5px 10px 10px 10px; 98 | } 99 | 100 | div.sphinxsidebar ul { 101 | margin: 10px; 102 | padding: 0; 103 | color: #ffffff; 104 | } 105 | 106 | div.sphinxsidebar a { 107 | color: #98dbcc; 108 | } 109 | 110 | div.sphinxsidebar input { 111 | border: 1px solid #98dbcc; 112 | font-family: sans-serif; 113 | font-size: 1em; 114 | } 115 | 116 | 117 | 118 | /* -- hyperlink styles ------------------------------------------------------ */ 119 | 120 | a { 121 | color: #355f7c; 122 | text-decoration: none; 123 | } 124 | 125 | a:visited { 126 | color: #355f7c; 127 | text-decoration: none; 128 | } 129 | 130 | a:hover { 131 | text-decoration: underline; 132 | } 133 | 134 | 135 | 136 | /* -- body styles ----------------------------------------------------------- */ 137 | 138 | div.body h1, 139 | div.body h2, 140 | div.body h3, 141 | div.body h4, 142 | div.body h5, 143 | div.body h6 { 144 | font-family: 'Trebuchet MS', sans-serif; 145 | background-color: #f2f2f2; 146 | font-weight: normal; 147 | color: #20435c; 148 | border-bottom: 1px solid #ccc; 149 | margin: 20px -20px 10px -20px; 150 | padding: 3px 0 3px 10px; 151 | } 152 | 153 | div.body h1 { margin-top: 0; font-size: 200%; } 154 | div.body h2 { font-size: 160%; } 155 | div.body h3 { font-size: 140%; } 156 | div.body h4 { font-size: 120%; } 157 | div.body h5 { font-size: 110%; } 158 | div.body h6 { font-size: 100%; } 159 | 160 | a.headerlink { 161 | color: #c60f0f; 162 | font-size: 0.8em; 163 | padding: 0 4px 0 4px; 164 | text-decoration: none; 165 | } 166 | 167 | a.headerlink:hover { 168 | background-color: #c60f0f; 169 | color: white; 170 | } 171 | 172 | div.body p, div.body dd, div.body li { 173 | text-align: justify; 174 | line-height: 130%; 175 | } 176 | 177 | div.admonition p.admonition-title + p { 178 | display: inline; 179 | } 180 | 181 | div.admonition p { 182 | margin-bottom: 5px; 183 | } 184 | 185 | div.admonition pre { 186 | margin-bottom: 5px; 187 | } 188 | 189 | div.admonition ul, div.admonition ol { 190 | margin-bottom: 5px; 191 | } 192 | 193 | div.note { 194 | background-color: #eee; 195 | border: 1px solid #ccc; 196 | } 197 | 198 | div.seealso { 199 | background-color: #ffc; 200 | border: 1px solid #ff6; 201 | } 202 | 203 | div.topic { 204 | background-color: #eee; 205 | } 206 | 207 | div.warning { 208 | background-color: #ffe4e4; 209 | border: 1px solid #f66; 210 | } 211 | 212 | p.admonition-title { 213 | display: inline; 214 | } 215 | 216 | p.admonition-title:after { 217 | content: ":"; 218 | } 219 | 220 | pre { 221 | padding: 5px; 222 | background-color: #eeffcc; 223 | color: #333333; 224 | line-height: 120%; 225 | border: 1px solid #ac9; 226 | border-left: none; 227 | border-right: none; 228 | } 229 | 230 | tt { 231 | background-color: #ecf0f3; 232 | padding: 0 1px 0 1px; 233 | font-size: 0.95em; 234 | } 235 | 236 | th { 237 | background-color: #ede; 238 | } 239 | 240 | .warning tt { 241 | background: #efc2c2; 242 | } 243 | 244 | .note tt { 245 | background: #d6d6d6; 246 | } 247 | 248 | .viewcode-back { 249 | font-family: sans-serif; 250 | } 251 | 252 | div.viewcode-block:target { 253 | background-color: #f4debf; 254 | border-top: 1px solid #ac9; 255 | border-bottom: 1px solid #ac9; 256 | } -------------------------------------------------------------------------------- /doc/_static/doctools.js: -------------------------------------------------------------------------------- 1 | /* 2 | * doctools.js 3 | * ~~~~~~~~~~~ 4 | * 5 | * Sphinx JavaScript utilities for all documentation. 6 | * 7 | * :copyright: Copyright 2007-2013 by the Sphinx team, see AUTHORS. 8 | * :license: BSD, see LICENSE for details. 9 | * 10 | */ 11 | 12 | /** 13 | * select a different prefix for underscore 14 | */ 15 | $u = _.noConflict(); 16 | 17 | /** 18 | * make the code below compatible with browsers without 19 | * an installed firebug like debugger 20 | if (!window.console || !console.firebug) { 21 | var names = ["log", "debug", "info", "warn", "error", "assert", "dir", 22 | "dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace", 23 | "profile", "profileEnd"]; 24 | window.console = {}; 25 | for (var i = 0; i < names.length; ++i) 26 | window.console[names[i]] = function() {}; 27 | } 28 | */ 29 | 30 | /** 31 | * small helper function to urldecode strings 32 | */ 33 | jQuery.urldecode = function(x) { 34 | return decodeURIComponent(x).replace(/\+/g, ' '); 35 | }; 36 | 37 | /** 38 | * small helper function to urlencode strings 39 | */ 40 | jQuery.urlencode = encodeURIComponent; 41 | 42 | /** 43 | * This function returns the parsed url parameters of the 44 | * current request. Multiple values per key are supported, 45 | * it will always return arrays of strings for the value parts. 46 | */ 47 | jQuery.getQueryParameters = function(s) { 48 | if (typeof s == 'undefined') 49 | s = document.location.search; 50 | var parts = s.substr(s.indexOf('?') + 1).split('&'); 51 | var result = {}; 52 | for (var i = 0; i < parts.length; i++) { 53 | var tmp = parts[i].split('=', 2); 54 | var key = jQuery.urldecode(tmp[0]); 55 | var value = jQuery.urldecode(tmp[1]); 56 | if (key in result) 57 | result[key].push(value); 58 | else 59 | result[key] = [value]; 60 | } 61 | return result; 62 | }; 63 | 64 | /** 65 | * highlight a given string on a jquery object by wrapping it in 66 | * span elements with the given class name. 67 | */ 68 | jQuery.fn.highlightText = function(text, className) { 69 | function highlight(node) { 70 | if (node.nodeType == 3) { 71 | var val = node.nodeValue; 72 | var pos = val.toLowerCase().indexOf(text); 73 | if (pos >= 0 && !jQuery(node.parentNode).hasClass(className)) { 74 | var span = document.createElement("span"); 75 | span.className = className; 76 | span.appendChild(document.createTextNode(val.substr(pos, text.length))); 77 | node.parentNode.insertBefore(span, node.parentNode.insertBefore( 78 | document.createTextNode(val.substr(pos + text.length)), 79 | node.nextSibling)); 80 | node.nodeValue = val.substr(0, pos); 81 | } 82 | } 83 | else if (!jQuery(node).is("button, select, textarea")) { 84 | jQuery.each(node.childNodes, function() { 85 | highlight(this); 86 | }); 87 | } 88 | } 89 | return this.each(function() { 90 | highlight(this); 91 | }); 92 | }; 93 | 94 | /** 95 | * Small JavaScript module for the documentation. 96 | */ 97 | var Documentation = { 98 | 99 | init : function() { 100 | this.fixFirefoxAnchorBug(); 101 | this.highlightSearchWords(); 102 | this.initIndexTable(); 103 | }, 104 | 105 | /** 106 | * i18n support 107 | */ 108 | TRANSLATIONS : {}, 109 | PLURAL_EXPR : function(n) { return n == 1 ? 0 : 1; }, 110 | LOCALE : 'unknown', 111 | 112 | // gettext and ngettext don't access this so that the functions 113 | // can safely bound to a different name (_ = Documentation.gettext) 114 | gettext : function(string) { 115 | var translated = Documentation.TRANSLATIONS[string]; 116 | if (typeof translated == 'undefined') 117 | return string; 118 | return (typeof translated == 'string') ? translated : translated[0]; 119 | }, 120 | 121 | ngettext : function(singular, plural, n) { 122 | var translated = Documentation.TRANSLATIONS[singular]; 123 | if (typeof translated == 'undefined') 124 | return (n == 1) ? singular : plural; 125 | return translated[Documentation.PLURALEXPR(n)]; 126 | }, 127 | 128 | addTranslations : function(catalog) { 129 | for (var key in catalog.messages) 130 | this.TRANSLATIONS[key] = catalog.messages[key]; 131 | this.PLURAL_EXPR = new Function('n', 'return +(' + catalog.plural_expr + ')'); 132 | this.LOCALE = catalog.locale; 133 | }, 134 | 135 | /** 136 | * add context elements like header anchor links 137 | */ 138 | addContextElements : function() { 139 | $('div[id] > :header:first').each(function() { 140 | $('\u00B6'). 141 | attr('href', '#' + this.id). 142 | attr('title', _('Permalink to this headline')). 143 | appendTo(this); 144 | }); 145 | $('dt[id]').each(function() { 146 | $('\u00B6'). 147 | attr('href', '#' + this.id). 148 | attr('title', _('Permalink to this definition')). 149 | appendTo(this); 150 | }); 151 | }, 152 | 153 | /** 154 | * workaround a firefox stupidity 155 | */ 156 | fixFirefoxAnchorBug : function() { 157 | if (document.location.hash && $.browser.mozilla) 158 | window.setTimeout(function() { 159 | document.location.href += ''; 160 | }, 10); 161 | }, 162 | 163 | /** 164 | * highlight the search words provided in the url in the text 165 | */ 166 | highlightSearchWords : function() { 167 | var params = $.getQueryParameters(); 168 | var terms = (params.highlight) ? params.highlight[0].split(/\s+/) : []; 169 | if (terms.length) { 170 | var body = $('div.body'); 171 | if (!body.length) { 172 | body = $('body'); 173 | } 174 | window.setTimeout(function() { 175 | $.each(terms, function() { 176 | body.highlightText(this.toLowerCase(), 'highlighted'); 177 | }); 178 | }, 10); 179 | $('') 181 | .appendTo($('#searchbox')); 182 | } 183 | }, 184 | 185 | /** 186 | * init the domain index toggle buttons 187 | */ 188 | initIndexTable : function() { 189 | var togglers = $('img.toggler').click(function() { 190 | var src = $(this).attr('src'); 191 | var idnum = $(this).attr('id').substr(7); 192 | $('tr.cg-' + idnum).toggle(); 193 | if (src.substr(-9) == 'minus.png') 194 | $(this).attr('src', src.substr(0, src.length-9) + 'plus.png'); 195 | else 196 | $(this).attr('src', src.substr(0, src.length-8) + 'minus.png'); 197 | }).css('display', ''); 198 | if (DOCUMENTATION_OPTIONS.COLLAPSE_INDEX) { 199 | togglers.click(); 200 | } 201 | }, 202 | 203 | /** 204 | * helper function to hide the search marks again 205 | */ 206 | hideSearchWords : function() { 207 | $('#searchbox .highlight-link').fadeOut(300); 208 | $('span.highlighted').removeClass('highlighted'); 209 | }, 210 | 211 | /** 212 | * make the url absolute 213 | */ 214 | makeURL : function(relativeURL) { 215 | return DOCUMENTATION_OPTIONS.URL_ROOT + '/' + relativeURL; 216 | }, 217 | 218 | /** 219 | * get the current relative url 220 | */ 221 | getCurrentURL : function() { 222 | var path = document.location.pathname; 223 | var parts = path.split(/\//); 224 | $.each(DOCUMENTATION_OPTIONS.URL_ROOT.split(/\//), function() { 225 | if (this == '..') 226 | parts.pop(); 227 | }); 228 | var url = parts.join('/'); 229 | return path.substring(url.lastIndexOf('/') + 1, path.length - 1); 230 | } 231 | }; 232 | 233 | // quick alias for translations 234 | _ = Documentation.gettext; 235 | 236 | $(document).ready(function() { 237 | Documentation.init(); 238 | }); 239 | -------------------------------------------------------------------------------- /doc/_static/down-pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vergecurrency/verge-python/8b05f1589ec944f429e25299fb2f5d6e7641c141/doc/_static/down-pressed.png -------------------------------------------------------------------------------- /doc/_static/down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vergecurrency/verge-python/8b05f1589ec944f429e25299fb2f5d6e7641c141/doc/_static/down.png -------------------------------------------------------------------------------- /doc/_static/file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vergecurrency/verge-python/8b05f1589ec944f429e25299fb2f5d6e7641c141/doc/_static/file.png -------------------------------------------------------------------------------- /doc/_static/minus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vergecurrency/verge-python/8b05f1589ec944f429e25299fb2f5d6e7641c141/doc/_static/minus.png -------------------------------------------------------------------------------- /doc/_static/plus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vergecurrency/verge-python/8b05f1589ec944f429e25299fb2f5d6e7641c141/doc/_static/plus.png -------------------------------------------------------------------------------- /doc/_static/pygments.css: -------------------------------------------------------------------------------- 1 | .highlight .hll { background-color: #ffffcc } 2 | .highlight { background: #eeffcc; } 3 | .highlight .c { color: #408090; font-style: italic } /* Comment */ 4 | .highlight .err { border: 1px solid #FF0000 } /* Error */ 5 | .highlight .k { color: #007020; font-weight: bold } /* Keyword */ 6 | .highlight .o { color: #666666 } /* Operator */ 7 | .highlight .cm { color: #408090; font-style: italic } /* Comment.Multiline */ 8 | .highlight .cp { color: #007020 } /* Comment.Preproc */ 9 | .highlight .c1 { color: #408090; font-style: italic } /* Comment.Single */ 10 | .highlight .cs { color: #408090; background-color: #fff0f0 } /* Comment.Special */ 11 | .highlight .gd { color: #A00000 } /* Generic.Deleted */ 12 | .highlight .ge { font-style: italic } /* Generic.Emph */ 13 | .highlight .gr { color: #FF0000 } /* Generic.Error */ 14 | .highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */ 15 | .highlight .gi { color: #00A000 } /* Generic.Inserted */ 16 | .highlight .go { color: #333333 } /* Generic.Output */ 17 | .highlight .gp { color: #c65d09; font-weight: bold } /* Generic.Prompt */ 18 | .highlight .gs { font-weight: bold } /* Generic.Strong */ 19 | .highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */ 20 | .highlight .gt { color: #0044DD } /* Generic.Traceback */ 21 | .highlight .kc { color: #007020; font-weight: bold } /* Keyword.Constant */ 22 | .highlight .kd { color: #007020; font-weight: bold } /* Keyword.Declaration */ 23 | .highlight .kn { color: #007020; font-weight: bold } /* Keyword.Namespace */ 24 | .highlight .kp { color: #007020 } /* Keyword.Pseudo */ 25 | .highlight .kr { color: #007020; font-weight: bold } /* Keyword.Reserved */ 26 | .highlight .kt { color: #902000 } /* Keyword.Type */ 27 | .highlight .m { color: #208050 } /* Literal.Number */ 28 | .highlight .s { color: #4070a0 } /* Literal.String */ 29 | .highlight .na { color: #4070a0 } /* Name.Attribute */ 30 | .highlight .nb { color: #007020 } /* Name.Builtin */ 31 | .highlight .nc { color: #0e84b5; font-weight: bold } /* Name.Class */ 32 | .highlight .no { color: #60add5 } /* Name.Constant */ 33 | .highlight .nd { color: #555555; font-weight: bold } /* Name.Decorator */ 34 | .highlight .ni { color: #d55537; font-weight: bold } /* Name.Entity */ 35 | .highlight .ne { color: #007020 } /* Name.Exception */ 36 | .highlight .nf { color: #06287e } /* Name.Function */ 37 | .highlight .nl { color: #002070; font-weight: bold } /* Name.Label */ 38 | .highlight .nn { color: #0e84b5; font-weight: bold } /* Name.Namespace */ 39 | .highlight .nt { color: #062873; font-weight: bold } /* Name.Tag */ 40 | .highlight .nv { color: #bb60d5 } /* Name.Variable */ 41 | .highlight .ow { color: #007020; font-weight: bold } /* Operator.Word */ 42 | .highlight .w { color: #bbbbbb } /* Text.Whitespace */ 43 | .highlight .mf { color: #208050 } /* Literal.Number.Float */ 44 | .highlight .mh { color: #208050 } /* Literal.Number.Hex */ 45 | .highlight .mi { color: #208050 } /* Literal.Number.Integer */ 46 | .highlight .mo { color: #208050 } /* Literal.Number.Oct */ 47 | .highlight .sb { color: #4070a0 } /* Literal.String.Backtick */ 48 | .highlight .sc { color: #4070a0 } /* Literal.String.Char */ 49 | .highlight .sd { color: #4070a0; font-style: italic } /* Literal.String.Doc */ 50 | .highlight .s2 { color: #4070a0 } /* Literal.String.Double */ 51 | .highlight .se { color: #4070a0; font-weight: bold } /* Literal.String.Escape */ 52 | .highlight .sh { color: #4070a0 } /* Literal.String.Heredoc */ 53 | .highlight .si { color: #70a0d0; font-style: italic } /* Literal.String.Interpol */ 54 | .highlight .sx { color: #c65d09 } /* Literal.String.Other */ 55 | .highlight .sr { color: #235388 } /* Literal.String.Regex */ 56 | .highlight .s1 { color: #4070a0 } /* Literal.String.Single */ 57 | .highlight .ss { color: #517918 } /* Literal.String.Symbol */ 58 | .highlight .bp { color: #007020 } /* Name.Builtin.Pseudo */ 59 | .highlight .vc { color: #bb60d5 } /* Name.Variable.Class */ 60 | .highlight .vg { color: #bb60d5 } /* Name.Variable.Global */ 61 | .highlight .vi { color: #bb60d5 } /* Name.Variable.Instance */ 62 | .highlight .il { color: #208050 } /* Literal.Number.Integer.Long */ -------------------------------------------------------------------------------- /doc/_static/sidebar.js: -------------------------------------------------------------------------------- 1 | /* 2 | * sidebar.js 3 | * ~~~~~~~~~~ 4 | * 5 | * This script makes the Sphinx sidebar collapsible. 6 | * 7 | * .sphinxsidebar contains .sphinxsidebarwrapper. This script adds 8 | * in .sphixsidebar, after .sphinxsidebarwrapper, the #sidebarbutton 9 | * used to collapse and expand the sidebar. 10 | * 11 | * When the sidebar is collapsed the .sphinxsidebarwrapper is hidden 12 | * and the width of the sidebar and the margin-left of the document 13 | * are decreased. When the sidebar is expanded the opposite happens. 14 | * This script saves a per-browser/per-session cookie used to 15 | * remember the position of the sidebar among the pages. 16 | * Once the browser is closed the cookie is deleted and the position 17 | * reset to the default (expanded). 18 | * 19 | * :copyright: Copyright 2007-2013 by the Sphinx team, see AUTHORS. 20 | * :license: BSD, see LICENSE for details. 21 | * 22 | */ 23 | 24 | $(function() { 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | // global elements used by the functions. 34 | // the 'sidebarbutton' element is defined as global after its 35 | // creation, in the add_sidebar_button function 36 | var bodywrapper = $('.bodywrapper'); 37 | var sidebar = $('.sphinxsidebar'); 38 | var sidebarwrapper = $('.sphinxsidebarwrapper'); 39 | 40 | // for some reason, the document has no sidebar; do not run into errors 41 | if (!sidebar.length) return; 42 | 43 | // original margin-left of the bodywrapper and width of the sidebar 44 | // with the sidebar expanded 45 | var bw_margin_expanded = bodywrapper.css('margin-left'); 46 | var ssb_width_expanded = sidebar.width(); 47 | 48 | // margin-left of the bodywrapper and width of the sidebar 49 | // with the sidebar collapsed 50 | var bw_margin_collapsed = '.8em'; 51 | var ssb_width_collapsed = '.8em'; 52 | 53 | // colors used by the current theme 54 | var dark_color = $('.related').css('background-color'); 55 | var light_color = $('.document').css('background-color'); 56 | 57 | function sidebar_is_collapsed() { 58 | return sidebarwrapper.is(':not(:visible)'); 59 | } 60 | 61 | function toggle_sidebar() { 62 | if (sidebar_is_collapsed()) 63 | expand_sidebar(); 64 | else 65 | collapse_sidebar(); 66 | } 67 | 68 | function collapse_sidebar() { 69 | sidebarwrapper.hide(); 70 | sidebar.css('width', ssb_width_collapsed); 71 | bodywrapper.css('margin-left', bw_margin_collapsed); 72 | sidebarbutton.css({ 73 | 'margin-left': '0', 74 | 'height': bodywrapper.height() 75 | }); 76 | sidebarbutton.find('span').text('»'); 77 | sidebarbutton.attr('title', _('Expand sidebar')); 78 | document.cookie = 'sidebar=collapsed'; 79 | } 80 | 81 | function expand_sidebar() { 82 | bodywrapper.css('margin-left', bw_margin_expanded); 83 | sidebar.css('width', ssb_width_expanded); 84 | sidebarwrapper.show(); 85 | sidebarbutton.css({ 86 | 'margin-left': ssb_width_expanded-12, 87 | 'height': bodywrapper.height() 88 | }); 89 | sidebarbutton.find('span').text('«'); 90 | sidebarbutton.attr('title', _('Collapse sidebar')); 91 | document.cookie = 'sidebar=expanded'; 92 | } 93 | 94 | function add_sidebar_button() { 95 | sidebarwrapper.css({ 96 | 'float': 'left', 97 | 'margin-right': '0', 98 | 'width': ssb_width_expanded - 28 99 | }); 100 | // create the button 101 | sidebar.append( 102 | '
«
' 103 | ); 104 | var sidebarbutton = $('#sidebarbutton'); 105 | light_color = sidebarbutton.css('background-color'); 106 | // find the height of the viewport to center the '<<' in the page 107 | var viewport_height; 108 | if (window.innerHeight) 109 | viewport_height = window.innerHeight; 110 | else 111 | viewport_height = $(window).height(); 112 | sidebarbutton.find('span').css({ 113 | 'display': 'block', 114 | 'margin-top': (viewport_height - sidebar.position().top - 20) / 2 115 | }); 116 | 117 | sidebarbutton.click(toggle_sidebar); 118 | sidebarbutton.attr('title', _('Collapse sidebar')); 119 | sidebarbutton.css({ 120 | 'color': '#FFFFFF', 121 | 'border-left': '1px solid ' + dark_color, 122 | 'font-size': '1.2em', 123 | 'cursor': 'pointer', 124 | 'height': bodywrapper.height(), 125 | 'padding-top': '1px', 126 | 'margin-left': ssb_width_expanded - 12 127 | }); 128 | 129 | sidebarbutton.hover( 130 | function () { 131 | $(this).css('background-color', dark_color); 132 | }, 133 | function () { 134 | $(this).css('background-color', light_color); 135 | } 136 | ); 137 | } 138 | 139 | function set_position_from_cookie() { 140 | if (!document.cookie) 141 | return; 142 | var items = document.cookie.split(';'); 143 | for(var k=0; k2;a== 12 | null&&(a=[]);if(y&&a.reduce===y)return e&&(c=b.bind(c,e)),f?a.reduce(c,d):a.reduce(c);j(a,function(a,b,i){f?d=c.call(e,d,a,b,i):(d=a,f=true)});if(!f)throw new TypeError("Reduce of empty array with no initial value");return d};b.reduceRight=b.foldr=function(a,c,d,e){var f=arguments.length>2;a==null&&(a=[]);if(z&&a.reduceRight===z)return e&&(c=b.bind(c,e)),f?a.reduceRight(c,d):a.reduceRight(c);var g=b.toArray(a).reverse();e&&!f&&(c=b.bind(c,e));return f?b.reduce(g,c,d,e):b.reduce(g,c)};b.find=b.detect= 13 | function(a,c,b){var e;E(a,function(a,g,h){if(c.call(b,a,g,h))return e=a,true});return e};b.filter=b.select=function(a,c,b){var e=[];if(a==null)return e;if(A&&a.filter===A)return a.filter(c,b);j(a,function(a,g,h){c.call(b,a,g,h)&&(e[e.length]=a)});return e};b.reject=function(a,c,b){var e=[];if(a==null)return e;j(a,function(a,g,h){c.call(b,a,g,h)||(e[e.length]=a)});return e};b.every=b.all=function(a,c,b){var e=true;if(a==null)return e;if(B&&a.every===B)return a.every(c,b);j(a,function(a,g,h){if(!(e= 14 | e&&c.call(b,a,g,h)))return n});return e};var E=b.some=b.any=function(a,c,d){c||(c=b.identity);var e=false;if(a==null)return e;if(C&&a.some===C)return a.some(c,d);j(a,function(a,b,h){if(e||(e=c.call(d,a,b,h)))return n});return!!e};b.include=b.contains=function(a,c){var b=false;if(a==null)return b;return p&&a.indexOf===p?a.indexOf(c)!=-1:b=E(a,function(a){return a===c})};b.invoke=function(a,c){var d=i.call(arguments,2);return b.map(a,function(a){return(b.isFunction(c)?c||a:a[c]).apply(a,d)})};b.pluck= 15 | function(a,c){return b.map(a,function(a){return a[c]})};b.max=function(a,c,d){if(!c&&b.isArray(a))return Math.max.apply(Math,a);if(!c&&b.isEmpty(a))return-Infinity;var e={computed:-Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;b>=e.computed&&(e={value:a,computed:b})});return e.value};b.min=function(a,c,d){if(!c&&b.isArray(a))return Math.min.apply(Math,a);if(!c&&b.isEmpty(a))return Infinity;var e={computed:Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;bd?1:0}),"value")};b.groupBy=function(a,c){var d={},e=b.isFunction(c)?c:function(a){return a[c]};j(a,function(a,b){var c=e(a,b);(d[c]||(d[c]=[])).push(a)});return d};b.sortedIndex=function(a, 17 | c,d){d||(d=b.identity);for(var e=0,f=a.length;e>1;d(a[g])=0})})};b.difference=function(a){var c=b.flatten(i.call(arguments,1));return b.filter(a,function(a){return!b.include(c,a)})};b.zip=function(){for(var a=i.call(arguments),c=b.max(b.pluck(a,"length")),d=Array(c),e=0;e=0;d--)b=[a[d].apply(this,b)];return b[0]}}; 24 | b.after=function(a,b){return a<=0?b():function(){if(--a<1)return b.apply(this,arguments)}};b.keys=J||function(a){if(a!==Object(a))throw new TypeError("Invalid object");var c=[],d;for(d in a)b.has(a,d)&&(c[c.length]=d);return c};b.values=function(a){return b.map(a,b.identity)};b.functions=b.methods=function(a){var c=[],d;for(d in a)b.isFunction(a[d])&&c.push(d);return c.sort()};b.extend=function(a){j(i.call(arguments,1),function(b){for(var d in b)a[d]=b[d]});return a};b.defaults=function(a){j(i.call(arguments, 25 | 1),function(b){for(var d in b)a[d]==null&&(a[d]=b[d])});return a};b.clone=function(a){return!b.isObject(a)?a:b.isArray(a)?a.slice():b.extend({},a)};b.tap=function(a,b){b(a);return a};b.isEqual=function(a,b){return q(a,b,[])};b.isEmpty=function(a){if(b.isArray(a)||b.isString(a))return a.length===0;for(var c in a)if(b.has(a,c))return false;return true};b.isElement=function(a){return!!(a&&a.nodeType==1)};b.isArray=o||function(a){return l.call(a)=="[object Array]"};b.isObject=function(a){return a===Object(a)}; 26 | b.isArguments=function(a){return l.call(a)=="[object Arguments]"};if(!b.isArguments(arguments))b.isArguments=function(a){return!(!a||!b.has(a,"callee"))};b.isFunction=function(a){return l.call(a)=="[object Function]"};b.isString=function(a){return l.call(a)=="[object String]"};b.isNumber=function(a){return l.call(a)=="[object Number]"};b.isNaN=function(a){return a!==a};b.isBoolean=function(a){return a===true||a===false||l.call(a)=="[object Boolean]"};b.isDate=function(a){return l.call(a)=="[object Date]"}; 27 | b.isRegExp=function(a){return l.call(a)=="[object RegExp]"};b.isNull=function(a){return a===null};b.isUndefined=function(a){return a===void 0};b.has=function(a,b){return I.call(a,b)};b.noConflict=function(){r._=G;return this};b.identity=function(a){return a};b.times=function(a,b,d){for(var e=0;e/g,">").replace(/"/g,""").replace(/'/g,"'").replace(/\//g,"/")};b.mixin=function(a){j(b.functions(a), 28 | function(c){K(c,b[c]=a[c])})};var L=0;b.uniqueId=function(a){var b=L++;return a?a+b:b};b.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var t=/.^/,u=function(a){return a.replace(/\\\\/g,"\\").replace(/\\'/g,"'")};b.template=function(a,c){var d=b.templateSettings,d="var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('"+a.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(d.escape||t,function(a,b){return"',_.escape("+ 29 | u(b)+"),'"}).replace(d.interpolate||t,function(a,b){return"',"+u(b)+",'"}).replace(d.evaluate||t,function(a,b){return"');"+u(b).replace(/[\r\n\t]/g," ")+";__p.push('"}).replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/\t/g,"\\t")+"');}return __p.join('');",e=new Function("obj","_",d);return c?e(c,b):function(a){return e.call(this,a,b)}};b.chain=function(a){return b(a).chain()};var m=function(a){this._wrapped=a};b.prototype=m.prototype;var v=function(a,c){return c?b(a).chain():a},K=function(a,c){m.prototype[a]= 30 | function(){var a=i.call(arguments);H.call(a,this._wrapped);return v(c.apply(b,a),this._chain)}};b.mixin(b);j("pop,push,reverse,shift,sort,splice,unshift".split(","),function(a){var b=k[a];m.prototype[a]=function(){var d=this._wrapped;b.apply(d,arguments);var e=d.length;(a=="shift"||a=="splice")&&e===0&&delete d[0];return v(d,this._chain)}});j(["concat","join","slice"],function(a){var b=k[a];m.prototype[a]=function(){return v(b.apply(this._wrapped,arguments),this._chain)}});m.prototype.chain=function(){this._chain= 31 | true;return this};m.prototype.value=function(){return this._wrapped}}).call(this); 32 | -------------------------------------------------------------------------------- /doc/_static/up-pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vergecurrency/verge-python/8b05f1589ec944f429e25299fb2f5d6e7641c141/doc/_static/up-pressed.png -------------------------------------------------------------------------------- /doc/_static/up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vergecurrency/verge-python/8b05f1589ec944f429e25299fb2f5d6e7641c141/doc/_static/up.png -------------------------------------------------------------------------------- /doc/apireference.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | API reference — verge-python 0.1.3 documentation 10 | 11 | 12 | 13 | 14 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 49 | 50 |
51 | 72 |
73 |
74 |

Previous topic

75 |

Examples

77 |

Next topic

78 |

vergerpc — Convenience functions

80 |

This Page

81 | 85 | 97 | 98 |
99 |
100 |
101 |
102 | 120 | 124 | 125 | -------------------------------------------------------------------------------- /doc/examples.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Examples — verge-python 0.1.3 documentation 10 | 11 | 12 | 13 | 14 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 51 | 52 |
53 |
54 |
55 |
56 | 57 |
58 |

Examples

59 |

A basic program that uses python-verge looks like this:

60 |

First, import the library and exceptions.

61 |
import vergerpc
 62 | from vergerpc.exceptions import InsufficientFunds
 63 | 
64 |
65 |

Then, we connect to the currently running verge instance of the current user on the local machine 66 | with one call to 67 | connect_to_local(). This returns a VERGEConnection objects:

68 |
conn = vergerpc.connect_to_local()
 69 | 
70 |
71 |

Try to move one verge from account testaccount to account testaccount2 using 72 | move(). Catch the InsufficientFunds 73 | exception in the case the originating account is broke:

74 |
try:
 75 |     conn.move("testaccount", "testaccount2", 1.0)
 76 | except InsufficientFunds,e:
 77 |     print "Account does not have enough funds available!"
 78 | 
79 |
80 |

Retrieve general server information with getinfo() and print some statistics:

81 |
info = conn.getinfo()
 82 | print "Blocks: %i" % info.blocks
 83 | print "Connections: %i" % info.connections
 84 | print "Difficulty: %f" % info.difficulty
 85 | 
86 |
87 |
88 | 89 | 90 |
91 |
92 |
93 |
94 |
95 |

Previous topic

96 |

Usage

98 |

Next topic

99 |

API reference

101 |

This Page

102 | 106 | 118 | 119 |
120 |
121 |
122 |
123 | 142 | 146 | 147 | -------------------------------------------------------------------------------- /doc/gettingstarted.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Getting Started — verge-python 0.1.3 documentation 10 | 11 | 12 | 13 | 14 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 49 | 50 |
51 |
52 |
53 |
54 | 55 |
56 |

Getting Started

57 | 70 |
71 | 72 | 73 |
74 |
75 |
76 |
77 |
78 |

Previous topic

79 |

verge-python - Easy-to-use VERGE API client.

81 |

Next topic

82 |

Introduction

84 |

This Page

85 | 89 | 101 | 102 |
103 |
104 |
105 |
106 | 124 | 128 | 129 | -------------------------------------------------------------------------------- /doc/index.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | verge-python - Easy-to-use VERGE API client. — verge-python 0.1.3 documentation 10 | 11 | 12 | 13 | 14 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 45 | 46 |
47 |
48 |
49 |
50 | 51 |
52 |

verge-python - Easy-to-use VERGE API client.

53 |

verge-python is a set of Python libraries that allows easy access to the 54 | verge peer-to-peer cryptocurrency client API.

55 |

Contents:

56 | 74 |
75 |

Indices and tables

76 | 81 |
82 |
83 | 84 | 85 |
86 |
87 |
88 |
89 |
90 |

Table Of Contents

91 | 97 | 98 |

Next topic

99 |

Getting Started

101 |

This Page

102 | 106 | 118 | 119 |
120 |
121 |
122 |
123 | 138 | 142 | 143 | -------------------------------------------------------------------------------- /doc/introduction.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Introduction — verge-python 0.1.3 documentation 10 | 11 | 12 | 13 | 14 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 51 | 52 |
53 |
54 |
55 |
56 | 57 |
58 |

Introduction

59 |

The goal of this library is to make it easier for:

60 |
    61 |
  • Payment gateways to support verge
  • 62 |
  • Merchant sites to integrate verge payments directly
  • 63 |
  • Other services that require (micro-)payments to use verge
  • 64 |
65 |

In this initial release it implements a thin wrapper around the 66 | VERGE JSON-RPC API. Using this API from Python directly is conceptually very simple, 67 | here is the example from the API 68 | documentation page:

69 |
from jsonrpc import ServiceProxy
 70 | 
 71 | access = ServiceProxy("http://user:password@127.0.0.1:8332")
 72 | access.getinfo()
 73 | access.listreceivedbyaddress(6)
 74 | access.sendtoaddress("11yEmxiMso2RsFVfBcCa616npBvGgxiBX", 10)
 75 | 
76 |
77 |

However, this approach has some disadvantages, one thing is that error handling is complex, as it 78 | requires manually checking the contents of JSONException objects.

79 |

verge-python attempts to create an even more friendly interface by wrapping the JSON-RPC API. The major advantages 80 | compared to a raw jsonrpc based approach are:

81 |
    82 |
  • Better exception handling. Exceptions are converted to subclasses of VERGEException.
  • 83 |
  • Automatic verge configuration loading. In case the verge -server or verged program runs on the same 84 | machine as the client script, and as the same user, the configuration file can automatically be parsed. This 85 | makes it unneccesary to explicitly specify a username and password. Of course, this is still possible.
  • 86 |
  • Documentation in Pythonish format. You are reading this right now.
  • 87 |
  • The functions 88 | getinfo(), listreceivedbyaccount(), 89 | listreceivedbyaddress(), 90 | listtransactions() and more return actual Python objects, instead of simply 91 | dictionaries. This makes for cleaner code, as the fields can simply be addressed with x.foo instead of 92 | x['foo'].
  • 93 |
94 |

The plan for future releases is to add a more high-level interface on top of this.

95 |
96 | 97 | 98 |
99 |
100 |
101 |
102 |
103 |

Previous topic

104 |

Getting Started

106 |

Next topic

107 |

Usage

109 |

This Page

110 | 114 | 126 | 127 |
128 |
129 |
130 |
131 | 150 | 154 | 155 | -------------------------------------------------------------------------------- /doc/objects.inv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vergecurrency/verge-python/8b05f1589ec944f429e25299fb2f5d6e7641c141/doc/objects.inv -------------------------------------------------------------------------------- /doc/py-modindex.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Python Module Index — verge-python 0.1.3 documentation 10 | 11 | 12 | 13 | 14 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 44 | 45 |
46 |
47 |
48 |
49 | 50 | 51 |

Python Module Index

52 | 53 |
54 | d 55 |
56 | 57 | 58 | 59 | 61 | 62 | 64 | 67 | 68 | 69 | 72 | 73 | 74 | 77 | 78 | 79 | 82 | 83 | 84 | 87 | 88 | 89 | 92 |
 
60 | d
65 | vergerpc 66 |
    70 | vergerpc.config 71 |
    75 | vergerpc.connection 76 |
    80 | vergerpc.data 81 |
    85 | vergerpc.exceptions 86 |
    90 | vergerpc.util 91 |
93 | 94 | 95 |
96 |
97 |
98 |
99 |
100 | 112 | 113 |
114 |
115 |
116 |
117 | 129 | 133 | 134 | -------------------------------------------------------------------------------- /doc/search.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Search — verge-python 0.1.3 documentation 10 | 11 | 12 | 13 | 14 | 23 | 24 | 25 | 26 | 27 | 28 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 49 | 50 |
51 |
52 |
53 |
54 | 55 |

Search

56 |
57 | 58 |

59 | Please activate JavaScript to enable the search 60 | functionality. 61 |

62 |
63 |

64 | From here you can search these documents. Enter your search 65 | words into the box below and click "search". Note that the search 66 | function will automatically search for all of the words. Pages 67 | containing fewer words won't appear in the result list. 68 |

69 |
70 | 71 | 72 | 73 |
74 | 75 |
76 | 77 |
78 | 79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 | 100 | 104 | 105 | -------------------------------------------------------------------------------- /doc/searchindex.js: -------------------------------------------------------------------------------- 1 | Search.setIndex({titles:["vergerpc.util — Generic utilities used by verge client library","vergerpc — Convenience functions","Examples","vergerpc.exceptions — Exception definitions","API reference","Introduction","vergerpc.data — VERGE RPC service, data objects","vergerpc.config — Utilities for reading verge configuration files","Getting Started","vergerpc.connection — Connect to VERGE server via JSON-RPC","Usage","verge-python - Easy-to-use VERGE API client."],objnames:{"0":["py","module","Python module"],"1":["py","exception","Python exception"],"2":["py","method","Python method"],"3":["py","class","Python class"],"4":["py","function","Python function"],"5":["py","attribute","Python attribute"]},objtypes:{"0":"py:module","1":"py:exception","2":"py:method","3":"py:class","4":"py:function","5":"py:attribute"},objects:{"":{vergerpc:[1,0,0,"-"]},"vergerpc.util":{DStruct:[0,3,1,""]},"vergerpc.connection":{VERGEConnection:[9,3,1,""]},vergerpc:{data:[6,0,0,"-"],config:[7,0,0,"-"],util:[0,0,0,"-"],connect_to_local:[1,4,1,""],exceptions:[3,0,0,"-"],connect_to_remote:[1,4,1,""],connection:[9,0,0,"-"]},"vergerpc.exceptions":{wrap_exception:[3,4,1,""],WalletError:[3,1,1,""],NotConnected:[3,1,1,""],SafeMode:[3,1,1,""],VERGEException:[3,1,1,""],DownloadingBlocks:[3,1,1,""],InvalidParameter:[3,1,1,""],WalletPassphraseIncorrect:[3,1,1,""],InvalidTransactionID:[3,5,1,""],WalletEncryptionFailed:[3,1,1,""],SendError:[3,5,1,""],WalletWrongEncState:[3,1,1,""],ClientException:[3,1,1,""],OutOfMemory:[3,1,1,""],TransportException:[3,1,1,""],WalletUnlockNeeded:[3,1,1,""],KeypoolRanOut:[3,1,1,""],WalletAlreadyUnlocked:[3,1,1,""],JSONTypeError:[3,1,1,""],InvalidAddressOrKey:[3,1,1,""],InsufficientFunds:[3,1,1,""],InvalidAmount:[3,5,1,""],InvalidAccountName:[3,1,1,""]},"vergerpc.data":{MiningInfo:[6,3,1,""],AccountInfo:[6,3,1,""],TransactionInfo:[6,3,1,""],WorkItem:[6,3,1,""],ServerInfo:[6,3,1,""],AddressInfo:[6,3,1,""],AddressValidation:[6,3,1,""]},"vergerpc.connection.VERGEConnection":{getaccountaddress:[9,2,1,""],listunspent:[9,2,1,""],getmininginfo:[9,2,1,""],getinfo:[9,2,1,""],getblock:[9,2,1,""],validateaddress:[9,2,1,""],getbalance:[9,2,1,""],listreceivedbyaccount:[9,2,1,""],sendfrom:[9,2,1,""],sendtoaddress:[9,2,1,""],stop:[9,2,1,""],backupwallet:[9,2,1,""],listtransactions:[9,2,1,""],keypoolrefill:[9,2,1,""],walletlock:[9,2,1,""],setaccount:[9,2,1,""],getrawtransaction:[9,2,1,""],getreceivedbyaccount:[9,2,1,""],decoderawtransaction:[9,2,1,""],getreceivedbyaddress:[9,2,1,""],move:[9,2,1,""],getgenerate:[9,2,1,""],setgenerate:[9,2,1,""],getconnectioncount:[9,2,1,""],signmessage:[9,2,1,""],gettransaction:[9,2,1,""],getblockcount:[9,2,1,""],getblocknumber:[9,2,1,""],verifymessage:[9,2,1,""],walletpassphrasechange:[9,2,1,""],getdifficulty:[9,2,1,""],getaddressesbyaccount:[9,2,1,""],walletpassphrase:[9,2,1,""],sendmany:[9,2,1,""],listaccounts:[9,2,1,""],dumpprivkey:[9,2,1,""],getaccount:[9,2,1,""],gettxout:[9,2,1,""],listreceivedbyaddress:[9,2,1,""],getwork:[9,2,1,""],getblockhash:[9,2,1,""],getnewaddress:[9,2,1,""],importprivkey:[9,2,1,""],gethashespersec:[9,2,1,""],createrawtransaction:[9,2,1,""],signrawtransaction:[9,2,1,""]},"vergerpc.config":{read_config_file:[7,4,1,""],read_default_config:[7,4,1,""]}},envversion:43,filenames:["vergerpc.util","vergerpc","examples","vergerpc.exceptions","apireference","introduction","vergerpc.data","vergerpc.config","gettingstarted","vergerpc.connection","usage","index"],terms:{currentblocktx:6,also:10,paytxfe:6,doe:2,credit:9,ran:3,etc:3,block:[3,9,2,6],spend:9,usag:[],even:5,clientexcept:3,raw:[9,5],again:[9,10],all:9,between:10,main:10,specifi:[9,5,10],get:[],time:9,proxi:6,getbal:[9,10],origin:2,argument:[9,1,7,10],about:[9,10],give:10,node:9,level:[3,5],isvalid:[6,10],signatur:9,dat:9,move:[9,2,6],access:[11,5],skip:9,args_t:[0,6],com:10,getconnectioncount:9,passphras:[3,9],invalidaccountnam:3,ismin:6,implement:5,enabl:[9,6],args_d:[0,6],last:9,associ:[9,6],pars:[5,7],tri:9,deni:3,program:[5,2],importprivkei:9,found:3,effici:0,output:9,insufficientfund:[3,2],load:5,friendli:5,handl:5,getgener:9,yoyodyn:10,timestamp:6,command:[3,10],same:5,unneccesari:5,either:[9,10],variou:9,"function":[],getinfo:[9,5,2,10,6],disadvantag:5,dont_rais:9,"class":[0,9,6,3],"case":[5,2],consid:9,abl:[9,10],insuffici:3,invalidtransactionid:3,server:[],util:[],sourc:9,connect_to_loc:[1,2,10],hashespersec:6,more:[0,5,10,3],createrawtransact:9,unspent:9,maxconf:9,account:[],wrap:5,pass:3,invalidparamet:3,p2p:3,raw_detail:3,error:[3,5,6,7],serial:9,verbos:9,thin:[9,5],getdifficulti:9,onc:10,readabl:9,retriev:2,actual:5,private_kei:9,out:[3,10],input:9,onli:[9,6],vergeconnect:[9,1,2],peer:[3,11],bar:10,broke:2,gettransact:9,four:10,easi:[],requir:[9,5],thank:10,call:[3,9,2],pay_to:10,given:[3,9],conceptu:5,automat:5,outofmemori:3,unlock:[3,9],incorrect:3,look:2,"true":[9,6],than:9,count:9,minconf:9,thi:[1,2,3,5,9,10],acct:9,defin:[3,9],unless:9,listunsp:9,proof:9,introduct:[],conf:10,altcoin:9,copi:9,queri:9,produc:9,conn:[9,2,10],oper:3,localhost:[9,1],validateaddress:[9,6,10],accountinfo:[9,6],must:10,you:[9,5,10],done:10,walletpassphras:[3,9],goal:5,first:[3,9,2,6],processor:[9,6],simpli:[5,10],fee:6,"default":[9,1,7,10],vergeaddress:9,code:[3,5],otheraccount:6,chain:9,transact:[3,9,6],password:[5,9,1,10],unicod:9,pleas:10,setaccount:9,credenti:10,add:[9,5],multipl:[9,10],specif:3,fund:[3,2,6],latest:9,dynam:0,script:5,verged:[3,5,10],enter:3,unexpect:3,never:3,support:5,own:1,make:5,unabl:7,transport:3,version:6,memori:[0,9,3],name:[3,9,6],after:[9,6,10],host:[9,1,10],certain:[9,10],most:[6,10],getreceivedbyaccount:9,testnet:6,transcat:9,gettxout:9,cryptocurr:11,disablesafemod:3,page:[11,5],befor:9,mode:3,separ:10,walletpassphraseincorrect:[3,9],gethashespersec:9,attempt:5,much:10,confirm:[9,6],list:9,directori:[9,7,10],ioerror:7,altern:1,easiest:10,subclass:5,should:9,walletalreadyunlock:3,occur:7,buffer:6,work:9,here:5,manual:5,fill:9,pythonish:5,thei:9,cleaner:5,from_:9,togeth:10,dstruct:[0,6],haven:9,machin:[5,1,2,10],minimum:9,site:5,previou:[9,10],jsonrpc:5,receiv:[3,9,6,10],human:9,getblocknumb:9,fail:[3,9],decod:9,high:5,filenam:[9,1,7],your:[9,10],compar:5,connect:[],"while":9,been:10,advanc:10,map:9,how:[],read_config_fil:7,approach:5,includeempti:9,simpl:[0,5,7],keep:9,redeemscript:9,serviceproxi:5,paramet:[3,9,10],base58:9,right:5,deprec:9,coin:[9,10],problem:3,midstat:6,per:[9,6],whether:[9,10],failur:3,mempool:9,transactioninfo:[9,6],standard:[1,7],from:[],sent:6,fromaccount:9,modul:11,blockchain:9,validat:6,open:7,two:10,success:9,precomput:6,solv:9,send:[9,6,10],"new":[9,10],convert:[3,5],getaccountaddress:9,getmininginfo:[9,6],allow:[9,10,11],integr:5,privat:9,signmessag:9,softwar:10,set:[],current:[7,9,2,10,6],remov:9,basic:[2,10],remot:[],perform:9,merchant:5,recommend:9,previous_transact:9,see:10,via:[],hostnam:10,limit:6,serverinfo:[9,6],valueerror:7,best:9,use_http:[9,1],which:[9,6],walletencryptionfail:3,mkzbybiq6dnoqekakpmjegydbw2yinqnht:9,locat:[1,7],senderror:3,signrawtransact:9,transportexcept:3,repres:9,listaccount:9,setgener:9,local:[1,2,10],gener:[],configur:[],rpc:[],oldest:6,categori:6,whose:9,walleterror:3,chang:9,pirat:10,search:11,possibl:[9,5],littl:6,transactiond:9,second:[9,6],sign:9,prepar:10,destin:9,timeout:9,recent:[9,6],form:9,longest:9,workitem:[9,6],vout:9,futur:5,"11yemximso2rsfvfbcca616npbvggxibx":5,number:[9,6],encod:9,sendmani:9,made:10,except:[],tovergeaddress:9,jsontypeerror:3,epoch:6,keypoolrefil:[3,9],explicitli:[5,10],getnewaddress:[9,10],were:6,safemod:3,as_dict:9,less:[0,9],begin:10,a9d4599e15b53f3eb531608ddb31f48c695c3d0b3538a6bda871e8b34f2f430c:9,todict:9,dure:3,maxim:9,comment_to:9,none:[3,9,1,7],notconnect:3,object:[],clear:10,yet:9,accept:10,network:[3,6],instanc:[1,2,10],place:10,collect:0,rpcuser:10,sendfrom:9,mstgam1apjejfswfaarvazhrm26mv5gl73:10,least:9,each:9,howev:[5,10],verge:[],mine:9,depend:9,"try":2,alia:3,off:9,txid:[9,6],"float":9,submit:9,anoth:9,vergeexcept:[3,5],downloadingblock:3,target:6,ship:10,automag:10,listreceivedbyaddress:[9,5,6],read:[],detail:[9,10],config:[],easier:5,encrypt:[3,9,6],custom:10,authent:9,amount:[9,6,10],addressvalid:[9,6],verifymessag:9,backup:9,getreceivedbyaddress:[9,10],control:[],sinc:6,home:[7,10],background:10,path:[9,1,7],verifi:9,fals:[9,1,6],endian:6,hash1:6,print:[2,10],still:[3,5],utxo:9,hexstr:9,have:[2,10],file:[],download:3,unspecifi:3,behav:9,wrong:3,alreadi:3,unlimit:9,oldpassphras:9,pai:6,structur:0,els:10,dictionari:[9,5],type:[3,9],walletwrongencst:3,definit:[],document:[5,10],complex:5,getaddressesbyaccount:9,initi:5,statist:2,balanc:[9,6,10],instead:[9,5],real:6,plan:5,want:10,turn:9,complet:[3,9],python:[],round:9,decrypt:9,rais:[3,9,7],interfac:5,anyth:10,log:[9,10],unlocked_until:6,belong:9,some:[5,2],wallet:[],"catch":2,book:9,walletlock:9,json:[],comment:9,bool:9,releas:5,cours:5,non:[1,7],conveni:[],run:[3,5,2,10],half:6,vergerpc:[],sandwidth:10,like:[0,9,2],payment:[9,5,10],keypool:[3,9,6],check:[5,10],state:[3,9,6],total:[9,6],newpassphras:9,wrap_except:3,string:9,msg:3,exampl:[],foo:[5,10],stop:9,size:6,sort:10,invalidaddressorkei:3,mai:9,usernam:5,format:[9,5,6],wai:10,testaccount2:2,messag:[9,6],field:5,invalid:[3,10],addressinfo:[9,6],neccesari:10,mani:10,data:[],measur:9,getwork:[9,6],gatewai:5,content:[11,5],pool:[9,6],user:[1,2,5,7,9,10],connect_to_remot:[1,10],base:[0,9,5,6,3],contain:9,top:5,"public":9,mininginfo:[9,6],safe:[3,9,10],superclass:3,protocol:3,keypoolranout:3,delimit:7,getblock:9,getaccount:9,walletpassphrasechang:9,rescan:9,hash:[9,6],listreceivedbyaccount:[9,5,6],decoderawtransact:9,better:5,"import":[9,5,2,10],currentblocks:6,str:9,inform:[9,2,10,6],getrawtransact:9,within:10,method:[9,10],correct:10,difficulti:[9,2,6],provid:[3,9,10],backupwallet:9,jsonexcept:5,info:[9,2],port:[9,1,10],listtransact:[9,5,6],pooledtx:6,empti:9,sendtoaddress:[9,5,10],advantag:5,rpcpassword:10,servic:[],ani:[3,9,6,10],address:[3,9,5,6,10],avail:[9,2],thing:5,creat:[9,5,10],valid:[9,10],scriptpubkei:9,major:5,includ:[9,6],write:10,walletunlockneed:3,dogeconf:10,keypoololdest:6,genproclimit:[9,6],disabl:9,option:[9,1,7],builtin:[0,9,3],lock:[9,6],index:[9,11],nearest:9,wrapper:[9,5],getblockcount:9,veri:5,valu:9,transfer:9,http:[5,10],privkei:9,store:[9,10],directli:5,can:[9,5,10],when:10,invalidamount:3,paid:[9,6],around:[9,5],now:5,constructor:9,need:9,flexibl:0,kei:[3,9,6],process:10,testaccount:2,hex:9,read_default_config:7,"return":[1,2,5,6,9,10],micro:5,bank:10,getblockhash:9,dumpprivkei:9,toaccount:9,other:[3,9,5,6],enough:2,client:[],result:9,namedtupl:0},titleterms:{config:7,conveni:1,how:10,"function":1,introduct:5,object:6,set:10,easi:11,refer:4,remot:10,server:9,util:[0,7],control:10,exampl:2,usag:10,vergerpc:[0,1,3,7,6,9],python:[11,10],via:9,connect:[9,10],account:10,wallet:10,definit:3,indic:11,file:7,tabl:11,read:7,from:10,except:3,servic:6,data:6,librari:0,verge:[0,6,7,9,10,11],gener:0,json:9,get:8,configur:7,rpc:[9,6],api:[4,10,11],start:8,client:[0,11]}}) -------------------------------------------------------------------------------- /doc/usage.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Usage — verge-python 0.1.3 documentation 10 | 11 | 12 | 13 | 14 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 51 | 52 |
53 |
54 |
55 |
56 | 57 |
58 |

Usage

59 |

See also the `main verge documentation`_ for details and background on setting up and 60 | using verged remotely.

61 |
62 |

Setting up verge for remote control

63 |

If you run VERGE with the -server argument, or if you run verged, it can be controlled 64 | either by sending it HTTP-JSON-RPC commands.

65 |

However, beginning with VERGE 0.3.3 you must create a verge.conf file in the VERGE data directory 66 | (default $HOME/.dogeconf) and set an RPC password:

67 |
rpcuser=anything
 68 | rpcpassword=anything
 69 | 
70 |
71 |

Once that is done, the easiest way to check whether VERGE accepts remote commands is by running 72 | VERGE again, with the command (and any parameters) as arguments. For example:

73 |
$ verged getinfo
 74 | 
75 |
76 |
77 |
78 |

Connecting to the wallet from Python

79 |

There are two functions for this:

80 |
81 |
Connecting to local verge instance
82 |

Use the function connect_to_local(). This automagically 83 | sorts out the connection to a verge process running on the current machine, 84 | for the current user.

85 |
conn = vergerpc.connect_to_local()
 86 | 
87 |
88 |
89 |
Connecting to a remote verge instance
90 |

Use the function connect_to_remote(). For this function 91 | it is neccesary to explicitly specify a hostname and port to connect to, and 92 | to provide user credentials for logging in.

93 |
conn = vergerpc.connect_to_remote('foo', 'bar', host='payments.yoyodyne.com', port=8332)
 94 | 
95 |
96 |
97 |
98 |
99 |
100 |

How to use the API

101 |

For basic sending and receiving of payments, the four most important methods are

102 |
103 |
Getting the current balance
104 |

Use the method getbalance() to get the current server balance.

105 |
print "Your balance is %f" % (conn.getbalance(),)
106 | 
107 |
108 |
109 |
Check a customer address for validity and get information about it
110 |

This can be done with the method validateaddress().

111 |
rv = conn.validateaddress(foo)
112 | if rv.isvalid:
113 |     print "The address that you provided is valid"
114 | else:
115 |     print "The address that you provided is invalid, please correct"
116 | 
117 |
118 |
119 |
Sending payments
120 |

The method sendtoaddress() sends a specified 121 | amount of coins to a specified address.

122 |
conn.sendtoaddress("msTGAm1ApjEJfsWfAaRVaZHRm26mv5GL73", 20.0)
123 | 
124 |
125 |
126 |
Get a new address for accepting payments
127 |

To accept payments, use the method getnewaddress() 128 | to generate a new address. Give this address to the customer and store it in a safe place, to be able to check 129 | when the payment to this address has been made.

130 |
pay_to = conn.getnewaddress()
131 | print "We will ship the pirate sandwidth after payment of 200 coins to ", pay_to
132 | 
133 |
134 |
135 |
Check how much has been received at a certain address
136 |

The method getreceivedbyaddress() 137 | returns how many verges have been received at a certain address. Together with the 138 | previous function, this can be used to check whether a payment has been made 139 | by the customer.

140 |
amount = conn.getreceivedbyaddress(pay_to)
141 | if amount > 200.0:
142 |     print "Thanks, your sandwidth will be prepared and shipped."
143 | 
144 |
145 |
146 |
147 |
148 |
149 |

The account API

150 |

More advanced usage of verge allows multiple accounts within one wallet. This 151 | can be useful if you are writing software for a bank, or 152 | simply want to have a clear separation between customers payments.

153 |

For this, see the Account API documentation.

154 |
155 |
156 | 157 | 158 |
159 |
160 |
161 |
162 |
163 |

Table Of Contents

164 | 173 | 174 |

Previous topic

175 |

Introduction

177 |

Next topic

178 |

Examples

180 |

This Page

181 | 185 | 197 | 198 |
199 |
200 |
201 |
202 | 221 | 225 | 226 | -------------------------------------------------------------------------------- /doc/vergerpc.config.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | vergerpc.config — Utilities for reading verge configuration files — verge-python 0.1.3 documentation 10 | 11 | 12 | 13 | 14 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 47 | 48 |
49 |
50 |
51 |
52 | 53 |
54 |

vergerpc.config — Utilities for reading verge configuration files

55 |

Utilities for reading verge configuration files.

56 |
57 |
58 | vergerpc.config.read_config_file(filename)
59 |

Read a simple '='-delimited config file. 60 | Raises IOError if unable to open file, or ValueError 61 | if an parse error occurs.

62 |
63 | 64 |
65 |
66 | vergerpc.config.read_default_config(filename=None)
67 |

Read verge default configuration from the current user’s home directory.

68 |

Arguments:

69 |
    70 |
  • filename: Path to a configuration file in a non-standard location (optional)
  • 71 |
72 |
73 | 74 |
75 | 76 | 77 |
78 |
79 |
80 |
81 |
82 |

Previous topic

83 |

vergerpc.data — VERGE RPC service, data objects

85 |

This Page

86 | 90 | 102 | 103 |
104 |
105 |
106 |
107 | 123 | 127 | 128 | -------------------------------------------------------------------------------- /doc/vergerpc.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | vergerpc — Convenience functions — verge-python 0.1.3 documentation 10 | 11 | 12 | 13 | 14 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 51 | 52 |
53 |
54 |
55 |
56 | 57 |
58 |

vergerpc — Convenience functions

59 |

verge-python - Easy-to-use VERGE API client

60 |
61 |
62 | vergerpc.connect_to_local(filename=None)
63 |

Connect to default VERGE instance owned by this user, on this machine.

64 |

Returns a VERGEConnection object.

65 |

Arguments:

66 |
67 |
    68 |
  • filename: Path to a configuration file in a non-standard location (optional)
  • 69 |
70 |
71 |
72 | 73 |
74 |
75 | vergerpc.connect_to_remote(user, password, host='localhost', port=22555, use_https=False)
76 |

Connect to remote or alternative local verge client instance.

77 |

Returns a VERGEConnection object.

78 |
79 | 80 |
81 | 82 | 83 |
84 |
85 |
86 |
87 |
88 |

Previous topic

89 |

API reference

91 |

Next topic

92 |

vergerpc.connection — Connect to VERGE server via JSON-RPC

94 |

This Page

95 | 99 | 111 | 112 |
113 |
114 |
115 |
116 | 135 | 139 | 140 | -------------------------------------------------------------------------------- /doc/vergerpc.util.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | vergerpc.util — Generic utilities used by verge client library — verge-python 0.1.3 documentation 10 | 11 | 12 | 13 | 14 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 41 | 42 |
43 |
44 |
45 |
46 | 47 |
48 |

vergerpc.util — Generic utilities used by verge client library

49 |

Generic utilities used by verge client library.

50 |
51 |
52 | class vergerpc.util.DStruct(*args_t, **args_d)
53 |

Bases: builtins.object

54 |

Simple dynamic structure, like collections.namedtuple but more flexible 55 | (and less memory-efficient)

56 |
57 | 58 |
59 | 60 | 61 |
62 |
63 |
64 |
65 |
66 |

This Page

67 | 71 | 83 | 84 |
85 |
86 |
87 |
88 | 100 | 104 | 105 | -------------------------------------------------------------------------------- /release_process.txt: -------------------------------------------------------------------------------- 1 | Release process 2 | 3 | - Update Changelog (using git history output from dist-tools/changelog.sh) 4 | 5 | - Change version numbers in setup.py and sphinx/source/conf.py 6 | 7 | - Commit 8 | 9 | - Make tag and upload to github 10 | 11 | - git tag -a vX.X 12 | - git push origin vX.X 13 | 14 | - Run make in doc/ 15 | 16 | - Update documentation on github 17 | 18 | - git checkout gh_pages 19 | - rm -r doc 20 | - mkdir doc 21 | - cp -r sphinx/build/html/* doc/ 22 | - git add doc 23 | - git commit -a 24 | - git push origin gh-pages:gh-pages 25 | 26 | - Upload to pypi 27 | 28 | - python setup.py sdist upload 29 | 30 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup, find_packages 2 | setup( 3 | name='verge-python', 4 | version='0.1.3', 5 | description='Friendly VERGE JSON-RPC API binding for Python', 6 | long_description='This package allows performing commands such as listing the current balance' 7 | ' and sending coins to the original client from Python. The communication with the' 8 | ' client happens over JSON-RPC.', 9 | url='https://github.com/vergecurrency/verge-python', 10 | classifiers=[ 11 | 'Development Status :: 4 - Beta', 12 | 'Environment :: Console', 13 | 'Environment :: Web Environment', 14 | 'Intended Audience :: Developers', 15 | 'Programming Language :: Python', 16 | 'License :: OSI Approved :: MIT License', 17 | 'Topic :: Office/Business :: Financial' 18 | ], 19 | packages=find_packages("src"), 20 | package_dir={'': 'src'} 21 | ) 22 | -------------------------------------------------------------------------------- /sphinx/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | PAPER = 8 | BUILDDIR = build 9 | 10 | # Internal variables. 11 | PAPEROPT_a4 = -D latex_paper_size=a4 12 | PAPEROPT_letter = -D latex_paper_size=letter 13 | ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source 14 | 15 | .PHONY: help clean html dirhtml pickle json htmlhelp qthelp latex changes linkcheck doctest 16 | 17 | help: 18 | @echo "Please use \`make ' where is one of" 19 | @echo " html to make standalone HTML files" 20 | @echo " dirhtml to make HTML files named index.html in directories" 21 | @echo " pickle to make pickle files" 22 | @echo " json to make JSON files" 23 | @echo " htmlhelp to make HTML files and a HTML help project" 24 | @echo " qthelp to make HTML files and a qthelp project" 25 | @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" 26 | @echo " changes to make an overview of all changed/added/deprecated items" 27 | @echo " linkcheck to check all external links for integrity" 28 | @echo " doctest to run all doctests embedded in the documentation (if enabled)" 29 | 30 | clean: 31 | -rm -rf $(BUILDDIR)/* 32 | 33 | html: 34 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html 35 | @echo 36 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." 37 | 38 | dirhtml: 39 | $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml 40 | @echo 41 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." 42 | 43 | pickle: 44 | $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle 45 | @echo 46 | @echo "Build finished; now you can process the pickle files." 47 | 48 | json: 49 | $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json 50 | @echo 51 | @echo "Build finished; now you can process the JSON files." 52 | 53 | htmlhelp: 54 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp 55 | @echo 56 | @echo "Build finished; now you can run HTML Help Workshop with the" \ 57 | ".hhp project file in $(BUILDDIR)/htmlhelp." 58 | 59 | qthelp: 60 | $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp 61 | @echo 62 | @echo "Build finished; now you can run "qcollectiongenerator" with the" \ 63 | ".qhcp project file in $(BUILDDIR)/qthelp, like this:" 64 | @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/verge-python.qhcp" 65 | @echo "To view the help file:" 66 | @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/verge-python.qhc" 67 | 68 | latex: 69 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 70 | @echo 71 | @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." 72 | @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \ 73 | "run these through (pdf)latex." 74 | 75 | changes: 76 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes 77 | @echo 78 | @echo "The overview file is in $(BUILDDIR)/changes." 79 | 80 | linkcheck: 81 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck 82 | @echo 83 | @echo "Link check complete; look for any errors in the above output " \ 84 | "or in $(BUILDDIR)/linkcheck/output.txt." 85 | 86 | doctest: 87 | $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest 88 | @echo "Testing of doctests in the sources finished, look at the " \ 89 | "results in $(BUILDDIR)/doctest/output.txt." 90 | -------------------------------------------------------------------------------- /sphinx/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | REM Command file for Sphinx documentation 4 | 5 | set SPHINXBUILD=sphinx-build 6 | set BUILDDIR=build 7 | set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% source 8 | if NOT "%PAPER%" == "" ( 9 | set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% 10 | ) 11 | 12 | if "%1" == "" goto help 13 | 14 | if "%1" == "help" ( 15 | :help 16 | echo.Please use `make ^` where ^ is one of 17 | echo. html to make standalone HTML files 18 | echo. dirhtml to make HTML files named index.html in directories 19 | echo. pickle to make pickle files 20 | echo. json to make JSON files 21 | echo. htmlhelp to make HTML files and a HTML help project 22 | echo. qthelp to make HTML files and a qthelp project 23 | echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter 24 | echo. changes to make an overview over all changed/added/deprecated items 25 | echo. linkcheck to check all external links for integrity 26 | echo. doctest to run all doctests embedded in the documentation if enabled 27 | goto end 28 | ) 29 | 30 | if "%1" == "clean" ( 31 | for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i 32 | del /q /s %BUILDDIR%\* 33 | goto end 34 | ) 35 | 36 | if "%1" == "html" ( 37 | %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html 38 | echo. 39 | echo.Build finished. The HTML pages are in %BUILDDIR%/html. 40 | goto end 41 | ) 42 | 43 | if "%1" == "dirhtml" ( 44 | %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml 45 | echo. 46 | echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. 47 | goto end 48 | ) 49 | 50 | if "%1" == "pickle" ( 51 | %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle 52 | echo. 53 | echo.Build finished; now you can process the pickle files. 54 | goto end 55 | ) 56 | 57 | if "%1" == "json" ( 58 | %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json 59 | echo. 60 | echo.Build finished; now you can process the JSON files. 61 | goto end 62 | ) 63 | 64 | if "%1" == "htmlhelp" ( 65 | %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp 66 | echo. 67 | echo.Build finished; now you can run HTML Help Workshop with the ^ 68 | .hhp project file in %BUILDDIR%/htmlhelp. 69 | goto end 70 | ) 71 | 72 | if "%1" == "qthelp" ( 73 | %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp 74 | echo. 75 | echo.Build finished; now you can run "qcollectiongenerator" with the ^ 76 | .qhcp project file in %BUILDDIR%/qthelp, like this: 77 | echo.^> qcollectiongenerator %BUILDDIR%\qthelp\verge-python.qhcp 78 | echo.To view the help file: 79 | echo.^> assistant -collectionFile %BUILDDIR%\qthelp\verge-python.ghc 80 | goto end 81 | ) 82 | 83 | if "%1" == "latex" ( 84 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 85 | echo. 86 | echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. 87 | goto end 88 | ) 89 | 90 | if "%1" == "changes" ( 91 | %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes 92 | echo. 93 | echo.The overview file is in %BUILDDIR%/changes. 94 | goto end 95 | ) 96 | 97 | if "%1" == "linkcheck" ( 98 | %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck 99 | echo. 100 | echo.Link check complete; look for any errors in the above output ^ 101 | or in %BUILDDIR%/linkcheck/output.txt. 102 | goto end 103 | ) 104 | 105 | if "%1" == "doctest" ( 106 | %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest 107 | echo. 108 | echo.Testing of doctests in the sources finished, look at the ^ 109 | results in %BUILDDIR%/doctest/output.txt. 110 | goto end 111 | ) 112 | 113 | :end 114 | -------------------------------------------------------------------------------- /sphinx/source/apireference.rst: -------------------------------------------------------------------------------- 1 | ================= 2 | API reference 3 | ================= 4 | 5 | .. toctree:: 6 | :maxdepth: 2 7 | 8 | vergerpc.rst 9 | vergerpc.connection.rst 10 | vergerpc.exceptions.rst 11 | vergerpc.data.rst 12 | vergerpc.config.rst 13 | 14 | -------------------------------------------------------------------------------- /sphinx/source/conf.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # verge-python documentation build configuration file, created by 4 | # sphinx-quickstart on Fri Dec 10 21:45:49 2010. 5 | # 6 | # This file is execfile()d with the current directory set to its containing dir. 7 | # 8 | # Note that not all possible configuration values are present in this 9 | # autogenerated file. 10 | # 11 | # All configuration values have a default; values that are commented out 12 | # serve to show the default. 13 | 14 | import sys, os 15 | 16 | # If extensions (or modules to document with autodoc) are in another directory, 17 | # add these directories to sys.path here. If the directory is relative to the 18 | # documentation root, use os.path.abspath to make it absolute, like shown here. 19 | sys.path.append(os.path.abspath('../../src')) 20 | 21 | # -- General configuration ----------------------------------------------------- 22 | 23 | # Add any Sphinx extension module names here, as strings. They can be extensions 24 | # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. 25 | extensions = ['sphinx.ext.autodoc'] 26 | 27 | # Add any paths that contain templates here, relative to this directory. 28 | templates_path = ['_templates'] 29 | 30 | # The suffix of source filenames. 31 | source_suffix = '.rst' 32 | 33 | # The encoding of source files. 34 | #source_encoding = 'utf-8' 35 | 36 | # The master toctree document. 37 | master_doc = 'index' 38 | 39 | # General information about the project. 40 | project = u'verge-python' 41 | copyright = u'2016, verge-python developers' 42 | 43 | # The version info for the project you're documenting, acts as replacement for 44 | # |version| and |release|, also used in various other places throughout the 45 | # built documents. 46 | # 47 | # The short X.Y version. 48 | version = '0.1' 49 | # The full version, including alpha/beta/rc tags. 50 | release = '0.1.3' 51 | 52 | # The language for content autogenerated by Sphinx. Refer to documentation 53 | # for a list of supported languages. 54 | #language = None 55 | 56 | # There are two options for replacing |today|: either, you set today to some 57 | # non-false value, then it is used: 58 | #today = '' 59 | # Else, today_fmt is used as the format for a strftime call. 60 | #today_fmt = '%B %d, %Y' 61 | 62 | # List of documents that shouldn't be included in the build. 63 | #unused_docs = [] 64 | 65 | # List of directories, relative to source directory, that shouldn't be searched 66 | # for source files. 67 | exclude_trees = [] 68 | 69 | # The reST default role (used for this markup: `text`) to use for all documents. 70 | #default_role = None 71 | 72 | # If true, '()' will be appended to :func: etc. cross-reference text. 73 | #add_function_parentheses = True 74 | 75 | # If true, the current module name will be prepended to all description 76 | # unit titles (such as .. function::). 77 | #add_module_names = True 78 | 79 | # If true, sectionauthor and moduleauthor directives will be shown in the 80 | # output. They are ignored by default. 81 | #show_authors = False 82 | 83 | # The name of the Pygments (syntax highlighting) style to use. 84 | pygments_style = 'sphinx' 85 | 86 | # A list of ignored prefixes for module index sorting. 87 | #modindex_common_prefix = [] 88 | 89 | 90 | # -- Options for HTML output --------------------------------------------------- 91 | 92 | # The theme to use for HTML and HTML Help pages. Major themes that come with 93 | # Sphinx are currently 'default' and 'sphinxdoc'. 94 | html_theme = 'default' 95 | 96 | # Theme options are theme-specific and customize the look and feel of a theme 97 | # further. For a list of options available for each theme, see the 98 | # documentation. 99 | #html_theme_options = {} 100 | 101 | # Add any paths that contain custom themes here, relative to this directory. 102 | html_theme_path = ['_theme'] 103 | #html_theme_path = [] 104 | 105 | # The name for this set of Sphinx documents. If None, it defaults to 106 | # " v documentation". 107 | #html_title = None 108 | 109 | # A shorter title for the navigation bar. Default is the same as html_title. 110 | #html_short_title = None 111 | 112 | # The name of an image file (relative to this directory) to place at the top 113 | # of the sidebar. 114 | #html_logo = None 115 | 116 | # The name of an image file (within the static path) to use as favicon of the 117 | # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 118 | # pixels large. 119 | #html_favicon = None 120 | 121 | # Add any paths that contain custom static files (such as style sheets) here, 122 | # relative to this directory. They are copied after the builtin static files, 123 | # so a file named "default.css" will overwrite the builtin "default.css". 124 | html_static_path = ['_static'] 125 | 126 | # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, 127 | # using the given strftime format. 128 | #html_last_updated_fmt = '%b %d, %Y' 129 | 130 | # If true, SmartyPants will be used to convert quotes and dashes to 131 | # typographically correct entities. 132 | #html_use_smartypants = True 133 | 134 | # Custom sidebar templates, maps document names to template names. 135 | #html_sidebars = {} 136 | 137 | # Additional templates that should be rendered to pages, maps page names to 138 | # template names. 139 | #html_additional_pages = {} 140 | 141 | # If false, no module index is generated. 142 | #html_use_modindex = True 143 | 144 | # If false, no index is generated. 145 | #html_use_index = True 146 | 147 | # If true, the index is split into individual pages for each letter. 148 | #html_split_index = False 149 | 150 | # If true, links to the reST sources are added to the pages. 151 | #html_show_sourcelink = True 152 | 153 | # If true, an OpenSearch description file will be output, and all pages will 154 | # contain a tag referring to it. The value of this option must be the 155 | # base URL from which the finished HTML is served. 156 | #html_use_opensearch = '' 157 | 158 | # If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml"). 159 | #html_file_suffix = '' 160 | 161 | # Output file base name for HTML help builder. 162 | htmlhelp_basename = 'verge-pythondoc' 163 | 164 | 165 | # -- Options for LaTeX output -------------------------------------------------- 166 | 167 | # The paper size ('letter' or 'a4'). 168 | #latex_paper_size = 'letter' 169 | 170 | # The font size ('10pt', '11pt' or '12pt'). 171 | #latex_font_size = '10pt' 172 | 173 | # Grouping the document tree into LaTeX files. List of tuples 174 | # (source start file, target name, title, author, documentclass [howto/manual]). 175 | latex_documents = [ 176 | ('index', 'verge-python.tex', u'verge-python Documentation', 177 | u'Witchspace', 'manual'), 178 | ] 179 | 180 | # The name of an image file (relative to this directory) to place at the top of 181 | # the title page. 182 | #latex_logo = None 183 | 184 | # For "manual" documents, if this is true, then toplevel headings are parts, 185 | # not chapters. 186 | #latex_use_parts = False 187 | 188 | # Additional stuff for the LaTeX preamble. 189 | #latex_preamble = '' 190 | 191 | # Documents to append as an appendix to all manuals. 192 | #latex_appendices = [] 193 | 194 | # If false, no module index is generated. 195 | #latex_use_modindex = True 196 | -------------------------------------------------------------------------------- /sphinx/source/examples.rst: -------------------------------------------------------------------------------- 1 | **************************** 2 | Examples 3 | **************************** 4 | 5 | A basic program that uses ``python-verge`` looks like this: 6 | 7 | First, import the library and exceptions. 8 | 9 | :: 10 | 11 | import vergerpc 12 | from vergerpc.exceptions import InsufficientFunds 13 | 14 | Then, we connect to the currently running ``verge`` instance of the current user on the local machine 15 | with one call to 16 | :func:`~vergerpc.connect_to_local`. This returns a :class:`~vergerpc.connection.VERGEConnection` objects: 17 | 18 | :: 19 | 20 | conn = vergerpc.connect_to_local() 21 | 22 | Try to move one verge from account ``testaccount`` to account ``testaccount2`` using 23 | :func:`~vergerpc.connection.VERGEConnection.move`. Catch the :class:`~vergerpc.exceptions.InsufficientFunds` 24 | exception in the case the originating account is broke: 25 | 26 | :: 27 | 28 | try: 29 | conn.move("testaccount", "testaccount2", 100.0) 30 | except InsufficientFunds,e: 31 | print "Account does not have enough funds available!" 32 | 33 | 34 | Retrieve general server information with :func:`~vergerpc.connection.VERGEConnection.getinfo` and print some statistics: 35 | 36 | :: 37 | 38 | info = conn.getinfo() 39 | print "Blocks: %i" % info.blocks 40 | print "Connections: %i" % info.connections 41 | print "Difficulty: %f" % info.difficulty 42 | 43 | 44 | -------------------------------------------------------------------------------- /sphinx/source/gettingstarted.rst: -------------------------------------------------------------------------------- 1 | ================= 2 | Getting Started 3 | ================= 4 | 5 | .. toctree:: 6 | :maxdepth: 2 7 | 8 | introduction.rst 9 | usage.rst 10 | examples.rst 11 | 12 | -------------------------------------------------------------------------------- /sphinx/source/index.rst: -------------------------------------------------------------------------------- 1 | ================================================== 2 | verge-python - Easy-to-use VERGE API client. 3 | ================================================== 4 | 5 | ``verge-python`` is a set of Python libraries that allows easy access to the 6 | verge_ peer-to-peer cryptocurrency client API. 7 | 8 | Contents: 9 | 10 | .. toctree:: 11 | :maxdepth: 2 12 | 13 | gettingstarted.rst 14 | apireference.rst 15 | 16 | Indices and tables 17 | ================== 18 | 19 | * :ref:`genindex` 20 | * :ref:`modindex` 21 | * :ref:`search` 22 | 23 | .. _verge: http://vergecurrency.com/ 24 | 25 | -------------------------------------------------------------------------------- /sphinx/source/introduction.rst: -------------------------------------------------------------------------------- 1 | **************************** 2 | Introduction 3 | **************************** 4 | 5 | The goal of this library is to make it easier for: 6 | 7 | - Payment gateways to support verge 8 | - Merchant sites to integrate verge payments directly 9 | - Other services that require (micro-)payments to use verge 10 | 11 | In this initial release it implements a thin wrapper around the 12 | VERGE JSON-RPC API. Using this API from Python directly is conceptually very simple, 13 | here is the example from the API 14 | documentation page: 15 | 16 | :: 17 | 18 | from jsonrpc import ServiceProxy 19 | 20 | access = ServiceProxy("http://user:password@127.0.0.1:20102") 21 | access.getinfo() 22 | access.listreceivedbyaddress(6) 23 | access.sendtoaddress("11yEmxiMso2RsFVfBcCa616npBvGgxiBX", 1000) 24 | 25 | However, this approach has some disadvantages, one thing is that error handling is complex, as it 26 | requires manually checking the contents of :const:`JSONException` objects. 27 | 28 | ``verge-python`` attempts to create an even more friendly interface by wrapping the JSON-RPC API. The major advantages 29 | compared to a raw ``jsonrpc`` based approach are: 30 | 31 | - Better exception handling. Exceptions are converted to subclasses of :class:`~vergerpc.exceptions.VERGEException`. 32 | 33 | - Automatic verge configuration loading. In case the ``verge -server`` or ``verged`` program runs on the same 34 | machine as the client script, and as the same user, the configuration file can automatically be parsed. This 35 | makes it unneccesary to explicitly specify a *username* and *password*. Of course, this is still possible. 36 | 37 | - Documentation in Pythonish format. You are reading this right now. 38 | 39 | - The functions 40 | :func:`~vergerpc.connection.VERGEConnection.getinfo`, :func:`~vergerpc.connection.VERGEConnection.listreceivedbyaccount`, 41 | :func:`~vergerpc.connection.VERGEConnection.listreceivedbyaddress`, 42 | :func:`~vergerpc.connection.VERGEConnection.listtransactions` and more return actual Python objects, instead of simply 43 | dictionaries. This makes for cleaner code, as the fields can simply be addressed with ``x.foo`` instead of 44 | ``x['foo']``. 45 | 46 | The plan for future releases is to add a more high-level interface on top of this. 47 | 48 | -------------------------------------------------------------------------------- /sphinx/source/usage.rst: -------------------------------------------------------------------------------- 1 | ================= 2 | Usage 3 | ================= 4 | 5 | See also the `main verge documentation`_ for details and background on setting up and 6 | using verged remotely. 7 | 8 | Setting up verge for remote control 9 | ------------------------------------- 10 | 11 | If you run VERGE with the ``-server`` argument, or if you run ``verged``, it can be controlled 12 | either by sending it HTTP-JSON-RPC commands. 13 | 14 | However, beginning with VERGE 0.3.3 you must create a ``VERGE.conf`` file in the VERGE data directory 15 | (default ``$HOME/.vergeconf``) and set an RPC password: 16 | 17 | :: 18 | 19 | rpcuser=anything 20 | rpcpassword=anything 21 | 22 | Once that is done, the easiest way to check whether VERGE accepts remote commands is by running 23 | VERGE again, with the command (and any parameters) as arguments. For example: 24 | 25 | :: 26 | 27 | $ verged getinfo 28 | 29 | Connecting to the wallet from Python 30 | ------------------------------------- 31 | 32 | There are two functions for this: 33 | 34 | *Connecting to local verge instance* 35 | Use the function :func:`~vergerpc.connect_to_local`. This automagically 36 | sorts out the connection to a verge process running on the current machine, 37 | for the current user. 38 | 39 | :: 40 | 41 | conn = vergerpc.connect_to_local() 42 | 43 | *Connecting to a remote verge instance* 44 | Use the function :func:`~vergerpc.connect_to_remote`. For this function 45 | it is neccesary to explicitly specify a hostname and port to connect to, and 46 | to provide user credentials for logging in. 47 | 48 | :: 49 | 50 | conn = vergerpc.connect_to_remote('foo', 'bar', host='payments.yoyodyne.com', port=20102) 51 | 52 | 53 | How to use the API 54 | ------------------------------------- 55 | 56 | For basic sending and receiving of payments, the four most important methods are 57 | 58 | *Getting the current balance* 59 | Use the method :func:`~vergerpc.connection.VERGEConnection.getbalance` to get the current server balance. 60 | 61 | :: 62 | 63 | print "Your balance is %f" % (conn.getbalance(),) 64 | 65 | *Check a customer address for validity and get information about it* 66 | This can be done with the method :func:`~vergerpc.connection.VERGEConnection.validateaddress`. 67 | 68 | :: 69 | 70 | rv = conn.validateaddress(foo) 71 | if rv.isvalid: 72 | print "The address that you provided is valid" 73 | else: 74 | print "The address that you provided is invalid, please correct" 75 | 76 | *Sending payments* 77 | The method :func:`~vergerpc.connection.VERGEConnection.sendtoaddress` sends a specified 78 | amount of coins to a specified address. 79 | 80 | :: 81 | 82 | conn.sendtoaddress("msTGAm1ApjEJfsWfAaRVaZHRm26mv5GL73", 10000.0) 83 | 84 | *Get a new address for accepting payments* 85 | To accept payments, use the method :func:`~vergerpc.connection.VERGEConnection.getnewaddress` 86 | to generate a new address. Give this address to the customer and store it in a safe place, to be able to check 87 | when the payment to this address has been made. 88 | 89 | :: 90 | 91 | pay_to = conn.getnewaddress() 92 | print "We will ship the pirate sandwidth after payment of 200 coins to ", pay_to 93 | 94 | *Check how much has been received at a certain address* 95 | The method :func:`~vergerpc.connection.VERGEConnection.getreceivedbyaddress` 96 | returns how many verges have been received at a certain address. Together with the 97 | previous function, this can be used to check whether a payment has been made 98 | by the customer. 99 | 100 | :: 101 | 102 | amount = conn.getreceivedbyaddress(pay_to) 103 | if amount > 20000.0: 104 | print "Thanks, your order will be prepared and shipped." 105 | 106 | 107 | 108 | 109 | The account API 110 | ------------------------------------- 111 | More advanced usage of verge allows multiple accounts within one wallet. This 112 | can be useful if you are writing software for a bank, or 113 | simply want to have a clear separation between customers payments. 114 | 115 | For this, see the `Account API`_ documentation. 116 | 117 | .. _main bitcoin documentation: https://en.bitcoin.it/wiki/Main_Page 118 | .. _account API: https://en.bitcoin.it/wiki/Accounts_explained 119 | 120 | 121 | -------------------------------------------------------------------------------- /sphinx/source/vergerpc.config.rst: -------------------------------------------------------------------------------- 1 | :mod:`vergerpc.config` --- Utilities for reading verge configuration files 2 | ==================================================================================== 3 | 4 | .. automodule:: vergerpc.config 5 | :members: 6 | :show-inheritance: 7 | 8 | -------------------------------------------------------------------------------- /sphinx/source/vergerpc.connection.rst: -------------------------------------------------------------------------------- 1 | :mod:`vergerpc.connection` --- Connect to VERGE server via JSON-RPC 2 | ==================================================================================== 3 | 4 | .. automodule:: vergerpc.connection 5 | :members: 6 | :show-inheritance: 7 | 8 | 9 | -------------------------------------------------------------------------------- /sphinx/source/vergerpc.data.rst: -------------------------------------------------------------------------------- 1 | :mod:`vergerpc.data` --- VERGE RPC service, data objects 2 | ==================================================================================== 3 | 4 | .. automodule:: vergerpc.data 5 | :members: 6 | :show-inheritance: 7 | 8 | -------------------------------------------------------------------------------- /sphinx/source/vergerpc.exceptions.rst: -------------------------------------------------------------------------------- 1 | :mod:`vergerpc.exceptions` --- Exception definitions 2 | ==================================================================================== 3 | 4 | .. automodule:: vergerpc.exceptions 5 | :members: 6 | :show-inheritance: 7 | 8 | -------------------------------------------------------------------------------- /sphinx/source/vergerpc.rst: -------------------------------------------------------------------------------- 1 | :mod:`vergerpc` --- Convenience functions 2 | ==================================================================================== 3 | 4 | .. automodule:: vergerpc 5 | :members: 6 | :show-inheritance: 7 | 8 | -------------------------------------------------------------------------------- /sphinx/source/vergerpc.util.rst: -------------------------------------------------------------------------------- 1 | :mod:`vergerpc.util` --- Generic utilities used by verge client library 2 | ==================================================================================== 3 | 4 | .. automodule:: vergerpc.util 5 | :members: 6 | :show-inheritance: 7 | 8 | -------------------------------------------------------------------------------- /src/vergerpc/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2010 Witchspace 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a copy 4 | # of this software and associated documentation files (the "Software"), to deal 5 | # in the Software without restriction, including without limitation the rights 6 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | # copies of the Software, and to permit persons to whom the Software is 8 | # furnished to do so, subject to the following conditions: 9 | # 10 | # The above copyright notice and this permission notice shall be included in 11 | # all copies or substantial portions of the Software. 12 | # 13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | # THE SOFTWARE. 20 | """ 21 | verge-python - Easy-to-use VERGE API client 22 | """ 23 | 24 | 25 | def connect_to_local(filename=None): 26 | """ 27 | Connect to default verge instance owned by this user, on this machine. 28 | 29 | Returns a :class:`~vergerpc.connection.VERGEConnection` object. 30 | 31 | Arguments: 32 | 33 | - `filename`: Path to a configuration file in a non-standard location (optional) 34 | """ 35 | from vergerpc.connection import VERGEConnection 36 | from vergerpc.config import read_default_config 37 | 38 | cfg = read_default_config(filename) 39 | if cfg is None: 40 | cfg = {} 41 | #port = int(cfg.get('rpcport', '18332' if cfg.get('testnet') else '20102')) 42 | port = int(cfg.get('rpcport', '20102')) 43 | rpcuser = cfg.get('rpcuser', '') 44 | rpcpassword = cfg.get('rpcpassword', '') 45 | 46 | return VERGEConnection(rpcuser, rpcpassword, 'localhost', port) 47 | 48 | 49 | def connect_to_remote(user, password, host='localhost', port=20102, 50 | use_https=False): 51 | """ 52 | Connect to remote or alternative local verge client instance. 53 | 54 | Returns a :class:`~vergerpc.connection.VERGEConnection` object. 55 | """ 56 | from vergerpc.connection import VERGEConnection 57 | 58 | return VERGEConnection(user, password, host, port, use_https) 59 | -------------------------------------------------------------------------------- /src/vergerpc/config.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2010 Witchspace 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a copy 4 | # of this software and associated documentation files (the "Software"), to deal 5 | # in the Software without restriction, including without limitation the rights 6 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | # copies of the Software, and to permit persons to whom the Software is 8 | # furnished to do so, subject to the following conditions: 9 | # 10 | # The above copyright notice and this permission notice shall be included in 11 | # all copies or substantial portions of the Software. 12 | # 13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | # THE SOFTWARE. 20 | """ 21 | Utilities for reading verge configuration files. 22 | """ 23 | 24 | 25 | def read_config_file(filename): 26 | """ 27 | Read a simple ``'='``-delimited config file. 28 | Raises :const:`IOError` if unable to open file, or :const:`ValueError` 29 | if an parse error occurs. 30 | """ 31 | f = open(filename) 32 | try: 33 | cfg = {} 34 | for line in f: 35 | line = line.strip() 36 | if line and not line.startswith("#"): 37 | try: 38 | (key, value) = line.split('=', 1) 39 | cfg[key] = value 40 | except ValueError: 41 | pass # Happens when line has no '=', ignore 42 | finally: 43 | f.close() 44 | return cfg 45 | 46 | 47 | def read_default_config(filename=None): 48 | """ 49 | Read verge default configuration from the current user's home directory. 50 | 51 | Arguments: 52 | 53 | - `filename`: Path to a configuration file in a non-standard location (optional) 54 | """ 55 | if filename is None: 56 | import os 57 | import platform 58 | home = os.getenv("HOME") 59 | if not home: 60 | raise IOError("Home directory not defined, don't know where to look for config file") 61 | 62 | if platform.system() == "Darwin": 63 | location = 'Library/Application Support/VERGE/VERGE.conf' 64 | elif platform.system() in ('Windows', 'Microsoft'): 65 | location = 'AppData\\Roaming\\VERGE\\VERGE.conf' 66 | else: 67 | location = '.VERGE/VERGE.conf' 68 | filename = os.path.join(home, location) 69 | 70 | elif filename.startswith("~"): 71 | import os 72 | filename = os.path.expanduser(filename) 73 | 74 | try: 75 | return read_config_file(filename) 76 | except (IOError, ValueError): 77 | pass # Cannot read config file, ignore 78 | -------------------------------------------------------------------------------- /src/vergerpc/data.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2010 Witchspace 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a copy 4 | # of this software and associated documentation files (the "Software"), to deal 5 | # in the Software without restriction, including without limitation the rights 6 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | # copies of the Software, and to permit persons to whom the Software is 8 | # furnished to do so, subject to the following conditions: 9 | # 10 | # The above copyright notice and this permission notice shall be included in 11 | # all copies or substantial portions of the Software. 12 | # 13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | # THE SOFTWARE. 20 | """ 21 | VERGE RPC service, data objects. 22 | """ 23 | from vergerpc.util import DStruct 24 | 25 | 26 | class ServerInfo(DStruct): 27 | """ 28 | Information object returned by :func:`~vergerpc.connection.VERGEConnection.getinfo`. 29 | 30 | - *errors* -- Number of errors. 31 | 32 | - *blocks* -- Number of blocks. 33 | 34 | - *paytxfee* -- Amount of transaction fee to pay. 35 | 36 | - *keypoololdest* -- Oldest key in keypool. 37 | 38 | - *genproclimit* -- Processor limit for generation. 39 | 40 | - *connections* -- Number of connections to other clients. 41 | 42 | - *difficulty* -- Current generating difficulty. 43 | 44 | - *testnet* -- True if connected to testnet, False if on real network. 45 | 46 | - *version* -- VERGE client version. 47 | 48 | - *proxy* -- Proxy configured in client. 49 | 50 | - *hashespersec* -- Number of hashes per second (if generation enabled). 51 | 52 | - *balance* -- Total current server balance. 53 | 54 | - *generate* -- True if generation enabled, False if not. 55 | 56 | - *unlocked_until* -- Timestamp (seconds since epoch) after which the wallet 57 | will be/was locked (if wallet encryption is enabled). 58 | 59 | """ 60 | 61 | 62 | class AccountInfo(DStruct): 63 | """ 64 | Information object returned by :func:`~vergerpc.connection.VERGEConnection.listreceivedbyaccount`. 65 | 66 | - *account* -- The account of the receiving address. 67 | 68 | - *amount* -- Total amount received by the address. 69 | 70 | - *confirmations* -- Number of confirmations of the most recent transaction included. 71 | 72 | """ 73 | 74 | 75 | class AddressInfo(DStruct): 76 | """ 77 | Information object returned by :func:`~vergerpc.connection.VERGEConnection.listreceivedbyaddress`. 78 | 79 | - *address* -- Receiving address. 80 | 81 | - *account* -- The account of the receiving address. 82 | 83 | - *amount* -- Total amount received by the address. 84 | 85 | - *confirmations* -- Number of confirmations of the most recent transaction included. 86 | 87 | """ 88 | 89 | 90 | class TransactionInfo(DStruct): 91 | """ 92 | Information object returned by :func:`~vergerpc.connection.VERGEConnection.listtransactions`. 93 | 94 | - *account* -- account name. 95 | 96 | - *address* -- the address verges were sent to, or received from. 97 | 98 | - *category* -- will be generate, send, receive, or move. 99 | 100 | - *amount* -- amount of transaction. 101 | 102 | - *fee* -- Fee (if any) paid (only for send transactions). 103 | 104 | - *confirmations* -- number of confirmations (only for generate/send/receive). 105 | 106 | - *txid* -- transaction ID (only for generate/send/receive). 107 | 108 | - *otheraccount* -- account funds were moved to or from (only for move). 109 | 110 | - *message* -- message associated with transaction (only for send). 111 | 112 | - *to* -- message-to associated with transaction (only for send). 113 | """ 114 | 115 | 116 | class AddressValidation(DStruct): 117 | """ 118 | Information object returned by :func:`~vergerpc.connection.VERGEConnection.validateaddress`. 119 | 120 | - *isvalid* -- Validatity of address (:const:`True` or :const:`False`). 121 | 122 | - *ismine* -- :const:`True` if the address is in the server's wallet. 123 | 124 | - *address* -- VERGE address. 125 | 126 | """ 127 | 128 | 129 | class WorkItem(DStruct): 130 | """ 131 | Information object returned by :func:`~vergerpc.connection.VERGEConnection.getwork`. 132 | 133 | - *midstate* -- Precomputed hash state after hashing the first half of the data. 134 | 135 | - *data* -- Block data. 136 | 137 | - *hash1* -- Formatted hash buffer for second hash. 138 | 139 | - *target* -- Little endian hash target. 140 | 141 | """ 142 | 143 | 144 | class MiningInfo(DStruct): 145 | """ 146 | Information object returned by :func:`~vergerpc.connection.VERGEConnection.getmininginfo`. 147 | 148 | - *blocks* -- Number of blocks. 149 | 150 | - *currentblocksize* -- Size of current block. 151 | 152 | - *currentblocktx* -- Number of transactions in current block. 153 | 154 | - *difficulty* -- Current generating difficulty. 155 | 156 | - *errors* -- Number of errors. 157 | 158 | - *generate* -- True if generation enabled, False if not. 159 | 160 | - *genproclimit* -- Processor limit for generation. 161 | 162 | - *hashespersec* -- Number of hashes per second (if generation enabled). 163 | 164 | - *pooledtx* -- Number of pooled transactions. 165 | 166 | - *testnet* -- True if connected to testnet, False if on real network. 167 | 168 | """ 169 | -------------------------------------------------------------------------------- /src/vergerpc/exceptions.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2010 Witchspace 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a copy 4 | # of this software and associated documentation files (the "Software"), to deal 5 | # in the Software without restriction, including without limitation the rights 6 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | # copies of the Software, and to permit persons to whom the Software is 8 | # furnished to do so, subject to the following conditions: 9 | # 10 | # The above copyright notice and this permission notice shall be included in 11 | # all copies or substantial portions of the Software. 12 | # 13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | # THE SOFTWARE. 20 | """ 21 | Exception definitions. 22 | """ 23 | 24 | 25 | class VERGEException(Exception): 26 | """ 27 | Base class for exceptions received from VERGE server. 28 | 29 | - *code* -- Error code from ``verged``. 30 | """ 31 | # Standard JSON-RPC 2.0 errors 32 | INVALID_REQUEST = -32600, 33 | METHOD_NOT_FOUND = -32601, 34 | INVALID_PARAMS = -32602, 35 | INTERNAL_ERROR = -32603, 36 | PARSE_ERROR = -32700, 37 | 38 | # General application defined errors 39 | MISC_ERROR = -1 # std::exception thrown in command handling 40 | FORBIDDEN_BY_SAFE_MODE = -2 # Server is in safe mode, and command is not allowed in safe mode 41 | TYPE_ERROR = -3 # Unexpected type was passed as parameter 42 | INVALID_ADDRESS_OR_KEY = -5 # Invalid address or key 43 | OUT_OF_MEMORY = -7 # Ran out of memory during operation 44 | INVALID_PARAMETER = -8 # Invalid, missing or duplicate parameter 45 | DATABASE_ERROR = -20 # Database error 46 | DESERIALIZATION_ERROR = -22 # Error parsing or validating structure in raw format 47 | 48 | # P2P client errors 49 | CLIENT_NOT_CONNECTED = -9 # VERGE is not connected 50 | CLIENT_IN_INITIAL_DOWNLOAD = -10 # Still downloading initial blocks 51 | 52 | # Wallet errors 53 | WALLET_ERROR = -4 # Unspecified problem with wallet (key not found etc.) 54 | WALLET_INSUFFICIENT_FUNDS = -6 # Not enough funds in wallet or account 55 | WALLET_INVALID_ACCOUNT_NAME = -11 # Invalid account name 56 | WALLET_KEYPOOL_RAN_OUT = -12 # Keypool ran out, call keypoolrefill first 57 | WALLET_UNLOCK_NEEDED = -13 # Enter the wallet passphrase with walletpassphrase first 58 | WALLET_PASSPHRASE_INCORRECT = -14 # The wallet passphrase entered was incorrect 59 | WALLET_WRONG_ENC_STATE = -15 # Command given in wrong wallet encryption state (encrypting an encrypted wallet etc.) 60 | WALLET_ENCRYPTION_FAILED = -16 # Failed to encrypt the wallet 61 | WALLET_ALREADY_UNLOCKED = -17 # Wallet is already unlocked 62 | 63 | def __init__(self, error): 64 | Exception.__init__(self, error['message']) 65 | self.code = error['code'] 66 | 67 | 68 | class TransportException(Exception): 69 | """ 70 | Class to define transport-level failures. 71 | """ 72 | def __init__(self, msg, code=None, protocol=None, raw_detail=None): 73 | self.msg = msg 74 | self.code = code 75 | self.protocol = protocol 76 | self.raw_detail = raw_detail 77 | self.s = """ 78 | Transport-level failure: {msg} 79 | Code: {code} 80 | Protocol: {protocol} 81 | """.format(msg=msg, code=code, protocol=protocol) 82 | 83 | def __str__(self): 84 | return self.s 85 | 86 | 87 | ##### General application defined errors 88 | class SafeMode(VERGEException): 89 | """ 90 | Operation denied in safe mode (run ``verged`` with ``-disablesafemode``). 91 | """ 92 | 93 | 94 | class JSONTypeError(VERGEException): 95 | """ 96 | Unexpected type was passed as parameter 97 | """ 98 | InvalidAmount = JSONTypeError # Backwards compatibility 99 | 100 | 101 | class InvalidAddressOrKey(VERGEException): 102 | """ 103 | Invalid address or key. 104 | """ 105 | InvalidTransactionID = InvalidAddressOrKey # Backwards compatibility 106 | 107 | 108 | class OutOfMemory(VERGEException): 109 | """ 110 | Out of memory during operation. 111 | """ 112 | 113 | 114 | class InvalidParameter(VERGEException): 115 | """ 116 | Invalid parameter provided to RPC call. 117 | """ 118 | 119 | 120 | ##### Client errors 121 | class ClientException(VERGEException): 122 | """ 123 | P2P network error. 124 | This exception is never raised but functions as a superclass 125 | for other P2P client exceptions. 126 | """ 127 | 128 | 129 | class NotConnected(ClientException): 130 | """ 131 | Not connected to any peers. 132 | """ 133 | 134 | 135 | class DownloadingBlocks(ClientException): 136 | """ 137 | Client is still downloading blocks. 138 | """ 139 | 140 | 141 | ##### Wallet errors 142 | class WalletError(VERGEException): 143 | """ 144 | Unspecified problem with wallet (key not found etc.) 145 | """ 146 | SendError = WalletError # Backwards compatibility 147 | 148 | 149 | class InsufficientFunds(WalletError): 150 | """ 151 | Insufficient funds to complete transaction in wallet or account 152 | """ 153 | 154 | 155 | class InvalidAccountName(WalletError): 156 | """ 157 | Invalid account name 158 | """ 159 | 160 | 161 | class KeypoolRanOut(WalletError): 162 | """ 163 | Keypool ran out, call keypoolrefill first 164 | """ 165 | 166 | 167 | class WalletUnlockNeeded(WalletError): 168 | """ 169 | Enter the wallet passphrase with walletpassphrase first 170 | """ 171 | 172 | 173 | class WalletPassphraseIncorrect(WalletError): 174 | """ 175 | The wallet passphrase entered was incorrect 176 | """ 177 | 178 | 179 | class WalletWrongEncState(WalletError): 180 | """ 181 | Command given in wrong wallet encryption state (encrypting an encrypted wallet etc.) 182 | """ 183 | 184 | 185 | class WalletEncryptionFailed(WalletError): 186 | """ 187 | Failed to encrypt the wallet 188 | """ 189 | 190 | 191 | class WalletAlreadyUnlocked(WalletError): 192 | """ 193 | Wallet is already unlocked 194 | """ 195 | 196 | 197 | # For convenience, we define more specific exception classes 198 | # for the more common errors. 199 | _exception_map = { 200 | VERGEException.FORBIDDEN_BY_SAFE_MODE: SafeMode, 201 | VERGEException.TYPE_ERROR: JSONTypeError, 202 | VERGEException.WALLET_ERROR: WalletError, 203 | VERGEException.INVALID_ADDRESS_OR_KEY: InvalidAddressOrKey, 204 | VERGEException.WALLET_INSUFFICIENT_FUNDS: InsufficientFunds, 205 | VERGEException.OUT_OF_MEMORY: OutOfMemory, 206 | VERGEException.INVALID_PARAMETER: InvalidParameter, 207 | VERGEException.CLIENT_NOT_CONNECTED: NotConnected, 208 | VERGEException.CLIENT_IN_INITIAL_DOWNLOAD: DownloadingBlocks, 209 | VERGEException.WALLET_INSUFFICIENT_FUNDS: InsufficientFunds, 210 | VERGEException.WALLET_INVALID_ACCOUNT_NAME: InvalidAccountName, 211 | VERGEException.WALLET_KEYPOOL_RAN_OUT: KeypoolRanOut, 212 | VERGEException.WALLET_UNLOCK_NEEDED: WalletUnlockNeeded, 213 | VERGEException.WALLET_PASSPHRASE_INCORRECT: WalletPassphraseIncorrect, 214 | VERGEException.WALLET_WRONG_ENC_STATE: WalletWrongEncState, 215 | VERGEException.WALLET_ENCRYPTION_FAILED: WalletEncryptionFailed, 216 | VERGEException.WALLET_ALREADY_UNLOCKED: WalletAlreadyUnlocked, 217 | } 218 | 219 | 220 | def wrap_exception(error): 221 | """ 222 | Convert a JSON error object to a more specific VERGE exception. 223 | """ 224 | # work around to temporarily fix https://github.com/bitcoin/bitcoin/issues/3007 225 | if error['code'] == VERGEException.WALLET_ERROR and error['message'] == u'Insufficient funds': 226 | error['code'] = VERGEException.WALLET_INSUFFICIENT_FUNDS 227 | return _exception_map.get(error['code'], VERGEException)(error) 228 | -------------------------------------------------------------------------------- /src/vergerpc/proxy.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2007 Jan-Klaas Kollhof 3 | Copyright (c) 2011-2013 Jeff Garzik 4 | Copyright (c) 2013 Nikolay Belikov (nikolay@belikov.me) 5 | 6 | 7 | jsonrpc is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 2.1 of the License, or 10 | (at your option) any later version. 11 | 12 | This software is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with this software; if not, write to the Free Software 19 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | """ 21 | 22 | try: 23 | import http.client as httplib 24 | except ImportError: 25 | import httplib 26 | import base64 27 | import json 28 | import decimal 29 | try: 30 | import urllib.parse as urlparse 31 | except ImportError: 32 | import urlparse 33 | from collections import defaultdict, deque 34 | from vergerpc.exceptions import TransportException 35 | 36 | USER_AGENT = "AuthServiceProxy/0.1" 37 | 38 | HTTP_TIMEOUT = 30 39 | 40 | 41 | class JSONRPCException(Exception): 42 | def __init__(self, rpc_error): 43 | Exception.__init__(self) 44 | self.error = rpc_error 45 | 46 | 47 | class HTTPTransport(object): 48 | def __init__(self, service_url): 49 | self.service_url = service_url 50 | self.parsed_url = urlparse.urlparse(service_url) 51 | if self.parsed_url.port is None: 52 | port = 80 53 | else: 54 | port = self.parsed_url.port 55 | authpair = "%s:%s" % (self.parsed_url.username, 56 | self.parsed_url.password) 57 | authpair = authpair.encode('utf8') 58 | self.auth_header = "Basic ".encode('utf8') + base64.b64encode(authpair) 59 | if self.parsed_url.scheme == 'https': 60 | self.connection = httplib.HTTPSConnection(self.parsed_url.hostname, 61 | port, None, None, False, 62 | HTTP_TIMEOUT) 63 | else: 64 | self.connection = httplib.HTTPConnection(self.parsed_url.hostname, 65 | port, False, HTTP_TIMEOUT) 66 | 67 | def request(self, serialized_data): 68 | self.connection.request('POST', self.parsed_url.path, serialized_data, 69 | {'Host': self.parsed_url.hostname, 70 | 'User-Agent': USER_AGENT, 71 | 'Authorization': self.auth_header, 72 | 'Content-type': 'application/json'}) 73 | 74 | httpresp = self.connection.getresponse() 75 | if httpresp is None: 76 | self._raise_exception({ 77 | 'code': -342, 'message': 'missing HTTP response from server'}) 78 | elif httpresp.status == httplib.FORBIDDEN: 79 | msg = "verged returns 403 Forbidden. Is your IP allowed?" 80 | raise TransportException(msg, code=403, 81 | protocol=self.parsed_url.scheme, 82 | raw_detail=httpresp) 83 | 84 | resp = httpresp.read() 85 | return resp.decode('utf8') 86 | 87 | 88 | class FakeTransport(object): 89 | """A simple testing facility.""" 90 | def __init__(self): 91 | self._data = defaultdict(deque) 92 | 93 | def load_serialized(self, method_name, fixture): 94 | self._data[method_name].append(fixture) 95 | 96 | def load_raw(self, method_name, fixture): 97 | self._data[method_name].append(json.dumps(fixture)) 98 | 99 | def request(self, serialized_data): 100 | data = json.loads(serialized_data, parse_float=decimal.Decimal) 101 | method_name = data['method'] 102 | return self._data[method_name].popleft() 103 | 104 | 105 | class RPCMethod(object): 106 | def __init__(self, name, service_proxy): 107 | self._method_name = name 108 | self._service_proxy = service_proxy 109 | 110 | def __getattr__(self, name): 111 | new_name = '{}.{}'.format(self._method_name, name) 112 | return RPCMethod(new_name, self._service_proxy) 113 | 114 | def __call__(self, *args): 115 | self._service_proxy._id_counter += 1 116 | data = {'version': '1.1', 117 | 'method': self._method_name, 118 | 'params': args, 119 | 'id': self._service_proxy._id_counter} 120 | postdata = json.dumps(data) 121 | resp = self._service_proxy._transport.request(postdata) 122 | resp = json.loads(resp, parse_float=decimal.Decimal) 123 | 124 | if resp['error'] is not None: 125 | self._service_proxy._raise_exception(resp['error']) 126 | elif 'result' not in resp: 127 | self._service_proxy._raise_exception({ 128 | 'code': -343, 'message': 'missing JSON-RPC result'}) 129 | else: 130 | return resp['result'] 131 | 132 | def __repr__(self): 133 | return ''.format(name=self._method_name) 134 | 135 | 136 | class AuthServiceProxy(object): 137 | """ 138 | You can use custom transport to test your app's behavior without calling 139 | the remote service. 140 | 141 | exception_wrapper is a callable accepting a dictionary containing error 142 | code and message and returning a suitable exception object. 143 | """ 144 | def __init__(self, service_url, transport=None, exception_wrapper=None): 145 | self._service_url = service_url 146 | self._id_counter = 0 147 | self._transport = (HTTPTransport(service_url) if transport is None 148 | else transport) 149 | self._exception_wrapper = exception_wrapper 150 | 151 | def __getattr__(self, name): 152 | return RPCMethod(name, self) 153 | 154 | def _get_method(self, name): 155 | """ 156 | Get method instance when the name contains forbidden characters or 157 | already taken by internal attribute. 158 | """ 159 | return RPCMethod(name, self) 160 | 161 | def _raise_exception(self, error): 162 | if self._exception_wrapper is None: 163 | raise JSONRPCException(error) 164 | else: 165 | raise self._exception_wrapper(error) 166 | -------------------------------------------------------------------------------- /src/vergerpc/util.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2010 Witchspace 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a copy 4 | # of this software and associated documentation files (the "Software"), to deal 5 | # in the Software without restriction, including without limitation the rights 6 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | # copies of the Software, and to permit persons to whom the Software is 8 | # furnished to do so, subject to the following conditions: 9 | # 10 | # The above copyright notice and this permission notice shall be included in 11 | # all copies or substantial portions of the Software. 12 | # 13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | # THE SOFTWARE. 20 | """Generic utilities used by verge client library.""" 21 | from copy import copy 22 | 23 | 24 | class DStruct(object): 25 | """ 26 | Simple dynamic structure, like :const:`collections.namedtuple` but more flexible 27 | (and less memory-efficient) 28 | """ 29 | # Default arguments. Defaults are *shallow copied*, to allow defaults such as []. 30 | _fields = [] 31 | _defaults = {} 32 | 33 | def __init__(self, *args_t, **args_d): 34 | # order 35 | if len(args_t) > len(self._fields): 36 | raise TypeError("Number of arguments is larger than of predefined fields") 37 | # Copy default values 38 | for (k, v) in self._defaults.items(): 39 | self.__dict__[k] = copy(v) 40 | # Set pass by value arguments 41 | self.__dict__.update(zip(self._fields, args_t)) 42 | # dict 43 | self.__dict__.update(args_d) 44 | 45 | def __repr__(self): 46 | return '{module}.{classname}({slots})'.format( 47 | module=self.__class__.__module__, classname=self.__class__.__name__, 48 | slots=", ".join('{k}={v!r}'.format(k=k, v=v) for k, v in 49 | self.__dict__.items())) 50 | -------------------------------------------------------------------------------- /tests/test.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | ''' 3 | Test script 4 | *WARNING* Don't run this on a production verge server! *WARNING* 5 | Only on the test network. 6 | ''' 7 | import argparse 8 | import sys 9 | sys.path.append('../src') 10 | 11 | import vergerpc 12 | from vergerpc.exceptions import VERGEException, InsufficientFunds 13 | 14 | 15 | from decimal import Decimal 16 | 17 | parser = argparse.ArgumentParser() 18 | parser.add_argument('--config', help="Specify configuration file") 19 | parser.add_argument('--nolocal', help="Don't use connect_to_local", 20 | action='store_true') 21 | parser.add_argument('--noremote', help="Don't use connect_to_remote", 22 | action='store_true') 23 | args = parser.parse_args() 24 | 25 | if __name__ == "__main__": 26 | 27 | if args.config: 28 | from vergerpc.config import read_config_file 29 | cfg = read_config_file(args.config) 30 | else: 31 | from vergerpc.config import read_default_config 32 | cfg = read_default_config(None) 33 | port = int(cfg.get('rpcport', '20102')) 34 | rpcuser = cfg.get('rpcuser', '') 35 | 36 | connections = [] 37 | if not args.nolocal: 38 | local_conn = vergerpc.connect_to_local() # will use read_default_config 39 | connections.append(local_conn) 40 | if not args.noremote: 41 | remote_conn = vergerpc.connect_to_remote( 42 | user=rpcuser, password=cfg['rpcpassword'], host='localhost', 43 | port=port, use_https=False) 44 | connections.append(remote_conn) 45 | 46 | for conn in connections: 47 | assert(conn.getinfo().testnet) # don't test on prodnet 48 | 49 | assert(type(conn.getblockcount()) is int) 50 | assert(type(conn.getconnectioncount()) is int) 51 | assert(type(conn.getdifficulty()) is Decimal) 52 | assert(type(conn.getgenerate()) is bool) 53 | conn.setgenerate(True) 54 | conn.setgenerate(True, 2) 55 | conn.setgenerate(False) 56 | assert(type(conn.gethashespersec()) is int) 57 | account = "testaccount" 58 | account2 = "testaccount2" 59 | vergeaddress = conn.getnewaddress(account) 60 | conn.setaccount(vergeaddress, account) 61 | address = conn.getaccountaddress(account) 62 | address2 = conn.getaccountaddress(account2) 63 | assert(conn.getaccount(address) == account) 64 | addresses = conn.getaddressesbyaccount(account) 65 | assert(address in addresses) 66 | #conn.sendtoaddress(vergeaddress, amount, comment=None, comment_to=None) 67 | conn.getreceivedbyaddress(vergeaddress) 68 | conn.getreceivedbyaccount(account) 69 | conn.listreceivedbyaddress() 70 | conn.listreceivedbyaccount() 71 | #conn.backupwallet(destination) 72 | x = conn.validateaddress(address) 73 | assert(x.isvalid == True) 74 | x = conn.validateaddress("invalid") 75 | assert(x.isvalid == False) 76 | messages = ('Hello, world!', u'かたな') 77 | for message in messages: 78 | signature = conn.signmessage(vergeaddress, message) 79 | assert(conn.verifymessage(vergeaddress, signature, message) is True) 80 | 81 | for accid in conn.listaccounts(as_dict=True).iterkeys(): 82 | tx = conn.listtransactions(accid) 83 | if len(tx) > 0: 84 | txid = tx[0].txid 85 | txdata = conn.gettransaction(txid) 86 | assert(txdata.txid == tx[0].txid) 87 | 88 | assert(type(conn.listunspent()) is list) # needs better testing 89 | 90 | try: 91 | conn.sendtoaddress(vergeaddress, 10000000) 92 | assert(0) # Should raise InsufficientFunds 93 | except InsufficientFunds: 94 | pass 95 | 96 | info = conn.getinfo() 97 | print "Blocks: %i" % info.blocks 98 | print "Connections: %i" % info.connections 99 | print "Difficulty: %f" % info.difficulty 100 | 101 | m_info = conn.getmininginfo() 102 | print ("Pooled Transactions: {pooledtx}\n" 103 | "Testnet: {testnet}\n" 104 | "Hash Rate: {hashes} H/s".format(pooledtx=m_info.pooledtx, 105 | testnet=m_info.testnet, 106 | hashes=m_info.hashespersec)) 107 | --------------------------------------------------------------------------------