Skip to content
Snippets Groups Projects
Commit 1e2c2c92 authored by Roman Khlopkov's avatar Roman Khlopkov 🔜
Browse files

Merge branch 'bugfix-4969' into 'release-3.0'

bugfix-4969

See merge request !63
parents 04fb2e9b 4ad936c3
No related branches found
No related tags found
1 merge request!63bugfix-4969
...@@ -96,7 +96,7 @@ static PyTypeObject DapChainTxOutCond_DapChainTxOutCondType = { ...@@ -96,7 +96,7 @@ static PyTypeObject DapChainTxOutCond_DapChainTxOutCondType = {
//============= DapChaTxOutCondSubtype //============= DapChaTxOutCondSubtype
typedef struct PyDapChainTxOutCondSubType{ typedef struct PyDapChainTxOutCondSubType{
PyObject_HEAD PyObject_HEAD
dap_chain_tx_out_cond_subtype_t *out_cond_subtype; dap_chain_tx_out_cond_subtype_t out_cond_subtype;
}PyDapChainTxOutCondSubTypeObject; }PyDapChainTxOutCondSubTypeObject;
PyObject *PyDapChainTxOutCondSubType_str(PyObject *self); PyObject *PyDapChainTxOutCondSubType_str(PyObject *self);
......
...@@ -22,7 +22,8 @@ PyObject *dap_chain_datum_size_py(PyObject *self, PyObject *args){ ...@@ -22,7 +22,8 @@ PyObject *dap_chain_datum_size_py(PyObject *self, PyObject *args){
PyObject *dap_chain_datum_get_ts_created(PyObject *self, void* closure){ PyObject *dap_chain_datum_get_ts_created(PyObject *self, void* closure){
(void)closure; (void)closure;
return PyDateTime_FromTimestamp(((PyDapChainDatumObject*)self)->datum->header.ts_create); PyObject *timestamp = Py_BuildValue("k", ((PyDapChainDatumObject*)self)->datum->header.ts_create);
return PyDateTime_FromTimestamp(timestamp);
} }
PyObject *dap_chain_datum_is_type_tx(PyObject *self, PyObject *args){ PyObject *dap_chain_datum_is_type_tx(PyObject *self, PyObject *args){
...@@ -40,7 +41,7 @@ PyObject *wrapping_dap_chain_datum_get_datum_tx(PyObject *self, PyObject *args){ ...@@ -40,7 +41,7 @@ PyObject *wrapping_dap_chain_datum_get_datum_tx(PyObject *self, PyObject *args){
PyObject *obj_datum_tx = _PyObject_New(&DapChainDatumTx_DapChainDatumTxObjectType); PyObject *obj_datum_tx = _PyObject_New(&DapChainDatumTx_DapChainDatumTxObjectType);
obj_datum_tx = PyObject_Init(obj_datum_tx, &DapChainDatumTx_DapChainDatumTxObjectType); obj_datum_tx = PyObject_Init(obj_datum_tx, &DapChainDatumTx_DapChainDatumTxObjectType);
PyObject_Dir(obj_datum_tx); PyObject_Dir(obj_datum_tx);
((PyDapChainDatumTxObject*)obj_datum_tx)->datum_tx = ((PyDapChainDatumObject*)self)->datum->data; ((PyDapChainDatumTxObject*)obj_datum_tx)->datum_tx = (dap_chain_datum_tx_t *)((PyDapChainDatumObject*)self)->datum->data;
return obj_datum_tx; return obj_datum_tx;
}else{ }else{
PyErr_SetString(PyExc_Exception, "Due to the type of this datum, it is not possible to get the transaction datum."); PyErr_SetString(PyExc_Exception, "Due to the type of this datum, it is not possible to get the transaction datum.");
......
...@@ -3,11 +3,12 @@ ...@@ -3,11 +3,12 @@
PyObject *wrapping_dap_chain_tx_out_cond_get_ts_expires(PyObject *self, void *closure){ PyObject *wrapping_dap_chain_tx_out_cond_get_ts_expires(PyObject *self, void *closure){
(void)closure; (void)closure;
PyDateTime_IMPORT; PyDateTime_IMPORT;
return PyDateTime_FromTimestamp((time_t)((PyDapChainTxOutCondObject*)self)->out_cond->header.ts_expires); PyObject *timestamp = Py_BuildValue("k", ((PyDapChainTxOutCondObject*)self)->out_cond->header.ts_expires);
return PyDateTime_FromTimestamp(timestamp);
} }
PyObject *wrapping_dap_chain_tx_out_cond_get_value(PyObject *self, void *closure){ PyObject *wrapping_dap_chain_tx_out_cond_get_value(PyObject *self, void *closure){
(void)closure; (void)closure;
Py_BuildValue("k", ((PyDapChainTxOutCondObject*)self)->out_cond->header.value); return Py_BuildValue("k", ((PyDapChainTxOutCondObject*)self)->out_cond->header.value);
} }
PyObject *wrapping_dap_chain_tx_out_cond_get_type_subtype(PyObject *self, void *closure){ PyObject *wrapping_dap_chain_tx_out_cond_get_type_subtype(PyObject *self, void *closure){
(void)closure; (void)closure;
...@@ -24,6 +25,6 @@ PyObject *wrapping_dap_chain_tx_out_cond_get_subtype(PyObject *self, void *closu ...@@ -24,6 +25,6 @@ PyObject *wrapping_dap_chain_tx_out_cond_get_subtype(PyObject *self, void *closu
PyObject *PyDapChainTxOutCondSubType_str(PyObject *self){ PyObject *PyDapChainTxOutCondSubType_str(PyObject *self){
return Py_BuildValue("s", return Py_BuildValue("s",
dap_chain_tx_out_cond_subtype_to_str(*((PyDapChainTxOutCondSubTypeObject*)self)->out_cond_subtype) dap_chain_tx_out_cond_subtype_to_str(((PyDapChainTxOutCondSubTypeObject*)self)->out_cond_subtype)
); );
} }
...@@ -18,6 +18,6 @@ PyObject *wrapping_dap_chain_tx_pkey_seq_no(PyObject *self, void *closure){ ...@@ -18,6 +18,6 @@ PyObject *wrapping_dap_chain_tx_pkey_seq_no(PyObject *self, void *closure){
PyObject *wrapping_dap_chain_tx_pkey_get_pkey(PyObject *self, void *closure){ PyObject *wrapping_dap_chain_tx_pkey_get_pkey(PyObject *self, void *closure){
(void)closure; (void)closure;
PyDapPkeyObject *obj_pkey = PyObject_NEW(PyDapPkeyObject, &DapPkeyTypeObject_DapPkeyTypeObjectType); PyDapPkeyObject *obj_pkey = PyObject_NEW(PyDapPkeyObject, &DapPkeyTypeObject_DapPkeyTypeObjectType);
obj_pkey->pkey = ((PyDapChainTXPkeyObject*)self)->tx_pkey->pkey; obj_pkey->pkey = (dap_pkey_t *)((PyDapChainTXPkeyObject*)self)->tx_pkey->pkey;
return (PyObject*)obj_pkey; return (PyObject*)obj_pkey;
} }
\ No newline at end of file
...@@ -36,9 +36,9 @@ PyObject *wrapping_dap_chain_tx_receipt_get_sig_provider(PyObject *self, void *c ...@@ -36,9 +36,9 @@ PyObject *wrapping_dap_chain_tx_receipt_get_sig_provider(PyObject *self, void *c
((PyDapSignObject*)obj_sign_provider)->sign, ((PyDapSignObject*)obj_sign_provider)->sign,
((PyDapChainTXReceiptObject*)self)->tx_receipt->exts_n_signs, ((PyDapChainTXReceiptObject*)self)->tx_receipt->exts_n_signs,
sizeof(dap_sign_t)); sizeof(dap_sign_t));
} else { return obj_sign_provider;
return Py_None;
} }
return Py_None;
} }
PyObject *wrapping_dap_chain_tx_receipt_get_sig_client(PyObject *self, void *closure){ PyObject *wrapping_dap_chain_tx_receipt_get_sig_client(PyObject *self, void *closure){
uint16_t l_exts_size = ((PyDapChainTXReceiptObject*)self)->tx_receipt->exts_size; uint16_t l_exts_size = ((PyDapChainTXReceiptObject*)self)->tx_receipt->exts_size;
...@@ -51,7 +51,7 @@ PyObject *wrapping_dap_chain_tx_receipt_get_sig_client(PyObject *self, void *clo ...@@ -51,7 +51,7 @@ PyObject *wrapping_dap_chain_tx_receipt_get_sig_client(PyObject *self, void *clo
((PyDapSignObject*)obj_sign_client)->sign, ((PyDapSignObject*)obj_sign_client)->sign,
((PyDapChainTXReceiptObject*)self)->tx_receipt->exts_n_signs + sizeof(dap_sign_t), ((PyDapChainTXReceiptObject*)self)->tx_receipt->exts_n_signs + sizeof(dap_sign_t),
sizeof(dap_sign_t)); sizeof(dap_sign_t));
} else { return obj_sign_client;
return Py_None;
} }
return Py_None;
} }
...@@ -156,7 +156,7 @@ PyObject *dap_chain_net_get_chain_by_chain_type_py(PyObject *self, PyObject *arg ...@@ -156,7 +156,7 @@ PyObject *dap_chain_net_get_chain_by_chain_type_py(PyObject *self, PyObject *arg
PyObject *dap_chain_net_get_ledger_py(PyObject *self, PyObject *args){ PyObject *dap_chain_net_get_ledger_py(PyObject *self, PyObject *args){
(void)args; (void)args;
PyObject *obj_ledger = PyObject_New(PyDapChainLedgerObject, &DapChainLedger_DapChainLedgerType); PyObject *obj_ledger = (PyObject *)PyObject_New(PyDapChainLedgerObject, &DapChainLedger_DapChainLedgerType);
PyObject_Dir(obj_ledger); PyObject_Dir(obj_ledger);
((PyDapChainLedgerObject*)obj_ledger)->ledger = ((PyDapChainNetObject*)self)->chain_net->pub.ledger; ((PyDapChainLedgerObject*)obj_ledger)->ledger = ((PyDapChainNetObject*)self)->chain_net->pub.ledger;
return obj_ledger; return obj_ledger;
......
...@@ -7,7 +7,7 @@ struct _w_json_rpc_handler *handlers = NULL; ...@@ -7,7 +7,7 @@ struct _w_json_rpc_handler *handlers = NULL;
void _w_dap_json_rpc_request_handler(dap_json_rpc_params_t *a_params, dap_json_rpc_response_t *a_response, const char *a_method){ void _w_dap_json_rpc_request_handler(dap_json_rpc_params_t *a_params, dap_json_rpc_response_t *a_response, const char *a_method){
int count_params = a_params->lenght; int count_params = a_params->lenght;
PyDapJSONRPCResponseObject *obj_response = PyObject_NEW(PyDapJSONRPCResponseObject, &DapJSONRPCResponse_DapJSONRPCResponseType); PyDapJSONRPCResponseObject *obj_response = PyObject_NEW(PyDapJSONRPCResponseObject, &DapJSONRPCResponse_DapJSONRPCResponseType);
obj_response = PyObject_Init((PyObject*)obj_response, &DapJSONRPCResponse_DapJSONRPCResponseType); obj_response = (PyDapJSONRPCResponseObject *)PyObject_Init((PyObject*)obj_response, &DapJSONRPCResponse_DapJSONRPCResponseType);
obj_response->response = a_response; obj_response->response = a_response;
PyObject *obj_params = PyList_New(count_params); PyObject *obj_params = PyList_New(count_params);
for (int i=0; i < count_params; i++) { for (int i=0; i < count_params; i++) {
...@@ -33,6 +33,7 @@ void _w_dap_json_rpc_request_handler(dap_json_rpc_params_t *a_params, dap_json_r ...@@ -33,6 +33,7 @@ void _w_dap_json_rpc_request_handler(dap_json_rpc_params_t *a_params, dap_json_r
tmp_string = (char *) a_params->params[i]->value_param; tmp_string = (char *) a_params->params[i]->value_param;
obj_ptr = PyUnicode_FromString(tmp_string); obj_ptr = PyUnicode_FromString(tmp_string);
break; break;
default: break;
} }
if (obj_ptr != NULL) { if (obj_ptr != NULL) {
...@@ -53,14 +54,14 @@ void _w_dap_json_rpc_request_handler(dap_json_rpc_params_t *a_params, dap_json_r ...@@ -53,14 +54,14 @@ void _w_dap_json_rpc_request_handler(dap_json_rpc_params_t *a_params, dap_json_r
if (!obj_result){ if (!obj_result){
log_it(L_ERROR, "Can't called method: %s", a_method); log_it(L_ERROR, "Can't called method: %s", a_method);
a_response->type_result = TYPE_RESPONSE_NULL; a_response->type_result = TYPE_RESPONSE_NULL;
a_response->error = dap_json_rpc_error_JSON_create(); a_response->error = DAP_NEW(dap_json_rpc_error_t);
a_response->error->code_error = 0xF1; a_response->error->code_error = 0xF1;
a_response->error->msg = "Can't called method"; a_response->error->msg = "Can't called method";
//a_response->error = dap_json_rpc_error_search_by_code(1); //a_response->error = dap_json_rpc_error_search_by_code(1);
return; return;
} }
} else { } else {
log_it(L_WARNING, "%s method can't be called, it is not in the python function call table."); log_it(L_WARNING, "%s method can't be called, it is not in the python function call table.", a_method);
a_response->type_result = TYPE_RESPONSE_NULL; a_response->type_result = TYPE_RESPONSE_NULL;
a_response->error = dap_json_rpc_error_search_by_code(1); a_response->error = dap_json_rpc_error_search_by_code(1);
} }
......
...@@ -44,20 +44,17 @@ PyObject *wrapping_json_rpc_response_get_result(PyObject *self, void *closure){ ...@@ -44,20 +44,17 @@ PyObject *wrapping_json_rpc_response_get_result(PyObject *self, void *closure){
switch (l_resp->type_result) { switch (l_resp->type_result) {
case TYPE_RESPONSE_BOOLEAN: case TYPE_RESPONSE_BOOLEAN:
return l_resp->result_boolean ? Py_BuildValue("O", Py_True) : Py_BuildValue("O", Py_False); return l_resp->result_boolean ? Py_BuildValue("O", Py_True) : Py_BuildValue("O", Py_False);
break;
case TYPE_RESPONSE_INTEGER: case TYPE_RESPONSE_INTEGER:
return PyLong_FromLong(l_resp->result_int); return PyLong_FromLong(l_resp->result_int);
break;
case TYPE_RESPONSE_DOUBLE: case TYPE_RESPONSE_DOUBLE:
return PyLong_FromDouble(l_resp->result_double); return PyLong_FromDouble(l_resp->result_double);
break;
case TYPE_RESPONSE_STRING: case TYPE_RESPONSE_STRING:
return Py_BuildValue("s", l_resp->result_string); return Py_BuildValue("s", l_resp->result_string);
break;
case TYPE_RESPONSE_NULL: case TYPE_RESPONSE_NULL:
return Py_BuildValue("O", Py_None); default:
break; break;
} }
return Py_BuildValue("O", Py_None);
} }
PyObject *wrapping_json_rpc_response_get_error(PyObject *self, void *closure){ PyObject *wrapping_json_rpc_response_get_error(PyObject *self, void *closure){
UNUSED(closure); UNUSED(closure);
......
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