webfunds.client
Interface WalletInterface

All Known Implementing Classes:
SOXWallet

public interface WalletInterface

The Wallet. Implementation dependant, as this interface must cope with diverging requirements. Within each wallet, WebFunds will expect the wallet to open and manage an account. This is a unit of authentication, a complete unit of payments, in that value within is managed separately from any other value. Within each account, WebFunds will expect the wallet to add and manage subaccounts. Subaccounts are the intersection between the account - authentication - and a particular type of value. So, for example, an account might be "Household Funds" and a sub-account might be "dollars." More specifically, types of value are identified by Ricardian contracts, so the subaccounts are often called contracts.


Field Summary
static int CODE_FREEZE
          adminEvent() codes.
static int CODE_SHUTDOWN
          adminEvent() codes.
static int CODE_UNFREEZE
          adminEvent() codes.
 
Method Summary
 AccountInfo addAccount()
          Add an account.
 ItemId addContract(AccountInfo info, ItemId item)
          Add a contract to this account.
 int adminEvent(int code, java.lang.String reason)
          Signal the wallet.
 void cancel(Transaction transaction)
          Try to undo a given payment that this wallet has made.
 void cancel(Transaction[] transactions)
          Try to undo a batch of payments that this wallet has made.
 void debug(java.io.PrintWriter bug)
          A debugging interface, set this PrintWriter as where logs go.
 java.lang.String getAccountHelp()
           
 AccountInfo[] getAccounts()
          Get all accounts known to this wallet.
 java.lang.String getContractHelp()
           
 ItemId[] getContracts(AccountInfo accountInfo)
          Get all contracts that are in this account
 java.lang.String getProtocol()
          Get the protocol name.
 java.lang.String getShortName()
          Get a name for this wallet.
 Transaction[] getTransactions(AccountInfo account, ItemId contract)
          Get all the Transactions for a particular sub account, for display purposes.
 long getValue(AccountInfo account, ItemId contract, boolean pending)
          Get the value held in a subaccount (contract) in a given account.
 java.lang.String getVersion()
          Get the version number of the protocol.
 java.lang.String getWalletHelp()
          Provide a help string for each of the different levels.
 void makeDeposit(byte[] payment, AccountInfo target, byte[] desc)
          Make a deposit of a payment supplied by some other user's client via email or similar means.
 byte[] makePayment(ItemId contract, AccountInfo source, AccountInfo target, long amount, byte[] description, java.util.Date validFrom, java.util.Date validTill)
          Make a payment.
 boolean removeAccount(AccountInfo accountInfo)
          Remove this account.
 boolean removeContract(AccountInfo accountInfo, ItemId contract)
          Remove this contract from this account.
 boolean renameAccount(AccountInfo accountInfo, java.lang.String name)
          Rename this account to a new String.
 void setWalletContext(WalletContext wm)
          Set the WalletContext so the WI can access the other components.
 void update(AccountInfo target, ItemId contractId)
          Update the subaccount with the latest info.
 

Field Detail

CODE_SHUTDOWN

public static final int CODE_SHUTDOWN
adminEvent() codes.

CODE_FREEZE

public static final int CODE_FREEZE
adminEvent() codes.

CODE_UNFREEZE

public static final int CODE_UNFREEZE
adminEvent() codes.
Method Detail

getShortName

public java.lang.String getShortName()
Get a name for this wallet. Only used for debugging currently.

getProtocol

public java.lang.String getProtocol()
Get the protocol name. Only used for debugging currently.

getVersion

public java.lang.String getVersion()
Get the version number of the protocol. This is a high level wallet version number, not effecting protocol compatibility. Only used for debugging currently.

debug

public void debug(java.io.PrintWriter bug)
A debugging interface, set this PrintWriter as where logs go.

setWalletContext

public void setWalletContext(WalletContext wm)
Set the WalletContext so the WI can access the other components. Wallet gets access to ContractStore, GUI, Store, PluginManager, Addressbook, SecureRandom objects.

adminEvent

public int adminEvent(int code,
                      java.lang.String reason)
Signal the wallet. For some reason, the application has decided to conduct some admin, and wishes to freeze or shut this wallet down; the wallet should cease doing anything that might involve state. THIS IS NOT A SIGNAL TO SAVE DATA ; ALL DATA SHOULD HAVE BEEN SAVED ALREADY ACCORDING TO NORMAL TRANSACTIONAL PRINCIPLES! Experimental call at this stage, the precise semantics are unclear. May be irreversable..., see the codes in SOXWallet. Purposes include backups and upgrades.
Parameters:
code - a number that might indicate urgency or reason
reason - a printable or loggable string that might indicate reason
Returns:
0 if wallet believes it has successfully shutdown, else some number indicating something...

getValue

public long getValue(AccountInfo account,
                     ItemId contract,
                     boolean pending)
Get the value held in a subaccount (contract) in a given account. If pending is true, what is returned is the sum of outstanding, non-confirmed transactions, i.e., those that haven't hit the server as yet and might not happen.
Parameters:
pending - if true, the value of pending payments, else confirmed
Returns:
the total value if countable, else Long.MIN_VALUE on error

getAccounts

public AccountInfo[] getAccounts()
Get all accounts known to this wallet.

addAccount

public AccountInfo addAccount()
Add an account.

getContracts

public ItemId[] getContracts(AccountInfo accountInfo)
Get all contracts that are in this account

renameAccount

public boolean renameAccount(AccountInfo accountInfo,
                             java.lang.String name)
Rename this account to a new String. This action is wallet dependant, and is an advisory only, useful for debugging.
Returns:
true if succeeded

removeAccount

public boolean removeAccount(AccountInfo accountInfo)
Remove this account. This action is wallet dependant. Some wallets have conceptual difficulty with removing past history of transactions.
Returns:
true if succeeded

removeContract

public boolean removeContract(AccountInfo accountInfo,
                              ItemId contract)
Remove this contract from this account. Wallet dependant.
Returns:
true if succeeded

addContract

public ItemId addContract(AccountInfo info,
                          ItemId item)
Add a contract to this account.

makePayment

public byte[] makePayment(ItemId contract,
                          AccountInfo source,
                          AccountInfo target,
                          long amount,
                          byte[] description,
                          java.util.Date validFrom,
                          java.util.Date validTill)
Make a payment.

makeDeposit

public void makeDeposit(byte[] payment,
                        AccountInfo target,
                        byte[] desc)
Make a deposit of a payment supplied by some other user's client via email or similar means.
Parameters:
payment - is the byte array holding the raw payment
desc - a text description
target - account to deposit to (may already be directed)

cancel

public void cancel(Transaction transaction)
Try to undo a given payment that this wallet has made. Transaction is a GUI level entity. Wallet dependant.

cancel

public void cancel(Transaction[] transactions)
Try to undo a batch of payments that this wallet has made. Wallet dependant. As an abstract call, it would call single Transaction many times.

update

public void update(AccountInfo target,
                   ItemId contractId)
Update the subaccount with the latest info. This is a chance to go to the server and ask if anything's come in. Wallet dependant.

getTransactions

public Transaction[] getTransactions(AccountInfo account,
                                     ItemId contract)
Get all the Transactions for a particular sub account, for display purposes.

getWalletHelp

public java.lang.String getWalletHelp()
Provide a help string for each of the different levels.

getAccountHelp

public java.lang.String getAccountHelp()

getContractHelp

public java.lang.String getContractHelp()