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


Python Tx.tx_outs_as_spendable方法代码示例

本文整理汇总了Python中pycoin.tx.Tx.Tx.tx_outs_as_spendable方法的典型用法代码示例。如果您正苦于以下问题:Python Tx.tx_outs_as_spendable方法的具体用法?Python Tx.tx_outs_as_spendable怎么用?Python Tx.tx_outs_as_spendable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pycoin.tx.Tx.Tx的用法示例。


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

示例1: multisig_M_of_N

# 需要导入模块: from pycoin.tx.Tx import Tx [as 别名]
# 或者: from pycoin.tx.Tx.Tx import tx_outs_as_spendable [as 别名]
 def multisig_M_of_N(self, M, N, unsigned_id, signed_id):
     keys = [Key(secret_exponent=i) for i in range(1, N+2)]
     tx_in = TxIn.coinbase_tx_in(script=b'')
     script = ScriptMultisig(m=M, sec_keys=[key.sec() for key in keys[:N]]).script()
     tx_out = TxOut(1000000, script)
     tx1 = Tx(version=1, txs_in=[tx_in], txs_out=[tx_out])
     tx2 = tx_utils.create_tx(tx1.tx_outs_as_spendable(), [keys[-1].address()])
     self.assertEqual(tx2.id(), unsigned_id)
     self.assertEqual(tx2.bad_signature_count(), 1)
     hash160_lookup = build_hash160_lookup(key.secret_exponent() for key in keys)
     tx2.sign(hash160_lookup=hash160_lookup)
     self.assertEqual(tx2.id(), signed_id)
     self.assertEqual(tx2.bad_signature_count(), 0)
开发者ID:onestarshang,项目名称:pycoin,代码行数:15,代码来源:pay_to_test.py

示例2: multisig_M_of_N_individually

# 需要导入模块: from pycoin.tx.Tx import Tx [as 别名]
# 或者: from pycoin.tx.Tx.Tx import tx_outs_as_spendable [as 别名]
 def multisig_M_of_N_individually(self, M, N):
     keys = [Key(secret_exponent=i) for i in range(1, N+2)]
     tx_in = TxIn.coinbase_tx_in(script=b'')
     script = ScriptMultisig(m=M, sec_keys=[key.sec() for key in keys[:N]]).script()
     tx_out = TxOut(1000000, script)
     tx1 = Tx(version=1, txs_in=[tx_in], txs_out=[tx_out])
     for partial_key_list in itertools.permutations(keys[:N], M):
         tx2 = create_tx(tx1.tx_outs_as_spendable(), [keys[-1].address()])
         for key in partial_key_list:
             self.assertEqual(tx2.bad_signature_count(), 1)
             hash160_lookup = build_hash160_lookup([key.secret_exponent()])
             tx2.sign(hash160_lookup=hash160_lookup)
         self.assertEqual(tx2.bad_signature_count(), 0)
开发者ID:onestarshang,项目名称:pycoin,代码行数:15,代码来源:multisig_individual_test.py

示例3: test_sign_pay_to_script_multisig

# 需要导入模块: from pycoin.tx.Tx import Tx [as 别名]
# 或者: from pycoin.tx.Tx.Tx import tx_outs_as_spendable [as 别名]
 def test_sign_pay_to_script_multisig(self):
     M, N = 3, 3
     keys = [Key(secret_exponent=i) for i in range(1, N+2)]
     tx_in = TxIn.coinbase_tx_in(script=b'')
     underlying_script = ScriptMultisig(m=M, sec_keys=[key.sec() for key in keys[:N]]).script()
     address = address_for_pay_to_script(underlying_script)
     self.assertEqual(address, "39qEwuwyb2cAX38MFtrNzvq3KV9hSNov3q")
     script = standard_tx_out_script(address)
     tx_out = TxOut(1000000, script)
     tx1 = Tx(version=1, txs_in=[tx_in], txs_out=[tx_out])
     tx2 = tx_utils.create_tx(tx1.tx_outs_as_spendable(), [address])
     hash160_lookup = build_hash160_lookup(key.secret_exponent() for key in keys[:N])
     p2sh_lookup = build_p2sh_lookup([underlying_script])
     tx2.sign(hash160_lookup=hash160_lookup, p2sh_lookup=p2sh_lookup)
     self.assertEqual(tx2.bad_signature_count(), 0)
开发者ID:onestarshang,项目名称:pycoin,代码行数:17,代码来源:pay_to_test.py

示例4: test_multisig_one_at_a_time

# 需要导入模块: from pycoin.tx.Tx import Tx [as 别名]
# 或者: from pycoin.tx.Tx.Tx import tx_outs_as_spendable [as 别名]
 def test_multisig_one_at_a_time(self):
     M = 3
     N = 3
     keys = [Key(secret_exponent=i) for i in range(1, N+2)]
     tx_in = TxIn.coinbase_tx_in(script=b'')
     script = ScriptMultisig(m=M, sec_keys=[key.sec() for key in keys[:N]]).script()
     tx_out = TxOut(1000000, script)
     tx1 = Tx(version=1, txs_in=[tx_in], txs_out=[tx_out])
     tx2 = tx_utils.create_tx(tx1.tx_outs_as_spendable(), [keys[-1].address()])
     ids = ["403e5bfc59e097bb197bf77a692d158dd3a4f7affb4a1fa41072dafe7bec7058",
            "5931d9995e83721243dca24772d7012afcd4378996a8b953c458175f15a544db",
            "9bb4421088190bbbb5b42a9eaa9baed7ec7574a407c25f71992ba56ca43d9c44",
            "03a1dc2a63f93a5cf5a7cb668658eb3fc2eda88c06dc287b85ba3e6aff751771"]
     for i in range(1, N+1):
         self.assertEqual(tx2.bad_signature_count(), 1)
         self.assertEqual(tx2.id(), ids[i-1])
         hash160_lookup = build_hash160_lookup(key.secret_exponent() for key in keys[i-1:i])
         tx2.sign(hash160_lookup=hash160_lookup)
         self.assertEqual(tx2.id(), ids[i])
     self.assertEqual(tx2.bad_signature_count(), 0)
开发者ID:onestarshang,项目名称:pycoin,代码行数:22,代码来源:pay_to_test.py


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