def test_issue_tx(self): miner_tx = MinerTransaction() miner_tx.Nonce = 2083236893 share_tx = GetSystemShare() coin_tx = GetSystemCoin() script = Contract.CreateMultiSigRedeemScript(int(len(Blockchain.StandbyValidators()) / 2) + 1, Blockchain.StandbyValidators()) if Settings.MAGIC == 1953787457: self.assertEqual(script, self.contractraw) out = Crypto.ToScriptHash(script) output = TransactionOutput( share_tx.Hash, Blockchain.SystemShare().Amount, out ) script = Witness( bytearray(0), bytearray(PUSHT)) issue_tx = IssueTransaction([],[output],[], [script]) self.assertEqual(issue_tx.GetHashData(), self.issuetx_rraw) self.assertEqual(issue_tx.Hash.ToBytes(), self.gen_issue_tx_id)
def GenesisBlock(): prev_hash = UInt256(data=bytearray(32)) timestamp = int( datetime(2016, 7, 15, 15, 8, 21, tzinfo=pytz.utc).timestamp()) index = 0 consensus_data = 2083236893 #向比特币致敬 ( Pay Tribute To Bitcoin ) next_consensus = Blockchain.GetConsensusAddress( Blockchain.StandbyValidators()) script = Witness(bytearray(0), bytearray(PUSHT)) mt = MinerTransaction() mt.Nonce = 2083236893 output = TransactionOutput( Blockchain.SystemShare().Hash, Blockchain.SystemShare().Amount, Crypto.ToScriptHash( Contract.CreateMultiSigRedeemScript( int(len(Blockchain.StandbyValidators()) / 2) + 1, Blockchain.StandbyValidators()))) it = IssueTransaction([], [output], [], [script]) return Block( prev_hash, timestamp, index, consensus_data, next_consensus, script, [mt, Blockchain.SystemShare(), Blockchain.SystemCoin(), it], True)
def GetConsensusAddress(validators): vlen = len(validators) script = Contract.CreateMultiSigRedeemScript( vlen - int((vlen - 1) / 3), validators) return Crypto.ToScriptHash(script)
def CheckWitnessPubkey(self, engine, pubkey): #the ToScriptHash thing needs fixing return self.CheckWitnessHash( engine, Crypto.ToScriptHash(Contract.CreateSignatureRedeemScript(pubkey)))