[Webfunds-commits] java/webfunds/client/sox SOXWallet.java
Ian Grigg
iang@cypherpunks.ai
Mon, 18 Dec 2000 00:21:19 -0400 (AST)
iang 00/12/18 00:21:19
Modified: webfunds/sox PaymentFactory.java
webfunds/client/sox SOXWallet.java
Log:
1. moved Token type dependency from SOXWallet to PaymentFactory
with static factory call getProtoTokens().
2. also decided to make withdrawal payments made out to Bearer for
now, seems poetically judicial given circumstances...
Revision Changes Path
1.8 +27 -2 java/webfunds/sox/PaymentFactory.java
Index: PaymentFactory.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/sox/PaymentFactory.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- PaymentFactory.java 2000/12/05 17:38:29 1.7
+++ PaymentFactory.java 2000/12/18 04:21:18 1.8
@@ -1,4 +1,4 @@
-/* $Id: PaymentFactory.java,v 1.7 2000/12/05 17:38:29 iang Exp $
+/* $Id: PaymentFactory.java,v 1.8 2000/12/18 04:21:18 iang Exp $
*
* Copyright (c) Systemics Inc. 1995-2000 on behalf of
* The WebFunds Development Team. All Rights Reserved.
@@ -139,7 +139,7 @@
{
if (!valid(typ) || (series == null) || (log < 0))
- throw new IllegalArgumentException("PF.createKeyPair(?)");
+ throw new IllegalArgumentException("PF.createKeyPair("+typ+"?)");
KeyPair kp;
@@ -153,6 +153,31 @@
throw new IllegalArgumentException("createKeyPair("+typ+")");
return kp;
+ }
+
+ /**
+ * Get me a list of proto Tokens for a particular type.
+ * This is the first step in withdrawing coins.
+ */
+ public static Token[] getProtoTokens(int typ, long amount)
+ throws SOXArgsException
+ {
+
+ if (!valid(typ) || (amount < 0))
+ throw new SOXArgsException("PF.createKeyPair("+typ+"?)");
+
+ Token[] tokens;
+
+ if (typ == RANDOM_TOKEN)
+ tokens = RandomToken.getProtoTokens(amount);
+ /*
+ else if (typ == WAGNER_TOKEN)
+ tokens = WagnerToken.getProtoTokens(amount);
+ */
+ else
+ throw new SOXArgsException("getProtoTokens("+typ+")");
+
+ return tokens;
}
1.140 +19 -12 java/webfunds/client/sox/SOXWallet.java
Index: SOXWallet.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/client/sox/SOXWallet.java,v
retrieving revision 1.139
retrieving revision 1.140
diff -u -r1.139 -r1.140
--- SOXWallet.java 2000/11/30 13:46:31 1.139
+++ SOXWallet.java 2000/12/18 04:21:18 1.140
@@ -1,4 +1,4 @@
-/* $Id: SOXWallet.java,v 1.139 2000/11/30 13:46:31 iang Exp $
+/* $Id: SOXWallet.java,v 1.140 2000/12/18 04:21:18 iang Exp $
*
* Copyright (c) Systemics Inc. 1995-2000 on behalf of
* The WebFunds Development Team. All Rights Reserved.
@@ -42,7 +42,7 @@
import webfunds.sox.Payment;
import webfunds.sox.TokenPayment;
import webfunds.sox.Token;
-import webfunds.sox.RandomToken;
+// import webfunds.sox.RandomToken;
import webfunds.sox.Receipt;
import webfunds.sox.SOXAccountException;
@@ -1012,11 +1012,8 @@
* of the primary payment in order to pay for the proto.
*
* We need to write a payment to someone who can cash these
- * payments ... it could be bearer, but here, let's make it
- * "someone" and see what happens.
- AccountId bearerFloat = new AccountId();
- byte[] f = webfunds.sox.Crypto.digest("Random".getBytes());
- bearerFloat.setId(f);
+ * payments ... it has to be bearer, as we don't otherwise
+ * know the name of the float as yet.
*/
Payment pay;
@@ -1031,14 +1028,22 @@
}
Token[] tokens;
- if (type == PaymentFactory.RANDOM_TOKEN)
- tokens = RandomToken.getProtoTokens(amount);
- else
- {
+ try {
+ tokens = PaymentFactory.getProtoTokens(type, amount);
+ } catch (SOXArgsException ex) {
+ ex.printStackTrace();
throw new PaymentException(PaymentException.UNKNOWN_TYPE,
- "Token Type " + type + " not supported");
+ "Token Type " + type + " not supported");
}
+// if (type == PaymentFactory.RANDOM_TOKEN)
+// tokens = RandomToken.getProtoTokens(amount);
+// else
+// {
+// throw new PaymentException(PaymentException.UNKNOWN_TYPE,
+// "Token Type " + type + " not supported");
+// }
+
TokenPayment proto;
String pid = pay.getId();
try {
@@ -1063,6 +1068,8 @@
throw new PaymentException(ex.getNumber(), "Later: " + ex);
} catch (SOXSubAccountException ex) {
throw new PaymentException(ex.getNumber(), "SOXSAEx: " + ex);
+ } catch (SOXDepositException ex) {
+ throw new PaymentException(ex.getNumber(), "SOXDepEx: " + ex);
} catch (SOXException ex) {
throw new PaymentException(ex.getNumber(), "SOXEx: " + ex);
}