Signs the input using the private key
(self, input_index, private_key)
| 230 | return True |
| 231 | |
| 232 | def sign_input(self, input_index, private_key): |
| 233 | '''Signs the input using the private key''' |
| 234 | # get the signature hash (z) |
| 235 | z = self.sig_hash(input_index) |
| 236 | # get der signature of z from private key |
| 237 | der = private_key.sign(z).der() |
| 238 | # append the SIGHASH_ALL to der (use SIGHASH_ALL.to_bytes(1, 'big')) |
| 239 | sig = der + SIGHASH_ALL.to_bytes(1, 'big') |
| 240 | # calculate the sec |
| 241 | sec = private_key.point.sec() |
| 242 | # initialize a new script with [sig, sec] as the cmds |
| 243 | script_sig = Script([sig, sec]) |
| 244 | # change input's script_sig to new script |
| 245 | self.tx_ins[input_index].script_sig = script_sig |
| 246 | # return whether sig is valid using self.verify_input |
| 247 | return self.verify_input(input_index) |
| 248 | |
| 249 | |
| 250 | class TxIn: |