I thought of open transactions (and maybe I'll still look into), but I really want something very simple that works very much like a typical Bitcoin client works (with similar a addressing scheme, etc).
CREATE ASSET ACCOUNT -- SOURCE CODE
def OT_ME::create_asset_acct(SERVER_ID, NYM_ID, ASSET_TYPE_ID)
{
var ot_Msg := OTAPI_Func()
// -------------------------
var theRequest := OTAPI_Func(ot_Msg.CREATE_ASSET_ACCT, SERVER_ID, NYM_ID, ASSET_TYPE_ID)
var strResponse = theRequest.SendRequest(theRequest, "CREATE_ASSET_ACCT")
return strResponse
}
------------------------------------------------------------------------------------------
SHOW ACCOUNT BALANCE:
~/Projects/Open-Transactions/include
> opentxs balance
Welcome to Open Transactions -- version 0.82.h
PLEASE SIGN YOUR PASSPHRASE:
Balance: 1211
eMldMMiKfJRO8B8yJjzcezs9xvSt7dkdlWt50e8CDxn (FT's Silver)
------------------------------------------------------------------------------------------
SOURCE CODE for "balance" command, using OT API:def details_account_balance(strID)
{
var strName = OT_API_GetAccountWallet_Name(strID)
var strBalance = OT_API_GetAccountWallet_Balance(strID)
OT_API_Output(0, "\n Balance: ") //stderr
print(strBalance) // stdout
OT_API_Output(0, strID + " (" + strName + ")\n\n") //stderr
}
------------------------------------------------------------------------------------------
SHOW CASH PURSE (on local client):
~/Projects/Open-Transactions/include
> opentxs showpurse
Welcome to Open Transactions -- version 0.82.h
PLEASE SIGN YOUR PASSPHRASE:
Total value: 1
Token count: 1
Index Value Series ValidFrom ValidTo Status
0 1 0 1339606926 1355158926 valid
------------------------------------------------------------------------------------------
WITHDRAW CASH:
~/Projects/Open-Transactions/include
> opentxs withdraw
Welcome to Open Transactions -- version 0.82.h
PLEASE SIGN YOUR PASSPHRASE:
Enter the amount as integer[1]: 109
Server response (withdraw_cash): SUCCESS withdrawing cash! (From account on server, to local purse.)
Success retrieving intermediary files for account.
------------------------------------------------------------------------------------------
SOURCE CODE for withdraw cash: var madeEasy = OT_ME()
var strResponse = madeEasy.withdraw_cash(Server, strMyNymID, MyAcct, strAmount)
var strAttempt = "withdraw_cash"
// ***************************************************************
// Interpret the server's reply...
var nInterpretReply = InterpretTransactionMsgReply(Server, strMyNymID, MyAcct, strAttempt, strResponse)
if (1 == nInterpretReply)
{
// Download all the intermediary files (account balance, inbox, outbox, etc)
// since they have probably changed from this operation.
//
var bRetrieved = madeEasy.retrieve_account(Server, strMyNymID, MyAcct) //bForceDownload defaults to false.
OT_API_Output(0, "\n\nServer response ("+strAttempt+"): SUCCESS withdrawing cash! (From account on server to local purse.) \n")
OT_API_Output(0, (bRetrieved ? "Success" : "Failed") + " retrieving intermediary files for account.\n")
}
------------------------------------------------------------------------------------------
VIEW (UPDATED) BALANCE:
~/Projects/Open-Transactions/include
> opentxs balance
Welcome to Open Transactions -- version 0.82.h
PLEASE SIGN YOUR PASSPHRASE:
Balance: 1102
eMldMMiKfJRO8B8yJjzcezs9xvSt7dkdlWt50e8CDxn (FT's Silver)
------------------------------------------------------------------------------------------
VIEW UPDATED PURSE (on local client):
~/Projects/Open-Transactions/include
> opentxs showpurse
Welcome to Open Transactions -- version 0.82.h
PLEASE SIGN YOUR PASSPHRASE:
Total value: 110
Token count: 7
Index Value Series ValidFrom ValidTo Status
0 1 0 1339606926 1355158926 valid
1 100 0 1339606926 1355158926 valid
2 1 0 1339606926 1355158926 valid
3 5 0 1339606926 1355158926 valid
4 1 0 1339606926 1355158926 valid
5 1 0 1339606926 1355158926 valid
6 1 0 1339606926 1355158926 valid
~/Projects/Open-Transactions/include
>
------------------------------------------------------------------------------------------
SOURCE CODE for "show purse": var strAmount = OT_API_Purse_GetTotalValue(Server, MyPurse, strPurse)
print("\n\nTotal value: " + strAmount)
// Loop through purse contents and display tokens.
var nCount = OT_API_Purse_Count(Server, MyPurse, strPurse)
// ----------------------
if (nCount > 0)
{
print("Token count: " + nCount.to_string() + "\n")
print("Index\tValue\tSeries\tValidFrom\tValidTo\t\tStatus")
var nIndex = -1
while (nCount > 0)
{
--nCount
++nIndex // on first iteration, this is now 0.
// -------------------
var strToken = OT_API_Purse_Peek(Server, MyPurse, MyNym, strPurse)
var strNewPurse = OT_API_Purse_Pop(Server, MyPurse, MyNym, strPurse)
strPurse = strNewPurse
// ------------------------------------------
var strDenomination = OT_API_Token_GetDenomination(Server, MyPurse, strToken)
var nSeries = OT_API_Token_GetSeries (Server, MyPurse, strToken)
var strValidFrom = OT_API_Token_GetValidFrom (Server, MyPurse, strToken)
var strValidTo = OT_API_Token_GetValidTo (Server, MyPurse, strToken)
var strTime = OT_API_GetTime()
// ------------------------------------------
// Output the token...
var strStatus = (strTime.to_int() > strValidTo.to_int()) ? "expired" : "valid"
print(nIndex.to_string() + "\t" + strDenomination + "\t" + nSeries.to_string() + "\t" + strValidFrom + "\t" + strValidTo + "\t" + strStatus)
// ------------------------------------------
} // while
} // if nCount > 0
More examples here:
https://github.com/FellowTraveler/Open-Transactions/wiki/Use-CasesSupport available.
Full examples for using the high-level API are also available in Java (in the Moneychanger test GUI),
as well as in
the new opentxs high-level command-line interface (which itself is actually written in OT script):
> opentxs help
Welcome to Open Transactions -- version 0.82.h
PLEASE SIGN YOUR PASSPHRASE:
From command-line-opt.ot (defaults):
Using as server: tBy5mL14qSQXCJK7Uz3WlTOKRP9M0JZksA3Eg7EnnQ1
Using as mynym: T1Q3wZWgeTUoaUvn9m1lzIK5tn5wITlzxzrGNI8qtaV
Using as myacct: eMldMMiKfJRO8B8yJjzcezs9xvSt7dkdlWt50e8CDxn
Using as hisacct: iT4nJZbqlT8EPd4ZjWKsA9YxsAboO334sCJ0oYdgh1G
Using as 'his' nym: SP8rPHc6GMRPL517UL5J8RK2yOiToyVqMaj3PUHvLzM
Commands:
acceptall accept all receipts in myacct's inbox.
activate activate a smart contract or payment plan.
addsignature add a signature to a contract without releasing others.
balance display balance for a specific account.
canceloffer cancel a still-running, recurring market offer.
cancelplan cancel a still-running, recurring payment plan.
checknym download a nym's public key based on his ID.
cheque write a cheque.
confirm confirm your agreement to a smart contract or payment plan.
decode OT-base64-decode out of armor.
decrypt decrypt ciphertext using nym's private key.
delmail delete an in-mail item.
deloutmail delete an out-mail item.
deposit deposit cash, cheque, voucher, or tokens.
discard discard/cancel a not-yet-cashed, outgoing instrument.
encode OT-base64-encode into armor.
encrypt encrypt plaintext to a nym's public key.
exchange exchange in/out of a basket currency.
getcontract download an asset or server contract by its ID.
inbox display inbox of a particular account.
issueasset issue a currency contract onto an OT server.
mail display in-mail for a particular nym.
newacct create a new asset account.
newasset create a new asset contract.
newbasket create a new basket currency.
newkey create a new symmetric key.
newnym create a new nym.
newoffer create a new market offer.
newserver create a new server contract.
outbox display outbox of a particular account.
outmail display out-mail for a particular nym.
outpayments display contents of outgoing payments box.
pass_decrypt password-decrypt a ciphertext using a symmetric key.
pass_encrypt password-encrypt a plaintext using a symmetric key.
payments display contents of incoming payments box.
records display contents of record box.
refresh download latest intermediary files for myacct.
refreshnym download latest intermediary files for mynym.
register register a nym onto an OT server.
sendmsg send a message to another nym's in-mail.
showacct show account stats for a single account.
showbaskets show basket currencies issued on a particular server.
showmint show a mint file for specific asset ID. Download if necessary.
showmyoffers show mynym's offers on a particular server and market.
showoffers show all offers on a particular server and market.
showpurse show contents of cash purse.
sign sign a contract, releasing all other signatures first.
stat display wallet contents.
transfer send a transfer from myacct to hisacct.
trigger trigger a clause on a running smart contract.
verifyreceipt verify your intermediary files against the last signed receipt.
verifysig verify a signature on a contract.
voucher withdraw a voucher (cashier's cheque).
withdraw withdraw cash. (From acct on server into local purse.)