FellowTraveler / Open-Transactions-old

Open-Transactions democratizes financial and monetary actions. You can use it for issuing currencies/stock, paying dividends, creating asset accounts, sending/receiving digital cash, writing/depositing cheques, cashier's cheques, creating basket currencies, trading on markets, scripting custom agreements, recurring payments, escrow, etc. Open-Transactions uses strong crypto. The balances are unchangeable (even by a malicious server.) The receipt history is destructible. The transactions are unforgeable. The cash is unlinkable. The cheques are non-repudiable. Etc.
http://opentransactions.org
408 stars 84 forks source link

New C++API (low level api) #121

Closed da2ce7 closed 11 years ago

da2ce7 commented 12 years ago

All the old C functions have been moved to the new C++ API. Now swig connects to a C++ api, instead of the C api.

da2ce7 commented 12 years ago

Don't pull yet... still needs lots of testing!

da2ce7 commented 11 years ago

Don't Pull Yet.... Just finished a big change... Now int64_t numbers are passed as int64_t (not wrapped in strings any more)!!!

Need to complete the changes to the ot chaiscript files... It would be loverly if there was some compile-time type safety... however I guess I'll just have to do it by hand.

jspit commented 11 years ago

Cameron

I managed to compile the otapi-php.dll but there was a lot of warnings. It needs to be compiled by VS2008

however i will wait for your go-ahead.

NOTE - that glue/php - this is calling a different dll than the one genrated on compilation

Jesmond

On 10 November 2012 02:07, Cameron Garnham notifications@github.com wrote:

Don't Pull Yet.... Just finished a big change... Now int64_t numbers are passed as int64_t (not wrapped in strings any more)!!!

Need to complete the changes to the ot chaiscript files... It would be loverly if there was some compile-time type safety... however I guess I'll just have to do it by hand.

— Reply to this email directly or view it on GitHubhttps://github.com/FellowTraveler/Open-Transactions/pull/121#issuecomment-10250127.

Jesmond Spiteri

da2ce7 commented 11 years ago

I have got around to making a release that has the otapi-php.dll compiled for win32. https://bitcointalk.org/index.php?topic=77301.msg859040#msg859040

jspit commented 11 years ago

Cameron

Thanks

To run moneymonager , after you run

a) install_userdata b) run_moneymanager

the java throws the following error

We are on Windows! Loading libzmq: Success! Loading chaiscript: Success! Loading otlib: Success! Loading otapi: Success! Loading otapi-java: ERROR: Loading OTAPI Native Failed java.lang.UnsatisfiedLinkError: C:\Open-Transactions\MoneyChanger\data\lib\Win32\Release\otapi-java.dll: The specified procedure could not be fo at java.lang.ClassLoader$NativeLibrary.load(Native Method)

What could be missing ?

Jesmond Spiteri

da2ce7 commented 11 years ago

Ok... I've removed my otapi.i file... and replaced it with the original for this commit.

da2ce7 commented 11 years ago

Should be ready to merge.

da2ce7 commented 11 years ago

Remember! \ REQUIRES LATEST VERSION OF CHAISCRIPT **

jspit commented 11 years ago

HI Cameron

VERY important:

note that php latest version are not allowing the use of dl() command so that it will have to be loaded as an extension in php.ini

Also I noticed that the extension has been compiled with the debug option - and that will not load if the php installation was not compiled with the debug option as well.

I am trying to compile it myself.

have yo compiled the otapi-php.so for unix ?

Regards

Jesmond

Jesmond Spiteri

On 12 November 2012 14:07, Cameron Garnham notifications@github.com wrote:

Remember! \ REQUIRES LATEST VERSION OF CHAISCRIPT **

— Reply to this email directly or view it on GitHubhttps://github.com/FellowTraveler/Open-Transactions/pull/121#issuecomment-10286332.

Jesmond Spiteri

da2ce7 commented 11 years ago

I haven't been working on the php swig extension that much. I have been working hard on the C++ API. As usual, I recommend that you use IRC for support, it is much easier for these types of questions. Additionally, can I please ask that you move your PHP related messages to your php issue: https://github.com/FellowTraveler/Open-Transactions/issues/123

Commenting on un-related pull requests is not helpful.

jspit commented 11 years ago

Thanks

Jesmond

On 14 November 2012 00:23, Cameron Garnham notifications@github.com wrote:

I haven't been working on the php swig extension that much. I have been working hard on the C++ API. As usual, I recommend that you use IRC for support, it is much easier for these types of questions. Additionally, can I please ask that you move your PHP related messages to your php issue:

123 https://github.com/FellowTraveler/Open-Transactions/issues/123

Commenting on un-related pull requests is not helpful.

— Reply to this email directly or view it on GitHubhttps://github.com/FellowTraveler/Open-Transactions/pull/121#issuecomment-10348567.

Jesmond Spiteri

jspit commented 11 years ago

HI Cameron

i am using http://webchat.freenode.net/ nickname - jspit

but i don't seem to have the option to write / post messages there.

IF you can help me with this

i am attaching two files:

opentxs - what i see when i run from command line

php - some php scripts to test the api

from php scripts.

a) connection - always 0 - seems that connection to server is not being made

b) ot_api_loadwallet - there it hangs when i looked at the apache logs i found out that it is waiting for the passphrase - i assume this is the reason it is hanging.

is there a way to set the password or send it as a parameter ?

thanks

jesmond C:\Open Transactions>run_opentxs.bat

Welcome to Open Transactions -- version 0.86.m CALLING:: OT_CTX::InitOTAPI: OTCrypto::It();

Enter the master passphrase. (LoadPrivateKeyFromCertString) (OT) passphrase: Wrong Password: Try Again:

Enter the master passphrase. (LoadPrivateKeyFromCertString) (OT) passphrase: Using as server: wmY1B8o94PFENzqPVK6wLOLvkog9TvA3GDxZuAMGCpW Using as mynym: T3lcsLUv7N7G02kQgRyf6EAt7r4a7NLI8DXNfheFo7E

. .. ... .... .....

opentxs> showservers

\ SERVERS:

qpoRvoI6wm1tbqS8kwO91nfzXb059jPYsGQaqXx3p6N --- OTdemo wmY1B8o94PFENzqPVK6wLOLvkog9TvA3GDxZuAMGCpW --- Digitalis . include('otapi.php');

$a = otapi::OT_API_Init();

$b = otapi::OT_API_Cleanup();

//$connection = otapi::OT_API_ConnectServer('Digitails','jestest','','','jestest'); //$connection = otapi::OT_API_ConnectServer('Digitails','jestest','wmY1B8o94PFENzqPVK6wLOLvkog9TvA3GDxZuAMGCpW','T3lcsLUv7N7G02kQgRyf6EAt7r4a7NLI8DXNfheFo7E','jestest'); $connection = otapi::OT_API_ConnectServer('wmY1B8o94PFENzqPVK6wLOLvkog9TvA3GDxZuAMGCpW','T3lcsLUv7N7G02kQgRyf6EAt7r4a7NLI8DXNfheFo7E','','','jestest'); die('connection = ' . $connection . '
');

$c = otapi::OT_API_SetWallet("wallet.xml"); echo('set wallet : ' . $c .'
');

date_default_timezone_set('UTC'); $tm = otapi::OT_API_GetTime(); $date = date("d/m/Y H:i:s", $tm); echo($tm . " = " . $date . "
");

$ww = otapi::OT_API_LoadWallet(); die('wallet = ' . $ww);

$cnt = otapi::OT_API_GetServerCount(); echo('server count = ' . $cnt . '
'); for ($i=0;$i<$cnt;$i++) { $d = OT_API_GetServer_ID($i); $echo($d); $server_name = OT_API_GetServer_Name($i); echo($server_name . '
'); }

die('jes');

da2ce7 commented 11 years ago

i am using http://webchat.freenode.net/ nickname - jspit

If you connect to http://webchat.freenode.net/ you need to hop into #opentransactions you may want to use the command /join #opentransactions Unregistered users are able to speak in #opentransactions

b) ot_api_loadwallet - there it hangs

If you want to not have a password prompt, you can change your password to 'test' and that will not prompt anymore (if you are using my cx11 branch).

da2ce7 commented 11 years ago

I also recommend kvirc (imho the best IRC client). http://www.kvirc.net/

jspit commented 11 years ago

thanks. that did the trick. but is there a way of passing it as a parameter ?

note : ot_api_get_servercount() and ot_api_get_nymcount() are returning 0 from php

while from opentxs i am seeing 1 server and 2 nyms

what could this be ?

jspit commented 11 years ago

any reason why ot_api_get_servercount() and ot_api_get_nymcount() are returning 0 from php

this is the code i am using

$a = otapi::OT_API_Init(); $b = otapi::OT_API_Cleanup(); $c = otapi::OT_API_SetWallet("wallet.xml");

date_default_timezone_set('UTC'); $tm = otapi::OT_API_GetTime(); $date = date("d/m/Y H:i:s", $tm); echo( $tm . " = " . $date . "
");

$ww = otapi::OT_API_LoadWallet(); echo('load wallet = ' . $ww . "
");

*** all the above return 1 which mean ok **

$cnt = otapi::OT_API_GetServerCount(); echo('server coount : ' . otapi::OT_API_GetServerCount() . '
');

for ($i=0;$i<$cnt;$i++) { $srvID = OT_API_GetServer_ID($i); $echo($srvID . ' '); $server_name = OT_API_GetServer_Name($srvID); echo($server_name . '
'); }

$cnt = otapi::OT_API_GetNymCount(); echo('nym count = ' . $cnt . '
'); for ($i=0;$i<$cnt;$i++) { $nymID = OT_API_GetNym_ID($i); $echo($nymID); $nym_name = OT_API_GetNym_Name($nymID); echo($nym_name . '
'); }

FellowTraveler commented 11 years ago

On 11/20/12 3:11 PM, Jesmond Spiteri wrote:

$a = otapi::OT_API_Init(); $b = otapi::OT_API_Cleanup(); $c = otapi::OT_API_SetWallet("wallet.xml");

This is the mistake here I think.

You should Init() first.

You should Cleanup() LAST. (You cannot make any more OT calls, once you call Cleanup.) The program is over.

You probably don't need to set the wallet if you are just using the defaults. But if you were, you would probably set it before Init.

-FT

jspit commented 11 years ago

great work on the php class - much better

is there any way to set the path for ot client and server data to be in a one place place only ?

normally they are installed in C:\Users\JSpit-PC\AppData\Roaming\OpenTransactions

but when i run from php another opentransactions folder is created in

to C:\Windows\System32\config\systemprofile\AppData\Roaming

i suspect that that is the reason why i am getting a 0 count for server and nyms.

can you also post the lib folder in github so that i can have the latest lib / dll /exe . when i try to compile the sources i end up with a lot of warnings - most probably due to compatability issues. nut they still compile

thanks

jspit commented 11 years ago

HI - In this version, i realize that the php-otapi.dll is compiled with the debug flag on and i cannot load it as an extension in my php

https://github.com/downloads/da2ce7/Moneychanger/da2ce7-Moneychanger-00.12.03-Win32_x64.7z

can that module be compiled without debug - i tried - but was giving me warnings - even tough it compiled.

this could be the reason get_servercount and get_nymcount() are returning 0

jspit commented 11 years ago

HI Cameron

did you receive my message on kvirc - i am as jspit ?

the new version of otapi.php is much better - makes more sense,.

the only thing is that i cannot use the dll as yours is compiled with the debug flag on and my php cannot load it. can you compile it with no debug - i tried to compile it but then was not compatable with your new otlib.dll and otapi.dll.

another thing - what system environmental variables should be set in windows so that in browser ot will not look in C:\Windows\system32\config\systemprofile\AppData\Roaming.... folder

this should be in C:\Users\JSpit-PC\AppData\Roaming as that is where moneychanger and opentxs are updating data.

OTLog::Path_Setup: Error! Scripts folder unable to be accessed: C:\Windows\system32\config\systemprofile\AppData\Roaming\OpenTransactions\opentxs

thanks again for your patience.

Jesmond On 18 November 2012 10:53, Cameron Garnham notifications@github.com wrote:

I also recommend kvirc (imho the best IRC client). http://www.kvirc.net/

— Reply to this email directly or view it on GitHubhttps://github.com/FellowTraveler/Open-Transactions/pull/121#issuecomment-10484317.

Jesmond Spiteri

jspit commented 11 years ago

Hi

I have sent some messages to Cameron (daec27) on this as I cannot solve it.

However, I am going to try another tack.

Do you have by any chance 'otapi.so'' - unix version for php ?

If so, can you send it to me as i don't have unix on my machine ?

If I can put forward a suggestion :

Why don't you include the lib folder as well on github to inlcude all lib/dll needed ?

Even the includes folder should house all required files.

This so as to avoid any errors on compliation.

Thanks

On 21 November 2012 00:24, FellowTraveler notifications@github.com wrote:

On 11/20/12 3:11 PM, Jesmond Spiteri wrote:

$a = otapi::OT_API_Init(); $b = otapi::OT_API_Cleanup(); $c = otapi::OT_API_SetWallet("wallet.xml");

This is the mistake here I think.

You should Init() first.

You should Cleanup() LAST. (You cannot make any more OT calls, once you call Cleanup.) The program is over.

You probably don't need to set the wallet if you are just using the defaults. But if you were, you would probably set it before Init.

-FT

— Reply to this email directly or view it on GitHubhttps://github.com/FellowTraveler/Open-Transactions/pull/121#issuecomment-10578901.

Jesmond Spiteri

da2ce7 commented 11 years ago

OTLog::Path_Setup: Error! Scripts folder unable to be accessed: C:\Windows\system32\config\systemprofile\AppData\Roaming\OpenTransactions\opentxs

I've never seen this before! Maybe my app-data location code is broken for your system... :P I'll have to check this out...

What OS are you using?

jspit commented 11 years ago

Hi Cameron

It's Windows7 32 bit

Please if you can compile the otapi-php.dll WITHOUT the debug flag, please do so as when I try to compile the module a lot of warning come up

Also note my previous email as this is strange.

I run opentxs and MoneyChanger and data is ok - I check folder to see if nyms are created and they are I query opentxs with shownyms and showservers and data is ok

Data is created in c:\Users\Jspi\AppData\Roamin\OpenTransactions

There I only have client_data, server_data , opentxs folders, .cfg files and command-line.txt

When I go to the web browser a new path is created in C:\Windows\System32\config\systemprofile\AppData\Roaming\OpenTransactions

with client_data folder with empty sub-folders.

Points:

a) What needs to be places in the php folder apart from otapi-php.dll ? b) What environmental variables need to be set in Windows ? APPDATA or app-data

Thanks. Jes

On 28 November 2012 00:19, Cameron Garnham notifications@github.com wrote:

OTLog::Path_Setup: Error! Scripts folder unable to be accessed:

C:\Windows\system32\config\systemprofile\AppData\Roaming\OpenTransactions\opentxs

I've never seen this before! Maybe my app-data location code is broken for your system... :P I'll have to check this out...

What OS are you using?

— Reply to this email directly or view it on GitHubhttps://github.com/FellowTraveler/Open-Transactions/pull/121#issuecomment-10782305.

Jesmond Spiteri

jspit commented 11 years ago

Cameron

When you deploy on the web, what files are required in:

a) php directory - i gues this will only need otapi.dll, otlib.dll and otapi-php.dll - the former 2 are called from otaspi-php.dll

b) under apache2/httdocs/ot do you need the whole ot directory + any php files ?

c) do you need any settings in httpd-conf of apache ?

the data folder / config problem lies as soon as you carry out php new otapi-basic() it's not going to the same path that opentxs and moneychanger are using ie users\appdata\roaming\iopentransactions

thanks

On 28 November 2012 00:19, Cameron Garnham notifications@github.com wrote:

OTLog::Path_Setup: Error! Scripts folder unable to be accessed:

C:\Windows\system32\config\systemprofile\AppData\Roaming\OpenTransactions\opentxs

I've never seen this before! Maybe my app-data location code is broken for your system... :P I'll have to check this out...

What OS are you using?

— Reply to this email directly or view it on GitHubhttps://github.com/FellowTraveler/Open-Transactions/pull/121#issuecomment-10782305.

Jesmond Spiteri

da2ce7 commented 11 years ago

The code for getting the App-Data folder location should be somewhat standard: https://github.com/FellowTraveler/Open-Transactions/blob/da2ce7_c%2B%2Bapi/src/otlib/OTLog.cpp#L1780

jspit commented 11 years ago

When run from command prompt, both 'run_opentxs' and 'run_moneychanger' are pointing to appdata as in c:\user\xxxxxxx\appdata\roaming\opentransactions data is correct

when called from php this is not found and a folder OpenTransactions is created in

C:\Windows\System32\config\systemprofile\AppData\Roaming

This means that OT is being initialized from php but data/home paths are not reading the APPDATA variable in windows ennvironment varaibales

Can you pass on a parameter when calling class eg new OTAPI_Basic('./opentransactions/client_data') or something like that ?

I know that there was an issue with SHGetFolderPath under windows 7 not returning the correct paths

Or it could be that you need to effect some settings in php.ini or apache htpd.conf. Unless you need to copy the whole ot folder under httpdocs

the weirdest thing is when i try to call

$otapi = new OTAPI_Basic('client_data'); $otapi->WalletExists() return 1 - meaning ok: $otapi->LoadWallet() returns1 - meaning ok date_default_timezone_set('UTC'); $tm = $otapi->GetTime(); - time is being returned

so ot is communicating with php EXCEPT for data folders

jspit commented 11 years ago

from apache error log

[Fri Nov 30 00:10:24 2012] [error] [client 127.0.0.1] OTPseudonym::Loadx509CertAndPrivateKey: Although the ascii-armored file (certs/Zt1qCebiS0TlrS98nIJ6X4ujrfDFaZfIkdKpQclkT83) was read, LoadPrivateKey returned false.

[Fri Nov 30 00:10:24 2012] [error] [client 127.0.0.1] OTPseudonym::LoadPrivateNym OTPseudonym::LoadPrivateNym: Failure calling Loadx509CertAndPrivateKey: Zt1qCebiS0TlrS98nIJ6X4ujrfDFaZfIkdKpQclkT83

does this mean that i need to supply the image ? even in php

note : if i use your version of data - with test this error does not come up but this is logged:

[Thu Nov 29 16:20:36 2012] [error] [client 127.0.0.1] Welcome to Open Transactions -- version 0.87.a [Thu Nov 29 16:20:36 2012] [error] [client 127.0.0.1] OTPseudonym::Loadx509CertAndPrivateKey: File does not exist: certs/test [Thu Nov 29 16:20:36 2012] [error] [client 127.0.0.1] OTPseudonym::LoadPrivateNym OTPseudonym::LoadPrivateNym: Failure calling Loadx509CertAndPrivateKey: test [Thu Nov 29 16:20:36 2012] [error] [client 127.0.0.1] OTAPI_Wrap::LoadPubkey: Failure loading Nym public key: test