* code : number
* message: error message
+Depending on the type of asynchronous call, there may be other key-value pairs. For example, a z_sendmany operation will also include the following in an OperationStatus object:
+
+* params : an object containing the parameters to z_sendmany
+
Currently, as soon as you retrieve the operation status for an operation which has finished, that is it has either succeeded, failed, or been cancelled, the operation and any associated information is removed.
It is currently not possible to cancel operations.
else:
status = results[0]["status"]
errorString = results[0]["error"]["message"]
+
+ # Test that the returned status object contains a params field with the operation's input parameters
+ params =results[0]["params"]
+ assert_equal(params["fee"], Decimal('0.0001')) # default
+ assert_equal(params["minconf"], Decimal('1')) # default
+ assert_equal(params["fromaddress"], mytaddr)
+ assert_equal(params["amounts"][0]["address"], myzaddr)
+ assert_equal(params["amounts"][0]["amount"], Decimal('1.23456789'))
break
assert_equal("failed", status)
assert_equal("wallet does not allow any change" in errorString, True)
return creation_time_;
}
- Value getStatus() const;
+ // Override this method to add data to the default status object.
+ virtual Value getStatus() const;
Value getError() const;
std::vector<SendManyRecipient> tOutputs,
std::vector<SendManyRecipient> zOutputs,
int minDepth,
- CAmount fee) :
- fromaddress_(fromAddress), t_outputs_(tOutputs), z_outputs_(zOutputs), mindepth_(minDepth), fee_(fee)
+ CAmount fee,
+ Value contextInfo) :
+ fromaddress_(fromAddress), t_outputs_(tOutputs), z_outputs_(zOutputs), mindepth_(minDepth), fee_(fee), contextinfo_(contextInfo)
{
assert(fee_ > 0);
return memo;
}
+/**
+ * Override getStatus() to append the operation's input parameters to the default status object.
+ */
+Value AsyncRPCOperation_sendmany::getStatus() const {
+ Value v = AsyncRPCOperation::getStatus();
+ if (contextinfo_.is_null()) {
+ return v;
+ }
+
+ Object obj = v.get_obj();
+ obj.push_back(Pair("method", "z_sendmany"));
+ obj.push_back(Pair("params", contextinfo_ ));
+ return Value(obj);
+}
class AsyncRPCOperation_sendmany : public AsyncRPCOperation {
public:
- AsyncRPCOperation_sendmany(std::string fromAddress, std::vector<SendManyRecipient> tOutputs, std::vector<SendManyRecipient> zOutputs, int minDepth, CAmount fee = ASYNC_RPC_OPERATION_DEFAULT_MINERS_FEE);
+ AsyncRPCOperation_sendmany(std::string fromAddress, std::vector<SendManyRecipient> tOutputs, std::vector<SendManyRecipient> zOutputs, int minDepth, CAmount fee = ASYNC_RPC_OPERATION_DEFAULT_MINERS_FEE, Value contextInfo = Value::null);
virtual ~AsyncRPCOperation_sendmany();
// We don't want to be copied or moved around
virtual void main();
+ virtual Value getStatus() const;
+
bool testmode = false; // Set to true to disable sending txs and generating proofs
private:
friend class TEST_FRIEND_AsyncRPCOperation_sendmany; // class for unit testing
+ Value contextinfo_; // optional data to include in return value from getStatus()
+
CAmount fee_;
int mindepth_;
std::string fromaddress_;
}
}
+ // Use input parameters as the optional context info to be returned by z_getoperationstatus and z_getoperationresult.
+ Object o;
+ o.push_back(Pair("fromaddress", params[0]));
+ o.push_back(Pair("amounts", params[1]));
+ o.push_back(Pair("minconf", nMinDepth));
+ o.push_back(Pair("fee", std::stod(FormatMoney(nFee))));
+ Value contextInfo = Value(o);
+
// Create operation and add to global queue
std::shared_ptr<AsyncRPCQueue> q = getAsyncRPCQueue();
- std::shared_ptr<AsyncRPCOperation> operation( new AsyncRPCOperation_sendmany(fromaddress, taddrRecipients, zaddrRecipients, nMinDepth, nFee) );
+ std::shared_ptr<AsyncRPCOperation> operation( new AsyncRPCOperation_sendmany(fromaddress, taddrRecipients, zaddrRecipients, nMinDepth, nFee, contextInfo) );
q->addOperation(operation);
AsyncRPCOperationId operationId = operation->getId();
return operationId;