What does "16: mandatory-script-verify-flag-failed (Non-canonical DER signature)" error mean? What can this error mean?  I've read through the code for it, and several of my transactions have not met the criteria for the error, yet are still rejected.  I've tried decoding via several means (none are super detailed though) to no avail in discerning the problem.  Some have claimed by reading the bitcoin debug log one can find a more detailed reason, but my log says nothing about my rejected raw transaction.

Yes, there is another question very similar to this, but he provided code so as to get an answer for his specific code and the answers didn't address what could have caused it nor how to discern, more specifically, what may be causing it within the code.

Everything in my transactions that I've been trying are manually created.  But they meet those criteria specified.  I'm remaking some right now, but I was kind of wondering if there are other checks being done besides those you have referenced for this particular error.

I have even considered I got the wrong numbers in my manual creation of the variables, but I would think that would cause it to fail under a different error if that were the case.
What can this error mean?


This error can only mean that this function returned false:

bool static IsValidSignatureEncoding(const std::vector&lt;unsigned char&gt; &amp;sig) {


When does this function return true? When all of these conditions are satisfied:

/**
 * A canonical signature exists of: &lt;30&gt; &lt;total len&gt; &lt;02&gt; &lt;len R&gt; &lt;R&gt; &lt;02&gt; &lt;len S&gt; &lt;S&gt; &lt;hashtype&gt;
 * Where R and S are not negative (their first byte has its highest bit not set), and not
 * excessively padded (do not start with a 0 byte, unless an otherwise negative number follows,
 * in which case a single 0 byte is necessary and even required).


How are you generating your signature?