From 5718d2e7f7cf3ccc01989abc4b16856a3ef95c8d Mon Sep 17 00:00:00 2001
From: Jean-Paul Calderone <exarkun@twistedmatrix.com>
Date: Wed, 13 Nov 2019 20:06:22 -0500
Subject: [PATCH] Some alternate ideas for representing the Voucher state

---
 docs/source/interface.rst | 39 ++++++++++++++++++++++++++++++++++++++-
 1 file changed, 38 insertions(+), 1 deletion(-)

diff --git a/docs/source/interface.rst b/docs/source/interface.rst
index d899f54..5255a96 100644
--- a/docs/source/interface.rst
+++ b/docs/source/interface.rst
@@ -32,7 +32,11 @@ If the voucher is not known then the response is **NOT FOUND**.
 For any voucher which has previously been submitted,
 the response is **OK** with an ``application/json`` content-type response body like::
 
-  {"value": <string>, "created": <iso8601 timestamp>, "redeemed": <boolean>, "token-count": <number>, "version": 1}
+  { "value": <string>
+  , "created": <iso8601 timestamp>
+  , "state": <state object>
+  , "version": 1
+  }
 
 The ``value`` property merely indicates the voucher which was requested.
 The ``created`` property indicates when the voucher was first added to the node.
@@ -42,6 +46,39 @@ The ``token-count`` property gives the number of blinded token signatures the cl
 if it has been redeemed.
 If it has not been redeemed then it is ``null``.
 
+The ``state`` property is an object that gives more details about the current state of the voucher.
+The following values are possible::
+
+  { "name": "pending"
+  }
+
+  { "name": "redeeming"
+  , "started": <iso8601 timestamp>
+  }
+
+  { "name": "error"
+  , "started": <iso8601 timestamp>
+  , "error-at": <iso8601 timestamp>
+  , "next-try-at": <iso8601 timestamp>
+  , "error-details": <text>
+  }
+
+  { "name": "unpaid"
+  , "started": <iso8601 timestamp>
+  , "error-at": <iso8601 timestamp>
+  }
+
+  { "name": "double-spend"
+  , "started": <iso8601 timestamp>
+  , "error-at": <iso8601 timestamp>
+  }
+
+  { "name": "redeemed"
+  , "started": <iso8601 timestamp>
+  , "finished": <iso8601 timestamp>
+  , "token-count": <number>
+  }
+
 The ``version`` property indicates the semantic version of the data being returned.
 When properties are removed or the meaning of a property is changed,
 the value of the ``version`` property will be incremented.
-- 
GitLab