def issue_coins(self, moniker, pck, units, atoms_in_unit): """Issues a new color of name <moniker> using coloring scheme <pck> with <units> per share and <atoms_in_unit> total. """ color_definition_cls = ColorDefinition.get_color_def_cls_for_code(pck) if not color_definition_cls: msg = 'Color scheme "%s" not recognized' raise InvalidColorDefinitionError(msg % pck) total = int(units * atoms_in_unit) op_tx_spec = SimpleOperationalTxSpec(self.model, None) wam = self.model.get_address_manager() address = wam.get_new_genesis_address() colorvalue = SimpleColorValue(colordef=GENESIS_OUTPUT_MARKER, value=total) color_target = ColorTarget(address.get_address(), colorvalue) op_tx_spec.add_target(color_target) genesis_ctxs = color_definition_cls.compose_genesis_tx_spec(op_tx_spec) genesis_tx = self.model.transform_tx_spec(genesis_ctxs, 'signed') height = self.model.ccc.blockchain_state.get_block_count() - 1 genesis_tx_hash = self.publish_tx(genesis_tx) color_desc = ':'.join([pck, genesis_tx_hash, '0', str(height)]) adm = self.model.get_asset_definition_manager() asset = adm.add_asset_definition({"monikers": [moniker], "color_set": [color_desc], "unit": atoms_in_unit}) wam.update_genesis_address(address, asset.get_color_set()) # scan the tx so that the rest of the system knows self.model.ccc.colordata.cdbuilder_manager.scan_txhash( asset.color_set.color_id_set, genesis_tx_hash)
def issue_coins(self, moniker, pck, units, atoms_in_unit): """Issues a new color of name <moniker> using coloring scheme <pck> with <units> per share and <atoms_in_unit> total. """ color_definition_cls = ColorDefinition.get_color_def_cls_for_code(pck) if not color_definition_cls: raise InvalidColorDefinitionError( 'color scheme %s not recognized' % pck) total = units * atoms_in_unit op_tx_spec = SimpleOperationalTxSpec(self.model, None) wam = self.model.get_address_manager() address = wam.get_new_genesis_address() colorvalue = SimpleColorValue(colordef=GENESIS_OUTPUT_MARKER, value=total) color_target = ColorTarget(address.get_address(), colorvalue) op_tx_spec.add_target(color_target) genesis_ctxs = color_definition_cls.compose_genesis_tx_spec(op_tx_spec) genesis_tx = self.model.transform_tx_spec(genesis_ctxs, 'signed') height = self.model.ccc.blockchain_state.bitcoind.getblockcount() \ - 1 genesis_tx_hash = self.publish_tx(genesis_tx) color_desc = ':'.join([pck, genesis_tx_hash, '0', str(height)]) adm = self.model.get_asset_definition_manager() asset = adm.add_asset_definition({ "monikers": [moniker], "color_set": [color_desc], "unit": atoms_in_unit }) wam.update_genesis_address(address, asset.get_color_set()) # scan the tx so that the rest of the system knows self.model.ccc.colordata.cdbuilder_manager.scan_txhash( asset.color_set.color_id_set, genesis_tx_hash)
def issue_coins(self, moniker, pck, units, atoms_in_unit): """Issues a new color of name <moniker> using coloring scheme <pck> with <units> per share and <atoms_in_unit> total. """ color_definition_cls = ColorDefinition.get_color_def_cls_for_code(pck) if not color_definition_cls: raise Exception("color scheme %s not recognized" % pck) total = units * atoms_in_unit op_tx_spec = SimpleOperationalTxSpec(self.model, None) wam = self.model.get_address_manager() address = wam.get_new_genesis_address() op_tx_spec.add_target(address.get_address(), GENESIS_OUTPUT_MARKER, total) genesis_ctxs = color_definition_cls.compose_genesis_tx_spec(op_tx_spec) genesis_tx = self.model.transform_tx_spec(genesis_ctxs, "signed") height = self.model.ccc.blockchain_state.bitcoind.getblockcount() - 1 genesis_tx_hash = self.publish_tx(genesis_tx) color_desc = ":".join([pck, genesis_tx_hash, "0", str(height)]) adm = self.model.get_asset_definition_manager() asset = adm.add_asset_definition({"monikers": [moniker], "color_set": [color_desc], "unit": atoms_in_unit}) wam.update_genesis_address(address, asset.get_color_set()) # scan the tx so that the rest of the system knows self.model.ccc.colordata.cdbuilder_manager.scan_txhash(asset.color_set.color_id_set, genesis_tx_hash)
def sendmany_coins(self, entries): """Sendmany coins given in entries [(asset, address, value), ...] """ self.validate_sendmany_entries(entries) tx_spec = SimpleOperationalTxSpec(self.model, None) for asset, address, value in entries: color_id = asset.get_color_id() colordef = self.model.get_color_def(color_id) colorvalue = SimpleColorValue(colordef=colordef, value=value) tx_spec.add_target(ColorTarget(address, colorvalue)) signed_tx_spec = self.model.transform_tx_spec(tx_spec, 'signed') txhash = self.publish_tx(signed_tx_spec) # TODO add to history return txhash