本文整理汇总了Python中transaction.Transaction.pay_script方法的典型用法代码示例。如果您正苦于以下问题:Python Transaction.pay_script方法的具体用法?Python Transaction.pay_script怎么用?Python Transaction.pay_script使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类transaction.Transaction
的用法示例。
在下文中一共展示了Transaction.pay_script方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: make_unsigned_request
# 需要导入模块: from transaction import Transaction [as 别名]
# 或者: from transaction.Transaction import pay_script [as 别名]
def make_unsigned_request(req):
from transaction import Transaction
addr = req['address']
time = req.get('time', 0)
exp = req.get('exp', 0)
if time and type(time) != int:
time = 0
if exp and type(exp) != int:
exp = 0
amount = req['amount']
if amount is None:
amount = 0
memo = req['memo']
script = Transaction.pay_script('address', addr).decode('hex')
outputs = [(script, amount)]
pd = pb2.PaymentDetails()
for script, amount in outputs:
pd.outputs.add(amount=amount, script=script)
pd.time = time
pd.expires = time + exp if exp else 0
pd.memo = memo
pr = pb2.PaymentRequest()
pr.serialized_payment_details = pd.SerializeToString()
pr.signature = ''
return pr
示例2: make_request
# 需要导入模块: from transaction import Transaction [as 别名]
# 或者: from transaction.Transaction import pay_script [as 别名]
def make_request(config, req):
from transaction import Transaction
addr = req['address']
time = req['timestamp']
amount = req['amount']
expiration = req['expiration']
message = req['memo']
script = Transaction.pay_script('address', addr).decode('hex')
outputs = [(script, amount)]
key_path = config.get('ssl_privkey')
cert_path = config.get('ssl_chain')
return make_payment_request(outputs, message, time, time + expiration if expiration else None, key_path, cert_path)
示例3: sweep
# 需要导入模块: from transaction import Transaction [as 别名]
# 或者: from transaction.Transaction import pay_script [as 别名]
def sweep(self, privkey, to_address, fee = 0.0001):
pubkey = public_key_from_private_key(privkey)
address = address_from_private_key(privkey)
pay_script = Transaction.pay_script(address)
unspent = self.network.synchronous_get([ ('blockchain.address.listunspent',[address])])[0]
if not unspent:
return
total = sum( map(lambda x:int(x.get('value')), unspent) ) - int(Decimal(fee)*100000000)
inputs = map(lambda i: {'prevout_hash': i['tx_hash'], 'prevout_n':i['tx_pos'], 'scriptPubKey':pay_script, 'redeemPubkey':pubkey}, unspent)
outputs = [(to_address, total)]
tx = Transaction.from_io(inputs, outputs)
tx.sign({ pubkey:privkey })
return tx
示例4: make_unsigned_request
# 需要导入模块: from transaction import Transaction [as 别名]
# 或者: from transaction.Transaction import pay_script [as 别名]
def make_unsigned_request(req):
from transaction import Transaction
addr = req['address']
time = req['timestamp']
amount = req['amount']
if amount is None:
amount = 0
expires = req['expiration']
memo = req['memo']
script = Transaction.pay_script('address', addr).decode('hex')
outputs = [(script, amount)]
pd = pb2.PaymentDetails()
for script, amount in outputs:
pd.outputs.add(amount=amount, script=script)
pd.time = time
pd.expires = time + expires if expires else 0
pd.memo = memo
pr = pb2.PaymentRequest()
pr.serialized_payment_details = pd.SerializeToString()
pr.signature = ''
return pr