Best patch for invalid nonce and duplicate share

Best patch for invalid nonce and duplicate share
Thanks sandor for help new code