[Webfunds-commits] java/webfunds/sox RandomToken.java Token.java ValueAccount.java

Ian Grigg iang@cypherpunks.ai
Mon, 18 Dec 2000 00:25:25 -0400 (AST)


iang        00/12/18 00:25:25

  Modified:    webfunds/sox RandomToken.java Token.java ValueAccount.java
  Log:
  added psuedo-abstract static methods to handle getting a list
  of proto payments without needing to specifically call the
  Token method directly.

Revision  Changes    Path
1.4       +17 -2     java/webfunds/sox/RandomToken.java

Index: RandomToken.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/sox/RandomToken.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- RandomToken.java	2000/12/05 17:40:37	1.3
+++ RandomToken.java	2000/12/18 04:25:24	1.4
@@ -1,5 +1,5 @@
 /*
- * $Id: RandomToken.java,v 1.3 2000/12/05 17:40:37 iang Exp $
+ * $Id: RandomToken.java,v 1.4 2000/12/18 04:25:24 iang Exp $
  *
  * Copyright (c) Systemics Inc 1995-2000 on behalf of
  * the WebFunds Development Team.  All Rights Reserved.
@@ -102,10 +102,25 @@
     /**
      *  Make a set of Tokens that can handle a quantity.
      *  Simply calls qty2coins() then uses those sizes.
+     *
+     *  What to do with the zero quantity is undefined,
+     *  here, we implement a zero token as valid (according
+     *  to well-established SOX design principles), so a
+     *  single zero token is returned for zero amount.
      */
     public static Token[] getProtoTokens(long qty)
     {
-        return getProtoTokens( PaymentFactory.qty2coins(qty) );
+        int[] coins;
+        if (qty == 0)
+        {
+            coins = new int[1];
+            coins[0] = 0;
+        }
+        else
+        {
+            coins = PaymentFactory.qty2coins(qty);
+        }
+        return getProtoTokens(coins);
     }
 
     /**



1.6       +21 -1     java/webfunds/sox/Token.java

Index: Token.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/sox/Token.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Token.java	2000/12/05 17:41:13	1.5
+++ Token.java	2000/12/18 04:25:24	1.6
@@ -1,5 +1,5 @@
 /*
- * $Id: Token.java,v 1.5 2000/12/05 17:41:13 iang Exp $
+ * $Id: Token.java,v 1.6 2000/12/18 04:25:24 iang Exp $
  *
  * Copyright (c) Systemics Inc 1995-2000 on behalf of
  * the WebFunds Development Team.  All Rights Reserved.
@@ -227,13 +227,33 @@
      *  Create a PrivateKey and matching PublicKey for signing
      *  the tokens.
      *  This is really a static call, not to do with the object.
+     *  See PaymentFactory.createKeyPair()
      *  It also needs to be audited by the Issuer.
      *
      *  @param series is a string identifying batch
      *  @param log is the value number that applies for this key
+     *
     public static abstract KeyPair createKeyPair(byte[] series, int log)
         throws SOXKeyException;
      */
+
+    /**
+     *  Create a list of proto-Tokens ready for withdrawal.
+     *  This is a static call.  See PaymentFactory.getProtoTokens()
+     *
+     *  @param amount is the total quantity of value in the tokens
+     *  @except SOXArgsException if amount is invalid
+     *
+    public static abstract Token[] getProtoTokens(long amount)
+        throws SOXArgsException;
+     */
+
+    /**
+     *  Unblind the signed coin, revealing the signed, private coin.
+     *  Normally called by client, no standard paramaters.
+     */
+    public abstract void unblind();
+
 
 
 



1.23      +3 -1      java/webfunds/sox/ValueAccount.java

Index: ValueAccount.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/sox/ValueAccount.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- ValueAccount.java	2000/11/30 13:45:53	1.22
+++ ValueAccount.java	2000/12/18 04:25:24	1.23
@@ -1,5 +1,5 @@
 /*
- * $Id: ValueAccount.java,v 1.22 2000/11/30 13:45:53 iang Exp $
+ * $Id: ValueAccount.java,v 1.23 2000/12/18 04:25:24 iang Exp $
  *
  * Copyright (c) Systemics Ltd 1995-1999 on behalf of
  * the WebFunds Development Team.  All Rights Reserved.
@@ -200,6 +200,8 @@
                      (err == Errors.ERROR_UNKNOWN_SOURCE)    ||
                      (err == Errors.ERROR_ILLEGAL_DEBIT)     ||
                      (err == Errors.ERROR_ALREADY)           ||
+                     (err == Errors.ERROR_NOT_ENUF)          ||
+                     (err == Errors.ERROR_UNAVAILABLE)       ||
                      ( (err == Errors.ERROR_DEP_ALREADY) && !myDID )
                 )
             throw new SOXDepositException(err, txt);