├── .clang-format ├── .gitignore ├── .gitmodules ├── AUTHORS ├── LICENSE ├── README.md ├── codegen ├── generator.py ├── parser.py └── templates │ ├── class.cc │ ├── class.h │ ├── enum.cc │ ├── enum.h │ ├── header.template │ ├── includes.template │ ├── module.cc │ ├── properties.template │ ├── struct.cc │ └── struct.h ├── demo ├── address.py ├── sample.py └── wallet.py ├── setup.py └── src ├── AnySigner.cc ├── AnySigner.h ├── Bool.h ├── Data.cc ├── Data.h ├── Number.h ├── String.cc ├── String.h └── generated ├── AES.cc ├── AES.h ├── AESPaddingMode.cc ├── AESPaddingMode.h ├── Account.cc ├── Account.h ├── AnyAddress.cc ├── AnyAddress.h ├── Base32.cc ├── Base32.h ├── Base58.cc ├── Base58.h ├── Base64.cc ├── Base64.h ├── BitcoinAddress.cc ├── BitcoinAddress.h ├── BitcoinMessageSigner.cc ├── BitcoinMessageSigner.h ├── BitcoinScript.cc ├── BitcoinScript.h ├── BitcoinSigHashType.cc ├── BitcoinSigHashType.h ├── Blockchain.cc ├── Blockchain.h ├── Cardano.cc ├── Cardano.h ├── CoinType.cc ├── CoinType.h ├── CoinTypeConfiguration.cc ├── CoinTypeConfiguration.h ├── Curve.cc ├── Curve.h ├── DataVector.cc ├── DataVector.h ├── Derivation.cc ├── Derivation.h ├── DerivationPath.cc ├── DerivationPath.h ├── DerivationPathIndex.cc ├── DerivationPathIndex.h ├── EthereumAbi.cc ├── EthereumAbi.h ├── EthereumAbiFunction.cc ├── EthereumAbiFunction.h ├── EthereumAbiValue.cc ├── EthereumAbiValue.h ├── EthereumEip2645.cc ├── EthereumEip2645.h ├── EthereumMessageSigner.cc ├── EthereumMessageSigner.h ├── FIOAccount.cc ├── FIOAccount.h ├── GroestlcoinAddress.cc ├── GroestlcoinAddress.h ├── HDVersion.cc ├── HDVersion.h ├── HDWallet.cc ├── HDWallet.h ├── HRP.cc ├── HRP.h ├── Hash.cc ├── Hash.h ├── Mnemonic.cc ├── Mnemonic.h ├── NEARAccount.cc ├── NEARAccount.h ├── NervosAddress.cc ├── NervosAddress.h ├── PBKDF2.cc ├── PBKDF2.h ├── PrivateKey.cc ├── PrivateKey.h ├── PrivateKeyType.cc ├── PrivateKeyType.h ├── PublicKey.cc ├── PublicKey.h ├── PublicKeyType.cc ├── PublicKeyType.h ├── Purpose.cc ├── Purpose.h ├── RippleXAddress.cc ├── RippleXAddress.h ├── SS58AddressType.cc ├── SS58AddressType.h ├── SegwitAddress.cc ├── SegwitAddress.h ├── SolanaAddress.cc ├── SolanaAddress.h ├── StarkExMessageSigner.cc ├── StarkExMessageSigner.h ├── StarkWare.cc ├── StarkWare.h ├── StellarMemoType.cc ├── StellarMemoType.h ├── StellarPassphrase.cc ├── StellarPassphrase.h ├── StellarVersionByte.cc ├── StellarVersionByte.h ├── StoredKey.cc ├── StoredKey.h ├── StoredKeyEncryption.cc ├── StoredKeyEncryption.h ├── StoredKeyEncryptionLevel.cc ├── StoredKeyEncryptionLevel.h ├── THORChainSwap.cc ├── THORChainSwap.h ├── TransactionCompiler.cc ├── TransactionCompiler.h └── module.cc /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | Language: Cpp 3 | BasedOnStyle: Chromium 4 | --- 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode 2 | build 3 | dist 4 | *.pyc 5 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "wallet-core"] 2 | path = wallet-core 3 | url = https://github.com/trustwallet/wallet-core.git 4 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Peng Huang 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # wallet-core-python 2 | Python binding for wallet-core 3 | 4 | # Build and install 5 | ``` 6 | # Checkout wallet-core-python 7 | git clone https://github.com/phuang/wallet-core-python.git 8 | cd wallet-core-python 9 | 10 | # Checkout wallet-core submosule 11 | git submodule init 12 | git submodule update 13 | 14 | # Build wallet-core 15 | (cd wallet-core/; ./bootstrap.sh) 16 | 17 | # Build wallet-core-python 18 | python3 setup.py build 19 | 20 | # Install wallet-core-python in $HOME directory 21 | python3 setup.py install --prefix=~/.local 22 | 23 | # Or install wallet-core-python in global python library directory 24 | # sudo python3 setup.py install 25 | 26 | ``` 27 | 28 | # Generate python binding from wallet-core 29 | This step is optional, the repository alreay includes generated python binding source code. 30 | ``` 31 | python3 codegen/generator.py 32 | ``` 33 | 34 | # Test 35 | ``` 36 | python3 ./demo/sample.py 37 | ``` 38 | -------------------------------------------------------------------------------- /codegen/templates/class.cc: -------------------------------------------------------------------------------- 1 | {% include "header.template" %} 2 | 3 | {% include "includes.template" %} 4 | 5 | 6 | struct Py{{ name }}Object { 7 | PyObject_HEAD; 8 | TW{{ name }}* value; 9 | }; 10 | 11 | static PyTypeObject Py{{ name }}Type = { 12 | // clang-format off 13 | PyVarObject_HEAD_INIT(NULL, 0) 14 | // clang-format on 15 | "walletcore.{{ name }}", /* tp_name */ 16 | sizeof(Py{{ name }}Object), /* tp_basicsize */ 17 | 0, /* tp_itemsize */ 18 | 0, /* tp_dealloc */ 19 | 0, /* tp_print */ 20 | 0, /* tp_getattr */ 21 | 0, /* tp_setattr */ 22 | 0, /* tp_reserved */ 23 | 0, /* tp_repr */ 24 | 0, /* tp_as_number */ 25 | 0, /* tp_as_sequence */ 26 | 0, /* tp_as_mapping */ 27 | 0, /* tp_hash */ 28 | 0, /* tp_call */ 29 | 0, /* tp_str */ 30 | 0, /* tp_getattro */ 31 | 0, /* tp_setattro */ 32 | 0, /* tp_as_buffer */ 33 | Py_TPFLAGS_DEFAULT, /* tp_flags */ 34 | nullptr, /* tp_doc */ 35 | }; 36 | 37 | 38 | bool Py{{ name }}_Check(PyObject* object) { 39 | return PyObject_TypeCheck(object, &Py{{ name }}Type) != 0; 40 | } 41 | 42 | // Create Py{{ name }} from enum TW{{ name }}. 43 | PyObject* Py{{ name }}_FromTW{{ name }}(TW{{ name }}* value) { 44 | if (!value) 45 | Py_RETURN_NONE; 46 | 47 | Py{{ name }}Object* object = PyObject_New(Py{{ name }}Object, &Py{{ name }}Type); 48 | if (!object) 49 | return nullptr; 50 | 51 | object->value = value; 52 | 53 | return (PyObject*)object; 54 | } 55 | 56 | TW{{ name }}* Py{{ name }}_GetTW{{ name }}(PyObject* object) { 57 | assert(Py{{ name }}_Check(object)); 58 | return ((Py{{ name }}Object*)object)->value; 59 | } 60 | 61 | static void Py{{ name }}_dealloc(Py{{ name }}Object *self) { 62 | if (self->value) { 63 | TW{{ name }}Delete(self->value); 64 | } 65 | Py_TYPE(self)->tp_free(self); 66 | } 67 | 68 | {% for function in functions %} 69 | {{ function }} 70 | {%- endfor %} 71 | 72 | {% include "properties.template" %} 73 | 74 | static const PyGetSetDef get_set_defs[] = { 75 | {%- for def in getsetdefs -%} 76 | {{ def }}, 77 | {%- endfor -%} 78 | {} 79 | }; 80 | 81 | static const PyMethodDef method_defs[] = { 82 | {%- for def in methoddefs -%} 83 | {{ def }}, 84 | {%- endfor -%} 85 | {} 86 | }; 87 | 88 | bool PyInit_{{ name }}(PyObject *module) { 89 | Py{{ name }}Type.tp_dealloc = (destructor)Py{{ name }}_dealloc; 90 | Py{{ name }}Type.tp_getset = (PyGetSetDef*)get_set_defs; 91 | Py{{ name }}Type.tp_methods = (PyMethodDef*)method_defs; 92 | 93 | if (PyType_Ready(&Py{{ name }}Type) < 0) 94 | return false; 95 | 96 | Py_INCREF(&Py{{ name }}Type); 97 | if (PyModule_AddObject(module, "{{ name }}", (PyObject *) &Py{{ name }}Type) < 0) { 98 | Py_DECREF(&Py{{ name }}Type); 99 | return false; 100 | } 101 | 102 | return true; 103 | } -------------------------------------------------------------------------------- /codegen/templates/class.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #pragma once 20 | 21 | #define PY_SSIZE_T_CLEAN 22 | #include 23 | 24 | #include 25 | 26 | // Returns true if the object is a Py{{ name }}. 27 | bool Py{{ name }}_Check(PyObject* object); 28 | 29 | // Create Py{{ name }} from an TW{{ name }}. 30 | PyObject* Py{{ name }}_FromTW{{ name }}(TW{{ name }}* value); 31 | 32 | // Get enum TW{{ name }} value from a Py{{ name }} object. 33 | TW{{ name }}* Py{{ name }}_GetTW{{ name }}(PyObject* object); 34 | 35 | // Initialize for Py{{ name }}. It is called by python module init function. 36 | bool PyInit_{{ name }}(PyObject *module); -------------------------------------------------------------------------------- /codegen/templates/enum.cc: -------------------------------------------------------------------------------- 1 | {% include "header.template" %} 2 | 3 | {% include "includes.template" %} 4 | 5 | #include 6 | #include 7 | 8 | 9 | static PyTypeObject Py{{ name }}Type = { 10 | // clang-format off 11 | PyVarObject_HEAD_INIT(NULL, 0) 12 | // clang-format on 13 | "walletcore.{{ name }}", /* tp_name */ 14 | sizeof(Py{{ name }}Object), /* tp_basicsize */ 15 | 0, /* tp_itemsize */ 16 | 0, /* tp_dealloc */ 17 | 0, /* tp_print */ 18 | 0, /* tp_getattr */ 19 | 0, /* tp_setattr */ 20 | 0, /* tp_reserved */ 21 | 0, /* tp_repr */ 22 | 0, /* tp_as_number */ 23 | 0, /* tp_as_sequence */ 24 | 0, /* tp_as_mapping */ 25 | 0, /* tp_hash */ 26 | 0, /* tp_call */ 27 | 0, /* tp_str */ 28 | 0, /* tp_getattro */ 29 | 0, /* tp_setattro */ 30 | 0, /* tp_as_buffer */ 31 | Py_TPFLAGS_DEFAULT, /* tp_flags */ 32 | nullptr, /* tp_doc */ 33 | }; 34 | 35 | 36 | bool Py{{ name }}_Check(PyObject* object) { 37 | return PyObject_TypeCheck(object, &Py{{ name }}Type) != 0; 38 | } 39 | 40 | struct Constant { 41 | const TW{{ name }} value; 42 | const char* name; 43 | PyObject* pyvalue; 44 | }; 45 | 46 | static Constant constants[] = { 47 | // clang-format off 48 | {%- for constant in constants %} 49 | { TW{{ name }}{{ constant }}, "{{ constant }}", nullptr }, 50 | {%- endfor %} 51 | // clang-format on 52 | }; 53 | 54 | 55 | // Create Py{{ name }} from enum TW{{ name }}. It returns the same Py{{ name }} instance 56 | // for the same enum TW{{ name }} value. 57 | PyObject* Py{{ name }}_FromTW{{ name }}(TW{{ name }} value) { 58 | Constant* constant = 59 | std::find_if(std::begin(constants), std::end(constants), 60 | [value](const Constant& v) { return v.value == value; }); 61 | 62 | if (!constant) { 63 | PyErr_Format(PyExc_ValueError, "Invalid {{ name }} value: %d", value); 64 | return nullptr; 65 | } 66 | 67 | if (!constant->pyvalue) { 68 | auto* pyvalue = PyObject_New(Py{{ name }}Object, &Py{{ name }}Type); 69 | *const_cast(&pyvalue->value) = value; 70 | constant->pyvalue = (PyObject*)pyvalue; 71 | } 72 | 73 | Py_INCREF(constant->pyvalue); 74 | return constant->pyvalue; 75 | } 76 | 77 | TW{{ name }} Py{{ name }}_GetTW{{ name }}(PyObject* object) { 78 | assert(Py{{ name }}_Check(object)); 79 | return ((Py{{ name }}Object*)object)->value; 80 | } 81 | 82 | static int Py{{ name }}_init(Py{{ name }}Object *self, PyObject *args, PyObject *kwds) { 83 | return 0; 84 | } 85 | 86 | static PyObject* Py{{ name }}_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds) { 87 | int value = 0; 88 | if (!PyArg_ParseTuple(args, "|i", &value)) { 89 | return nullptr; 90 | } 91 | return Py{{ name }}_FromTW{{ name }}((TW{{ name }})value); 92 | } 93 | 94 | static PyObject* Py{{ name }}_str(Py{{ name }}Object *self) { 95 | Constant* constant = 96 | std::find_if(std::begin(constants), std::end(constants), 97 | [self](const Constant& v) { return v.value == self->value; }); 98 | 99 | return PyUnicode_FromString(constant ? constant->name : "Unknown"); 100 | } 101 | 102 | {% for function in functions %} 103 | {{ function }} 104 | {%- endfor %} 105 | 106 | {% include "properties.template" %} 107 | 108 | static const PyGetSetDef get_set_defs[] = { 109 | {%- for def in getsetdefs -%} 110 | {{ def }}, 111 | {%- endfor -%} 112 | {} 113 | }; 114 | 115 | static const PyMethodDef method_defs[] = { 116 | {%- for def in methoddefs -%} 117 | {{ def }}, 118 | {%- endfor -%} 119 | {} 120 | }; 121 | 122 | bool PyInit_{{ name }}(PyObject *module) { 123 | 124 | Py{{ name }}Type.tp_new = Py{{ name }}_new; 125 | Py{{ name }}Type.tp_init = (initproc)Py{{ name }}_init; 126 | Py{{ name }}Type.tp_str = (reprfunc)Py{{ name }}_str; 127 | Py{{ name }}Type.tp_getset = (PyGetSetDef*)get_set_defs; 128 | Py{{ name }}Type.tp_methods = (PyMethodDef*)method_defs; 129 | 130 | if (PyType_Ready(&Py{{ name }}Type) < 0) 131 | return false; 132 | 133 | Py_INCREF(&Py{{ name }}Type); 134 | if (PyModule_AddObject(module, "{{ name }}", (PyObject *) &Py{{ name }}Type) < 0) { 135 | Py_DECREF(&Py{{ name }}Type); 136 | return false; 137 | } 138 | 139 | PyObject* dict = Py{{ name }}Type.tp_dict; 140 | (void)dict; 141 | 142 | for (const Constant& constant : constants) { 143 | PyDict_SetItemString(dict, constant.name, Py{{ name }}_FromTW{{ name }}(constant.value)); 144 | } 145 | 146 | return true; 147 | } -------------------------------------------------------------------------------- /codegen/templates/enum.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #pragma once 20 | 21 | #define PY_SSIZE_T_CLEAN 22 | #include 23 | 24 | #include 25 | 26 | struct Py{{ name }}Object { 27 | PyObject_HEAD; 28 | const TW{{ name }} value; 29 | }; 30 | 31 | // Returns true if the object is a Py{{ name }}. 32 | bool Py{{ name }}_Check(PyObject* object); 33 | 34 | // Create Py{{ name }} from an enum TW{{ name }} value. 35 | // Note: it returns the same Py{{ name }} instance for the same enum TW{{ name }} value. 36 | // the caller should release the reference after using. 37 | PyObject* Py{{ name }}_FromTW{{ name }}(TW{{ name }} value); 38 | 39 | // Get enum TW{{ name }} value from a Py{{ name }} object. 40 | TW{{ name }} Py{{ name }}_GetTW{{ name }}(PyObject* object); 41 | 42 | // Initialize for Py{{ name }}. It is called by python module init function. 43 | bool PyInit_{{ name }}(PyObject *module); -------------------------------------------------------------------------------- /codegen/templates/header.template: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. -------------------------------------------------------------------------------- /codegen/templates/includes.template: -------------------------------------------------------------------------------- 1 | #include "generated/{{ name }}.h" 2 | 3 | {% for include in includes %} 4 | {{ include }} 5 | {%- endfor %} -------------------------------------------------------------------------------- /codegen/templates/module.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #define PY_SSIZE_T_CLEAN 20 | #include 21 | 22 | {% for include in includes -%} 23 | {{ include }} 24 | {% endfor %} 25 | 26 | typedef bool (*InitProc)(PyObject* module); 27 | const InitProc init_functions[]= { 28 | // clang-format off 29 | {%- for function in functions %} 30 | {{ function }}, 31 | {%- endfor %} 32 | // clang-format on 33 | }; 34 | 35 | PyMODINIT_FUNC 36 | PyInit_walletcore(void) { 37 | static struct PyModuleDef enum_module_def = { 38 | PyModuleDef_HEAD_INIT, 39 | "walletcore", /* m_name */ 40 | nullptr, /* m_doc */ 41 | -1, /* m_size */ 42 | nullptr /* m_methods */ 43 | }; 44 | 45 | PyObject *module = PyModule_Create(&enum_module_def); 46 | if (module == nullptr) { 47 | return nullptr; 48 | } 49 | 50 | for (const auto func : init_functions) { 51 | if (!func(module)) { 52 | Py_DECREF(module); 53 | return nullptr; 54 | } 55 | } 56 | 57 | return module; 58 | } -------------------------------------------------------------------------------- /codegen/templates/properties.template: -------------------------------------------------------------------------------- 1 | // properties 2 | {% for prop in properties %} 3 | {# {{ prop }}; #} 4 | {%- endfor %} -------------------------------------------------------------------------------- /codegen/templates/struct.cc: -------------------------------------------------------------------------------- 1 | {% include "header.template" %} 2 | 3 | {% include "includes.template" %} 4 | 5 | 6 | struct Py{{ name }}Object { 7 | PyObject_HEAD; 8 | }; 9 | 10 | static PyTypeObject Py{{ name }}Type = { 11 | // clang-format off 12 | PyVarObject_HEAD_INIT(NULL, 0) 13 | // clang-format on 14 | "walletcore.{{ name }}", /* tp_name */ 15 | sizeof(Py{{ name }}Object), /* tp_basicsize */ 16 | 0, /* tp_itemsize */ 17 | 0, /* tp_dealloc */ 18 | 0, /* tp_print */ 19 | 0, /* tp_getattr */ 20 | 0, /* tp_setattr */ 21 | 0, /* tp_reserved */ 22 | 0, /* tp_repr */ 23 | 0, /* tp_as_number */ 24 | 0, /* tp_as_sequence */ 25 | 0, /* tp_as_mapping */ 26 | 0, /* tp_hash */ 27 | 0, /* tp_call */ 28 | 0, /* tp_str */ 29 | 0, /* tp_getattro */ 30 | 0, /* tp_setattro */ 31 | 0, /* tp_as_buffer */ 32 | Py_TPFLAGS_DEFAULT, /* tp_flags */ 33 | nullptr, /* tp_doc */ 34 | }; 35 | 36 | {% for function in functions %} 37 | {{ function }} 38 | {%- endfor %} 39 | 40 | {% include "properties.template" %} 41 | 42 | static const PyGetSetDef get_set_defs[] = { 43 | {%- for def in getsetdefs -%} 44 | {{ def }}, 45 | {%- endfor -%} 46 | {} 47 | }; 48 | 49 | static const PyMethodDef method_defs[] = { 50 | {%- for def in methoddefs -%} 51 | {{ def }}, 52 | {%- endfor -%} 53 | {} 54 | }; 55 | 56 | bool PyInit_{{ name }}(PyObject *module) { 57 | Py{{ name }}Type.tp_getset = (PyGetSetDef*)get_set_defs; 58 | Py{{ name }}Type.tp_methods = (PyMethodDef*)method_defs; 59 | 60 | if (PyType_Ready(&Py{{ name }}Type) < 0) 61 | return false; 62 | 63 | Py_INCREF(&Py{{ name }}Type); 64 | if (PyModule_AddObject(module, "{{ name }}", (PyObject *) &Py{{ name }}Type) < 0) { 65 | Py_DECREF(&Py{{ name }}Type); 66 | return false; 67 | } 68 | 69 | return true; 70 | } -------------------------------------------------------------------------------- /codegen/templates/struct.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #pragma once 20 | 21 | #define PY_SSIZE_T_CLEAN 22 | #include 23 | 24 | #include 25 | 26 | // Initialize for Py{{ name }}. It is called by python module init function. 27 | bool PyInit_{{ name }}(PyObject *module); -------------------------------------------------------------------------------- /demo/address.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright 2021 Peng Huang 3 | # This file is part of Wallet-core-python. 4 | # 5 | # Wallet-core-python is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # Wallet-core-python is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with Wallet-core-python. If not, see . 17 | 18 | import walletcore as core 19 | 20 | def main(): 21 | mnemonic = input('mnemonic:') 22 | passphrase = input('passphrase:') 23 | wallet = core.HDWallet.create_with_mnemonic(mnemonic, passphrase) 24 | if not wallet: 25 | print('Invalid mnemonic') 26 | return 27 | address = wallet.get_address_for_coin(core.CoinType.Bitcoin) 28 | print('BTC address="{}"'.format(address)) 29 | address = wallet.get_address_for_coin(core.CoinType.Ethereum) 30 | print('ETH address="{}"'.format(address)) 31 | 32 | if __name__ == '__main__': 33 | main() -------------------------------------------------------------------------------- /demo/sample.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright 2021 Peng Huang 3 | # This file is part of Wallet-core-python. 4 | # 5 | # Wallet-core-python is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # Wallet-core-python is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with Wallet-core-python. If not, see . 17 | 18 | import walletcore as core 19 | import base64 20 | 21 | def main(): 22 | print(''' 23 | Wallet Core Demo, python 24 | 25 | *** DISCLAIMER *** 26 | THIS IS A SAMPLE APPLICATION WITH DEMONSTRATION PURPOSES ONLY. 27 | DO NOT USE WITH REAL SECRETS, REAL ADDRESSESS, OR REAL TRANSACTIONS. USE IT AT YOUR OWN RISK. 28 | *** DISCLAIMER *** 29 | ''') 30 | 31 | # Create a new multi-coin HD wallet, with new recovery phrase (mnemonic) 32 | print('Creating a new HD wallet ... ') 33 | wallet = core.HDWallet.create(128, '') 34 | print('Done.') 35 | print('Secret mnemonic for new wallet:') 36 | print(wallet.mnemonic) 37 | 38 | # Alternative: Import wallet with existing recovery phrase (mnemonic) 39 | print('Importing an HD wallet from earlier ... ') 40 | secret_mnemonic = 'ripple scissors kick mammal hire column oak again sun offer wealth tomorrow wagon turn fatal' 41 | wallet = core.HDWallet.create_with_mnemonic(secret_mnemonic, '') 42 | print('Done.') 43 | print('Secret mnemonic for new wallet:') 44 | print(wallet.mnemonic) 45 | 46 | # coin type: we use Ethereum 47 | coin_type = core.CoinType.Ethereum 48 | print('Working with coin: {} {}'.format( 49 | core.CoinTypeConfiguration.get_name(coin_type), 50 | core.CoinTypeConfiguration.get_symbol(coin_type))) 51 | 52 | # Derive default address. 53 | print('Obtaining default address ... ') 54 | address = wallet.get_address_for_coin(coin_type) 55 | print('Default address: "{}"'.format(address)) 56 | 57 | 58 | # Alternative: Derive address using default derivation path. 59 | # Done in 2 steps: derive private key, then address from private key. 60 | # Note that private key is passed around between the two calls by the wallet -- be always cautious when handling secrets, avoid the risk of leaking secrets. 61 | print('Default derivation path: ' + coin_type.derivation_path()) 62 | secret_private_key_default = wallet.get_key_for_coin(coin_type) 63 | address_default = coin_type.derive_address(secret_private_key_default) 64 | print('Address from default key: ' + address_default) 65 | 66 | # Alternative: Derive address using custom derivation path. 67 | # Done in 2 steps: derive private key, then address. 68 | custom_derivation_path = "m/44'/60'/1'/0/0" 69 | secret_private_key_custom = wallet.get_key(coin_type, custom_derivation_path) 70 | address_custom = coin_type.derive_address(secret_private_key_custom) 71 | print('custom address for derivation path {}: "{}"'.format(custom_derivation_path, address_custom)) 72 | 73 | # Steps for sending: 74 | # 1. put together a send message (contains sender and receiver address, amount, gas price, etc.) 75 | # 2. sign this message 76 | # 3. broadcast this message to the P2P network -- not done in this sample 77 | # Note that Signer input and output are represented as protobuf binary messages, for which support is missing in C++. 78 | # Therefore some direct serialization/parsing is done in helper methods. 79 | print('SEND funds:') 80 | dummy_receiver_address = '0xC37054b3b48C3317082E7ba872d7753D13da4986' 81 | secret_priv_key = secret_private_key_default.data 82 | 83 | print('preparing transaction (using AnySigner) ... ') 84 | chainIdB64 = 'AQ==' # base64(parse_hex("01")) 85 | gasPriceB64 = '1pOkAA==' # base64(parse_hex("d693a4")) decimal 3600000000 86 | gasLimitB64 = 'Ugg=' # base64(parse_hex("5208")) decimal 21000 87 | amountB64 = 'A0i8paFgAA==' # base64(parse_hex("0348bca5a160")) 924400000000000 88 | transaction = ''' 89 | {{ 90 | "chainId": "{}", 91 | "gasPrice":"{}", 92 | "gasLimit":"{}", 93 | "toAddress":"{}", 94 | "transaction":{{ 95 | "transfer":{{ 96 | "amount":"{}" 97 | }} 98 | }} 99 | }}'''.format(chainIdB64, gasPriceB64, gasLimitB64, dummy_receiver_address, amountB64) 100 | 101 | print('transaction: ' + transaction) 102 | 103 | print('signing transaction ... ') 104 | 105 | json = transaction 106 | signed_transaction = core.AnySigner.sign_json(json, secret_priv_key, coin_type) 107 | 108 | print('done') 109 | print('Signed transaction data (to be broadcast to network): (len {}) "{}"'.format( 110 | len(signed_transaction), signed_transaction)) 111 | # see e.g. https://github.com/flightwallet/decode-eth-tx for checking binary output content 112 | 113 | if __name__ == '__main__': 114 | main() 115 | -------------------------------------------------------------------------------- /demo/wallet.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright 2021 Peng Huang 3 | # This file is part of Wallet-core-python. 4 | # 5 | # Wallet-core-python is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # Wallet-core-python is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with Wallet-core-python. If not, see . 17 | 18 | import walletcore as core 19 | 20 | def create_wallet(): 21 | print('=== creat wallet') 22 | wallet = core.HDWallet.create(128, 'aabbcc') 23 | mnemonic = wallet.mnemonic 24 | entropy = wallet.entropy 25 | print('mnemonic="{}"'.format(mnemonic)) 26 | print('Entropy="{}" size={}'.format(entropy, len(entropy))) 27 | 28 | address = wallet.get_address_for_coin(core.CoinType.Bitcoin) 29 | print('BTC address="{}"'.format(address)) 30 | 31 | address = wallet.get_address_for_coin(core.CoinType.Ethereum) 32 | print('ETH address="{}"'.format(address)) 33 | 34 | def mnemonic_demo(): 35 | print('=== mnemonic demo') 36 | suggestion = core.Mnemonic.suggest('be') 37 | print('Mnemonic suggestion for "be": {}'.format(suggestion)) 38 | 39 | 40 | if __name__ == '__main__': 41 | create_wallet() 42 | mnemonic_demo() 43 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | # Copyright 2021 Peng Huang 2 | # This file is part of Wallet-core-python. 3 | # 4 | # Wallet-core-python is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation, either version 3 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # Wallet-core-python is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License 15 | # along with Wallet-core-python. If not, see . 16 | 17 | import os 18 | from glob import glob 19 | from distutils.core import setup, Extension 20 | 21 | # Use clang since wallet-core headers don't compile with gcc 22 | if 'CC' not in os.environ: 23 | os.environ['CC'] = 'clang' 24 | if 'CXX' not in os.environ: 25 | os.environ['CXX'] = 'clang++' 26 | 27 | WALLET_CORE_ROOT = 'wallet-core' 28 | WALLET_CORE_INCLUDE = os.path.join(WALLET_CORE_ROOT, 'include') 29 | WALLET_CORE_BUILD = os.path.join(WALLET_CORE_ROOT, 'build') 30 | TREZOR_CRYPTO = os.path.join(WALLET_CORE_BUILD, 'trezor-crypto') 31 | 32 | link_args = [] 33 | # Add --coverage link arg otherwise linking fails with undefined symbols 34 | for line in open(os.path.join(WALLET_CORE_BUILD, 'CMakeCache.txt')): 35 | line = line.strip() 36 | if line == 'CODE_COVERAGE:BOOL=ON': 37 | link_args.append('--coverage') 38 | break 39 | 40 | compile_args = ['-std=c++17'] 41 | 42 | module = Extension('walletcore', 43 | include_dirs=[WALLET_CORE_INCLUDE, 'src'], 44 | library_dirs=[WALLET_CORE_BUILD, TREZOR_CRYPTO], 45 | libraries=['TrustWalletCore', 'protobuf', 'TrezorCrypto'], 46 | extra_compile_args=compile_args, 47 | extra_link_args=link_args, 48 | sources=glob('src/*.cc') + glob('src/generated/*.cc')) 49 | 50 | setup(name='walletcore', 51 | version='0.1.0', 52 | description='Trust wallet core', 53 | author='Peng Huang', 54 | author_email='shawn.p.huang@gmail.com', 55 | url='https://github.com/phuang/wallet-core-python', 56 | download_url='', 57 | keywords=['cryptocurrency', 'wallet'], 58 | ext_modules=[module], 59 | classifiers=[ 60 | 'Development Status :: 3 - Alpha', 61 | 'Intended Audience :: Developers', 62 | 'Operating System :: POSIX :: Linux', 63 | 'Topic :: Software Development :: Libraries :: Python Modules', 64 | 'License :: OSI Approved :: GPL3', 65 | 'Programming Language :: C++', 66 | '', 67 | ]) 68 | -------------------------------------------------------------------------------- /src/AnySigner.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | 17 | #pragma once 18 | 19 | #define PY_SSIZE_T_CLEAN 20 | #include 21 | 22 | #include 23 | 24 | // Initialize for PyAnySigner. It is called by python module init function. 25 | bool PyInit_AnySigner(PyObject* module); -------------------------------------------------------------------------------- /src/Bool.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | 17 | #pragma once 18 | 19 | #define PY_SSIZE_T_CLEAN 20 | #include 21 | #include 22 | 23 | #define PyBool_IsTrue(o) ((o) == Py_True) 24 | -------------------------------------------------------------------------------- /src/Data.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | 17 | #include "Data.h" 18 | 19 | PyObject* PyBytes_FromTWData(const TWDataPtr& data) { 20 | if (!data) 21 | Py_RETURN_NONE; 22 | 23 | return PyBytes_FromStringAndSize((const char*)TWDataBytes(data.get()), 24 | TWDataSize(data.get())); 25 | } 26 | 27 | TWDataPtr PyBytes_GetTWData(PyObject* object) { 28 | if (!PyBytes_Check(object)) 29 | return {}; 30 | 31 | TWData* result = TWDataCreateWithBytes( 32 | (const uint8_t*)PyBytes_AS_STRING(object), PyBytes_GET_SIZE(object)); 33 | return TWDataPtr(result); 34 | } -------------------------------------------------------------------------------- /src/Data.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | 17 | #pragma once 18 | 19 | #include 20 | 21 | #define PY_SSIZE_T_CLEAN 22 | #include 23 | #include 24 | 25 | struct TWDataDeleter { 26 | void operator()(TWData* data) { 27 | TWDataDelete(data); 28 | } 29 | }; 30 | 31 | // std::unique_ptr for holding TWData* 32 | using TWDataPtr = std::unique_ptr; 33 | 34 | // Create PyBytes object from TWData. 35 | PyObject* PyBytes_FromTWData(const TWDataPtr& data); 36 | 37 | // Get content of PyBytes in a new allocated TWData. 38 | TWDataPtr PyBytes_GetTWData(PyObject* object); -------------------------------------------------------------------------------- /src/Number.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | 17 | #pragma once 18 | 19 | #include 20 | #include 21 | 22 | #define PY_SSIZE_T_CLEAN 23 | #include 24 | 25 | template 26 | inline std::optional NumericCast(Src value) { 27 | typedef std::numeric_limits DstLim; 28 | typedef std::numeric_limits SrcLim; 29 | 30 | constexpr bool positive_overflow_possible = DstLim::max() < SrcLim::max(); 31 | constexpr bool negative_overflow_possible = 32 | SrcLim::is_signed || (DstLim::lowest() > SrcLim::lowest()); 33 | 34 | // unsigned <-- unsigned 35 | if ((!DstLim::is_signed) && (!SrcLim::is_signed)) { 36 | if (positive_overflow_possible && (value > DstLim::max())) { 37 | return std::nullopt; 38 | } 39 | } 40 | // unsigned <-- signed 41 | else if ((!DstLim::is_signed) && SrcLim::is_signed) { 42 | if (positive_overflow_possible && (value > DstLim::max())) { 43 | return std::nullopt; 44 | } else if (negative_overflow_possible && (value < 0)) { 45 | return std::nullopt; 46 | } 47 | 48 | } 49 | // signed <-- unsigned 50 | else if (DstLim::is_signed && (!SrcLim::is_signed)) { 51 | if (positive_overflow_possible && (value > DstLim::max())) { 52 | return std::nullopt; 53 | } 54 | } 55 | // signed <-- signed 56 | else if (DstLim::is_signed && SrcLim::is_signed) { 57 | if (positive_overflow_possible && (value > DstLim::max())) { 58 | return std::nullopt; 59 | } else if (negative_overflow_possible && (value < DstLim::lowest())) { 60 | return std::nullopt; 61 | } 62 | } 63 | 64 | // limits have been checked, therefore safe to cast 65 | return std::make_optional(static_cast(value)); 66 | } 67 | 68 | template 69 | inline std::optional PyLongArg_ToNumber(PyObject* arg, 70 | int i, 71 | const char* type) { 72 | if (!PyLong_Check(arg)) { 73 | PyErr_Format(PyExc_TypeError, "The arg %d is not in a number", i); 74 | return std::nullopt; 75 | } 76 | 77 | auto longlong = PyLong_AsLongLong(arg); 78 | if (PyErr_Occurred()) { 79 | return std::nullopt; 80 | } 81 | 82 | auto result = NumericCast(longlong); 83 | if (!result) { 84 | PyErr_Format(PyExc_ValueError, "The arg %d value %lld doesn't fit in %s", i, 85 | longlong, type); 86 | return std::nullopt; 87 | } 88 | 89 | return result; 90 | } -------------------------------------------------------------------------------- /src/String.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | 17 | #include "String.h" 18 | 19 | PyObject* PyUnicode_FromTWString(const TWStringPtr& str) { 20 | if (!str) 21 | Py_RETURN_NONE; 22 | 23 | return PyUnicode_FromStringAndSize(TWStringUTF8Bytes(str.get()), 24 | TWStringSize(str.get())); 25 | } 26 | 27 | TWStringPtr PyUnicode_GetTWString(PyObject* object) { 28 | if (!PyUnicode_Check(object)) 29 | return {}; 30 | 31 | Py_ssize_t size = 0; 32 | const char* str = PyUnicode_AsUTF8AndSize(object, &size); 33 | TWString* result = TWStringCreateWithRawBytes((const uint8_t*)str, size); 34 | return TWStringPtr(result); 35 | } -------------------------------------------------------------------------------- /src/String.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | 17 | #pragma once 18 | 19 | #include 20 | 21 | #define PY_SSIZE_T_CLEAN 22 | #include 23 | #include 24 | 25 | struct TWStringDeleter { 26 | void operator()(TWString* string) { 27 | TWStringDelete(string); 28 | } 29 | }; 30 | 31 | // std::unique_ptr for holding TWString* 32 | using TWStringPtr = std::unique_ptr; 33 | 34 | // Create a PyUnicode object from a TWString. 35 | PyObject* PyUnicode_FromTWString(const TWStringPtr& str); 36 | 37 | // Get content of a PyUnicode in a new allocated TWString. 38 | TWStringPtr PyUnicode_GetTWString(PyObject* object); -------------------------------------------------------------------------------- /src/generated/AES.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #pragma once 20 | 21 | #define PY_SSIZE_T_CLEAN 22 | #include 23 | 24 | #include 25 | 26 | // Initialize for PyAES. It is called by python module init function. 27 | bool PyInit_AES(PyObject* module); -------------------------------------------------------------------------------- /src/generated/AESPaddingMode.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #include "generated/AESPaddingMode.h" 20 | 21 | #include 22 | #include 23 | 24 | static PyTypeObject PyAESPaddingModeType = { 25 | // clang-format off 26 | PyVarObject_HEAD_INIT(NULL, 0) 27 | // clang-format on 28 | "walletcore.AESPaddingMode", /* tp_name */ 29 | sizeof(PyAESPaddingModeObject), /* tp_basicsize */ 30 | 0, /* tp_itemsize */ 31 | 0, /* tp_dealloc */ 32 | 0, /* tp_print */ 33 | 0, /* tp_getattr */ 34 | 0, /* tp_setattr */ 35 | 0, /* tp_reserved */ 36 | 0, /* tp_repr */ 37 | 0, /* tp_as_number */ 38 | 0, /* tp_as_sequence */ 39 | 0, /* tp_as_mapping */ 40 | 0, /* tp_hash */ 41 | 0, /* tp_call */ 42 | 0, /* tp_str */ 43 | 0, /* tp_getattro */ 44 | 0, /* tp_setattro */ 45 | 0, /* tp_as_buffer */ 46 | Py_TPFLAGS_DEFAULT, /* tp_flags */ 47 | nullptr, /* tp_doc */ 48 | }; 49 | 50 | bool PyAESPaddingMode_Check(PyObject* object) { 51 | return PyObject_TypeCheck(object, &PyAESPaddingModeType) != 0; 52 | } 53 | 54 | struct Constant { 55 | const TWAESPaddingMode value; 56 | const char* name; 57 | PyObject* pyvalue; 58 | }; 59 | 60 | static Constant constants[] = { 61 | // clang-format off 62 | { TWAESPaddingModeZero, "Zero", nullptr }, 63 | { TWAESPaddingModePKCS7, "PKCS7", nullptr }, 64 | // clang-format on 65 | }; 66 | 67 | // Create PyAESPaddingMode from enum TWAESPaddingMode. It returns the same 68 | // PyAESPaddingMode instance for the same enum TWAESPaddingMode value. 69 | PyObject* PyAESPaddingMode_FromTWAESPaddingMode(TWAESPaddingMode value) { 70 | Constant* constant = 71 | std::find_if(std::begin(constants), std::end(constants), 72 | [value](const Constant& v) { return v.value == value; }); 73 | 74 | if (!constant) { 75 | PyErr_Format(PyExc_ValueError, "Invalid AESPaddingMode value: %d", value); 76 | return nullptr; 77 | } 78 | 79 | if (!constant->pyvalue) { 80 | auto* pyvalue = PyObject_New(PyAESPaddingModeObject, &PyAESPaddingModeType); 81 | *const_cast(&pyvalue->value) = value; 82 | constant->pyvalue = (PyObject*)pyvalue; 83 | } 84 | 85 | Py_INCREF(constant->pyvalue); 86 | return constant->pyvalue; 87 | } 88 | 89 | TWAESPaddingMode PyAESPaddingMode_GetTWAESPaddingMode(PyObject* object) { 90 | assert(PyAESPaddingMode_Check(object)); 91 | return ((PyAESPaddingModeObject*)object)->value; 92 | } 93 | 94 | static int PyAESPaddingMode_init(PyAESPaddingModeObject* self, 95 | PyObject* args, 96 | PyObject* kwds) { 97 | return 0; 98 | } 99 | 100 | static PyObject* PyAESPaddingMode_new(PyTypeObject* subtype, 101 | PyObject* args, 102 | PyObject* kwds) { 103 | int value = 0; 104 | if (!PyArg_ParseTuple(args, "|i", &value)) { 105 | return nullptr; 106 | } 107 | return PyAESPaddingMode_FromTWAESPaddingMode((TWAESPaddingMode)value); 108 | } 109 | 110 | static PyObject* PyAESPaddingMode_str(PyAESPaddingModeObject* self) { 111 | Constant* constant = std::find_if( 112 | std::begin(constants), std::end(constants), 113 | [self](const Constant& v) { return v.value == self->value; }); 114 | 115 | return PyUnicode_FromString(constant ? constant->name : "Unknown"); 116 | } 117 | 118 | // properties 119 | 120 | static const PyGetSetDef get_set_defs[] = {{}}; 121 | 122 | static const PyMethodDef method_defs[] = {{}}; 123 | 124 | bool PyInit_AESPaddingMode(PyObject* module) { 125 | PyAESPaddingModeType.tp_new = PyAESPaddingMode_new; 126 | PyAESPaddingModeType.tp_init = (initproc)PyAESPaddingMode_init; 127 | PyAESPaddingModeType.tp_str = (reprfunc)PyAESPaddingMode_str; 128 | PyAESPaddingModeType.tp_getset = (PyGetSetDef*)get_set_defs; 129 | PyAESPaddingModeType.tp_methods = (PyMethodDef*)method_defs; 130 | 131 | if (PyType_Ready(&PyAESPaddingModeType) < 0) 132 | return false; 133 | 134 | Py_INCREF(&PyAESPaddingModeType); 135 | if (PyModule_AddObject(module, "AESPaddingMode", 136 | (PyObject*)&PyAESPaddingModeType) < 0) { 137 | Py_DECREF(&PyAESPaddingModeType); 138 | return false; 139 | } 140 | 141 | PyObject* dict = PyAESPaddingModeType.tp_dict; 142 | (void)dict; 143 | 144 | for (const Constant& constant : constants) { 145 | PyDict_SetItemString(dict, constant.name, 146 | PyAESPaddingMode_FromTWAESPaddingMode(constant.value)); 147 | } 148 | 149 | return true; 150 | } -------------------------------------------------------------------------------- /src/generated/AESPaddingMode.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #pragma once 20 | 21 | #define PY_SSIZE_T_CLEAN 22 | #include 23 | 24 | #include 25 | 26 | struct PyAESPaddingModeObject { 27 | PyObject_HEAD; 28 | const TWAESPaddingMode value; 29 | }; 30 | 31 | // Returns true if the object is a PyAESPaddingMode. 32 | bool PyAESPaddingMode_Check(PyObject* object); 33 | 34 | // Create PyAESPaddingMode from an enum TWAESPaddingMode value. 35 | // Note: it returns the same PyAESPaddingMode instance for the same enum 36 | // TWAESPaddingMode value. the caller should release the reference after using. 37 | PyObject* PyAESPaddingMode_FromTWAESPaddingMode(TWAESPaddingMode value); 38 | 39 | // Get enum TWAESPaddingMode value from a PyAESPaddingMode object. 40 | TWAESPaddingMode PyAESPaddingMode_GetTWAESPaddingMode(PyObject* object); 41 | 42 | // Initialize for PyAESPaddingMode. It is called by python module init function. 43 | bool PyInit_AESPaddingMode(PyObject* module); -------------------------------------------------------------------------------- /src/generated/Account.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #pragma once 20 | 21 | #define PY_SSIZE_T_CLEAN 22 | #include 23 | 24 | #include 25 | 26 | // Returns true if the object is a PyAccount. 27 | bool PyAccount_Check(PyObject* object); 28 | 29 | // Create PyAccount from an TWAccount. 30 | PyObject* PyAccount_FromTWAccount(TWAccount* value); 31 | 32 | // Get enum TWAccount value from a PyAccount object. 33 | TWAccount* PyAccount_GetTWAccount(PyObject* object); 34 | 35 | // Initialize for PyAccount. It is called by python module init function. 36 | bool PyInit_Account(PyObject* module); -------------------------------------------------------------------------------- /src/generated/AnyAddress.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #pragma once 20 | 21 | #define PY_SSIZE_T_CLEAN 22 | #include 23 | 24 | #include 25 | 26 | // Returns true if the object is a PyAnyAddress. 27 | bool PyAnyAddress_Check(PyObject* object); 28 | 29 | // Create PyAnyAddress from an TWAnyAddress. 30 | PyObject* PyAnyAddress_FromTWAnyAddress(TWAnyAddress* value); 31 | 32 | // Get enum TWAnyAddress value from a PyAnyAddress object. 33 | TWAnyAddress* PyAnyAddress_GetTWAnyAddress(PyObject* object); 34 | 35 | // Initialize for PyAnyAddress. It is called by python module init function. 36 | bool PyInit_AnyAddress(PyObject* module); -------------------------------------------------------------------------------- /src/generated/Base32.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #pragma once 20 | 21 | #define PY_SSIZE_T_CLEAN 22 | #include 23 | 24 | #include 25 | 26 | // Initialize for PyBase32. It is called by python module init function. 27 | bool PyInit_Base32(PyObject* module); -------------------------------------------------------------------------------- /src/generated/Base58.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #pragma once 20 | 21 | #define PY_SSIZE_T_CLEAN 22 | #include 23 | 24 | #include 25 | 26 | // Initialize for PyBase58. It is called by python module init function. 27 | bool PyInit_Base58(PyObject* module); -------------------------------------------------------------------------------- /src/generated/Base64.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #pragma once 20 | 21 | #define PY_SSIZE_T_CLEAN 22 | #include 23 | 24 | #include 25 | 26 | // Initialize for PyBase64. It is called by python module init function. 27 | bool PyInit_Base64(PyObject* module); -------------------------------------------------------------------------------- /src/generated/BitcoinAddress.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #pragma once 20 | 21 | #define PY_SSIZE_T_CLEAN 22 | #include 23 | 24 | #include 25 | 26 | // Returns true if the object is a PyBitcoinAddress. 27 | bool PyBitcoinAddress_Check(PyObject* object); 28 | 29 | // Create PyBitcoinAddress from an TWBitcoinAddress. 30 | PyObject* PyBitcoinAddress_FromTWBitcoinAddress(TWBitcoinAddress* value); 31 | 32 | // Get enum TWBitcoinAddress value from a PyBitcoinAddress object. 33 | TWBitcoinAddress* PyBitcoinAddress_GetTWBitcoinAddress(PyObject* object); 34 | 35 | // Initialize for PyBitcoinAddress. It is called by python module init function. 36 | bool PyInit_BitcoinAddress(PyObject* module); -------------------------------------------------------------------------------- /src/generated/BitcoinMessageSigner.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #pragma once 20 | 21 | #define PY_SSIZE_T_CLEAN 22 | #include 23 | 24 | #include 25 | 26 | // Initialize for PyBitcoinMessageSigner. It is called by python module init 27 | // function. 28 | bool PyInit_BitcoinMessageSigner(PyObject* module); -------------------------------------------------------------------------------- /src/generated/BitcoinScript.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #pragma once 20 | 21 | #define PY_SSIZE_T_CLEAN 22 | #include 23 | 24 | #include 25 | 26 | // Returns true if the object is a PyBitcoinScript. 27 | bool PyBitcoinScript_Check(PyObject* object); 28 | 29 | // Create PyBitcoinScript from an TWBitcoinScript. 30 | PyObject* PyBitcoinScript_FromTWBitcoinScript(TWBitcoinScript* value); 31 | 32 | // Get enum TWBitcoinScript value from a PyBitcoinScript object. 33 | TWBitcoinScript* PyBitcoinScript_GetTWBitcoinScript(PyObject* object); 34 | 35 | // Initialize for PyBitcoinScript. It is called by python module init function. 36 | bool PyInit_BitcoinScript(PyObject* module); -------------------------------------------------------------------------------- /src/generated/BitcoinSigHashType.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #pragma once 20 | 21 | #define PY_SSIZE_T_CLEAN 22 | #include 23 | 24 | #include 25 | 26 | struct PyBitcoinSigHashTypeObject { 27 | PyObject_HEAD; 28 | const TWBitcoinSigHashType value; 29 | }; 30 | 31 | // Returns true if the object is a PyBitcoinSigHashType. 32 | bool PyBitcoinSigHashType_Check(PyObject* object); 33 | 34 | // Create PyBitcoinSigHashType from an enum TWBitcoinSigHashType value. 35 | // Note: it returns the same PyBitcoinSigHashType instance for the same enum 36 | // TWBitcoinSigHashType value. the caller should release the reference after 37 | // using. 38 | PyObject* PyBitcoinSigHashType_FromTWBitcoinSigHashType( 39 | TWBitcoinSigHashType value); 40 | 41 | // Get enum TWBitcoinSigHashType value from a PyBitcoinSigHashType object. 42 | TWBitcoinSigHashType PyBitcoinSigHashType_GetTWBitcoinSigHashType( 43 | PyObject* object); 44 | 45 | // Initialize for PyBitcoinSigHashType. It is called by python module init 46 | // function. 47 | bool PyInit_BitcoinSigHashType(PyObject* module); -------------------------------------------------------------------------------- /src/generated/Blockchain.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #pragma once 20 | 21 | #define PY_SSIZE_T_CLEAN 22 | #include 23 | 24 | #include 25 | 26 | struct PyBlockchainObject { 27 | PyObject_HEAD; 28 | const TWBlockchain value; 29 | }; 30 | 31 | // Returns true if the object is a PyBlockchain. 32 | bool PyBlockchain_Check(PyObject* object); 33 | 34 | // Create PyBlockchain from an enum TWBlockchain value. 35 | // Note: it returns the same PyBlockchain instance for the same enum 36 | // TWBlockchain value. the caller should release the reference after using. 37 | PyObject* PyBlockchain_FromTWBlockchain(TWBlockchain value); 38 | 39 | // Get enum TWBlockchain value from a PyBlockchain object. 40 | TWBlockchain PyBlockchain_GetTWBlockchain(PyObject* object); 41 | 42 | // Initialize for PyBlockchain. It is called by python module init function. 43 | bool PyInit_Blockchain(PyObject* module); -------------------------------------------------------------------------------- /src/generated/Cardano.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #include "generated/Cardano.h" 20 | 21 | #include "Data.h" 22 | #include "String.h" 23 | 24 | struct PyCardanoObject { 25 | PyObject_HEAD; 26 | }; 27 | 28 | static PyTypeObject PyCardanoType = { 29 | // clang-format off 30 | PyVarObject_HEAD_INIT(NULL, 0) 31 | // clang-format on 32 | "walletcore.Cardano", /* tp_name */ 33 | sizeof(PyCardanoObject), /* tp_basicsize */ 34 | 0, /* tp_itemsize */ 35 | 0, /* tp_dealloc */ 36 | 0, /* tp_print */ 37 | 0, /* tp_getattr */ 38 | 0, /* tp_setattr */ 39 | 0, /* tp_reserved */ 40 | 0, /* tp_repr */ 41 | 0, /* tp_as_number */ 42 | 0, /* tp_as_sequence */ 43 | 0, /* tp_as_mapping */ 44 | 0, /* tp_hash */ 45 | 0, /* tp_call */ 46 | 0, /* tp_str */ 47 | 0, /* tp_getattro */ 48 | 0, /* tp_setattro */ 49 | 0, /* tp_as_buffer */ 50 | Py_TPFLAGS_DEFAULT, /* tp_flags */ 51 | nullptr, /* tp_doc */ 52 | }; 53 | 54 | // static method function for MinAdaAmount 55 | static const char PyCardanoMinAdaAmount_doc[] = 56 | "uint64_t TWCardanoMinAdaAmount(TWData* tokenBundle)"; 57 | static PyObject* PyCardanoMinAdaAmount(PyCardanoObject* self, 58 | PyObject* const* args, 59 | Py_ssize_t nargs) { 60 | if (nargs != 1) { 61 | PyErr_Format(PyExc_TypeError, "Expect 1 args, but %d args are passed in.", 62 | nargs); 63 | return nullptr; 64 | } 65 | 66 | if (!PyBytes_Check(args[0])) { 67 | PyErr_SetString(PyExc_TypeError, "The arg 0 is not in type Bytes"); 68 | return nullptr; 69 | } 70 | auto arg0 = PyBytes_GetTWData(args[0]); 71 | 72 | uint64_t result = TWCardanoMinAdaAmount(arg0.get()); 73 | return PyLong_FromLong(result); 74 | } 75 | 76 | // static method function for GetStakingAddress 77 | static const char PyCardanoGetStakingAddress_doc[] = 78 | "TWString* TWCardanoGetStakingAddress(TWString* baseAddress)"; 79 | static PyObject* PyCardanoGetStakingAddress(PyCardanoObject* self, 80 | PyObject* const* args, 81 | Py_ssize_t nargs) { 82 | if (nargs != 1) { 83 | PyErr_Format(PyExc_TypeError, "Expect 1 args, but %d args are passed in.", 84 | nargs); 85 | return nullptr; 86 | } 87 | 88 | if (!PyUnicode_Check(args[0])) { 89 | PyErr_SetString(PyExc_TypeError, "The arg 0 is not in type Unicode"); 90 | return nullptr; 91 | } 92 | auto arg0 = PyUnicode_GetTWString(args[0]); 93 | 94 | TWStringPtr result(TWCardanoGetStakingAddress(arg0.get())); 95 | return PyUnicode_FromTWString(result); 96 | } 97 | 98 | // properties 99 | 100 | static const PyGetSetDef get_set_defs[] = {{}}; 101 | 102 | static const PyMethodDef method_defs[] = { 103 | {"min_ada_amount", (PyCFunction)PyCardanoMinAdaAmount, 104 | METH_FASTCALL | METH_STATIC, PyCardanoMinAdaAmount_doc}, 105 | {"get_staking_address", (PyCFunction)PyCardanoGetStakingAddress, 106 | METH_FASTCALL | METH_STATIC, PyCardanoGetStakingAddress_doc}, 107 | {}}; 108 | 109 | bool PyInit_Cardano(PyObject* module) { 110 | PyCardanoType.tp_getset = (PyGetSetDef*)get_set_defs; 111 | PyCardanoType.tp_methods = (PyMethodDef*)method_defs; 112 | 113 | if (PyType_Ready(&PyCardanoType) < 0) 114 | return false; 115 | 116 | Py_INCREF(&PyCardanoType); 117 | if (PyModule_AddObject(module, "Cardano", (PyObject*)&PyCardanoType) < 0) { 118 | Py_DECREF(&PyCardanoType); 119 | return false; 120 | } 121 | 122 | return true; 123 | } -------------------------------------------------------------------------------- /src/generated/Cardano.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #pragma once 20 | 21 | #define PY_SSIZE_T_CLEAN 22 | #include 23 | 24 | #include 25 | 26 | // Initialize for PyCardano. It is called by python module init function. 27 | bool PyInit_Cardano(PyObject* module); -------------------------------------------------------------------------------- /src/generated/CoinType.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #pragma once 20 | 21 | #define PY_SSIZE_T_CLEAN 22 | #include 23 | 24 | #include 25 | 26 | struct PyCoinTypeObject { 27 | PyObject_HEAD; 28 | const TWCoinType value; 29 | }; 30 | 31 | // Returns true if the object is a PyCoinType. 32 | bool PyCoinType_Check(PyObject* object); 33 | 34 | // Create PyCoinType from an enum TWCoinType value. 35 | // Note: it returns the same PyCoinType instance for the same enum TWCoinType 36 | // value. the caller should release the reference after using. 37 | PyObject* PyCoinType_FromTWCoinType(TWCoinType value); 38 | 39 | // Get enum TWCoinType value from a PyCoinType object. 40 | TWCoinType PyCoinType_GetTWCoinType(PyObject* object); 41 | 42 | // Initialize for PyCoinType. It is called by python module init function. 43 | bool PyInit_CoinType(PyObject* module); -------------------------------------------------------------------------------- /src/generated/CoinTypeConfiguration.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #pragma once 20 | 21 | #define PY_SSIZE_T_CLEAN 22 | #include 23 | 24 | #include 25 | 26 | // Initialize for PyCoinTypeConfiguration. It is called by python module init 27 | // function. 28 | bool PyInit_CoinTypeConfiguration(PyObject* module); -------------------------------------------------------------------------------- /src/generated/Curve.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #include "generated/Curve.h" 20 | 21 | #include 22 | #include 23 | 24 | static PyTypeObject PyCurveType = { 25 | // clang-format off 26 | PyVarObject_HEAD_INIT(NULL, 0) 27 | // clang-format on 28 | "walletcore.Curve", /* tp_name */ 29 | sizeof(PyCurveObject), /* tp_basicsize */ 30 | 0, /* tp_itemsize */ 31 | 0, /* tp_dealloc */ 32 | 0, /* tp_print */ 33 | 0, /* tp_getattr */ 34 | 0, /* tp_setattr */ 35 | 0, /* tp_reserved */ 36 | 0, /* tp_repr */ 37 | 0, /* tp_as_number */ 38 | 0, /* tp_as_sequence */ 39 | 0, /* tp_as_mapping */ 40 | 0, /* tp_hash */ 41 | 0, /* tp_call */ 42 | 0, /* tp_str */ 43 | 0, /* tp_getattro */ 44 | 0, /* tp_setattro */ 45 | 0, /* tp_as_buffer */ 46 | Py_TPFLAGS_DEFAULT, /* tp_flags */ 47 | nullptr, /* tp_doc */ 48 | }; 49 | 50 | bool PyCurve_Check(PyObject* object) { 51 | return PyObject_TypeCheck(object, &PyCurveType) != 0; 52 | } 53 | 54 | struct Constant { 55 | const TWCurve value; 56 | const char* name; 57 | PyObject* pyvalue; 58 | }; 59 | 60 | static Constant constants[] = { 61 | // clang-format off 62 | { TWCurveSECP256k1, "SECP256k1", nullptr }, 63 | { TWCurveED25519, "ED25519", nullptr }, 64 | { TWCurveED25519Blake2bNano, "ED25519Blake2bNano", nullptr }, 65 | { TWCurveCurve25519, "Curve25519", nullptr }, 66 | { TWCurveNIST256p1, "NIST256p1", nullptr }, 67 | { TWCurveED25519ExtendedCardano, "ED25519ExtendedCardano", nullptr }, 68 | { TWCurveStarkex, "Starkex", nullptr }, 69 | { TWCurveNone, "None", nullptr }, 70 | // clang-format on 71 | }; 72 | 73 | // Create PyCurve from enum TWCurve. It returns the same PyCurve instance 74 | // for the same enum TWCurve value. 75 | PyObject* PyCurve_FromTWCurve(TWCurve value) { 76 | Constant* constant = 77 | std::find_if(std::begin(constants), std::end(constants), 78 | [value](const Constant& v) { return v.value == value; }); 79 | 80 | if (!constant) { 81 | PyErr_Format(PyExc_ValueError, "Invalid Curve value: %d", value); 82 | return nullptr; 83 | } 84 | 85 | if (!constant->pyvalue) { 86 | auto* pyvalue = PyObject_New(PyCurveObject, &PyCurveType); 87 | *const_cast(&pyvalue->value) = value; 88 | constant->pyvalue = (PyObject*)pyvalue; 89 | } 90 | 91 | Py_INCREF(constant->pyvalue); 92 | return constant->pyvalue; 93 | } 94 | 95 | TWCurve PyCurve_GetTWCurve(PyObject* object) { 96 | assert(PyCurve_Check(object)); 97 | return ((PyCurveObject*)object)->value; 98 | } 99 | 100 | static int PyCurve_init(PyCurveObject* self, PyObject* args, PyObject* kwds) { 101 | return 0; 102 | } 103 | 104 | static PyObject* PyCurve_new(PyTypeObject* subtype, 105 | PyObject* args, 106 | PyObject* kwds) { 107 | int value = 0; 108 | if (!PyArg_ParseTuple(args, "|i", &value)) { 109 | return nullptr; 110 | } 111 | return PyCurve_FromTWCurve((TWCurve)value); 112 | } 113 | 114 | static PyObject* PyCurve_str(PyCurveObject* self) { 115 | Constant* constant = std::find_if( 116 | std::begin(constants), std::end(constants), 117 | [self](const Constant& v) { return v.value == self->value; }); 118 | 119 | return PyUnicode_FromString(constant ? constant->name : "Unknown"); 120 | } 121 | 122 | // properties 123 | 124 | static const PyGetSetDef get_set_defs[] = {{}}; 125 | 126 | static const PyMethodDef method_defs[] = {{}}; 127 | 128 | bool PyInit_Curve(PyObject* module) { 129 | PyCurveType.tp_new = PyCurve_new; 130 | PyCurveType.tp_init = (initproc)PyCurve_init; 131 | PyCurveType.tp_str = (reprfunc)PyCurve_str; 132 | PyCurveType.tp_getset = (PyGetSetDef*)get_set_defs; 133 | PyCurveType.tp_methods = (PyMethodDef*)method_defs; 134 | 135 | if (PyType_Ready(&PyCurveType) < 0) 136 | return false; 137 | 138 | Py_INCREF(&PyCurveType); 139 | if (PyModule_AddObject(module, "Curve", (PyObject*)&PyCurveType) < 0) { 140 | Py_DECREF(&PyCurveType); 141 | return false; 142 | } 143 | 144 | PyObject* dict = PyCurveType.tp_dict; 145 | (void)dict; 146 | 147 | for (const Constant& constant : constants) { 148 | PyDict_SetItemString(dict, constant.name, 149 | PyCurve_FromTWCurve(constant.value)); 150 | } 151 | 152 | return true; 153 | } -------------------------------------------------------------------------------- /src/generated/Curve.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #pragma once 20 | 21 | #define PY_SSIZE_T_CLEAN 22 | #include 23 | 24 | #include 25 | 26 | struct PyCurveObject { 27 | PyObject_HEAD; 28 | const TWCurve value; 29 | }; 30 | 31 | // Returns true if the object is a PyCurve. 32 | bool PyCurve_Check(PyObject* object); 33 | 34 | // Create PyCurve from an enum TWCurve value. 35 | // Note: it returns the same PyCurve instance for the same enum TWCurve value. 36 | // the caller should release the reference after using. 37 | PyObject* PyCurve_FromTWCurve(TWCurve value); 38 | 39 | // Get enum TWCurve value from a PyCurve object. 40 | TWCurve PyCurve_GetTWCurve(PyObject* object); 41 | 42 | // Initialize for PyCurve. It is called by python module init function. 43 | bool PyInit_Curve(PyObject* module); -------------------------------------------------------------------------------- /src/generated/DataVector.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #pragma once 20 | 21 | #define PY_SSIZE_T_CLEAN 22 | #include 23 | 24 | #include 25 | 26 | // Returns true if the object is a PyDataVector. 27 | bool PyDataVector_Check(PyObject* object); 28 | 29 | // Create PyDataVector from an TWDataVector. 30 | PyObject* PyDataVector_FromTWDataVector(TWDataVector* value); 31 | 32 | // Get enum TWDataVector value from a PyDataVector object. 33 | TWDataVector* PyDataVector_GetTWDataVector(PyObject* object); 34 | 35 | // Initialize for PyDataVector. It is called by python module init function. 36 | bool PyInit_DataVector(PyObject* module); -------------------------------------------------------------------------------- /src/generated/Derivation.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #include "generated/Derivation.h" 20 | 21 | #include 22 | #include 23 | 24 | static PyTypeObject PyDerivationType = { 25 | // clang-format off 26 | PyVarObject_HEAD_INIT(NULL, 0) 27 | // clang-format on 28 | "walletcore.Derivation", /* tp_name */ 29 | sizeof(PyDerivationObject), /* tp_basicsize */ 30 | 0, /* tp_itemsize */ 31 | 0, /* tp_dealloc */ 32 | 0, /* tp_print */ 33 | 0, /* tp_getattr */ 34 | 0, /* tp_setattr */ 35 | 0, /* tp_reserved */ 36 | 0, /* tp_repr */ 37 | 0, /* tp_as_number */ 38 | 0, /* tp_as_sequence */ 39 | 0, /* tp_as_mapping */ 40 | 0, /* tp_hash */ 41 | 0, /* tp_call */ 42 | 0, /* tp_str */ 43 | 0, /* tp_getattro */ 44 | 0, /* tp_setattro */ 45 | 0, /* tp_as_buffer */ 46 | Py_TPFLAGS_DEFAULT, /* tp_flags */ 47 | nullptr, /* tp_doc */ 48 | }; 49 | 50 | bool PyDerivation_Check(PyObject* object) { 51 | return PyObject_TypeCheck(object, &PyDerivationType) != 0; 52 | } 53 | 54 | struct Constant { 55 | const TWDerivation value; 56 | const char* name; 57 | PyObject* pyvalue; 58 | }; 59 | 60 | static Constant constants[] = { 61 | // clang-format off 62 | { TWDerivationDefault, "Default", nullptr }, 63 | { TWDerivationCustom, "Custom", nullptr }, 64 | { TWDerivationBitcoinSegwit, "BitcoinSegwit", nullptr }, 65 | { TWDerivationBitcoinLegacy, "BitcoinLegacy", nullptr }, 66 | { TWDerivationLitecoinLegacy, "LitecoinLegacy", nullptr }, 67 | { TWDerivationSolanaSolana, "SolanaSolana", nullptr }, 68 | // clang-format on 69 | }; 70 | 71 | // Create PyDerivation from enum TWDerivation. It returns the same PyDerivation 72 | // instance for the same enum TWDerivation value. 73 | PyObject* PyDerivation_FromTWDerivation(TWDerivation value) { 74 | Constant* constant = 75 | std::find_if(std::begin(constants), std::end(constants), 76 | [value](const Constant& v) { return v.value == value; }); 77 | 78 | if (!constant) { 79 | PyErr_Format(PyExc_ValueError, "Invalid Derivation value: %d", value); 80 | return nullptr; 81 | } 82 | 83 | if (!constant->pyvalue) { 84 | auto* pyvalue = PyObject_New(PyDerivationObject, &PyDerivationType); 85 | *const_cast(&pyvalue->value) = value; 86 | constant->pyvalue = (PyObject*)pyvalue; 87 | } 88 | 89 | Py_INCREF(constant->pyvalue); 90 | return constant->pyvalue; 91 | } 92 | 93 | TWDerivation PyDerivation_GetTWDerivation(PyObject* object) { 94 | assert(PyDerivation_Check(object)); 95 | return ((PyDerivationObject*)object)->value; 96 | } 97 | 98 | static int PyDerivation_init(PyDerivationObject* self, 99 | PyObject* args, 100 | PyObject* kwds) { 101 | return 0; 102 | } 103 | 104 | static PyObject* PyDerivation_new(PyTypeObject* subtype, 105 | PyObject* args, 106 | PyObject* kwds) { 107 | int value = 0; 108 | if (!PyArg_ParseTuple(args, "|i", &value)) { 109 | return nullptr; 110 | } 111 | return PyDerivation_FromTWDerivation((TWDerivation)value); 112 | } 113 | 114 | static PyObject* PyDerivation_str(PyDerivationObject* self) { 115 | Constant* constant = std::find_if( 116 | std::begin(constants), std::end(constants), 117 | [self](const Constant& v) { return v.value == self->value; }); 118 | 119 | return PyUnicode_FromString(constant ? constant->name : "Unknown"); 120 | } 121 | 122 | // properties 123 | 124 | static const PyGetSetDef get_set_defs[] = {{}}; 125 | 126 | static const PyMethodDef method_defs[] = {{}}; 127 | 128 | bool PyInit_Derivation(PyObject* module) { 129 | PyDerivationType.tp_new = PyDerivation_new; 130 | PyDerivationType.tp_init = (initproc)PyDerivation_init; 131 | PyDerivationType.tp_str = (reprfunc)PyDerivation_str; 132 | PyDerivationType.tp_getset = (PyGetSetDef*)get_set_defs; 133 | PyDerivationType.tp_methods = (PyMethodDef*)method_defs; 134 | 135 | if (PyType_Ready(&PyDerivationType) < 0) 136 | return false; 137 | 138 | Py_INCREF(&PyDerivationType); 139 | if (PyModule_AddObject(module, "Derivation", (PyObject*)&PyDerivationType) < 140 | 0) { 141 | Py_DECREF(&PyDerivationType); 142 | return false; 143 | } 144 | 145 | PyObject* dict = PyDerivationType.tp_dict; 146 | (void)dict; 147 | 148 | for (const Constant& constant : constants) { 149 | PyDict_SetItemString(dict, constant.name, 150 | PyDerivation_FromTWDerivation(constant.value)); 151 | } 152 | 153 | return true; 154 | } -------------------------------------------------------------------------------- /src/generated/Derivation.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #pragma once 20 | 21 | #define PY_SSIZE_T_CLEAN 22 | #include 23 | 24 | #include 25 | 26 | struct PyDerivationObject { 27 | PyObject_HEAD; 28 | const TWDerivation value; 29 | }; 30 | 31 | // Returns true if the object is a PyDerivation. 32 | bool PyDerivation_Check(PyObject* object); 33 | 34 | // Create PyDerivation from an enum TWDerivation value. 35 | // Note: it returns the same PyDerivation instance for the same enum 36 | // TWDerivation value. the caller should release the reference after using. 37 | PyObject* PyDerivation_FromTWDerivation(TWDerivation value); 38 | 39 | // Get enum TWDerivation value from a PyDerivation object. 40 | TWDerivation PyDerivation_GetTWDerivation(PyObject* object); 41 | 42 | // Initialize for PyDerivation. It is called by python module init function. 43 | bool PyInit_Derivation(PyObject* module); -------------------------------------------------------------------------------- /src/generated/DerivationPath.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #pragma once 20 | 21 | #define PY_SSIZE_T_CLEAN 22 | #include 23 | 24 | #include 25 | 26 | // Returns true if the object is a PyDerivationPath. 27 | bool PyDerivationPath_Check(PyObject* object); 28 | 29 | // Create PyDerivationPath from an TWDerivationPath. 30 | PyObject* PyDerivationPath_FromTWDerivationPath(TWDerivationPath* value); 31 | 32 | // Get enum TWDerivationPath value from a PyDerivationPath object. 33 | TWDerivationPath* PyDerivationPath_GetTWDerivationPath(PyObject* object); 34 | 35 | // Initialize for PyDerivationPath. It is called by python module init function. 36 | bool PyInit_DerivationPath(PyObject* module); -------------------------------------------------------------------------------- /src/generated/DerivationPathIndex.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #pragma once 20 | 21 | #define PY_SSIZE_T_CLEAN 22 | #include 23 | 24 | #include 25 | 26 | // Returns true if the object is a PyDerivationPathIndex. 27 | bool PyDerivationPathIndex_Check(PyObject* object); 28 | 29 | // Create PyDerivationPathIndex from an TWDerivationPathIndex. 30 | PyObject* PyDerivationPathIndex_FromTWDerivationPathIndex( 31 | TWDerivationPathIndex* value); 32 | 33 | // Get enum TWDerivationPathIndex value from a PyDerivationPathIndex object. 34 | TWDerivationPathIndex* PyDerivationPathIndex_GetTWDerivationPathIndex( 35 | PyObject* object); 36 | 37 | // Initialize for PyDerivationPathIndex. It is called by python module init 38 | // function. 39 | bool PyInit_DerivationPathIndex(PyObject* module); -------------------------------------------------------------------------------- /src/generated/EthereumAbi.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #pragma once 20 | 21 | #define PY_SSIZE_T_CLEAN 22 | #include 23 | 24 | #include 25 | 26 | // Initialize for PyEthereumAbi. It is called by python module init function. 27 | bool PyInit_EthereumAbi(PyObject* module); -------------------------------------------------------------------------------- /src/generated/EthereumAbiFunction.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #pragma once 20 | 21 | #define PY_SSIZE_T_CLEAN 22 | #include 23 | 24 | #include 25 | 26 | // Returns true if the object is a PyEthereumAbiFunction. 27 | bool PyEthereumAbiFunction_Check(PyObject* object); 28 | 29 | // Create PyEthereumAbiFunction from an TWEthereumAbiFunction. 30 | PyObject* PyEthereumAbiFunction_FromTWEthereumAbiFunction( 31 | TWEthereumAbiFunction* value); 32 | 33 | // Get enum TWEthereumAbiFunction value from a PyEthereumAbiFunction object. 34 | TWEthereumAbiFunction* PyEthereumAbiFunction_GetTWEthereumAbiFunction( 35 | PyObject* object); 36 | 37 | // Initialize for PyEthereumAbiFunction. It is called by python module init 38 | // function. 39 | bool PyInit_EthereumAbiFunction(PyObject* module); -------------------------------------------------------------------------------- /src/generated/EthereumAbiValue.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #pragma once 20 | 21 | #define PY_SSIZE_T_CLEAN 22 | #include 23 | 24 | #include 25 | 26 | // Initialize for PyEthereumAbiValue. It is called by python module init 27 | // function. 28 | bool PyInit_EthereumAbiValue(PyObject* module); -------------------------------------------------------------------------------- /src/generated/EthereumEip2645.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #include "generated/EthereumEip2645.h" 20 | 21 | #include "String.h" 22 | 23 | struct PyEthereumEip2645Object { 24 | PyObject_HEAD; 25 | }; 26 | 27 | static PyTypeObject PyEthereumEip2645Type = { 28 | // clang-format off 29 | PyVarObject_HEAD_INIT(NULL, 0) 30 | // clang-format on 31 | "walletcore.EthereumEip2645", /* tp_name */ 32 | sizeof(PyEthereumEip2645Object), /* tp_basicsize */ 33 | 0, /* tp_itemsize */ 34 | 0, /* tp_dealloc */ 35 | 0, /* tp_print */ 36 | 0, /* tp_getattr */ 37 | 0, /* tp_setattr */ 38 | 0, /* tp_reserved */ 39 | 0, /* tp_repr */ 40 | 0, /* tp_as_number */ 41 | 0, /* tp_as_sequence */ 42 | 0, /* tp_as_mapping */ 43 | 0, /* tp_hash */ 44 | 0, /* tp_call */ 45 | 0, /* tp_str */ 46 | 0, /* tp_getattro */ 47 | 0, /* tp_setattro */ 48 | 0, /* tp_as_buffer */ 49 | Py_TPFLAGS_DEFAULT, /* tp_flags */ 50 | nullptr, /* tp_doc */ 51 | }; 52 | 53 | // static method function for GetPath 54 | static const char PyEthereumEip2645GetPath_doc[] = 55 | "TWString* TWEthereumEip2645GetPath(TWString* ethAddress, TWString* layer, " 56 | "TWString* application, TWString* index)"; 57 | static PyObject* PyEthereumEip2645GetPath(PyEthereumEip2645Object* self, 58 | PyObject* const* args, 59 | Py_ssize_t nargs) { 60 | if (nargs != 4) { 61 | PyErr_Format(PyExc_TypeError, "Expect 4 args, but %d args are passed in.", 62 | nargs); 63 | return nullptr; 64 | } 65 | 66 | if (!PyUnicode_Check(args[0])) { 67 | PyErr_SetString(PyExc_TypeError, "The arg 0 is not in type Unicode"); 68 | return nullptr; 69 | } 70 | auto arg0 = PyUnicode_GetTWString(args[0]); 71 | 72 | if (!PyUnicode_Check(args[1])) { 73 | PyErr_SetString(PyExc_TypeError, "The arg 1 is not in type Unicode"); 74 | return nullptr; 75 | } 76 | auto arg1 = PyUnicode_GetTWString(args[1]); 77 | 78 | if (!PyUnicode_Check(args[2])) { 79 | PyErr_SetString(PyExc_TypeError, "The arg 2 is not in type Unicode"); 80 | return nullptr; 81 | } 82 | auto arg2 = PyUnicode_GetTWString(args[2]); 83 | 84 | if (!PyUnicode_Check(args[3])) { 85 | PyErr_SetString(PyExc_TypeError, "The arg 3 is not in type Unicode"); 86 | return nullptr; 87 | } 88 | auto arg3 = PyUnicode_GetTWString(args[3]); 89 | 90 | TWStringPtr result( 91 | TWEthereumEip2645GetPath(arg0.get(), arg1.get(), arg2.get(), arg3.get())); 92 | return PyUnicode_FromTWString(result); 93 | } 94 | 95 | // properties 96 | 97 | static const PyGetSetDef get_set_defs[] = {{}}; 98 | 99 | static const PyMethodDef method_defs[] = { 100 | {"get_path", (PyCFunction)PyEthereumEip2645GetPath, 101 | METH_FASTCALL | METH_STATIC, PyEthereumEip2645GetPath_doc}, 102 | {}}; 103 | 104 | bool PyInit_EthereumEip2645(PyObject* module) { 105 | PyEthereumEip2645Type.tp_getset = (PyGetSetDef*)get_set_defs; 106 | PyEthereumEip2645Type.tp_methods = (PyMethodDef*)method_defs; 107 | 108 | if (PyType_Ready(&PyEthereumEip2645Type) < 0) 109 | return false; 110 | 111 | Py_INCREF(&PyEthereumEip2645Type); 112 | if (PyModule_AddObject(module, "EthereumEip2645", 113 | (PyObject*)&PyEthereumEip2645Type) < 0) { 114 | Py_DECREF(&PyEthereumEip2645Type); 115 | return false; 116 | } 117 | 118 | return true; 119 | } -------------------------------------------------------------------------------- /src/generated/EthereumEip2645.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #pragma once 20 | 21 | #define PY_SSIZE_T_CLEAN 22 | #include 23 | 24 | #include 25 | 26 | // Initialize for PyEthereumEip2645. It is called by python module init 27 | // function. 28 | bool PyInit_EthereumEip2645(PyObject* module); -------------------------------------------------------------------------------- /src/generated/EthereumMessageSigner.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #include "generated/EthereumMessageSigner.h" 20 | 21 | #include "String.h" 22 | #include "generated/PrivateKey.h" 23 | #include "generated/PublicKey.h" 24 | 25 | struct PyEthereumMessageSignerObject { 26 | PyObject_HEAD; 27 | }; 28 | 29 | static PyTypeObject PyEthereumMessageSignerType = { 30 | // clang-format off 31 | PyVarObject_HEAD_INIT(NULL, 0) 32 | // clang-format on 33 | "walletcore.EthereumMessageSigner", /* tp_name */ 34 | sizeof(PyEthereumMessageSignerObject), /* tp_basicsize */ 35 | 0, /* tp_itemsize */ 36 | 0, /* tp_dealloc */ 37 | 0, /* tp_print */ 38 | 0, /* tp_getattr */ 39 | 0, /* tp_setattr */ 40 | 0, /* tp_reserved */ 41 | 0, /* tp_repr */ 42 | 0, /* tp_as_number */ 43 | 0, /* tp_as_sequence */ 44 | 0, /* tp_as_mapping */ 45 | 0, /* tp_hash */ 46 | 0, /* tp_call */ 47 | 0, /* tp_str */ 48 | 0, /* tp_getattro */ 49 | 0, /* tp_setattro */ 50 | 0, /* tp_as_buffer */ 51 | Py_TPFLAGS_DEFAULT, /* tp_flags */ 52 | nullptr, /* tp_doc */ 53 | }; 54 | 55 | // static method function for SignMessage 56 | static const char PyEthereumMessageSignerSignMessage_doc[] = 57 | "TWString* TWEthereumMessageSignerSignMessage(const struct TWPrivateKey* " 58 | "privateKey, TWString* message)"; 59 | static PyObject* PyEthereumMessageSignerSignMessage( 60 | PyEthereumMessageSignerObject* self, 61 | PyObject* const* args, 62 | Py_ssize_t nargs) { 63 | if (nargs != 2) { 64 | PyErr_Format(PyExc_TypeError, "Expect 2 args, but %d args are passed in.", 65 | nargs); 66 | return nullptr; 67 | } 68 | 69 | if (!PyPrivateKey_Check(args[0])) { 70 | PyErr_SetString(PyExc_TypeError, "The arg 0 is not in type PrivateKey"); 71 | return nullptr; 72 | } 73 | auto arg0 = PyPrivateKey_GetTWPrivateKey(args[0]); 74 | 75 | if (!PyUnicode_Check(args[1])) { 76 | PyErr_SetString(PyExc_TypeError, "The arg 1 is not in type Unicode"); 77 | return nullptr; 78 | } 79 | auto arg1 = PyUnicode_GetTWString(args[1]); 80 | 81 | TWStringPtr result(TWEthereumMessageSignerSignMessage(arg0, arg1.get())); 82 | return PyUnicode_FromTWString(result); 83 | } 84 | 85 | // static method function for VerifyMessage 86 | static const char PyEthereumMessageSignerVerifyMessage_doc[] = 87 | "bool TWEthereumMessageSignerVerifyMessage(const struct TWPublicKey* " 88 | "pubKey, TWString* message, TWString* signature)"; 89 | static PyObject* PyEthereumMessageSignerVerifyMessage( 90 | PyEthereumMessageSignerObject* self, 91 | PyObject* const* args, 92 | Py_ssize_t nargs) { 93 | if (nargs != 3) { 94 | PyErr_Format(PyExc_TypeError, "Expect 3 args, but %d args are passed in.", 95 | nargs); 96 | return nullptr; 97 | } 98 | 99 | if (!PyPublicKey_Check(args[0])) { 100 | PyErr_SetString(PyExc_TypeError, "The arg 0 is not in type PublicKey"); 101 | return nullptr; 102 | } 103 | auto arg0 = PyPublicKey_GetTWPublicKey(args[0]); 104 | 105 | if (!PyUnicode_Check(args[1])) { 106 | PyErr_SetString(PyExc_TypeError, "The arg 1 is not in type Unicode"); 107 | return nullptr; 108 | } 109 | auto arg1 = PyUnicode_GetTWString(args[1]); 110 | 111 | if (!PyUnicode_Check(args[2])) { 112 | PyErr_SetString(PyExc_TypeError, "The arg 2 is not in type Unicode"); 113 | return nullptr; 114 | } 115 | auto arg2 = PyUnicode_GetTWString(args[2]); 116 | 117 | bool result = 118 | TWEthereumMessageSignerVerifyMessage(arg0, arg1.get(), arg2.get()); 119 | return PyBool_FromLong(result); 120 | } 121 | 122 | // properties 123 | 124 | static const PyGetSetDef get_set_defs[] = {{}}; 125 | 126 | static const PyMethodDef method_defs[] = { 127 | {"sign_message", (PyCFunction)PyEthereumMessageSignerSignMessage, 128 | METH_FASTCALL | METH_STATIC, PyEthereumMessageSignerSignMessage_doc}, 129 | {"verify_message", (PyCFunction)PyEthereumMessageSignerVerifyMessage, 130 | METH_FASTCALL | METH_STATIC, PyEthereumMessageSignerVerifyMessage_doc}, 131 | {}}; 132 | 133 | bool PyInit_EthereumMessageSigner(PyObject* module) { 134 | PyEthereumMessageSignerType.tp_getset = (PyGetSetDef*)get_set_defs; 135 | PyEthereumMessageSignerType.tp_methods = (PyMethodDef*)method_defs; 136 | 137 | if (PyType_Ready(&PyEthereumMessageSignerType) < 0) 138 | return false; 139 | 140 | Py_INCREF(&PyEthereumMessageSignerType); 141 | if (PyModule_AddObject(module, "EthereumMessageSigner", 142 | (PyObject*)&PyEthereumMessageSignerType) < 0) { 143 | Py_DECREF(&PyEthereumMessageSignerType); 144 | return false; 145 | } 146 | 147 | return true; 148 | } -------------------------------------------------------------------------------- /src/generated/EthereumMessageSigner.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #pragma once 20 | 21 | #define PY_SSIZE_T_CLEAN 22 | #include 23 | 24 | #include 25 | 26 | // Initialize for PyEthereumMessageSigner. It is called by python module init 27 | // function. 28 | bool PyInit_EthereumMessageSigner(PyObject* module); -------------------------------------------------------------------------------- /src/generated/FIOAccount.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #include "generated/FIOAccount.h" 20 | 21 | #include "String.h" 22 | 23 | struct PyFIOAccountObject { 24 | PyObject_HEAD; 25 | TWFIOAccount* value; 26 | }; 27 | 28 | static PyTypeObject PyFIOAccountType = { 29 | // clang-format off 30 | PyVarObject_HEAD_INIT(NULL, 0) 31 | // clang-format on 32 | "walletcore.FIOAccount", /* tp_name */ 33 | sizeof(PyFIOAccountObject), /* tp_basicsize */ 34 | 0, /* tp_itemsize */ 35 | 0, /* tp_dealloc */ 36 | 0, /* tp_print */ 37 | 0, /* tp_getattr */ 38 | 0, /* tp_setattr */ 39 | 0, /* tp_reserved */ 40 | 0, /* tp_repr */ 41 | 0, /* tp_as_number */ 42 | 0, /* tp_as_sequence */ 43 | 0, /* tp_as_mapping */ 44 | 0, /* tp_hash */ 45 | 0, /* tp_call */ 46 | 0, /* tp_str */ 47 | 0, /* tp_getattro */ 48 | 0, /* tp_setattro */ 49 | 0, /* tp_as_buffer */ 50 | Py_TPFLAGS_DEFAULT, /* tp_flags */ 51 | nullptr, /* tp_doc */ 52 | }; 53 | 54 | bool PyFIOAccount_Check(PyObject* object) { 55 | return PyObject_TypeCheck(object, &PyFIOAccountType) != 0; 56 | } 57 | 58 | // Create PyFIOAccount from enum TWFIOAccount. 59 | PyObject* PyFIOAccount_FromTWFIOAccount(TWFIOAccount* value) { 60 | if (!value) 61 | Py_RETURN_NONE; 62 | 63 | PyFIOAccountObject* object = 64 | PyObject_New(PyFIOAccountObject, &PyFIOAccountType); 65 | if (!object) 66 | return nullptr; 67 | 68 | object->value = value; 69 | 70 | return (PyObject*)object; 71 | } 72 | 73 | TWFIOAccount* PyFIOAccount_GetTWFIOAccount(PyObject* object) { 74 | assert(PyFIOAccount_Check(object)); 75 | return ((PyFIOAccountObject*)object)->value; 76 | } 77 | 78 | static void PyFIOAccount_dealloc(PyFIOAccountObject* self) { 79 | if (self->value) { 80 | TWFIOAccountDelete(self->value); 81 | } 82 | Py_TYPE(self)->tp_free(self); 83 | } 84 | 85 | // getter function for Description 86 | static const char PyFIOAccountDescription_doc[] = 87 | "TWString* TWFIOAccountDescription(struct TWFIOAccount* account)"; 88 | static PyObject* PyFIOAccountDescription(PyFIOAccountObject* self, void*) { 89 | TWStringPtr prop(TWFIOAccountDescription(self->value)); 90 | return PyUnicode_FromTWString(prop); 91 | } 92 | 93 | // static method function for CreateWithString 94 | static const char PyFIOAccountCreateWithString_doc[] = 95 | "struct TWFIOAccount* TWFIOAccountCreateWithString(TWString* string)"; 96 | static PyObject* PyFIOAccountCreateWithString(PyFIOAccountObject* self, 97 | PyObject* const* args, 98 | Py_ssize_t nargs) { 99 | if (nargs != 1) { 100 | PyErr_Format(PyExc_TypeError, "Expect 1 args, but %d args are passed in.", 101 | nargs); 102 | return nullptr; 103 | } 104 | 105 | if (!PyUnicode_Check(args[0])) { 106 | PyErr_SetString(PyExc_TypeError, "The arg 0 is not in type Unicode"); 107 | return nullptr; 108 | } 109 | auto arg0 = PyUnicode_GetTWString(args[0]); 110 | 111 | TWFIOAccount* result = TWFIOAccountCreateWithString(arg0.get()); 112 | return PyFIOAccount_FromTWFIOAccount(result); 113 | } 114 | 115 | // properties 116 | 117 | static const PyGetSetDef get_set_defs[] = { 118 | {"description", (getter)PyFIOAccountDescription, nullptr, 119 | PyFIOAccountDescription_doc}, 120 | {}}; 121 | 122 | static const PyMethodDef method_defs[] = { 123 | {"create_with_string", (PyCFunction)PyFIOAccountCreateWithString, 124 | METH_FASTCALL | METH_STATIC, PyFIOAccountCreateWithString_doc}, 125 | {}}; 126 | 127 | bool PyInit_FIOAccount(PyObject* module) { 128 | PyFIOAccountType.tp_dealloc = (destructor)PyFIOAccount_dealloc; 129 | PyFIOAccountType.tp_getset = (PyGetSetDef*)get_set_defs; 130 | PyFIOAccountType.tp_methods = (PyMethodDef*)method_defs; 131 | 132 | if (PyType_Ready(&PyFIOAccountType) < 0) 133 | return false; 134 | 135 | Py_INCREF(&PyFIOAccountType); 136 | if (PyModule_AddObject(module, "FIOAccount", (PyObject*)&PyFIOAccountType) < 137 | 0) { 138 | Py_DECREF(&PyFIOAccountType); 139 | return false; 140 | } 141 | 142 | return true; 143 | } -------------------------------------------------------------------------------- /src/generated/FIOAccount.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #pragma once 20 | 21 | #define PY_SSIZE_T_CLEAN 22 | #include 23 | 24 | #include 25 | 26 | // Returns true if the object is a PyFIOAccount. 27 | bool PyFIOAccount_Check(PyObject* object); 28 | 29 | // Create PyFIOAccount from an TWFIOAccount. 30 | PyObject* PyFIOAccount_FromTWFIOAccount(TWFIOAccount* value); 31 | 32 | // Get enum TWFIOAccount value from a PyFIOAccount object. 33 | TWFIOAccount* PyFIOAccount_GetTWFIOAccount(PyObject* object); 34 | 35 | // Initialize for PyFIOAccount. It is called by python module init function. 36 | bool PyInit_FIOAccount(PyObject* module); -------------------------------------------------------------------------------- /src/generated/GroestlcoinAddress.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #pragma once 20 | 21 | #define PY_SSIZE_T_CLEAN 22 | #include 23 | 24 | #include 25 | 26 | // Returns true if the object is a PyGroestlcoinAddress. 27 | bool PyGroestlcoinAddress_Check(PyObject* object); 28 | 29 | // Create PyGroestlcoinAddress from an TWGroestlcoinAddress. 30 | PyObject* PyGroestlcoinAddress_FromTWGroestlcoinAddress( 31 | TWGroestlcoinAddress* value); 32 | 33 | // Get enum TWGroestlcoinAddress value from a PyGroestlcoinAddress object. 34 | TWGroestlcoinAddress* PyGroestlcoinAddress_GetTWGroestlcoinAddress( 35 | PyObject* object); 36 | 37 | // Initialize for PyGroestlcoinAddress. It is called by python module init 38 | // function. 39 | bool PyInit_GroestlcoinAddress(PyObject* module); -------------------------------------------------------------------------------- /src/generated/HDVersion.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #pragma once 20 | 21 | #define PY_SSIZE_T_CLEAN 22 | #include 23 | 24 | #include 25 | 26 | struct PyHDVersionObject { 27 | PyObject_HEAD; 28 | const TWHDVersion value; 29 | }; 30 | 31 | // Returns true if the object is a PyHDVersion. 32 | bool PyHDVersion_Check(PyObject* object); 33 | 34 | // Create PyHDVersion from an enum TWHDVersion value. 35 | // Note: it returns the same PyHDVersion instance for the same enum TWHDVersion 36 | // value. the caller should release the reference after using. 37 | PyObject* PyHDVersion_FromTWHDVersion(TWHDVersion value); 38 | 39 | // Get enum TWHDVersion value from a PyHDVersion object. 40 | TWHDVersion PyHDVersion_GetTWHDVersion(PyObject* object); 41 | 42 | // Initialize for PyHDVersion. It is called by python module init function. 43 | bool PyInit_HDVersion(PyObject* module); -------------------------------------------------------------------------------- /src/generated/HDWallet.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #pragma once 20 | 21 | #define PY_SSIZE_T_CLEAN 22 | #include 23 | 24 | #include 25 | 26 | // Returns true if the object is a PyHDWallet. 27 | bool PyHDWallet_Check(PyObject* object); 28 | 29 | // Create PyHDWallet from an TWHDWallet. 30 | PyObject* PyHDWallet_FromTWHDWallet(TWHDWallet* value); 31 | 32 | // Get enum TWHDWallet value from a PyHDWallet object. 33 | TWHDWallet* PyHDWallet_GetTWHDWallet(PyObject* object); 34 | 35 | // Initialize for PyHDWallet. It is called by python module init function. 36 | bool PyInit_HDWallet(PyObject* module); -------------------------------------------------------------------------------- /src/generated/HRP.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #pragma once 20 | 21 | #define PY_SSIZE_T_CLEAN 22 | #include 23 | 24 | #include 25 | 26 | struct PyHRPObject { 27 | PyObject_HEAD; 28 | const TWHRP value; 29 | }; 30 | 31 | // Returns true if the object is a PyHRP. 32 | bool PyHRP_Check(PyObject* object); 33 | 34 | // Create PyHRP from an enum TWHRP value. 35 | // Note: it returns the same PyHRP instance for the same enum TWHRP value. 36 | // the caller should release the reference after using. 37 | PyObject* PyHRP_FromTWHRP(TWHRP value); 38 | 39 | // Get enum TWHRP value from a PyHRP object. 40 | TWHRP PyHRP_GetTWHRP(PyObject* object); 41 | 42 | // Initialize for PyHRP. It is called by python module init function. 43 | bool PyInit_HRP(PyObject* module); -------------------------------------------------------------------------------- /src/generated/Hash.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #pragma once 20 | 21 | #define PY_SSIZE_T_CLEAN 22 | #include 23 | 24 | #include 25 | 26 | // Initialize for PyHash. It is called by python module init function. 27 | bool PyInit_Hash(PyObject* module); -------------------------------------------------------------------------------- /src/generated/Mnemonic.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #include "generated/Mnemonic.h" 20 | 21 | #include "String.h" 22 | 23 | struct PyMnemonicObject { 24 | PyObject_HEAD; 25 | }; 26 | 27 | static PyTypeObject PyMnemonicType = { 28 | // clang-format off 29 | PyVarObject_HEAD_INIT(NULL, 0) 30 | // clang-format on 31 | "walletcore.Mnemonic", /* tp_name */ 32 | sizeof(PyMnemonicObject), /* tp_basicsize */ 33 | 0, /* tp_itemsize */ 34 | 0, /* tp_dealloc */ 35 | 0, /* tp_print */ 36 | 0, /* tp_getattr */ 37 | 0, /* tp_setattr */ 38 | 0, /* tp_reserved */ 39 | 0, /* tp_repr */ 40 | 0, /* tp_as_number */ 41 | 0, /* tp_as_sequence */ 42 | 0, /* tp_as_mapping */ 43 | 0, /* tp_hash */ 44 | 0, /* tp_call */ 45 | 0, /* tp_str */ 46 | 0, /* tp_getattro */ 47 | 0, /* tp_setattro */ 48 | 0, /* tp_as_buffer */ 49 | Py_TPFLAGS_DEFAULT, /* tp_flags */ 50 | nullptr, /* tp_doc */ 51 | }; 52 | 53 | // static method function for IsValid 54 | static const char PyMnemonicIsValid_doc[] = 55 | "bool TWMnemonicIsValid(TWString* mnemonic)"; 56 | static PyObject* PyMnemonicIsValid(PyMnemonicObject* self, 57 | PyObject* const* args, 58 | Py_ssize_t nargs) { 59 | if (nargs != 1) { 60 | PyErr_Format(PyExc_TypeError, "Expect 1 args, but %d args are passed in.", 61 | nargs); 62 | return nullptr; 63 | } 64 | 65 | if (!PyUnicode_Check(args[0])) { 66 | PyErr_SetString(PyExc_TypeError, "The arg 0 is not in type Unicode"); 67 | return nullptr; 68 | } 69 | auto arg0 = PyUnicode_GetTWString(args[0]); 70 | 71 | bool result = TWMnemonicIsValid(arg0.get()); 72 | return PyBool_FromLong(result); 73 | } 74 | 75 | // static method function for IsValidWord 76 | static const char PyMnemonicIsValidWord_doc[] = 77 | "bool TWMnemonicIsValidWord(TWString* word)"; 78 | static PyObject* PyMnemonicIsValidWord(PyMnemonicObject* self, 79 | PyObject* const* args, 80 | Py_ssize_t nargs) { 81 | if (nargs != 1) { 82 | PyErr_Format(PyExc_TypeError, "Expect 1 args, but %d args are passed in.", 83 | nargs); 84 | return nullptr; 85 | } 86 | 87 | if (!PyUnicode_Check(args[0])) { 88 | PyErr_SetString(PyExc_TypeError, "The arg 0 is not in type Unicode"); 89 | return nullptr; 90 | } 91 | auto arg0 = PyUnicode_GetTWString(args[0]); 92 | 93 | bool result = TWMnemonicIsValidWord(arg0.get()); 94 | return PyBool_FromLong(result); 95 | } 96 | 97 | // static method function for Suggest 98 | static const char PyMnemonicSuggest_doc[] = 99 | "TWString* TWMnemonicSuggest(TWString* prefix)"; 100 | static PyObject* PyMnemonicSuggest(PyMnemonicObject* self, 101 | PyObject* const* args, 102 | Py_ssize_t nargs) { 103 | if (nargs != 1) { 104 | PyErr_Format(PyExc_TypeError, "Expect 1 args, but %d args are passed in.", 105 | nargs); 106 | return nullptr; 107 | } 108 | 109 | if (!PyUnicode_Check(args[0])) { 110 | PyErr_SetString(PyExc_TypeError, "The arg 0 is not in type Unicode"); 111 | return nullptr; 112 | } 113 | auto arg0 = PyUnicode_GetTWString(args[0]); 114 | 115 | TWStringPtr result(TWMnemonicSuggest(arg0.get())); 116 | return PyUnicode_FromTWString(result); 117 | } 118 | 119 | // properties 120 | 121 | static const PyGetSetDef get_set_defs[] = {{}}; 122 | 123 | static const PyMethodDef method_defs[] = { 124 | {"is_valid", (PyCFunction)PyMnemonicIsValid, METH_FASTCALL | METH_STATIC, 125 | PyMnemonicIsValid_doc}, 126 | {"is_valid_word", (PyCFunction)PyMnemonicIsValidWord, 127 | METH_FASTCALL | METH_STATIC, PyMnemonicIsValidWord_doc}, 128 | {"suggest", (PyCFunction)PyMnemonicSuggest, METH_FASTCALL | METH_STATIC, 129 | PyMnemonicSuggest_doc}, 130 | {}}; 131 | 132 | bool PyInit_Mnemonic(PyObject* module) { 133 | PyMnemonicType.tp_getset = (PyGetSetDef*)get_set_defs; 134 | PyMnemonicType.tp_methods = (PyMethodDef*)method_defs; 135 | 136 | if (PyType_Ready(&PyMnemonicType) < 0) 137 | return false; 138 | 139 | Py_INCREF(&PyMnemonicType); 140 | if (PyModule_AddObject(module, "Mnemonic", (PyObject*)&PyMnemonicType) < 0) { 141 | Py_DECREF(&PyMnemonicType); 142 | return false; 143 | } 144 | 145 | return true; 146 | } -------------------------------------------------------------------------------- /src/generated/Mnemonic.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #pragma once 20 | 21 | #define PY_SSIZE_T_CLEAN 22 | #include 23 | 24 | #include 25 | 26 | // Initialize for PyMnemonic. It is called by python module init function. 27 | bool PyInit_Mnemonic(PyObject* module); -------------------------------------------------------------------------------- /src/generated/NEARAccount.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #include "generated/NEARAccount.h" 20 | 21 | #include "String.h" 22 | 23 | struct PyNEARAccountObject { 24 | PyObject_HEAD; 25 | TWNEARAccount* value; 26 | }; 27 | 28 | static PyTypeObject PyNEARAccountType = { 29 | // clang-format off 30 | PyVarObject_HEAD_INIT(NULL, 0) 31 | // clang-format on 32 | "walletcore.NEARAccount", /* tp_name */ 33 | sizeof(PyNEARAccountObject), /* tp_basicsize */ 34 | 0, /* tp_itemsize */ 35 | 0, /* tp_dealloc */ 36 | 0, /* tp_print */ 37 | 0, /* tp_getattr */ 38 | 0, /* tp_setattr */ 39 | 0, /* tp_reserved */ 40 | 0, /* tp_repr */ 41 | 0, /* tp_as_number */ 42 | 0, /* tp_as_sequence */ 43 | 0, /* tp_as_mapping */ 44 | 0, /* tp_hash */ 45 | 0, /* tp_call */ 46 | 0, /* tp_str */ 47 | 0, /* tp_getattro */ 48 | 0, /* tp_setattro */ 49 | 0, /* tp_as_buffer */ 50 | Py_TPFLAGS_DEFAULT, /* tp_flags */ 51 | nullptr, /* tp_doc */ 52 | }; 53 | 54 | bool PyNEARAccount_Check(PyObject* object) { 55 | return PyObject_TypeCheck(object, &PyNEARAccountType) != 0; 56 | } 57 | 58 | // Create PyNEARAccount from enum TWNEARAccount. 59 | PyObject* PyNEARAccount_FromTWNEARAccount(TWNEARAccount* value) { 60 | if (!value) 61 | Py_RETURN_NONE; 62 | 63 | PyNEARAccountObject* object = 64 | PyObject_New(PyNEARAccountObject, &PyNEARAccountType); 65 | if (!object) 66 | return nullptr; 67 | 68 | object->value = value; 69 | 70 | return (PyObject*)object; 71 | } 72 | 73 | TWNEARAccount* PyNEARAccount_GetTWNEARAccount(PyObject* object) { 74 | assert(PyNEARAccount_Check(object)); 75 | return ((PyNEARAccountObject*)object)->value; 76 | } 77 | 78 | static void PyNEARAccount_dealloc(PyNEARAccountObject* self) { 79 | if (self->value) { 80 | TWNEARAccountDelete(self->value); 81 | } 82 | Py_TYPE(self)->tp_free(self); 83 | } 84 | 85 | // getter function for Description 86 | static const char PyNEARAccountDescription_doc[] = 87 | "TWString* TWNEARAccountDescription(struct TWNEARAccount* account)"; 88 | static PyObject* PyNEARAccountDescription(PyNEARAccountObject* self, void*) { 89 | TWStringPtr prop(TWNEARAccountDescription(self->value)); 90 | return PyUnicode_FromTWString(prop); 91 | } 92 | 93 | // static method function for CreateWithString 94 | static const char PyNEARAccountCreateWithString_doc[] = 95 | "struct TWNEARAccount* TWNEARAccountCreateWithString(TWString* string)"; 96 | static PyObject* PyNEARAccountCreateWithString(PyNEARAccountObject* self, 97 | PyObject* const* args, 98 | Py_ssize_t nargs) { 99 | if (nargs != 1) { 100 | PyErr_Format(PyExc_TypeError, "Expect 1 args, but %d args are passed in.", 101 | nargs); 102 | return nullptr; 103 | } 104 | 105 | if (!PyUnicode_Check(args[0])) { 106 | PyErr_SetString(PyExc_TypeError, "The arg 0 is not in type Unicode"); 107 | return nullptr; 108 | } 109 | auto arg0 = PyUnicode_GetTWString(args[0]); 110 | 111 | TWNEARAccount* result = TWNEARAccountCreateWithString(arg0.get()); 112 | return PyNEARAccount_FromTWNEARAccount(result); 113 | } 114 | 115 | // properties 116 | 117 | static const PyGetSetDef get_set_defs[] = { 118 | {"description", (getter)PyNEARAccountDescription, nullptr, 119 | PyNEARAccountDescription_doc}, 120 | {}}; 121 | 122 | static const PyMethodDef method_defs[] = { 123 | {"create_with_string", (PyCFunction)PyNEARAccountCreateWithString, 124 | METH_FASTCALL | METH_STATIC, PyNEARAccountCreateWithString_doc}, 125 | {}}; 126 | 127 | bool PyInit_NEARAccount(PyObject* module) { 128 | PyNEARAccountType.tp_dealloc = (destructor)PyNEARAccount_dealloc; 129 | PyNEARAccountType.tp_getset = (PyGetSetDef*)get_set_defs; 130 | PyNEARAccountType.tp_methods = (PyMethodDef*)method_defs; 131 | 132 | if (PyType_Ready(&PyNEARAccountType) < 0) 133 | return false; 134 | 135 | Py_INCREF(&PyNEARAccountType); 136 | if (PyModule_AddObject(module, "NEARAccount", (PyObject*)&PyNEARAccountType) < 137 | 0) { 138 | Py_DECREF(&PyNEARAccountType); 139 | return false; 140 | } 141 | 142 | return true; 143 | } -------------------------------------------------------------------------------- /src/generated/NEARAccount.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #pragma once 20 | 21 | #define PY_SSIZE_T_CLEAN 22 | #include 23 | 24 | #include 25 | 26 | // Returns true if the object is a PyNEARAccount. 27 | bool PyNEARAccount_Check(PyObject* object); 28 | 29 | // Create PyNEARAccount from an TWNEARAccount. 30 | PyObject* PyNEARAccount_FromTWNEARAccount(TWNEARAccount* value); 31 | 32 | // Get enum TWNEARAccount value from a PyNEARAccount object. 33 | TWNEARAccount* PyNEARAccount_GetTWNEARAccount(PyObject* object); 34 | 35 | // Initialize for PyNEARAccount. It is called by python module init function. 36 | bool PyInit_NEARAccount(PyObject* module); -------------------------------------------------------------------------------- /src/generated/NervosAddress.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #pragma once 20 | 21 | #define PY_SSIZE_T_CLEAN 22 | #include 23 | 24 | #include 25 | 26 | // Returns true if the object is a PyNervosAddress. 27 | bool PyNervosAddress_Check(PyObject* object); 28 | 29 | // Create PyNervosAddress from an TWNervosAddress. 30 | PyObject* PyNervosAddress_FromTWNervosAddress(TWNervosAddress* value); 31 | 32 | // Get enum TWNervosAddress value from a PyNervosAddress object. 33 | TWNervosAddress* PyNervosAddress_GetTWNervosAddress(PyObject* object); 34 | 35 | // Initialize for PyNervosAddress. It is called by python module init function. 36 | bool PyInit_NervosAddress(PyObject* module); -------------------------------------------------------------------------------- /src/generated/PBKDF2.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #include "generated/PBKDF2.h" 20 | 21 | #include "Data.h" 22 | #include "Number.h" 23 | 24 | struct PyPBKDF2Object { 25 | PyObject_HEAD; 26 | }; 27 | 28 | static PyTypeObject PyPBKDF2Type = { 29 | // clang-format off 30 | PyVarObject_HEAD_INIT(NULL, 0) 31 | // clang-format on 32 | "walletcore.PBKDF2", /* tp_name */ 33 | sizeof(PyPBKDF2Object), /* tp_basicsize */ 34 | 0, /* tp_itemsize */ 35 | 0, /* tp_dealloc */ 36 | 0, /* tp_print */ 37 | 0, /* tp_getattr */ 38 | 0, /* tp_setattr */ 39 | 0, /* tp_reserved */ 40 | 0, /* tp_repr */ 41 | 0, /* tp_as_number */ 42 | 0, /* tp_as_sequence */ 43 | 0, /* tp_as_mapping */ 44 | 0, /* tp_hash */ 45 | 0, /* tp_call */ 46 | 0, /* tp_str */ 47 | 0, /* tp_getattro */ 48 | 0, /* tp_setattro */ 49 | 0, /* tp_as_buffer */ 50 | Py_TPFLAGS_DEFAULT, /* tp_flags */ 51 | nullptr, /* tp_doc */ 52 | }; 53 | 54 | // static method function for HmacSha256 55 | static const char PyPBKDF2HmacSha256_doc[] = 56 | "TWData* TWPBKDF2HmacSha256(TWData* password, TWData* salt, uint32_t " 57 | "iterations, uint32_t dkLen)"; 58 | static PyObject* PyPBKDF2HmacSha256(PyPBKDF2Object* self, 59 | PyObject* const* args, 60 | Py_ssize_t nargs) { 61 | if (nargs != 4) { 62 | PyErr_Format(PyExc_TypeError, "Expect 4 args, but %d args are passed in.", 63 | nargs); 64 | return nullptr; 65 | } 66 | 67 | if (!PyBytes_Check(args[0])) { 68 | PyErr_SetString(PyExc_TypeError, "The arg 0 is not in type Bytes"); 69 | return nullptr; 70 | } 71 | auto arg0 = PyBytes_GetTWData(args[0]); 72 | 73 | if (!PyBytes_Check(args[1])) { 74 | PyErr_SetString(PyExc_TypeError, "The arg 1 is not in type Bytes"); 75 | return nullptr; 76 | } 77 | auto arg1 = PyBytes_GetTWData(args[1]); 78 | 79 | auto checked_arg2 = PyLongArg_ToNumber(args[2], 2, "uint32_t"); 80 | if (!checked_arg2) 81 | return nullptr; 82 | const auto& arg2 = checked_arg2.value(); 83 | 84 | auto checked_arg3 = PyLongArg_ToNumber(args[3], 3, "uint32_t"); 85 | if (!checked_arg3) 86 | return nullptr; 87 | const auto& arg3 = checked_arg3.value(); 88 | 89 | TWDataPtr result(TWPBKDF2HmacSha256(arg0.get(), arg1.get(), arg2, arg3)); 90 | return PyBytes_FromTWData(result); 91 | } 92 | 93 | // static method function for HmacSha512 94 | static const char PyPBKDF2HmacSha512_doc[] = 95 | "TWData* TWPBKDF2HmacSha512(TWData* password, TWData* salt, uint32_t " 96 | "iterations, uint32_t dkLen)"; 97 | static PyObject* PyPBKDF2HmacSha512(PyPBKDF2Object* self, 98 | PyObject* const* args, 99 | Py_ssize_t nargs) { 100 | if (nargs != 4) { 101 | PyErr_Format(PyExc_TypeError, "Expect 4 args, but %d args are passed in.", 102 | nargs); 103 | return nullptr; 104 | } 105 | 106 | if (!PyBytes_Check(args[0])) { 107 | PyErr_SetString(PyExc_TypeError, "The arg 0 is not in type Bytes"); 108 | return nullptr; 109 | } 110 | auto arg0 = PyBytes_GetTWData(args[0]); 111 | 112 | if (!PyBytes_Check(args[1])) { 113 | PyErr_SetString(PyExc_TypeError, "The arg 1 is not in type Bytes"); 114 | return nullptr; 115 | } 116 | auto arg1 = PyBytes_GetTWData(args[1]); 117 | 118 | auto checked_arg2 = PyLongArg_ToNumber(args[2], 2, "uint32_t"); 119 | if (!checked_arg2) 120 | return nullptr; 121 | const auto& arg2 = checked_arg2.value(); 122 | 123 | auto checked_arg3 = PyLongArg_ToNumber(args[3], 3, "uint32_t"); 124 | if (!checked_arg3) 125 | return nullptr; 126 | const auto& arg3 = checked_arg3.value(); 127 | 128 | TWDataPtr result(TWPBKDF2HmacSha512(arg0.get(), arg1.get(), arg2, arg3)); 129 | return PyBytes_FromTWData(result); 130 | } 131 | 132 | // properties 133 | 134 | static const PyGetSetDef get_set_defs[] = {{}}; 135 | 136 | static const PyMethodDef method_defs[] = { 137 | {"hmac_sha256", (PyCFunction)PyPBKDF2HmacSha256, 138 | METH_FASTCALL | METH_STATIC, PyPBKDF2HmacSha256_doc}, 139 | {"hmac_sha512", (PyCFunction)PyPBKDF2HmacSha512, 140 | METH_FASTCALL | METH_STATIC, PyPBKDF2HmacSha512_doc}, 141 | {}}; 142 | 143 | bool PyInit_PBKDF2(PyObject* module) { 144 | PyPBKDF2Type.tp_getset = (PyGetSetDef*)get_set_defs; 145 | PyPBKDF2Type.tp_methods = (PyMethodDef*)method_defs; 146 | 147 | if (PyType_Ready(&PyPBKDF2Type) < 0) 148 | return false; 149 | 150 | Py_INCREF(&PyPBKDF2Type); 151 | if (PyModule_AddObject(module, "PBKDF2", (PyObject*)&PyPBKDF2Type) < 0) { 152 | Py_DECREF(&PyPBKDF2Type); 153 | return false; 154 | } 155 | 156 | return true; 157 | } -------------------------------------------------------------------------------- /src/generated/PBKDF2.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #pragma once 20 | 21 | #define PY_SSIZE_T_CLEAN 22 | #include 23 | 24 | #include 25 | 26 | // Initialize for PyPBKDF2. It is called by python module init function. 27 | bool PyInit_PBKDF2(PyObject* module); -------------------------------------------------------------------------------- /src/generated/PrivateKey.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #pragma once 20 | 21 | #define PY_SSIZE_T_CLEAN 22 | #include 23 | 24 | #include 25 | 26 | // Returns true if the object is a PyPrivateKey. 27 | bool PyPrivateKey_Check(PyObject* object); 28 | 29 | // Create PyPrivateKey from an TWPrivateKey. 30 | PyObject* PyPrivateKey_FromTWPrivateKey(TWPrivateKey* value); 31 | 32 | // Get enum TWPrivateKey value from a PyPrivateKey object. 33 | TWPrivateKey* PyPrivateKey_GetTWPrivateKey(PyObject* object); 34 | 35 | // Initialize for PyPrivateKey. It is called by python module init function. 36 | bool PyInit_PrivateKey(PyObject* module); -------------------------------------------------------------------------------- /src/generated/PrivateKeyType.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #include "generated/PrivateKeyType.h" 20 | 21 | #include 22 | #include 23 | 24 | static PyTypeObject PyPrivateKeyTypeType = { 25 | // clang-format off 26 | PyVarObject_HEAD_INIT(NULL, 0) 27 | // clang-format on 28 | "walletcore.PrivateKeyType", /* tp_name */ 29 | sizeof(PyPrivateKeyTypeObject), /* tp_basicsize */ 30 | 0, /* tp_itemsize */ 31 | 0, /* tp_dealloc */ 32 | 0, /* tp_print */ 33 | 0, /* tp_getattr */ 34 | 0, /* tp_setattr */ 35 | 0, /* tp_reserved */ 36 | 0, /* tp_repr */ 37 | 0, /* tp_as_number */ 38 | 0, /* tp_as_sequence */ 39 | 0, /* tp_as_mapping */ 40 | 0, /* tp_hash */ 41 | 0, /* tp_call */ 42 | 0, /* tp_str */ 43 | 0, /* tp_getattro */ 44 | 0, /* tp_setattro */ 45 | 0, /* tp_as_buffer */ 46 | Py_TPFLAGS_DEFAULT, /* tp_flags */ 47 | nullptr, /* tp_doc */ 48 | }; 49 | 50 | bool PyPrivateKeyType_Check(PyObject* object) { 51 | return PyObject_TypeCheck(object, &PyPrivateKeyTypeType) != 0; 52 | } 53 | 54 | struct Constant { 55 | const TWPrivateKeyType value; 56 | const char* name; 57 | PyObject* pyvalue; 58 | }; 59 | 60 | static Constant constants[] = { 61 | // clang-format off 62 | { TWPrivateKeyTypeDefault, "Default", nullptr }, 63 | { TWPrivateKeyTypeCardano, "Cardano", nullptr }, 64 | // clang-format on 65 | }; 66 | 67 | // Create PyPrivateKeyType from enum TWPrivateKeyType. It returns the same 68 | // PyPrivateKeyType instance for the same enum TWPrivateKeyType value. 69 | PyObject* PyPrivateKeyType_FromTWPrivateKeyType(TWPrivateKeyType value) { 70 | Constant* constant = 71 | std::find_if(std::begin(constants), std::end(constants), 72 | [value](const Constant& v) { return v.value == value; }); 73 | 74 | if (!constant) { 75 | PyErr_Format(PyExc_ValueError, "Invalid PrivateKeyType value: %d", value); 76 | return nullptr; 77 | } 78 | 79 | if (!constant->pyvalue) { 80 | auto* pyvalue = PyObject_New(PyPrivateKeyTypeObject, &PyPrivateKeyTypeType); 81 | *const_cast(&pyvalue->value) = value; 82 | constant->pyvalue = (PyObject*)pyvalue; 83 | } 84 | 85 | Py_INCREF(constant->pyvalue); 86 | return constant->pyvalue; 87 | } 88 | 89 | TWPrivateKeyType PyPrivateKeyType_GetTWPrivateKeyType(PyObject* object) { 90 | assert(PyPrivateKeyType_Check(object)); 91 | return ((PyPrivateKeyTypeObject*)object)->value; 92 | } 93 | 94 | static int PyPrivateKeyType_init(PyPrivateKeyTypeObject* self, 95 | PyObject* args, 96 | PyObject* kwds) { 97 | return 0; 98 | } 99 | 100 | static PyObject* PyPrivateKeyType_new(PyTypeObject* subtype, 101 | PyObject* args, 102 | PyObject* kwds) { 103 | int value = 0; 104 | if (!PyArg_ParseTuple(args, "|i", &value)) { 105 | return nullptr; 106 | } 107 | return PyPrivateKeyType_FromTWPrivateKeyType((TWPrivateKeyType)value); 108 | } 109 | 110 | static PyObject* PyPrivateKeyType_str(PyPrivateKeyTypeObject* self) { 111 | Constant* constant = std::find_if( 112 | std::begin(constants), std::end(constants), 113 | [self](const Constant& v) { return v.value == self->value; }); 114 | 115 | return PyUnicode_FromString(constant ? constant->name : "Unknown"); 116 | } 117 | 118 | // properties 119 | 120 | static const PyGetSetDef get_set_defs[] = {{}}; 121 | 122 | static const PyMethodDef method_defs[] = {{}}; 123 | 124 | bool PyInit_PrivateKeyType(PyObject* module) { 125 | PyPrivateKeyTypeType.tp_new = PyPrivateKeyType_new; 126 | PyPrivateKeyTypeType.tp_init = (initproc)PyPrivateKeyType_init; 127 | PyPrivateKeyTypeType.tp_str = (reprfunc)PyPrivateKeyType_str; 128 | PyPrivateKeyTypeType.tp_getset = (PyGetSetDef*)get_set_defs; 129 | PyPrivateKeyTypeType.tp_methods = (PyMethodDef*)method_defs; 130 | 131 | if (PyType_Ready(&PyPrivateKeyTypeType) < 0) 132 | return false; 133 | 134 | Py_INCREF(&PyPrivateKeyTypeType); 135 | if (PyModule_AddObject(module, "PrivateKeyType", 136 | (PyObject*)&PyPrivateKeyTypeType) < 0) { 137 | Py_DECREF(&PyPrivateKeyTypeType); 138 | return false; 139 | } 140 | 141 | PyObject* dict = PyPrivateKeyTypeType.tp_dict; 142 | (void)dict; 143 | 144 | for (const Constant& constant : constants) { 145 | PyDict_SetItemString(dict, constant.name, 146 | PyPrivateKeyType_FromTWPrivateKeyType(constant.value)); 147 | } 148 | 149 | return true; 150 | } -------------------------------------------------------------------------------- /src/generated/PrivateKeyType.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #pragma once 20 | 21 | #define PY_SSIZE_T_CLEAN 22 | #include 23 | 24 | #include 25 | 26 | struct PyPrivateKeyTypeObject { 27 | PyObject_HEAD; 28 | const TWPrivateKeyType value; 29 | }; 30 | 31 | // Returns true if the object is a PyPrivateKeyType. 32 | bool PyPrivateKeyType_Check(PyObject* object); 33 | 34 | // Create PyPrivateKeyType from an enum TWPrivateKeyType value. 35 | // Note: it returns the same PyPrivateKeyType instance for the same enum 36 | // TWPrivateKeyType value. the caller should release the reference after using. 37 | PyObject* PyPrivateKeyType_FromTWPrivateKeyType(TWPrivateKeyType value); 38 | 39 | // Get enum TWPrivateKeyType value from a PyPrivateKeyType object. 40 | TWPrivateKeyType PyPrivateKeyType_GetTWPrivateKeyType(PyObject* object); 41 | 42 | // Initialize for PyPrivateKeyType. It is called by python module init function. 43 | bool PyInit_PrivateKeyType(PyObject* module); -------------------------------------------------------------------------------- /src/generated/PublicKey.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #pragma once 20 | 21 | #define PY_SSIZE_T_CLEAN 22 | #include 23 | 24 | #include 25 | 26 | // Returns true if the object is a PyPublicKey. 27 | bool PyPublicKey_Check(PyObject* object); 28 | 29 | // Create PyPublicKey from an TWPublicKey. 30 | PyObject* PyPublicKey_FromTWPublicKey(TWPublicKey* value); 31 | 32 | // Get enum TWPublicKey value from a PyPublicKey object. 33 | TWPublicKey* PyPublicKey_GetTWPublicKey(PyObject* object); 34 | 35 | // Initialize for PyPublicKey. It is called by python module init function. 36 | bool PyInit_PublicKey(PyObject* module); -------------------------------------------------------------------------------- /src/generated/PublicKeyType.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #pragma once 20 | 21 | #define PY_SSIZE_T_CLEAN 22 | #include 23 | 24 | #include 25 | 26 | struct PyPublicKeyTypeObject { 27 | PyObject_HEAD; 28 | const TWPublicKeyType value; 29 | }; 30 | 31 | // Returns true if the object is a PyPublicKeyType. 32 | bool PyPublicKeyType_Check(PyObject* object); 33 | 34 | // Create PyPublicKeyType from an enum TWPublicKeyType value. 35 | // Note: it returns the same PyPublicKeyType instance for the same enum 36 | // TWPublicKeyType value. the caller should release the reference after using. 37 | PyObject* PyPublicKeyType_FromTWPublicKeyType(TWPublicKeyType value); 38 | 39 | // Get enum TWPublicKeyType value from a PyPublicKeyType object. 40 | TWPublicKeyType PyPublicKeyType_GetTWPublicKeyType(PyObject* object); 41 | 42 | // Initialize for PyPublicKeyType. It is called by python module init function. 43 | bool PyInit_PublicKeyType(PyObject* module); -------------------------------------------------------------------------------- /src/generated/Purpose.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #include "generated/Purpose.h" 20 | 21 | #include 22 | #include 23 | 24 | static PyTypeObject PyPurposeType = { 25 | // clang-format off 26 | PyVarObject_HEAD_INIT(NULL, 0) 27 | // clang-format on 28 | "walletcore.Purpose", /* tp_name */ 29 | sizeof(PyPurposeObject), /* tp_basicsize */ 30 | 0, /* tp_itemsize */ 31 | 0, /* tp_dealloc */ 32 | 0, /* tp_print */ 33 | 0, /* tp_getattr */ 34 | 0, /* tp_setattr */ 35 | 0, /* tp_reserved */ 36 | 0, /* tp_repr */ 37 | 0, /* tp_as_number */ 38 | 0, /* tp_as_sequence */ 39 | 0, /* tp_as_mapping */ 40 | 0, /* tp_hash */ 41 | 0, /* tp_call */ 42 | 0, /* tp_str */ 43 | 0, /* tp_getattro */ 44 | 0, /* tp_setattro */ 45 | 0, /* tp_as_buffer */ 46 | Py_TPFLAGS_DEFAULT, /* tp_flags */ 47 | nullptr, /* tp_doc */ 48 | }; 49 | 50 | bool PyPurpose_Check(PyObject* object) { 51 | return PyObject_TypeCheck(object, &PyPurposeType) != 0; 52 | } 53 | 54 | struct Constant { 55 | const TWPurpose value; 56 | const char* name; 57 | PyObject* pyvalue; 58 | }; 59 | 60 | static Constant constants[] = { 61 | // clang-format off 62 | { TWPurposeBIP44, "BIP44", nullptr }, 63 | { TWPurposeBIP49, "BIP49", nullptr }, 64 | { TWPurposeBIP84, "BIP84", nullptr }, 65 | { TWPurposeBIP1852, "BIP1852", nullptr }, 66 | // clang-format on 67 | }; 68 | 69 | // Create PyPurpose from enum TWPurpose. It returns the same PyPurpose instance 70 | // for the same enum TWPurpose value. 71 | PyObject* PyPurpose_FromTWPurpose(TWPurpose value) { 72 | Constant* constant = 73 | std::find_if(std::begin(constants), std::end(constants), 74 | [value](const Constant& v) { return v.value == value; }); 75 | 76 | if (!constant) { 77 | PyErr_Format(PyExc_ValueError, "Invalid Purpose value: %d", value); 78 | return nullptr; 79 | } 80 | 81 | if (!constant->pyvalue) { 82 | auto* pyvalue = PyObject_New(PyPurposeObject, &PyPurposeType); 83 | *const_cast(&pyvalue->value) = value; 84 | constant->pyvalue = (PyObject*)pyvalue; 85 | } 86 | 87 | Py_INCREF(constant->pyvalue); 88 | return constant->pyvalue; 89 | } 90 | 91 | TWPurpose PyPurpose_GetTWPurpose(PyObject* object) { 92 | assert(PyPurpose_Check(object)); 93 | return ((PyPurposeObject*)object)->value; 94 | } 95 | 96 | static int PyPurpose_init(PyPurposeObject* self, 97 | PyObject* args, 98 | PyObject* kwds) { 99 | return 0; 100 | } 101 | 102 | static PyObject* PyPurpose_new(PyTypeObject* subtype, 103 | PyObject* args, 104 | PyObject* kwds) { 105 | int value = 0; 106 | if (!PyArg_ParseTuple(args, "|i", &value)) { 107 | return nullptr; 108 | } 109 | return PyPurpose_FromTWPurpose((TWPurpose)value); 110 | } 111 | 112 | static PyObject* PyPurpose_str(PyPurposeObject* self) { 113 | Constant* constant = std::find_if( 114 | std::begin(constants), std::end(constants), 115 | [self](const Constant& v) { return v.value == self->value; }); 116 | 117 | return PyUnicode_FromString(constant ? constant->name : "Unknown"); 118 | } 119 | 120 | // properties 121 | 122 | static const PyGetSetDef get_set_defs[] = {{}}; 123 | 124 | static const PyMethodDef method_defs[] = {{}}; 125 | 126 | bool PyInit_Purpose(PyObject* module) { 127 | PyPurposeType.tp_new = PyPurpose_new; 128 | PyPurposeType.tp_init = (initproc)PyPurpose_init; 129 | PyPurposeType.tp_str = (reprfunc)PyPurpose_str; 130 | PyPurposeType.tp_getset = (PyGetSetDef*)get_set_defs; 131 | PyPurposeType.tp_methods = (PyMethodDef*)method_defs; 132 | 133 | if (PyType_Ready(&PyPurposeType) < 0) 134 | return false; 135 | 136 | Py_INCREF(&PyPurposeType); 137 | if (PyModule_AddObject(module, "Purpose", (PyObject*)&PyPurposeType) < 0) { 138 | Py_DECREF(&PyPurposeType); 139 | return false; 140 | } 141 | 142 | PyObject* dict = PyPurposeType.tp_dict; 143 | (void)dict; 144 | 145 | for (const Constant& constant : constants) { 146 | PyDict_SetItemString(dict, constant.name, 147 | PyPurpose_FromTWPurpose(constant.value)); 148 | } 149 | 150 | return true; 151 | } -------------------------------------------------------------------------------- /src/generated/Purpose.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #pragma once 20 | 21 | #define PY_SSIZE_T_CLEAN 22 | #include 23 | 24 | #include 25 | 26 | struct PyPurposeObject { 27 | PyObject_HEAD; 28 | const TWPurpose value; 29 | }; 30 | 31 | // Returns true if the object is a PyPurpose. 32 | bool PyPurpose_Check(PyObject* object); 33 | 34 | // Create PyPurpose from an enum TWPurpose value. 35 | // Note: it returns the same PyPurpose instance for the same enum TWPurpose 36 | // value. the caller should release the reference after using. 37 | PyObject* PyPurpose_FromTWPurpose(TWPurpose value); 38 | 39 | // Get enum TWPurpose value from a PyPurpose object. 40 | TWPurpose PyPurpose_GetTWPurpose(PyObject* object); 41 | 42 | // Initialize for PyPurpose. It is called by python module init function. 43 | bool PyInit_Purpose(PyObject* module); -------------------------------------------------------------------------------- /src/generated/RippleXAddress.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #pragma once 20 | 21 | #define PY_SSIZE_T_CLEAN 22 | #include 23 | 24 | #include 25 | 26 | // Returns true if the object is a PyRippleXAddress. 27 | bool PyRippleXAddress_Check(PyObject* object); 28 | 29 | // Create PyRippleXAddress from an TWRippleXAddress. 30 | PyObject* PyRippleXAddress_FromTWRippleXAddress(TWRippleXAddress* value); 31 | 32 | // Get enum TWRippleXAddress value from a PyRippleXAddress object. 33 | TWRippleXAddress* PyRippleXAddress_GetTWRippleXAddress(PyObject* object); 34 | 35 | // Initialize for PyRippleXAddress. It is called by python module init function. 36 | bool PyInit_RippleXAddress(PyObject* module); -------------------------------------------------------------------------------- /src/generated/SS58AddressType.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #include "generated/SS58AddressType.h" 20 | 21 | #include 22 | #include 23 | 24 | static PyTypeObject PySS58AddressTypeType = { 25 | // clang-format off 26 | PyVarObject_HEAD_INIT(NULL, 0) 27 | // clang-format on 28 | "walletcore.SS58AddressType", /* tp_name */ 29 | sizeof(PySS58AddressTypeObject), /* tp_basicsize */ 30 | 0, /* tp_itemsize */ 31 | 0, /* tp_dealloc */ 32 | 0, /* tp_print */ 33 | 0, /* tp_getattr */ 34 | 0, /* tp_setattr */ 35 | 0, /* tp_reserved */ 36 | 0, /* tp_repr */ 37 | 0, /* tp_as_number */ 38 | 0, /* tp_as_sequence */ 39 | 0, /* tp_as_mapping */ 40 | 0, /* tp_hash */ 41 | 0, /* tp_call */ 42 | 0, /* tp_str */ 43 | 0, /* tp_getattro */ 44 | 0, /* tp_setattro */ 45 | 0, /* tp_as_buffer */ 46 | Py_TPFLAGS_DEFAULT, /* tp_flags */ 47 | nullptr, /* tp_doc */ 48 | }; 49 | 50 | bool PySS58AddressType_Check(PyObject* object) { 51 | return PyObject_TypeCheck(object, &PySS58AddressTypeType) != 0; 52 | } 53 | 54 | struct Constant { 55 | const TWSS58AddressType value; 56 | const char* name; 57 | PyObject* pyvalue; 58 | }; 59 | 60 | static Constant constants[] = { 61 | // clang-format off 62 | { TWSS58AddressTypePolkadot, "Polkadot", nullptr }, 63 | { TWSS58AddressTypeKusama, "Kusama", nullptr }, 64 | // clang-format on 65 | }; 66 | 67 | // Create PySS58AddressType from enum TWSS58AddressType. It returns the same 68 | // PySS58AddressType instance for the same enum TWSS58AddressType value. 69 | PyObject* PySS58AddressType_FromTWSS58AddressType(TWSS58AddressType value) { 70 | Constant* constant = 71 | std::find_if(std::begin(constants), std::end(constants), 72 | [value](const Constant& v) { return v.value == value; }); 73 | 74 | if (!constant) { 75 | PyErr_Format(PyExc_ValueError, "Invalid SS58AddressType value: %d", value); 76 | return nullptr; 77 | } 78 | 79 | if (!constant->pyvalue) { 80 | auto* pyvalue = 81 | PyObject_New(PySS58AddressTypeObject, &PySS58AddressTypeType); 82 | *const_cast(&pyvalue->value) = value; 83 | constant->pyvalue = (PyObject*)pyvalue; 84 | } 85 | 86 | Py_INCREF(constant->pyvalue); 87 | return constant->pyvalue; 88 | } 89 | 90 | TWSS58AddressType PySS58AddressType_GetTWSS58AddressType(PyObject* object) { 91 | assert(PySS58AddressType_Check(object)); 92 | return ((PySS58AddressTypeObject*)object)->value; 93 | } 94 | 95 | static int PySS58AddressType_init(PySS58AddressTypeObject* self, 96 | PyObject* args, 97 | PyObject* kwds) { 98 | return 0; 99 | } 100 | 101 | static PyObject* PySS58AddressType_new(PyTypeObject* subtype, 102 | PyObject* args, 103 | PyObject* kwds) { 104 | int value = 0; 105 | if (!PyArg_ParseTuple(args, "|i", &value)) { 106 | return nullptr; 107 | } 108 | return PySS58AddressType_FromTWSS58AddressType((TWSS58AddressType)value); 109 | } 110 | 111 | static PyObject* PySS58AddressType_str(PySS58AddressTypeObject* self) { 112 | Constant* constant = std::find_if( 113 | std::begin(constants), std::end(constants), 114 | [self](const Constant& v) { return v.value == self->value; }); 115 | 116 | return PyUnicode_FromString(constant ? constant->name : "Unknown"); 117 | } 118 | 119 | // properties 120 | 121 | static const PyGetSetDef get_set_defs[] = {{}}; 122 | 123 | static const PyMethodDef method_defs[] = {{}}; 124 | 125 | bool PyInit_SS58AddressType(PyObject* module) { 126 | PySS58AddressTypeType.tp_new = PySS58AddressType_new; 127 | PySS58AddressTypeType.tp_init = (initproc)PySS58AddressType_init; 128 | PySS58AddressTypeType.tp_str = (reprfunc)PySS58AddressType_str; 129 | PySS58AddressTypeType.tp_getset = (PyGetSetDef*)get_set_defs; 130 | PySS58AddressTypeType.tp_methods = (PyMethodDef*)method_defs; 131 | 132 | if (PyType_Ready(&PySS58AddressTypeType) < 0) 133 | return false; 134 | 135 | Py_INCREF(&PySS58AddressTypeType); 136 | if (PyModule_AddObject(module, "SS58AddressType", 137 | (PyObject*)&PySS58AddressTypeType) < 0) { 138 | Py_DECREF(&PySS58AddressTypeType); 139 | return false; 140 | } 141 | 142 | PyObject* dict = PySS58AddressTypeType.tp_dict; 143 | (void)dict; 144 | 145 | for (const Constant& constant : constants) { 146 | PyDict_SetItemString( 147 | dict, constant.name, 148 | PySS58AddressType_FromTWSS58AddressType(constant.value)); 149 | } 150 | 151 | return true; 152 | } -------------------------------------------------------------------------------- /src/generated/SS58AddressType.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #pragma once 20 | 21 | #define PY_SSIZE_T_CLEAN 22 | #include 23 | 24 | #include 25 | 26 | struct PySS58AddressTypeObject { 27 | PyObject_HEAD; 28 | const TWSS58AddressType value; 29 | }; 30 | 31 | // Returns true if the object is a PySS58AddressType. 32 | bool PySS58AddressType_Check(PyObject* object); 33 | 34 | // Create PySS58AddressType from an enum TWSS58AddressType value. 35 | // Note: it returns the same PySS58AddressType instance for the same enum 36 | // TWSS58AddressType value. the caller should release the reference after using. 37 | PyObject* PySS58AddressType_FromTWSS58AddressType(TWSS58AddressType value); 38 | 39 | // Get enum TWSS58AddressType value from a PySS58AddressType object. 40 | TWSS58AddressType PySS58AddressType_GetTWSS58AddressType(PyObject* object); 41 | 42 | // Initialize for PySS58AddressType. It is called by python module init 43 | // function. 44 | bool PyInit_SS58AddressType(PyObject* module); -------------------------------------------------------------------------------- /src/generated/SegwitAddress.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #pragma once 20 | 21 | #define PY_SSIZE_T_CLEAN 22 | #include 23 | 24 | #include 25 | 26 | // Returns true if the object is a PySegwitAddress. 27 | bool PySegwitAddress_Check(PyObject* object); 28 | 29 | // Create PySegwitAddress from an TWSegwitAddress. 30 | PyObject* PySegwitAddress_FromTWSegwitAddress(TWSegwitAddress* value); 31 | 32 | // Get enum TWSegwitAddress value from a PySegwitAddress object. 33 | TWSegwitAddress* PySegwitAddress_GetTWSegwitAddress(PyObject* object); 34 | 35 | // Initialize for PySegwitAddress. It is called by python module init function. 36 | bool PyInit_SegwitAddress(PyObject* module); -------------------------------------------------------------------------------- /src/generated/SolanaAddress.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #pragma once 20 | 21 | #define PY_SSIZE_T_CLEAN 22 | #include 23 | 24 | #include 25 | 26 | // Returns true if the object is a PySolanaAddress. 27 | bool PySolanaAddress_Check(PyObject* object); 28 | 29 | // Create PySolanaAddress from an TWSolanaAddress. 30 | PyObject* PySolanaAddress_FromTWSolanaAddress(TWSolanaAddress* value); 31 | 32 | // Get enum TWSolanaAddress value from a PySolanaAddress object. 33 | TWSolanaAddress* PySolanaAddress_GetTWSolanaAddress(PyObject* object); 34 | 35 | // Initialize for PySolanaAddress. It is called by python module init function. 36 | bool PyInit_SolanaAddress(PyObject* module); -------------------------------------------------------------------------------- /src/generated/StarkExMessageSigner.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #include "generated/StarkExMessageSigner.h" 20 | 21 | #include "String.h" 22 | #include "generated/PrivateKey.h" 23 | #include "generated/PublicKey.h" 24 | 25 | struct PyStarkExMessageSignerObject { 26 | PyObject_HEAD; 27 | }; 28 | 29 | static PyTypeObject PyStarkExMessageSignerType = { 30 | // clang-format off 31 | PyVarObject_HEAD_INIT(NULL, 0) 32 | // clang-format on 33 | "walletcore.StarkExMessageSigner", /* tp_name */ 34 | sizeof(PyStarkExMessageSignerObject), /* tp_basicsize */ 35 | 0, /* tp_itemsize */ 36 | 0, /* tp_dealloc */ 37 | 0, /* tp_print */ 38 | 0, /* tp_getattr */ 39 | 0, /* tp_setattr */ 40 | 0, /* tp_reserved */ 41 | 0, /* tp_repr */ 42 | 0, /* tp_as_number */ 43 | 0, /* tp_as_sequence */ 44 | 0, /* tp_as_mapping */ 45 | 0, /* tp_hash */ 46 | 0, /* tp_call */ 47 | 0, /* tp_str */ 48 | 0, /* tp_getattro */ 49 | 0, /* tp_setattro */ 50 | 0, /* tp_as_buffer */ 51 | Py_TPFLAGS_DEFAULT, /* tp_flags */ 52 | nullptr, /* tp_doc */ 53 | }; 54 | 55 | // static method function for SignMessage 56 | static const char PyStarkExMessageSignerSignMessage_doc[] = 57 | "TWString* TWStarkExMessageSignerSignMessage(const struct TWPrivateKey* " 58 | "privateKey, TWString* message)"; 59 | static PyObject* PyStarkExMessageSignerSignMessage( 60 | PyStarkExMessageSignerObject* self, 61 | PyObject* const* args, 62 | Py_ssize_t nargs) { 63 | if (nargs != 2) { 64 | PyErr_Format(PyExc_TypeError, "Expect 2 args, but %d args are passed in.", 65 | nargs); 66 | return nullptr; 67 | } 68 | 69 | if (!PyPrivateKey_Check(args[0])) { 70 | PyErr_SetString(PyExc_TypeError, "The arg 0 is not in type PrivateKey"); 71 | return nullptr; 72 | } 73 | auto arg0 = PyPrivateKey_GetTWPrivateKey(args[0]); 74 | 75 | if (!PyUnicode_Check(args[1])) { 76 | PyErr_SetString(PyExc_TypeError, "The arg 1 is not in type Unicode"); 77 | return nullptr; 78 | } 79 | auto arg1 = PyUnicode_GetTWString(args[1]); 80 | 81 | TWStringPtr result(TWStarkExMessageSignerSignMessage(arg0, arg1.get())); 82 | return PyUnicode_FromTWString(result); 83 | } 84 | 85 | // static method function for VerifyMessage 86 | static const char PyStarkExMessageSignerVerifyMessage_doc[] = 87 | "bool TWStarkExMessageSignerVerifyMessage(const struct TWPublicKey* " 88 | "pubKey, TWString* message, TWString* signature)"; 89 | static PyObject* PyStarkExMessageSignerVerifyMessage( 90 | PyStarkExMessageSignerObject* self, 91 | PyObject* const* args, 92 | Py_ssize_t nargs) { 93 | if (nargs != 3) { 94 | PyErr_Format(PyExc_TypeError, "Expect 3 args, but %d args are passed in.", 95 | nargs); 96 | return nullptr; 97 | } 98 | 99 | if (!PyPublicKey_Check(args[0])) { 100 | PyErr_SetString(PyExc_TypeError, "The arg 0 is not in type PublicKey"); 101 | return nullptr; 102 | } 103 | auto arg0 = PyPublicKey_GetTWPublicKey(args[0]); 104 | 105 | if (!PyUnicode_Check(args[1])) { 106 | PyErr_SetString(PyExc_TypeError, "The arg 1 is not in type Unicode"); 107 | return nullptr; 108 | } 109 | auto arg1 = PyUnicode_GetTWString(args[1]); 110 | 111 | if (!PyUnicode_Check(args[2])) { 112 | PyErr_SetString(PyExc_TypeError, "The arg 2 is not in type Unicode"); 113 | return nullptr; 114 | } 115 | auto arg2 = PyUnicode_GetTWString(args[2]); 116 | 117 | bool result = 118 | TWStarkExMessageSignerVerifyMessage(arg0, arg1.get(), arg2.get()); 119 | return PyBool_FromLong(result); 120 | } 121 | 122 | // properties 123 | 124 | static const PyGetSetDef get_set_defs[] = {{}}; 125 | 126 | static const PyMethodDef method_defs[] = { 127 | {"sign_message", (PyCFunction)PyStarkExMessageSignerSignMessage, 128 | METH_FASTCALL | METH_STATIC, PyStarkExMessageSignerSignMessage_doc}, 129 | {"verify_message", (PyCFunction)PyStarkExMessageSignerVerifyMessage, 130 | METH_FASTCALL | METH_STATIC, PyStarkExMessageSignerVerifyMessage_doc}, 131 | {}}; 132 | 133 | bool PyInit_StarkExMessageSigner(PyObject* module) { 134 | PyStarkExMessageSignerType.tp_getset = (PyGetSetDef*)get_set_defs; 135 | PyStarkExMessageSignerType.tp_methods = (PyMethodDef*)method_defs; 136 | 137 | if (PyType_Ready(&PyStarkExMessageSignerType) < 0) 138 | return false; 139 | 140 | Py_INCREF(&PyStarkExMessageSignerType); 141 | if (PyModule_AddObject(module, "StarkExMessageSigner", 142 | (PyObject*)&PyStarkExMessageSignerType) < 0) { 143 | Py_DECREF(&PyStarkExMessageSignerType); 144 | return false; 145 | } 146 | 147 | return true; 148 | } -------------------------------------------------------------------------------- /src/generated/StarkExMessageSigner.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #pragma once 20 | 21 | #define PY_SSIZE_T_CLEAN 22 | #include 23 | 24 | #include 25 | 26 | // Initialize for PyStarkExMessageSigner. It is called by python module init 27 | // function. 28 | bool PyInit_StarkExMessageSigner(PyObject* module); -------------------------------------------------------------------------------- /src/generated/StarkWare.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #include "generated/StarkWare.h" 20 | 21 | #include "String.h" 22 | #include "generated/DerivationPath.h" 23 | #include "generated/PrivateKey.h" 24 | 25 | struct PyStarkWareObject { 26 | PyObject_HEAD; 27 | }; 28 | 29 | static PyTypeObject PyStarkWareType = { 30 | // clang-format off 31 | PyVarObject_HEAD_INIT(NULL, 0) 32 | // clang-format on 33 | "walletcore.StarkWare", /* tp_name */ 34 | sizeof(PyStarkWareObject), /* tp_basicsize */ 35 | 0, /* tp_itemsize */ 36 | 0, /* tp_dealloc */ 37 | 0, /* tp_print */ 38 | 0, /* tp_getattr */ 39 | 0, /* tp_setattr */ 40 | 0, /* tp_reserved */ 41 | 0, /* tp_repr */ 42 | 0, /* tp_as_number */ 43 | 0, /* tp_as_sequence */ 44 | 0, /* tp_as_mapping */ 45 | 0, /* tp_hash */ 46 | 0, /* tp_call */ 47 | 0, /* tp_str */ 48 | 0, /* tp_getattro */ 49 | 0, /* tp_setattro */ 50 | 0, /* tp_as_buffer */ 51 | Py_TPFLAGS_DEFAULT, /* tp_flags */ 52 | nullptr, /* tp_doc */ 53 | }; 54 | 55 | // static method function for GetStarkKeyFromSignature 56 | static const char PyStarkWareGetStarkKeyFromSignature_doc[] = 57 | "struct TWPrivateKey* TWStarkWareGetStarkKeyFromSignature(const struct " 58 | "TWDerivationPath* derivationPath, TWString* signature)"; 59 | static PyObject* PyStarkWareGetStarkKeyFromSignature(PyStarkWareObject* self, 60 | PyObject* const* args, 61 | Py_ssize_t nargs) { 62 | if (nargs != 2) { 63 | PyErr_Format(PyExc_TypeError, "Expect 2 args, but %d args are passed in.", 64 | nargs); 65 | return nullptr; 66 | } 67 | 68 | if (!PyDerivationPath_Check(args[0])) { 69 | PyErr_SetString(PyExc_TypeError, "The arg 0 is not in type DerivationPath"); 70 | return nullptr; 71 | } 72 | auto arg0 = PyDerivationPath_GetTWDerivationPath(args[0]); 73 | 74 | if (!PyUnicode_Check(args[1])) { 75 | PyErr_SetString(PyExc_TypeError, "The arg 1 is not in type Unicode"); 76 | return nullptr; 77 | } 78 | auto arg1 = PyUnicode_GetTWString(args[1]); 79 | 80 | TWPrivateKey* result = TWStarkWareGetStarkKeyFromSignature(arg0, arg1.get()); 81 | return PyPrivateKey_FromTWPrivateKey(result); 82 | } 83 | 84 | // properties 85 | 86 | static const PyGetSetDef get_set_defs[] = {{}}; 87 | 88 | static const PyMethodDef method_defs[] = { 89 | {"get_stark_key_from_signature", 90 | (PyCFunction)PyStarkWareGetStarkKeyFromSignature, 91 | METH_FASTCALL | METH_STATIC, PyStarkWareGetStarkKeyFromSignature_doc}, 92 | {}}; 93 | 94 | bool PyInit_StarkWare(PyObject* module) { 95 | PyStarkWareType.tp_getset = (PyGetSetDef*)get_set_defs; 96 | PyStarkWareType.tp_methods = (PyMethodDef*)method_defs; 97 | 98 | if (PyType_Ready(&PyStarkWareType) < 0) 99 | return false; 100 | 101 | Py_INCREF(&PyStarkWareType); 102 | if (PyModule_AddObject(module, "StarkWare", (PyObject*)&PyStarkWareType) < 103 | 0) { 104 | Py_DECREF(&PyStarkWareType); 105 | return false; 106 | } 107 | 108 | return true; 109 | } -------------------------------------------------------------------------------- /src/generated/StarkWare.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #pragma once 20 | 21 | #define PY_SSIZE_T_CLEAN 22 | #include 23 | 24 | #include 25 | 26 | // Initialize for PyStarkWare. It is called by python module init function. 27 | bool PyInit_StarkWare(PyObject* module); -------------------------------------------------------------------------------- /src/generated/StellarMemoType.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #include "generated/StellarMemoType.h" 20 | 21 | #include 22 | #include 23 | 24 | static PyTypeObject PyStellarMemoTypeType = { 25 | // clang-format off 26 | PyVarObject_HEAD_INIT(NULL, 0) 27 | // clang-format on 28 | "walletcore.StellarMemoType", /* tp_name */ 29 | sizeof(PyStellarMemoTypeObject), /* tp_basicsize */ 30 | 0, /* tp_itemsize */ 31 | 0, /* tp_dealloc */ 32 | 0, /* tp_print */ 33 | 0, /* tp_getattr */ 34 | 0, /* tp_setattr */ 35 | 0, /* tp_reserved */ 36 | 0, /* tp_repr */ 37 | 0, /* tp_as_number */ 38 | 0, /* tp_as_sequence */ 39 | 0, /* tp_as_mapping */ 40 | 0, /* tp_hash */ 41 | 0, /* tp_call */ 42 | 0, /* tp_str */ 43 | 0, /* tp_getattro */ 44 | 0, /* tp_setattro */ 45 | 0, /* tp_as_buffer */ 46 | Py_TPFLAGS_DEFAULT, /* tp_flags */ 47 | nullptr, /* tp_doc */ 48 | }; 49 | 50 | bool PyStellarMemoType_Check(PyObject* object) { 51 | return PyObject_TypeCheck(object, &PyStellarMemoTypeType) != 0; 52 | } 53 | 54 | struct Constant { 55 | const TWStellarMemoType value; 56 | const char* name; 57 | PyObject* pyvalue; 58 | }; 59 | 60 | static Constant constants[] = { 61 | // clang-format off 62 | { TWStellarMemoTypeNone, "None", nullptr }, 63 | { TWStellarMemoTypeText, "Text", nullptr }, 64 | { TWStellarMemoTypeId, "Id", nullptr }, 65 | { TWStellarMemoTypeHash, "Hash", nullptr }, 66 | { TWStellarMemoTypeReturn, "Return", nullptr }, 67 | // clang-format on 68 | }; 69 | 70 | // Create PyStellarMemoType from enum TWStellarMemoType. It returns the same 71 | // PyStellarMemoType instance for the same enum TWStellarMemoType value. 72 | PyObject* PyStellarMemoType_FromTWStellarMemoType(TWStellarMemoType value) { 73 | Constant* constant = 74 | std::find_if(std::begin(constants), std::end(constants), 75 | [value](const Constant& v) { return v.value == value; }); 76 | 77 | if (!constant) { 78 | PyErr_Format(PyExc_ValueError, "Invalid StellarMemoType value: %d", value); 79 | return nullptr; 80 | } 81 | 82 | if (!constant->pyvalue) { 83 | auto* pyvalue = 84 | PyObject_New(PyStellarMemoTypeObject, &PyStellarMemoTypeType); 85 | *const_cast(&pyvalue->value) = value; 86 | constant->pyvalue = (PyObject*)pyvalue; 87 | } 88 | 89 | Py_INCREF(constant->pyvalue); 90 | return constant->pyvalue; 91 | } 92 | 93 | TWStellarMemoType PyStellarMemoType_GetTWStellarMemoType(PyObject* object) { 94 | assert(PyStellarMemoType_Check(object)); 95 | return ((PyStellarMemoTypeObject*)object)->value; 96 | } 97 | 98 | static int PyStellarMemoType_init(PyStellarMemoTypeObject* self, 99 | PyObject* args, 100 | PyObject* kwds) { 101 | return 0; 102 | } 103 | 104 | static PyObject* PyStellarMemoType_new(PyTypeObject* subtype, 105 | PyObject* args, 106 | PyObject* kwds) { 107 | int value = 0; 108 | if (!PyArg_ParseTuple(args, "|i", &value)) { 109 | return nullptr; 110 | } 111 | return PyStellarMemoType_FromTWStellarMemoType((TWStellarMemoType)value); 112 | } 113 | 114 | static PyObject* PyStellarMemoType_str(PyStellarMemoTypeObject* self) { 115 | Constant* constant = std::find_if( 116 | std::begin(constants), std::end(constants), 117 | [self](const Constant& v) { return v.value == self->value; }); 118 | 119 | return PyUnicode_FromString(constant ? constant->name : "Unknown"); 120 | } 121 | 122 | // properties 123 | 124 | static const PyGetSetDef get_set_defs[] = {{}}; 125 | 126 | static const PyMethodDef method_defs[] = {{}}; 127 | 128 | bool PyInit_StellarMemoType(PyObject* module) { 129 | PyStellarMemoTypeType.tp_new = PyStellarMemoType_new; 130 | PyStellarMemoTypeType.tp_init = (initproc)PyStellarMemoType_init; 131 | PyStellarMemoTypeType.tp_str = (reprfunc)PyStellarMemoType_str; 132 | PyStellarMemoTypeType.tp_getset = (PyGetSetDef*)get_set_defs; 133 | PyStellarMemoTypeType.tp_methods = (PyMethodDef*)method_defs; 134 | 135 | if (PyType_Ready(&PyStellarMemoTypeType) < 0) 136 | return false; 137 | 138 | Py_INCREF(&PyStellarMemoTypeType); 139 | if (PyModule_AddObject(module, "StellarMemoType", 140 | (PyObject*)&PyStellarMemoTypeType) < 0) { 141 | Py_DECREF(&PyStellarMemoTypeType); 142 | return false; 143 | } 144 | 145 | PyObject* dict = PyStellarMemoTypeType.tp_dict; 146 | (void)dict; 147 | 148 | for (const Constant& constant : constants) { 149 | PyDict_SetItemString( 150 | dict, constant.name, 151 | PyStellarMemoType_FromTWStellarMemoType(constant.value)); 152 | } 153 | 154 | return true; 155 | } -------------------------------------------------------------------------------- /src/generated/StellarMemoType.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #pragma once 20 | 21 | #define PY_SSIZE_T_CLEAN 22 | #include 23 | 24 | #include 25 | 26 | struct PyStellarMemoTypeObject { 27 | PyObject_HEAD; 28 | const TWStellarMemoType value; 29 | }; 30 | 31 | // Returns true if the object is a PyStellarMemoType. 32 | bool PyStellarMemoType_Check(PyObject* object); 33 | 34 | // Create PyStellarMemoType from an enum TWStellarMemoType value. 35 | // Note: it returns the same PyStellarMemoType instance for the same enum 36 | // TWStellarMemoType value. the caller should release the reference after using. 37 | PyObject* PyStellarMemoType_FromTWStellarMemoType(TWStellarMemoType value); 38 | 39 | // Get enum TWStellarMemoType value from a PyStellarMemoType object. 40 | TWStellarMemoType PyStellarMemoType_GetTWStellarMemoType(PyObject* object); 41 | 42 | // Initialize for PyStellarMemoType. It is called by python module init 43 | // function. 44 | bool PyInit_StellarMemoType(PyObject* module); -------------------------------------------------------------------------------- /src/generated/StellarPassphrase.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #pragma once 20 | 21 | #define PY_SSIZE_T_CLEAN 22 | #include 23 | 24 | #include 25 | 26 | struct PyStellarPassphraseObject { 27 | PyObject_HEAD; 28 | const TWStellarPassphrase value; 29 | }; 30 | 31 | // Returns true if the object is a PyStellarPassphrase. 32 | bool PyStellarPassphrase_Check(PyObject* object); 33 | 34 | // Create PyStellarPassphrase from an enum TWStellarPassphrase value. 35 | // Note: it returns the same PyStellarPassphrase instance for the same enum 36 | // TWStellarPassphrase value. the caller should release the reference after 37 | // using. 38 | PyObject* PyStellarPassphrase_FromTWStellarPassphrase( 39 | TWStellarPassphrase value); 40 | 41 | // Get enum TWStellarPassphrase value from a PyStellarPassphrase object. 42 | TWStellarPassphrase PyStellarPassphrase_GetTWStellarPassphrase( 43 | PyObject* object); 44 | 45 | // Initialize for PyStellarPassphrase. It is called by python module init 46 | // function. 47 | bool PyInit_StellarPassphrase(PyObject* module); -------------------------------------------------------------------------------- /src/generated/StellarVersionByte.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #pragma once 20 | 21 | #define PY_SSIZE_T_CLEAN 22 | #include 23 | 24 | #include 25 | 26 | struct PyStellarVersionByteObject { 27 | PyObject_HEAD; 28 | const TWStellarVersionByte value; 29 | }; 30 | 31 | // Returns true if the object is a PyStellarVersionByte. 32 | bool PyStellarVersionByte_Check(PyObject* object); 33 | 34 | // Create PyStellarVersionByte from an enum TWStellarVersionByte value. 35 | // Note: it returns the same PyStellarVersionByte instance for the same enum 36 | // TWStellarVersionByte value. the caller should release the reference after 37 | // using. 38 | PyObject* PyStellarVersionByte_FromTWStellarVersionByte( 39 | TWStellarVersionByte value); 40 | 41 | // Get enum TWStellarVersionByte value from a PyStellarVersionByte object. 42 | TWStellarVersionByte PyStellarVersionByte_GetTWStellarVersionByte( 43 | PyObject* object); 44 | 45 | // Initialize for PyStellarVersionByte. It is called by python module init 46 | // function. 47 | bool PyInit_StellarVersionByte(PyObject* module); -------------------------------------------------------------------------------- /src/generated/StoredKey.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #pragma once 20 | 21 | #define PY_SSIZE_T_CLEAN 22 | #include 23 | 24 | #include 25 | 26 | // Returns true if the object is a PyStoredKey. 27 | bool PyStoredKey_Check(PyObject* object); 28 | 29 | // Create PyStoredKey from an TWStoredKey. 30 | PyObject* PyStoredKey_FromTWStoredKey(TWStoredKey* value); 31 | 32 | // Get enum TWStoredKey value from a PyStoredKey object. 33 | TWStoredKey* PyStoredKey_GetTWStoredKey(PyObject* object); 34 | 35 | // Initialize for PyStoredKey. It is called by python module init function. 36 | bool PyInit_StoredKey(PyObject* module); -------------------------------------------------------------------------------- /src/generated/StoredKeyEncryption.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #pragma once 20 | 21 | #define PY_SSIZE_T_CLEAN 22 | #include 23 | 24 | #include 25 | 26 | struct PyStoredKeyEncryptionObject { 27 | PyObject_HEAD; 28 | const TWStoredKeyEncryption value; 29 | }; 30 | 31 | // Returns true if the object is a PyStoredKeyEncryption. 32 | bool PyStoredKeyEncryption_Check(PyObject* object); 33 | 34 | // Create PyStoredKeyEncryption from an enum TWStoredKeyEncryption value. 35 | // Note: it returns the same PyStoredKeyEncryption instance for the same enum 36 | // TWStoredKeyEncryption value. the caller should release the reference after 37 | // using. 38 | PyObject* PyStoredKeyEncryption_FromTWStoredKeyEncryption( 39 | TWStoredKeyEncryption value); 40 | 41 | // Get enum TWStoredKeyEncryption value from a PyStoredKeyEncryption object. 42 | TWStoredKeyEncryption PyStoredKeyEncryption_GetTWStoredKeyEncryption( 43 | PyObject* object); 44 | 45 | // Initialize for PyStoredKeyEncryption. It is called by python module init 46 | // function. 47 | bool PyInit_StoredKeyEncryption(PyObject* module); -------------------------------------------------------------------------------- /src/generated/StoredKeyEncryptionLevel.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #pragma once 20 | 21 | #define PY_SSIZE_T_CLEAN 22 | #include 23 | 24 | #include 25 | 26 | struct PyStoredKeyEncryptionLevelObject { 27 | PyObject_HEAD; 28 | const TWStoredKeyEncryptionLevel value; 29 | }; 30 | 31 | // Returns true if the object is a PyStoredKeyEncryptionLevel. 32 | bool PyStoredKeyEncryptionLevel_Check(PyObject* object); 33 | 34 | // Create PyStoredKeyEncryptionLevel from an enum TWStoredKeyEncryptionLevel 35 | // value. Note: it returns the same PyStoredKeyEncryptionLevel instance for the 36 | // same enum TWStoredKeyEncryptionLevel value. the caller should release the 37 | // reference after using. 38 | PyObject* PyStoredKeyEncryptionLevel_FromTWStoredKeyEncryptionLevel( 39 | TWStoredKeyEncryptionLevel value); 40 | 41 | // Get enum TWStoredKeyEncryptionLevel value from a PyStoredKeyEncryptionLevel 42 | // object. 43 | TWStoredKeyEncryptionLevel 44 | PyStoredKeyEncryptionLevel_GetTWStoredKeyEncryptionLevel(PyObject* object); 45 | 46 | // Initialize for PyStoredKeyEncryptionLevel. It is called by python module init 47 | // function. 48 | bool PyInit_StoredKeyEncryptionLevel(PyObject* module); -------------------------------------------------------------------------------- /src/generated/THORChainSwap.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #include "generated/THORChainSwap.h" 20 | 21 | #include "Data.h" 22 | 23 | struct PyTHORChainSwapObject { 24 | PyObject_HEAD; 25 | }; 26 | 27 | static PyTypeObject PyTHORChainSwapType = { 28 | // clang-format off 29 | PyVarObject_HEAD_INIT(NULL, 0) 30 | // clang-format on 31 | "walletcore.THORChainSwap", /* tp_name */ 32 | sizeof(PyTHORChainSwapObject), /* tp_basicsize */ 33 | 0, /* tp_itemsize */ 34 | 0, /* tp_dealloc */ 35 | 0, /* tp_print */ 36 | 0, /* tp_getattr */ 37 | 0, /* tp_setattr */ 38 | 0, /* tp_reserved */ 39 | 0, /* tp_repr */ 40 | 0, /* tp_as_number */ 41 | 0, /* tp_as_sequence */ 42 | 0, /* tp_as_mapping */ 43 | 0, /* tp_hash */ 44 | 0, /* tp_call */ 45 | 0, /* tp_str */ 46 | 0, /* tp_getattro */ 47 | 0, /* tp_setattro */ 48 | 0, /* tp_as_buffer */ 49 | Py_TPFLAGS_DEFAULT, /* tp_flags */ 50 | nullptr, /* tp_doc */ 51 | }; 52 | 53 | // static method function for BuildSwap 54 | static const char PyTHORChainSwapBuildSwap_doc[] = 55 | "TWData* TWTHORChainSwapBuildSwap(TWData* input)"; 56 | static PyObject* PyTHORChainSwapBuildSwap(PyTHORChainSwapObject* self, 57 | PyObject* const* args, 58 | Py_ssize_t nargs) { 59 | if (nargs != 1) { 60 | PyErr_Format(PyExc_TypeError, "Expect 1 args, but %d args are passed in.", 61 | nargs); 62 | return nullptr; 63 | } 64 | 65 | if (!PyBytes_Check(args[0])) { 66 | PyErr_SetString(PyExc_TypeError, "The arg 0 is not in type Bytes"); 67 | return nullptr; 68 | } 69 | auto arg0 = PyBytes_GetTWData(args[0]); 70 | 71 | TWDataPtr result(TWTHORChainSwapBuildSwap(arg0.get())); 72 | return PyBytes_FromTWData(result); 73 | } 74 | 75 | // properties 76 | 77 | static const PyGetSetDef get_set_defs[] = {{}}; 78 | 79 | static const PyMethodDef method_defs[] = { 80 | {"build_swap", (PyCFunction)PyTHORChainSwapBuildSwap, 81 | METH_FASTCALL | METH_STATIC, PyTHORChainSwapBuildSwap_doc}, 82 | {}}; 83 | 84 | bool PyInit_THORChainSwap(PyObject* module) { 85 | PyTHORChainSwapType.tp_getset = (PyGetSetDef*)get_set_defs; 86 | PyTHORChainSwapType.tp_methods = (PyMethodDef*)method_defs; 87 | 88 | if (PyType_Ready(&PyTHORChainSwapType) < 0) 89 | return false; 90 | 91 | Py_INCREF(&PyTHORChainSwapType); 92 | if (PyModule_AddObject(module, "THORChainSwap", 93 | (PyObject*)&PyTHORChainSwapType) < 0) { 94 | Py_DECREF(&PyTHORChainSwapType); 95 | return false; 96 | } 97 | 98 | return true; 99 | } -------------------------------------------------------------------------------- /src/generated/THORChainSwap.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #pragma once 20 | 21 | #define PY_SSIZE_T_CLEAN 22 | #include 23 | 24 | #include 25 | 26 | // Initialize for PyTHORChainSwap. It is called by python module init function. 27 | bool PyInit_THORChainSwap(PyObject* module); -------------------------------------------------------------------------------- /src/generated/TransactionCompiler.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #pragma once 20 | 21 | #define PY_SSIZE_T_CLEAN 22 | #include 23 | 24 | #include 25 | 26 | // Initialize for PyTransactionCompiler. It is called by python module init 27 | // function. 28 | bool PyInit_TransactionCompiler(PyObject* module); -------------------------------------------------------------------------------- /src/generated/module.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peng Huang 2 | // This file is part of Wallet-core-python. 3 | // 4 | // Wallet-core-python is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // Wallet-core-python is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Wallet-core-python. If not, see . 16 | // 17 | // NOTE: this is a GENERATED FILE, changes made here WILL BE LOST. 18 | 19 | #define PY_SSIZE_T_CLEAN 20 | #include 21 | 22 | #include "AnySigner.h" 23 | #include "generated/AES.h" 24 | #include "generated/AESPaddingMode.h" 25 | #include "generated/Account.h" 26 | #include "generated/AnyAddress.h" 27 | #include "generated/Base32.h" 28 | #include "generated/Base58.h" 29 | #include "generated/Base64.h" 30 | #include "generated/BitcoinAddress.h" 31 | #include "generated/BitcoinMessageSigner.h" 32 | #include "generated/BitcoinScript.h" 33 | #include "generated/BitcoinSigHashType.h" 34 | #include "generated/Blockchain.h" 35 | #include "generated/Cardano.h" 36 | #include "generated/CoinType.h" 37 | #include "generated/CoinTypeConfiguration.h" 38 | #include "generated/Curve.h" 39 | #include "generated/DataVector.h" 40 | #include "generated/Derivation.h" 41 | #include "generated/DerivationPath.h" 42 | #include "generated/DerivationPathIndex.h" 43 | #include "generated/EthereumAbi.h" 44 | #include "generated/EthereumAbiFunction.h" 45 | #include "generated/EthereumAbiValue.h" 46 | #include "generated/EthereumEip2645.h" 47 | #include "generated/EthereumMessageSigner.h" 48 | #include "generated/FIOAccount.h" 49 | #include "generated/GroestlcoinAddress.h" 50 | #include "generated/HDVersion.h" 51 | #include "generated/HDWallet.h" 52 | #include "generated/HRP.h" 53 | #include "generated/Hash.h" 54 | #include "generated/Mnemonic.h" 55 | #include "generated/NEARAccount.h" 56 | #include "generated/NervosAddress.h" 57 | #include "generated/PBKDF2.h" 58 | #include "generated/PrivateKey.h" 59 | #include "generated/PrivateKeyType.h" 60 | #include "generated/PublicKey.h" 61 | #include "generated/PublicKeyType.h" 62 | #include "generated/Purpose.h" 63 | #include "generated/RippleXAddress.h" 64 | #include "generated/SS58AddressType.h" 65 | #include "generated/SegwitAddress.h" 66 | #include "generated/SolanaAddress.h" 67 | #include "generated/StarkExMessageSigner.h" 68 | #include "generated/StarkWare.h" 69 | #include "generated/StellarMemoType.h" 70 | #include "generated/StellarPassphrase.h" 71 | #include "generated/StellarVersionByte.h" 72 | #include "generated/StoredKey.h" 73 | #include "generated/StoredKeyEncryption.h" 74 | #include "generated/StoredKeyEncryptionLevel.h" 75 | #include "generated/THORChainSwap.h" 76 | #include "generated/TransactionCompiler.h" 77 | 78 | typedef bool (*InitProc)(PyObject* module); 79 | const InitProc init_functions[] = { 80 | // clang-format off 81 | PyInit_AES, 82 | PyInit_AESPaddingMode, 83 | PyInit_Account, 84 | PyInit_AnyAddress, 85 | PyInit_AnySigner, 86 | PyInit_Base32, 87 | PyInit_Base58, 88 | PyInit_Base64, 89 | PyInit_BitcoinAddress, 90 | PyInit_BitcoinMessageSigner, 91 | PyInit_BitcoinScript, 92 | PyInit_BitcoinSigHashType, 93 | PyInit_Blockchain, 94 | PyInit_Cardano, 95 | PyInit_CoinType, 96 | PyInit_CoinTypeConfiguration, 97 | PyInit_Curve, 98 | PyInit_DataVector, 99 | PyInit_Derivation, 100 | PyInit_DerivationPath, 101 | PyInit_DerivationPathIndex, 102 | PyInit_EthereumAbi, 103 | PyInit_EthereumAbiFunction, 104 | PyInit_EthereumAbiValue, 105 | PyInit_EthereumEip2645, 106 | PyInit_EthereumMessageSigner, 107 | PyInit_FIOAccount, 108 | PyInit_GroestlcoinAddress, 109 | PyInit_HDVersion, 110 | PyInit_HDWallet, 111 | PyInit_HRP, 112 | PyInit_Hash, 113 | PyInit_Mnemonic, 114 | PyInit_NEARAccount, 115 | PyInit_NervosAddress, 116 | PyInit_PBKDF2, 117 | PyInit_PrivateKey, 118 | PyInit_PrivateKeyType, 119 | PyInit_PublicKey, 120 | PyInit_PublicKeyType, 121 | PyInit_Purpose, 122 | PyInit_RippleXAddress, 123 | PyInit_SS58AddressType, 124 | PyInit_SegwitAddress, 125 | PyInit_SolanaAddress, 126 | PyInit_StarkExMessageSigner, 127 | PyInit_StarkWare, 128 | PyInit_StellarMemoType, 129 | PyInit_StellarPassphrase, 130 | PyInit_StellarVersionByte, 131 | PyInit_StoredKey, 132 | PyInit_StoredKeyEncryption, 133 | PyInit_StoredKeyEncryptionLevel, 134 | PyInit_THORChainSwap, 135 | PyInit_TransactionCompiler, 136 | // clang-format on 137 | }; 138 | 139 | PyMODINIT_FUNC PyInit_walletcore(void) { 140 | static struct PyModuleDef enum_module_def = { 141 | PyModuleDef_HEAD_INIT, "walletcore", /* m_name */ 142 | nullptr, /* m_doc */ 143 | -1, /* m_size */ 144 | nullptr /* m_methods */ 145 | }; 146 | 147 | PyObject* module = PyModule_Create(&enum_module_def); 148 | if (module == nullptr) { 149 | return nullptr; 150 | } 151 | 152 | for (const auto func : init_functions) { 153 | if (!func(module)) { 154 | Py_DECREF(module); 155 | return nullptr; 156 | } 157 | } 158 | 159 | return module; 160 | } --------------------------------------------------------------------------------