def serialize(self):
		"""
		Serializes the MultiSigTransaction.

		Return value:
		str; the serialized MultiSigTransaction.
		"""

		serializedList = tcd.serializeList(self.TCDlist)
		return struct.pack('!I', len(serializedList)) + \
			serializedList + self.transaction.serialize()
	def setOutputs(self, ownPubKey, peerPubKey, escrowPubKey,
		ownAmount, peerAmount):
		"""
		Re-write the outputs of the transaction, based on the TCDlist attribute
		and the given arguments.

		Arguments:
		ownPubKey: str; our own public key.
		peerPubKey: str; the public key of the peer.
		escrowPubKey: str; the public key of the escrow service.
		ownAmount: int; the non-locked funds available to ourselves (in Satoshi).
		peerAmount: int; the non-locked funds available to the peer (in Satoshi).
		"""

		ownKeyHash = RIPEMD160(SHA256(ownPubKey))
		peerKeyHash = RIPEMD160(SHA256(peerPubKey))

		lockedAmount = sum([doc.amount for doc in self.TCDlist])

		self.transaction.tx_out = []

		if len(self.TCDlist) > 0:
			serializedList = tcd.serializeList(self.TCDlist)
			hashValue = RIPEMD160(SHA256(serializedList))
			self.transaction.tx_out.append(bitcointransaction.TxOut(
				0, #Don't send any funds here: they're unspendable.
				bitcointransaction.Script.dataPubKey(hashValue)
				))

		if ownAmount > 0:
			self.transaction.tx_out.append(bitcointransaction.TxOut(
				ownAmount,
				bitcointransaction.Script.standardPubKey(ownKeyHash)
				))

		if peerAmount > 0:
			self.transaction.tx_out.append(bitcointransaction.TxOut(
				peerAmount,
				bitcointransaction.Script.standardPubKey(peerKeyHash)
				))

		if lockedAmount > 0:
			self.transaction.tx_out.append(bitcointransaction.TxOut(
				lockedAmount,
				bitcointransaction.Script.multiSigPubKey(
					[ownPubKey, peerPubKey, escrowPubKey])
				))
	def getState(self, forDisplay=False):
		"""
		Return a data structure that contains state information of the
		MultiSigTransaction.

		Arguments:
		forDisplay: bool; indicates whether the returned state is for user
		            interface display purposes (True) or for state saving
		            purposes (False). For user interface display purposes, a
		            summary may be returned instead of the complete state.

		Return value:
		A data structure, consisting of only standard Python types like dict,
		list, str, bool, int.
		"""

		ret = {}
		if forDisplay:
			ret["ID"] = self.transaction.getTransactionID()[::-1].encode("hex")
		else:
			ret["tx"] = self.transaction.serialize().encode("hex")
			ret["TCDs"] = tcd.serializeList(self.TCDlist).encode("hex")
		return ret