Signs the input using the private key
(self, input_index, private_key)
| 356 | return True |
| 357 | |
| 358 | def sign_input(self, input_index, private_key): |
| 359 | '''Signs the input using the private key''' |
| 360 | # get the signature hash (z) |
| 361 | z = self.sig_hash(input_index) |
| 362 | # get der signature of z from private key |
| 363 | der = private_key.sign(z).der() |
| 364 | # append the SIGHASH_ALL to der (use SIGHASH_ALL.to_bytes(1, 'big')) |
| 365 | sig = der + SIGHASH_ALL.to_bytes(1, 'big') |
| 366 | # calculate the sec |
| 367 | sec = private_key.point.sec() |
| 368 | # initialize a new script with [sig, sec] as the cmds |
| 369 | script_sig = Script([sig, sec]) |
| 370 | # change input's script_sig to new script |
| 371 | self.tx_ins[input_index].script_sig = script_sig |
| 372 | # return whether sig is valid using self.verify_input |
| 373 | return self.verify_input(input_index) |
| 374 | |
| 375 | def is_coinbase(self): |
| 376 | '''Returns whether this transaction is a coinbase transaction or not''' |