Sign tx that has been created by MiniWallet in P2PK mode
(self, tx, fixed_length=True)
| 108 | self._utxos.append({'txid': tx['txid'], 'vout': out['n'], 'value': out['value'], 'height': 0}) |
| 109 | |
| 110 | def sign_tx(self, tx, fixed_length=True): |
| 111 | """Sign tx that has been created by MiniWallet in P2PK mode""" |
| 112 | assert self._priv_key is not None |
| 113 | (sighash, err) = LegacySignatureHash(CScript(self._scriptPubKey), tx, 0, SIGHASH_ALL) |
| 114 | assert err is None |
| 115 | # for exact fee calculation, create only signatures with fixed size by default (>49.89% probability): |
| 116 | # 65 bytes: high-R val (33 bytes) + low-S val (32 bytes) |
| 117 | # with the DER header/skeleton data of 6 bytes added, this leads to a target size of 71 bytes |
| 118 | der_sig = b'' |
| 119 | while not len(der_sig) == 71: |
| 120 | der_sig = self._priv_key.sign_ecdsa(sighash) |
| 121 | if not fixed_length: |
| 122 | break |
| 123 | tx.vin[0].scriptSig = CScript([der_sig + bytes(bytearray([SIGHASH_ALL]))]) |
| 124 | |
| 125 | def generate(self, num_blocks, **kwargs): |
| 126 | """Generate blocks with coinbase outputs to the internal address, and append the outputs to the internal list""" |
no test coverage detected