当前位置: 首页>>代码示例>>Python>>正文


Python coloredcoinlib.ColorSet类代码示例

本文整理汇总了Python中coloredcoinlib.ColorSet的典型用法代码示例。如果您正苦于以下问题:Python ColorSet类的具体用法?Python ColorSet怎么用?Python ColorSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ColorSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUp

 def setUp(self):
     self.colormap = MockColorMap()
     d = self.colormap.d
     self.colorset0 = ColorSet(self.colormap, [''])
     self.colorset1 = ColorSet(self.colormap, [d[1]])
     self.colorset1alt = ColorSet(self.colormap, [d[1],d[6]])
     self.colorset2 = ColorSet(self.colormap, [d[2]])
     self.colorset3 = ColorSet(self.colormap, [d[3], d[4]])
     self.def1 = {'monikers': ['test1'],
                  'color_set': self.colorset1.get_data(),
                  'unit':10}
     self.asset1 = AssetDefinition(self.colormap, self.def1)
     self.master_key = '265a1a0ad05e82fa321e3f6f6767679df0c68515797e0e4e24be1afc3272ee658ec53cecb683ab76a8377273347161e123fddf5320cbbce8849b0a00557bd12c'
     self.privkey = '5Kb8kLf9zgWQnogidDA76MzPL6TsZZY36hWXMssSzNydYXYB9KF'
     self.pubkey = '1CC3X2gu58d6wXUWMffpuzN9JAfTUWu4Kj'
     c = {
         'dw_master_key': self.master_key,
         'dwam': {
             'genesis_color_sets':[self.colorset1.get_data(),
                                   self.colorset2.get_data()],
             'color_set_states':[
                 {'color_set':self.colorset0.get_data(), "max_index":0},
                 {'color_set':self.colorset1.get_data(), "max_index":3},
                 {'color_set':self.colorset2.get_data(), "max_index":2},
                 ],
             },
         'addresses':[{'address_data': self.privkey,
                       'color_set': self.colorset1.get_data(),
                       }],
         'testnet': False,
         }
     self.config = copy.deepcopy(c)
     self.maindwam = DWalletAddressManager(self.colormap, c)
开发者ID:Andymeows,项目名称:ngcccbase,代码行数:33,代码来源:test_deterministic.py

示例2: make_etx_spec

 def make_etx_spec(self, our, their):
     our_color_def = self.resolve_color_spec(our['color_spec'])
     our_color_set = ColorSet.from_color_ids(self.model.get_color_map(),
                                               [our_color_def.get_color_id()])
     their_color_def = self.resolve_color_spec(their['color_spec'])
     their_color_set = ColorSet.from_color_ids(self.model.get_color_map(),
                                               [their_color_def.get_color_id()])
     extra_value = 0
     if our_color_def == UNCOLORED_MARKER:
         # pay fee + padding for one colored outputs
         extra_value = 10000 + 8192 * 1
     c_utxos, c_change = self.select_inputs(
         SimpleColorValue(colordef=our_color_def,
                          value=our['value'] + extra_value))
     inputs = {our['color_spec']: 
               [utxo.get_outpoint() for utxo in c_utxos]}
     wam = self.model.get_address_manager()
     our_address = wam.get_change_address(their_color_set)
     targets = [(our_address.get_address(),
                 their['color_spec'], their['value'])]
     if c_change > 0:
         our_change_address = wam.get_change_address(our_color_set)
         targets.append((our_change_address.get_address(),
                         our['color_spec'], c_change.get_value()))
     return ETxSpec(inputs, targets, c_utxos)
开发者ID:CharlyRielle,项目名称:ngcccbase,代码行数:25,代码来源:ewctrl.py

示例3: test_from_color_ids

 def test_from_color_ids(self):
     self.assertTrue(self.colorset0.equals(ColorSet.from_color_ids(self.colormap, [0])))
     self.assertTrue(self.colorset3.equals(ColorSet.from_color_ids(self.colormap, [1, 2])))
     tmp = ColorSet.from_color_ids(self.colormap, [1, 2, 3])
     self.assertTrue(tmp.has_color_id(1))
     self.assertTrue(tmp.has_color_id(2))
     self.assertTrue(tmp.has_color_id(3))
开发者ID:shadowxxx,项目名称:ngcccbase,代码行数:7,代码来源:test_colorset.py

示例4: setUp

    def setUp(self):
        self.colormap = MockColorMap()
        d = self.colormap.d
        self.colorset0 = ColorSet(self.colormap, [''])
        self.colorset1 = ColorSet(self.colormap, [d[1], d[2]])
        self.colorset2 = ColorSet(self.colormap, [d[3]])
        self.def0 = {'monikers': ['bitcoin'],
                     'color_set': self.colorset0.get_data(),
                     'unit':100000000}
        self.def1 = {'monikers': ['test1'],
                     'color_set': self.colorset1.get_data(),
                     'unit':10}
        self.def2 = {'monikers': ['test2','test2alt'],
                     'color_set': self.colorset2.get_data(),
                     'unit':1}
        self.asset0 = AssetDefinition(self.colormap, self.def0)
        self.asset1 = AssetDefinition(self.colormap, self.def1)
        self.asset2 = AssetDefinition(self.colormap, self.def2)

        self.assetvalue0 = AdditiveAssetValue(asset=self.asset0, value=5)
        self.assetvalue1 = AdditiveAssetValue(asset=self.asset0, value=6)
        self.assetvalue2 = AdditiveAssetValue(asset=self.asset1, value=7)

        self.assettarget0 = AssetTarget('address0', self.assetvalue0)
        self.assettarget1 = AssetTarget('address1', self.assetvalue1)
        self.assettarget2 = AssetTarget('address2', self.assetvalue2)

        config = {'asset_definitions': [self.def1, self.def2]}
        self.adm = AssetDefinitionManager(self.colormap, config)
开发者ID:Andymeows,项目名称:ngcccbase,代码行数:29,代码来源:test_asset.py

示例5: AssetDefinition

class AssetDefinition(object):
    """Stores the definition of a particular asset, including its color set,
    it's name (moniker), and the wallet model that represents it.
    """
    def __init__(self, colormap, params):
        """Create an Asset for a color map <colormap> and configuration
        <params>. Note params has the color definitions used for this
        Asset.
        """
        self.monikers = params.get('monikers', [])
        self.color_set = ColorSet(colormap, params.get('color_set'))
        self.unit = int(params.get('unit', 1))

    def __repr__(self):
        return "%s: %s" % (self.monikers, self.color_set)

    def get_monikers(self):
        """Returns the list of monikers for this asset.
        """
        return self.monikers

    def get_color_set(self):
        """Returns the list of colors for this asset.
        """
        return self.color_set

    def get_colorvalue(self, utxo):
        """ return colorvalue for a given utxo"""
        if self.color_set.uncolored_only():
            return utxo.value
        else:
            if utxo.colorvalues:
                for cv in utxo.colorvalues:
                    if cv[0] in self.color_set.color_id_set:
                        return cv[1]
            raise Exception("cannot get colorvalue for UTXO: "
                            "no colorvalues available")

    def parse_value(self, portion):
        """Returns actual number of Satoshis for this Asset
        given the <portion> of the asset.
        """
        return int(float(portion) * self.unit)

    def format_value(self, atoms):
        """Returns a string representation of the portion of the asset.
        can involve rounding.  doesn't display insignificant zeros
        """
        return '{0:g}'.format(atoms / float(self.unit))

    def get_data(self):
        """Returns a JSON-compatible object that represents this Asset
        """
        return {
            "monikers": self.monikers,
            "color_set": self.color_set.get_data(),
            "unit": self.unit
            }
开发者ID:amidvidy,项目名称:ngcccbase,代码行数:58,代码来源:asset.py

示例6: setUp

 def setUp(self):
     self.colormap = MockColorMap()
     d = self.colormap.d
     self.colorset0 = ColorSet(self.colormap, [d[0]])
     self.colorset1 = ColorSet(self.colormap, [d[1]])
     self.main_p = '5Kb8kLf9zgWQnogidDA76MzPL6TsZZY36hWXMssSzNydYXYB9KF'
     self.main = LooseAddressRecord(address_data=self.main_p,
                                    color_set=self.colorset0,
                                    testnet=False)
     self.test_p = '91avARGdfge8E4tZfYLoxeJ5sGBdNJQH4kvjJoQFacbgyUY4Gk1'
     self.test = LooseAddressRecord(address_data=self.test_p,
                                    color_set=self.colorset1,
                                    testnet=True)
开发者ID:amidvidy,项目名称:ngcccbase,代码行数:13,代码来源:test_address.py

示例7: TestAddress

class TestAddress(unittest.TestCase):

    def setUp(self):
        self.colormap = MockColorMap()
        d = self.colormap.d
        self.colorset0 = ColorSet(self.colormap, [d[0]])
        self.colorset1 = ColorSet(self.colormap, [d[1]])
        self.main_p = '5Kb8kLf9zgWQnogidDA76MzPL6TsZZY36hWXMssSzNydYXYB9KF'
        self.main = LooseAddressRecord(address_data=self.main_p,
                                       color_set=self.colorset0,
                                       testnet=False)
        self.test_p = '91avARGdfge8E4tZfYLoxeJ5sGBdNJQH4kvjJoQFacbgyUY4Gk1'
        self.test = LooseAddressRecord(address_data=self.test_p,
                                       color_set=self.colorset1,
                                       testnet=True)


    def test_init(self):
        self.assertEqual(self.main.get_address(),
                         '1CC3X2gu58d6wXUWMffpuzN9JAfTUWu4Kj')
        self.assertEqual(self.test.get_address(),
                         'mo3oihY41iwPco1GKwehHPHmxMT4Ld5W3q')
        self.assertRaises(EncodingError, LooseAddressRecord,
                          address_data=self.main_p[:-2] + '88')
        self.assertRaises(EncodingError, LooseAddressRecord,
                          address_data=self.test_p[:-2] + '88',
                          testnet=True)
        self.assertRaises(InvalidAddressError, LooseAddressRecord,
                          address_data=self.main_p, testnet=True)
        self.assertRaises(InvalidAddressError, LooseAddressRecord,
                          address_data=self.test_p, testnet=False)

    def test_get_color_set(self):
        self.assertEqual(self.main.get_color_set().__repr__(),
                         self.colorset0.__repr__())

    def test_get_color_address(self):
        self.assertEqual(self.main.get_color_address(),
                         '1CC3X2gu58d6wXUWMffpuzN9JAfTUWu4Kj')
        self.assertEqual(self.test.get_color_address(),
                         '[email protected]')

    def test_get_data(self):
        self.assertEqual(self.main.get_data()['color_set'],
                         self.colorset0.get_data())
        self.assertEqual(self.main.get_data()['address_data'],
                         self.main_p)
        self.assertEqual(self.test.get_data()['color_set'],
                         self.colorset1.get_data())
        self.assertEqual(self.test.get_data()['address_data'],
                         self.test_p)
开发者ID:amidvidy,项目名称:ngcccbase,代码行数:51,代码来源:test_address.py

示例8: increment_max_index_for_color_set

 def increment_max_index_for_color_set(self, color_set):
     """Given a color <color_set>, record that there is one more
     new address for that color.
     """
     # TODO: speed up, cache(?)
     for color_set_st in self.color_set_states:
         color_desc_list = color_set_st['color_set']
         max_index = color_set_st['max_index']
         cur_color_set = ColorSet(self.colormap,
                                  color_desc_list)
         if cur_color_set.equals(color_set):
             max_index += 1
             color_set_st['max_index'] = max_index
             return max_index
     self.color_set_states.append({"color_set": color_set.get_data(),
                                   "max_index": 0})
     return 0
开发者ID:Andymeows,项目名称:ngcccbase,代码行数:17,代码来源:deterministic.py

示例9: make_etx_spec

 def make_etx_spec(self, our, their):
     fee = FEE if our.get_colordef() == UNCOLORED_MARKER else 0
     c_utxos, c_change = self.select_inputs(our + fee)
     inputs = {our.get_colordef(): 
               [utxo.get_outpoint() for utxo in c_utxos]}
     wam = self.model.get_address_manager()
     our_color_set = ColorSet.from_color_ids(self.model.get_color_map(),
                                             [our.get_color_id()]) 
     their_color_set = ColorSet.from_color_ids(self.model.get_color_map(),
                                               [their.get_color_id()]) 
     our_address = wam.get_change_address(their_color_set)
     targets = [ColorTarget(our_address.get_address(), their)]
     if c_change > 0:
         our_change_address = wam.get_change_address(our_color_set)
         targets.append(ColorTarget(our_change_address.get_address(),
                                    c_change))
     return ETxSpec(inputs, targets, c_utxos)
开发者ID:MattFaus,项目名称:ngcccbase,代码行数:17,代码来源:ewctrl.py

示例10: __init__

 def __init__(self, colormap, params):
     """Create an Asset for a color map <colormap> and configuration
     <params>. Note params has the color definitions used for this
     Asset.
     """
     self.monikers = params.get('monikers', [])
     self.color_set = ColorSet(colormap, params.get('color_set'))
     self.unit = int(params.get('unit', 1))
开发者ID:amidvidy,项目名称:ngcccbase,代码行数:8,代码来源:asset.py

示例11: get_asset_value_for_colorvalue

 def get_asset_value_for_colorvalue(self, colorvalue):
     colorset = ColorSet.from_color_ids(self.colormap, 
                                        [colorvalue.get_color_id()])
     asset = self.find_asset_by_color_set(colorset)
     if not asset:
         raise Exception('asset not found')
     return AdditiveAssetValue(asset=asset,
                               value=colorvalue.get_value())
开发者ID:foodiesgit,项目名称:ngcccbase,代码行数:8,代码来源:asset.py

示例12: prepare_targets

 def prepare_targets(self, etx_spec, their):
     self.targets = etx_spec.targets
     wam = self.model.get_address_manager()
     colormap = self.model.get_color_map()
     their_color_set = ColorSet.from_color_ids(self.model.get_color_map(),
                                               [their.get_color_id()]) 
     ct = ColorTarget(wam.get_change_address(their_color_set).get_address(),
                      their)
     self.targets.append(ct)
开发者ID:MattFaus,项目名称:ngcccbase,代码行数:9,代码来源:ewctrl.py

示例13: __init__

 def __init__(self, colormap, params):
     """Create an Asset for a color map <colormap> and configuration
     <params>. Note params has the color definitions used for this
     Asset.
     """
     self.colormap = colormap
     self.monikers = params.get('monikers', [])
     # currently only single-color assets are supported
     assert len(params.get('color_set')) == 1
     self.color_set = ColorSet(colormap, params.get('color_set'))
     self.unit = int(params.get('unit', 1))
开发者ID:F483,项目名称:ngcccbase,代码行数:11,代码来源:asset.py

示例14: setUp

    def setUp(self):
        self.colormap = MockColorMap()
        d = self.colormap.d
        self.colorset0 = ColorSet(self.colormap, [d[0]])
        self.colorset1 = ColorSet(self.colormap, [d[1], d[2]])
        self.colorset2 = ColorSet(self.colormap, [d[3]])
        self.def0 = {'monikers': ['bitcoin'],
                     'color_set': self.colorset0.get_data(),
                     'unit':100000000}
        self.def1 = {'monikers': ['test1'],
                     'color_set': self.colorset1.get_data(),
                     'unit':10}
        self.def2 = {'monikers': ['test2','test2alt'],
                     'color_set': self.colorset2.get_data(),
                     'unit':1}
        self.asset0 = AssetDefinition(self.colormap, self.def0)
        self.asset1 = AssetDefinition(self.colormap, self.def1)
        self.asset2 = AssetDefinition(self.colormap, self.def2)

        config = {'asset_definitions': [self.def1, self.def2]}
        self.adm = AssetDefinitionManager(self.colormap, config)
开发者ID:amidvidy,项目名称:ngcccbase,代码行数:21,代码来源:test_asset.py

示例15: setUp

 def setUp(self):
     self.colormap = MockColorMap()
     d = self.colormap.d
     self.colorset0 = ColorSet(self.colormap, [""])
     self.colorset1 = ColorSet(self.colormap, [d[1]])
     self.colorset2 = ColorSet(self.colormap, [d[2]])
     self.colorset3 = ColorSet(self.colormap, [d[1], d[2]])
     self.colorset4 = ColorSet(self.colormap, [d[3], d[2]])
     self.colorset5 = ColorSet(self.colormap, [d[3], d[1]])
     self.colorset6 = ColorSet(self.colormap, [])
开发者ID:shadowxxx,项目名称:ngcccbase,代码行数:10,代码来源:test_colorset.py


注:本文中的coloredcoinlib.ColorSet类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。