[Webfunds-commits] java/webfunds/client/sox/gui PaymentFrame.java

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


iang        00/12/18 00:19:12

  Modified:    webfunds/client/sox/gui PaymentFrame.java
  Log:
  1. clarified type strings, still hard coded.
  2. handled "not available" error which is most likely for issuer
  that has not been configured for this particular token withdrawal.

Revision  Changes    Path
1.3       +22 -14    java/webfunds/client/sox/gui/PaymentFrame.java

Index: PaymentFrame.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/client/sox/gui/PaymentFrame.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- PaymentFrame.java	2000/12/07 20:14:19	1.2
+++ PaymentFrame.java	2000/12/18 04:19:11	1.3
@@ -1,5 +1,5 @@
 /*
- * $Id: PaymentFrame.java,v 1.2 2000/12/07 20:14:19 iang Exp $
+ * $Id: PaymentFrame.java,v 1.3 2000/12/18 04:19:11 iang Exp $
  *
  * Copyright (c) Systemics Ltd 1995-1999 on behalf of
  * the WebFunds Development Team.  All Rights Reserved.
@@ -373,15 +373,14 @@
         //
         //  Extract the payment from the wallet.  What sort?
         //
-        String typ = (String)typeChoice.getSelectedItem();
+        String typeString = (String)typeChoice.getSelectedItem();
         byte[] pay = null;
         byte[] desc = description.getText().getBytes();
         AbstractPayment payment = null;
         long from = validFrom.getTime();
         long till = validTill.getTime();
-        String typeString = typ;
 
-        if (SOX.equals(typ))
+        if (SOX.equals(typeString))
         {
             // the payment itself
             pay = wallet.makePayment(contractid, source, target,
@@ -390,7 +389,7 @@
             if (pay == null)     // wallet encountered error, already reported
                 return ;
         }
-        if (FRZ.equals(typ))
+        if (FRZ.equals(typeString))
         {
             // a rollover payment causes account to freeze and transfer funds
             try {
@@ -414,33 +413,42 @@
                 return;
             typeString = "Rollover";
         }
-        else if (BRN.equals(typ))
+        else if (BRN.equals(typeString))
         {
+            String q = "This experimental TOKEN payment is highly dangerous "+
+                       "and could lose your value." +
+                       "\n\nAre you absolutely sure?";
+            if ( !wallet.ask(q) )
+                return;
+
+            int typ = webfunds.sox.PaymentFactory.RANDOM_TOKEN;
+            String tokenType = webfunds.sox.PaymentFactory.getTypeString(typ);
             // the payment itself
             try {
                 payment = wallet.makeTokenPayment(src, tgt,
                              contractid, longamount,
                              desc,
                              from, till,
-                             webfunds.sox.PaymentFactory.RANDOM_TOKEN);
+                             typ);
             } catch (PaymentException ex) {
-                String e = "didn't work: " + ex;
+                String e = "Wothdrawal Failed:\n\n" + ex;
+                if (ex.getNumber() == Errors.ERROR_UNAVAILABLE)
+                {
+                    e = "The Issuer for " + contractName + "\n" +
+                        "does not support minting of tokens of type\n" +
+                        tokenType;
+                }
                 wallet.error(e);
                 return ;
             }
             if (payment == null)
                 return ;
 
-            String q = "This experimental TOKEN payment is highly dangerous "+
-                       "and could lose your value." +
-                       "\n\nAre you absolutely sure?";
-            if ( !wallet.ask(q) )
-                return;
             pay = wallet.asciiArmourWithError(payment);
             if (pay == null)
                 return;
         }
-        else if (DAW.equals(typ))
+        else if (DAW.equals(typeString))
         {
             String e = "Sorry, this payment type not yet available.";
             wallet.error(e);