What does "16: mandatory-script-verify-flag-failed (Non-canonical DER signature)" error mean?
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?