title: Blockchain tutorials for double spending and signature verification
body: <p>I've been studying blockchain from basics, and studying the TPCoin python codes line by line.
  While looking into the code, I found that there is no validation method that will prevent the double spending issues or reject the transaction request with invalid signatures.</p>
  <p>I was studying with article below:
  <a href="https://morioh.com/p/7bfc126c22c2" rel="nofollow noreferrer">https://morioh.com/p/7bfc126c22c2</a></p>
  <pre><code>class Transaction:
  
      def __init__( self, sender, recipient, value ):
          self.sender = sender 
          self.recipient = recipient 
          self.value = value
          self.time = datetime.datetime.now()
          self.signer = &quot;&quot;
      
      def to_dict( self ):
  
          if self.sender == &quot;Genesis&quot;:
              identity = &quot;Genesis&quot;
          else:
              identity = self.sender.identity
  
          return collections.OrderedDict( { 'sender': identity, 'recipient': self.recipient, 'value': self.value, 'time' : self.time } )
  
      def sign_transaction( self ):
  
          private_key = self.sender._private_key
          signer = PKCS1_v1_5.new( private_key )
          h = SHA.new( str( self.to_dict( ) ).encode( 'utf8' ) )
          self.signer = binascii.hexlify( signer.sign( h ) ).decode( 'ascii' )
          return self.signer
  
      def display_transaction( self ):
          dict = self.to_dict( )
          print (&quot;sender: &quot; + dict['sender'])
          print ('-----')
          print (&quot;recipient: &quot; + dict['recipient'])
          print ('-----')
          print (&quot;value: &quot; + str(dict['value']))
          print ('-----')
          print (&quot;time: &quot; + str(dict['time']))
          print ('-----')
          print (&quot;signature: &quot; + self.signer)
          print ('-----')
  
      def validate_transaction( self ):
          ### Double spending? Signature Verification?
          return
  </code></pre>
  <p>I think there should be a sort of validation function within the Transaction class...but
  not quite sure what to do.
  I would like to see some brilliant ideas on how to handle this.</p>