Package: pyskycoin
PySkycoinPython extension for Skycoin API.
A Python extension generated with SWIG to access Skycoin API from Python.Table of ContentsInstallationUsing the APINamingParametersHandlesByte SlicesStructuresFixed Size ArraysOther SlicesMemory ManagemanetMake rulesDevelopment setupRunning testsReleasesUpdate the versionPre-release testingRelease signingAlternative signing keysCreating release buildsCreating release builds to manylinuxPython wrapper for Skycoin ApiInstallationDownload the repository fromhttp://github.com/simelo/pyskycoin.git.
Execute (python setup.py install) to install the library. Although executing (python setup.py develop) is a better choice for making changes to the library. However, when using tox these commands are not required at all because calling tox will make any necessary installation and execute the tests.UsageNamingThe exported function in PySkycoin have the following naming format:SKY_package_func_namewhere package is replace by the package where the original Skycoin function is and func_name is the name of the function. For example,LoadConfigfunction fromclipackage is called in PythonSKY_cli_LoadConfigParametersAll skycoin exported functions return an error object as the last of the return parameters. In Pyskycoin error is return as an integer and it is the first return parameter. The rest of the parameters are returned in the same order.Receivers in Skycoin are the first of the input parameters. Simple types, like integer, float, string will be used as the corresponding types in Python.HandlesSome of Skycoin types are too complex to be exported to a scripting language. So, handles are used instead. Therefore all functions taking a complex type will receive a handle instead of the original Skycoin type. For example, having these functions exported from Skycoin:funcLoadConfig()(Config,error)func(cConfig)FullWalletPath()stringConfig is a struct type that is treated as a handle in Pyskycoin. The usage in Python will be:importskycoindefmain:err,configHandle=skycoin.SKY_cli_LoadConfig()iferr==skycoin.SKY_OK:# 0 then no errorfullWalletPath=skycoin.SKY_cli_FullWalletPath(configHandle)printfullWallerPath#Close the handle after using the it#so the garbage collector can delete the object associated with it.skycoin.SKY_handle_close(configHandle)else:#ErrorprinterrByte slicesParameters of type byte[] will treated as string . Example, this function in Skycoin:func(sScryptChacha20poly1305)Encrypt(data,password[]byte)([]byte,error)Will be called like this:encrypt_settings=skycoin.encrypt__ScryptChacha20poly1305()data="Data to encrypt"#It will be passed as a parameter of type []bytepwd="password"#As []byte tooerr,encrypted=skycoin.SKY_encrypt_ScryptChacha20poly1305_Encrypt(encrypt_settings,data,pwd)iferr==skycoin.SKY_OK:printencrypted#Encrypted is stringStructuresStructures that are not exported as handles are treated like classes in Python. In the previous example type ScryptChacha20poly1305 is created in Python like:encrypt_settings=skycoin.encrypt__ScryptChacha20poly1305()And passed as first parameter in call to SKY_encrypt_ScryptChacha20poly1305_Encrypt.Fixed Sized ArraysParameters of fixed size array are wrapped in structures when called from python.Given these types in Skycoin:typePubKey[33]bytetypeSecKey[32]byteAnd this exported function:funcGenerateDeterministicKeyPair(seed[]byte)(PubKey,SecKey)This is how it is used in Python:#Generates random seederr,data=skycoin.SKY_cipher_RandByte(32)asserterr==skycoin.SKY_OKpubkey=skycoin.cipher_PubKey()seckey=skycoin.cipher_SecKey()err=skycoin.SKY_cipher_GenerateDeterministicKeyPair(data,pubkey,seckey)pubkey and seckey are objects of type structure containing a field name data for the corresponding type of PubKey and SecKey. Something like:cipher_PubKeystruct{data[33]byte;}cipher_PubKey;cipher_SecKeystruct{data[32]byte;};Other SlicesOther slices of type different than byte were wrapped inside classes. Calling the following function:funcGenerateDeterministicKeyPairs(seed[]byte,nint)[]SecKeyWould be like:#Generates random seederr,seed=skycoin.SKY_cipher_RandByte(32)err,seckeys=skycoin.SKY_cipher_GenerateDeterministicKeyPairs(seed,2)forseckeyinseckeys:pubkey=skycoin.cipher_PubKey()skycoin.SKY_cipher_PubKeyFromSecKey(seckey,pubkey)err=skycoin.SKY_cipher_PubKey_Verify(pubkey)asserterr==skycoin.SKY_OKExample of how to verify addressdefaddressIsValid(addr):addres=skycoin.cipher__Address()err=skycoin.SKY_cipher_DecodeBase58Address(addr,addres)returnerr!=skycoin.SKY_OKMemory ManagementMemory management is transparent to the user. Any object allocated inside the library is left to be managed by Python garbage collector.Make RulesAll these make rules require skycoin to be a git submodule of pyskycoinbuild-libcCompiles skycoin C language library.build-swigCreates the wrapper C code to generate the Python library.developInstall a developer version of the module.testCompiles skycoin C language library, creates the wrapper and execute Tox. Tox installs compiles the Python library and executes the tests.Development setupIt is highly recommended for developers to setup their environment using
the available Docker images.
Read thePySkycoin Docker docsfor further
details.The project has two branches:masteranddevelop.developis the default branch and will always have the latest code.
The submodule atgopath/src/github.com/skycoin/skycoinhas to be
in sync withskycoin/skycoindevelopbranch.masterwill always be equal to the current stable release on the website, and should correspond with the latest release tag.
The submodule atgopath/src/github.com/skycoin/skycoinhas to be
in sync withskycoin/skycoinmasterbranch.Separate stable development branches will be created to work on releases for supporting the
most recent stable version of Skycoin. The name of these branches should be the Skycoin
major and minor version numbers followed bydevsuffix e.g.0.25dev.
These branches may be forked out of eithermasterordevelopbranches, and
the submodule atgopath/src/github.com/skycoin/skycoinhas to be
in sync with the corresponding tag ofskycoin/skycoinofficial repository.Stable development branches are created most of the time for the following reasons:A Skycoin release increasingpatch version number.Enhanced support and bug fixes for a version of PySkycoin compiled against an
stable version of SkycoinBackporting useful features added indevelop.Running tests$maketestReleasesUpdate the versionIf themasterbranch has commits that are not indevelop(e.g. due to a hotfix applied tomaster), mergemasterintodevelop(and fix any build or test failures)Switch to a new release branch namedrelease-X.Y.Zfor preparing the release.Ensure that the submodule atgopath/src/github.com/skycoin/skycoinis in sync with respect to the corresponding tag inhttps://github.com/skycoin/skycoinrepository.Update__version__inskycoin/__init__.pyRunmake buildto make sure that the code base is up to dateUpdateCHANGELOG.md: move the "unreleased" changes to the version and add the date.Follow the steps inpre-release testingMake a PR merging the release branch intomasterReview the PR and merge itUpdate files inhttps://github.com/skycoin/repo-info/tree/master/repos/skycoin/remoteforsimelotech/skycoindev-dotnetDocker image, adding a new file for the new version and adjusting any configuration text that may have changedTag themasterbranch with the version number. Version tags start withv, e.g.v0.20.0. Sign the tag. If you have your GPG key in github, creating a release on the Github website will automatically tag the release. It can be tagged from the command line withgit tag -as v0.20.0 $COMMIT_ID, but Github will not recognize it as a "release".Release builds are created and uploaded by travis. To do it manually, checkout the master branch and follow thecreate release builds instructions.Checkoutdevelopbranch and bump__version__to nextdevversion number.Pre-release testingPerform these actions before releasing:maketest-ciRelease signingReleases are signed with this PGP key:0x5801631BD27C7874The fingerprint for this key is:pub   ed25519 2017-09-01 [SC] [expires: 2023-03-18]
      10A7 22B7 6F2F FE7B D238  0222 5801 631B D27C 7874
uid                      GZ-C SKYCOIN <token@protonmail.com>
sub   cv25519 2017-09-01 [E] [expires: 2023-03-18]Keybase.io account:https://keybase.io/gzcAlternative signing keys:Keybase.io account:https://keybase.io/olemisThe fingerprint for this key is:pub   rsa4096 2019-01-17 [SC] [expires: 2024-01-16]
uid           Olemis Lang <olemis@simelo.tech>
sub   rsa4096 2019-01-17 [E] [expires: 2024-01-16]Follow theTor Project's instructions for verifying signatures.Releases and their signatures can be found on thereleases page.Instructions for generating a PGP key, publishing it, signing the tags and binaries:https://gist.github.com/gz-c/de3f9c43343b2f1a27c640fe529b067cCreating release buildsRelease builds should be created from git tags . Afterupdating release versionit is necessary to follow these stepscd/path/to/pyskycoin
python3setup.pysdistbdist_wheel
python3-mpipinstall--user--upgradetwine
twineupload--repository-urlhttps://test.pypi.org/legacy/dist/*This is automatically done fortravis-ciandcircle-ci.Creating release builds to manylinuxRelease builds should be created from git tags . Afterupdating release versionit is necessary to follow these stepsFor64bitsbuilds:cd/path/to/pyskycoin
makebdist_manylinux
python3-mpipinstall--user--upgradetwine
twineupload--repository-urlhttps://test.pypi.org/legacy/dist/*In case32bitsbuilds:cd/path/to/pyskycoin
makebdist_manylinux_i686
python3-mpipinstall--user--upgradetwine
twineupload--repository-urlhttps://test.pypi.org/legacy/dist/*This is the same process thatskyapifollows.This is done automatically intravis-ciandcircle-ci, and even if there is an option to do it manually, this process should be automatic.Python wrapper for Skycoin ApiThis wrapper is Auto generated by openapi-generator directly fromSkycoin Apicode for version v0.25.1.For further details of usage ofPython wrapper for Skycoin ApiseeAutogenerated documentationTo use wrapper for specific node of Skycoin api, just do the next:# create an instance of the Configuration classconfiguration=skyapi.Configuration()# set new hostconfiguration.host='some_host'# create an instance of the API class with new configurationapi_instance=skyapi.DefaultApi(skyapi.ApiClient(configuration))