Skip to content
Snippets Groups Projects
Commit f99223f0 authored by alexey.stratulat's avatar alexey.stratulat
Browse files

[+] Added functions getPath, openFile, open, save, getCertsNumber and...

[+] Added functions getPath, openFile, open, save, getCertsNumber and destructor close for ChainWallet object.
parent d47fc417
No related branches found
No related tags found
1 merge request!26Support 3689
......@@ -28,7 +28,7 @@ PyObject *dap_chain_wallet_open_file_py(PyObject *self, PyObject *argv);
PyObject *dap_chain_wallet_open_py(PyObject *self, PyObject *argv);
PyObject *dap_chain_wallet_save_py(PyObject *self, PyObject *argv);
PyObject *dap_chain_wallet_close_py(PyObject *self, PyObject *argv);
void dap_chain_wallet_close_py(PyDapChainWalletObject *self);
PyObject *dap_cert_to_addr_py(PyObject *self, PyObject *argv);
......@@ -37,10 +37,15 @@ PyObject *dap_chain_wallet_get_certs_number_py(PyObject *self, PyObject *argv);
PyObject *dap_chain_wallet_get_pkey_py(PyObject *self, PyObject *argv);
PyObject *dap_chain_wallet_get_key_p(PyObject *self, PyObject *argv);
PyObject *dap_chain_wallet_save_file_py(PyObject *self, PyObject *argv);
//PyObject *dap_chain_wallet_save_file_py(PyObject *self, PyObject *argv);
static PyMethodDef ChainWalletMethods[] = {
{NULL, NULL, 0, NULL}
{"getPath", (PyCFunction)dap_chain_wallet_get_path_py, METH_VARARGS | METH_STATIC, ""},
{"openFile", (PyCFunction)dap_chain_wallet_open_file_py, METH_VARARGS | METH_STATIC, ""},
{"open", (PyCFunction)dap_chain_wallet_open_py, METH_VARARGS | METH_STATIC, ""},
{"save", (PyCFunction)dap_chain_wallet_save_py, METH_NOARGS, ""},
{"getCertsNumber", (PyCFunction)dap_chain_wallet_get_certs_number_py, METH_NOARGS, ""},
{NULL, NULL, 0, NULL}
};
static PyTypeObject DapChainWallet_dapChainWalletType = {
......@@ -48,7 +53,7 @@ static PyTypeObject DapChainWallet_dapChainWalletType = {
"ChainWallet", /* tp_name */
sizeof(PyDapChainWalletObject), /* tp_basicsize */
0, /* tp_itemsize */
0, /* tp_dealloc */
(destructor)dap_chain_wallet_close_py, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr */
0, /* tp_setattr */
......
......@@ -6,3 +6,46 @@ int dap_chain_wallet_init_py(void){
void dap_chain_wallet_deinit_py(void){
dap_chain_wallet_deinit();
}
PyObject *dap_chain_wallet_get_path_py(PyObject *self, PyObject *argv){
(void)self;
(void)argv;
const char *path = dap_chain_wallet_get_path(g_config);
return Py_BuildValue("(s)", path);
}
PyObject *dap_chain_wallet_open_file_py(PyObject *self, PyObject *argv){
(void)self;
const char *file_path;
if (!PyArg_ParseTuple(argv, "s", &file_path))
return NULL;
PyObject *obj_wallet = _PyObject_New(&DapChainWallet_dapChainWalletType);
((PyDapChainWalletObject*)obj_wallet)->wallet = dap_chain_wallet_open_file(file_path);
return Py_BuildValue("(O)", obj_wallet);
}
PyObject *dap_chain_wallet_open_py(PyObject *self, PyObject *argv){
(void)self;
const char *wallet_name;
const char *wallet_path;
if (!PyArg_ParseTuple(argv, "ss", &wallet_name, &wallet_path))
return NULL;
PyObject *obj_wallet = _PyObject_New(&DapChainWallet_dapChainWalletType);
((PyDapChainWalletObject*)obj_wallet)->wallet = dap_chain_wallet_open(wallet_name, wallet_path);
return Py_BuildValue("(O)", obj_wallet);
}
PyObject *dap_chain_wallet_save_py(PyObject *self, PyObject *argv){
(void)argv;
int result = dap_chain_wallet_save(((PyDapChainWalletObject*)self)->wallet);
return PyLong_FromLong(result);
}
void dap_chain_wallet_close_py(PyDapChainWalletObject *self){
dap_chain_wallet_close(self->wallet);
Py_TYPE(self)->tp_free((PyObject*)self);
}
PyObject *dap_chain_wallet_get_certs_number_py(PyObject *self, PyObject *argv){
(void)argv;
size_t result = dap_chain_wallet_get_certs_number(((PyDapChainWalletObject*)self)->wallet);
return PyLong_FromLong(result);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment