[Webfunds-commits] java/webfunds/sox Payment.java

Ian Grigg iang@cypherpunks.ai
Sun, 18 Mar 2001 19:22:01 -0400 (AST)


iang        01/03/18 19:22:01

  Modified:    webfunds/sox Payment.java
  Log:
  fixed some bugs in encoding:  empty sig ==> null and null desc ==> empty.

Revision  Changes    Path
1.27      +7 -13     java/webfunds/sox/Payment.java

Index: Payment.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/sox/Payment.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- Payment.java	2001/02/27 14:22:23	1.26
+++ Payment.java	2001/03/18 23:22:01	1.27
@@ -1,5 +1,5 @@
 /*
- * $Id: Payment.java,v 1.26 2001/02/27 14:22:23 iang Exp $
+ * $Id: Payment.java,v 1.27 2001/03/18 23:22:01 iang Exp $
  *
  * Copyright (c) Systemics Inc 1995-2000 on behalf of
  * the WebFunds Development Team.  All Rights Reserved.
@@ -218,11 +218,13 @@
     /**
      * Define the signature for this payment
      * @param sig the signature to place on the payment,
-     * or if null, then the signature (if any) is removed.
+     * or if null or empty, then the signature (if any) is removed.
      */
     public void setSignature(byte[] sig)
     {
         this.sig = sig;
+        if (sig != null && sig.length == 0)
+            this.sig = null;
     }
 
     /**
@@ -284,8 +286,9 @@
         item = new ItemId(dis);
         qty = dis.readLong();
         desc = readByteArray(dis);
-        if (desc.length == 0)       // always returns array
-            desc = null;
+// AbstractPayment requires this to be byte[0];
+//        if (desc.length == 0)       // always returns array
+//            desc = null;
         changekey = dis.readBoolean(); // Boolean is a byte 0/1 should change
         validFrom = dis.readLong();
         validTill = dis.readLong();
@@ -428,15 +431,6 @@
     public static Payment example()
     {
         ItemId item   = ItemId.example();
-/* now does it itself
-        int len;
-        do {                              // no payment with null ItemId?
-            item   = ItemId.example();
-            byte[] b = item.getByteArray();
-            len = (b == null) ? 0 : b.length;
-        }
-            while (len <= 0);
-*/
 
         AccountId ac1 = AccountId.example();
         AccountId ac2 = AccountId.example();