[Webfunds-commits] java/webfunds/client/sox SOXWallet.java

Ian Grigg iang@cypherpunks.ai
Sun, 3 Sep 2000 12:51:52 -0400 (AST)


iang        00/09/03 12:51:52

  Modified:    webfunds/client/sox SOXWallet.java
  Log:
  moved AccountInfo part into the upper layer conversion call of
  makePurePayment, so that the working code is the AccountId call.
  (No change to interface or functionality.)
  Next, get rid of the error() calls and do exceptions instead...

Revision  Changes    Path
1.131     +38 -16    java/webfunds/client/sox/SOXWallet.java

Index: SOXWallet.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/client/sox/SOXWallet.java,v
retrieving revision 1.130
retrieving revision 1.131
diff -u -r1.130 -r1.131
--- SOXWallet.java	2000/08/16 19:51:18	1.130
+++ SOXWallet.java	2000/09/03 16:51:51	1.131
@@ -1,4 +1,4 @@
-/* $Id: SOXWallet.java,v 1.130 2000/08/16 19:51:18 iang Exp $
+/* $Id: SOXWallet.java,v 1.131 2000/09/03 16:51:51 iang Exp $
  *
  * Copyright (c) Systemics Inc. 1995-2000 on behalf of
  * The WebFunds Development Team.  All Rights Reserved.
@@ -445,15 +445,30 @@
     }
 
 
-    public Payment makePurePayment(AccountId source, AccountId target,
+    /**
+     *  Conversion between high level and low level.
+     */
+//    public Payment makePurePayment(AccountId source, AccountId target,
+    public Payment makePurePayment(AccountInfo source, AccountInfo target,
                                    ItemId instrument, long amount,
                                    byte[] description,
                                    long validFrom, long validTill, 
                                    String paymentId)
     {
+        AccountId tgt = new AccountId();
+        if (target != null)               // target might be bearer
+            tgt.setId(target.getId());
+
+        AccountId src = new AccountId();
+        if (source == null)
+            throw new IllegalArgumentException("source == null");
+
+        src.setId(source.getId());        // source better not be bearer
+
         return makePurePayment(
-                    new AccountInfo(source.getId(), null, null),
-                    new AccountInfo(target.getId(), null, null),
+                    src, tgt,
+                    // new AccountInfo(source.getId(), null, null),
+                    // new AccountInfo(target.getId(), null, null),
                     instrument,
                     amount,
                     description,
@@ -474,8 +489,8 @@
      *  As a principle, we deal in Units of Contract (underlying units)
      *  and not Units of Account (displayed units).
      *
-     * @param target the target account, may be bearer
-     * @param source the source account where funds are written from
+     * @param tgt the target account, may be bearer
+     * @param src the source account where funds are written from
      * @param contractid is the name of the contract
      * @param amount the (contract) qty of items of which the payment is for
      * @param desc a description of what this payment is for (optional)
@@ -484,21 +499,22 @@
      * @param till the time at which the payment will expire
      * @param pid a payment identifier, ignored if empty
      */
-    public Payment makePurePayment(AccountInfo source, AccountInfo targetinfo,
+//    public Payment makePurePayment(AccountInfo source, AccountInfo targetinfo,
+    public Payment makePurePayment(AccountId src, AccountId tgt,
                               ItemId contractid, long amount,
                               byte[] desc,
                               long from, long till,
                               String pid)
     {
-        //  Need a quiet non-GUI version (no AccountInfos) !
+        //  Need a quiet non-GUI version:  no AccountInfos, no error()'s  !
 
-        AccountId target = new AccountId();
-        if (targetinfo != null)
-            target.setId(targetinfo.getId());
+//        AccountId tgt = new AccountId();
+//        if (targetinfo != null)
+//            tgt.setId(targetinfo.getId());
 
         Account acc;
         try {
-            acc = getAccount(source);
+            acc = getAccount(src);
         } catch (StoreException ex) {
             ex.printStackTrace();
             error("Error getting account");
@@ -507,8 +523,9 @@
 
         //checkIssuer(acc, contractid);
 
-        AccountId src = new AccountId();
-        src.setId(source.getId());
+//        AccountId src = new AccountId();
+//        src.setId(source.getId());
+
         long pend = getValue(src, contractid, true);
         long confirmed = getValue(src, contractid, false);
 
@@ -568,7 +585,7 @@
                 error("No such subaccount? " + contractid);
                 return null ;
             }
-            pay = sub.createPayment(target, amount,
+            pay = sub.createPayment(tgt, amount,
                                     desc, false,
                                     from, till,
                                     pid);
@@ -578,6 +595,10 @@
             return null ;
         }
 
+        // this disappears when we get new better StateReceipts....
+        AccountInfo targetinfo = new AccountInfo(tgt.getId(), null, null);
+        AccountInfo sourceinfo = new AccountInfo(src.getId(), null, null);
+
         //
         //  Have to create and store the PendingReceipt securely
         //  before returning the payment to the caller.  Once
@@ -585,7 +606,8 @@
         //  PendingReceipt receipt there for matching or cancelling.
         //
         PendingReceipt pending = new PendingReceipt(pay.getId(),
-                                          contractid, source, targetinfo,
+                                          contractid,
+                                          sourceinfo, targetinfo,
                                           amount, desc, new Date());
         try {
             receiptStore.addPendingReceipt(pending, src);