本文整理汇总了Python中armoryengine.BDM.TheBDM.execCleanShutdown方法的典型用法代码示例。如果您正苦于以下问题:Python TheBDM.execCleanShutdown方法的具体用法?Python TheBDM.execCleanShutdown怎么用?Python TheBDM.execCleanShutdown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类armoryengine.BDM.TheBDM
的用法示例。
在下文中一共展示了TheBDM.execCleanShutdown方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: distributeBtc
# 需要导入模块: from armoryengine.BDM import TheBDM [as 别名]
# 或者: from armoryengine.BDM.TheBDM import execCleanShutdown [as 别名]
def distributeBtc(masterWallet, amount, sendingAddrList):
pytx = None
setupTheBDM()
try:
recipValuePairs = []
utxoList = []
for sendingAddr in sendingAddrList:
addr160 = sendingAddr.getAddr160()
# Make sure the sending addresses are in the masterWallet
if not masterWallet.hasAddr(addr160):
raise WalletAddressError, 'Address is not in wallet! [%s]' % sendingAddr.getAddrStr()
utxoList.extend(masterWallet.getAddrTxOutList(addr160))
for importedAddr in masterWallet.getLinearAddrList():
if importedAddr.chainIndex<0:
recipValuePairs.append((importedAddr.getAddr160(),amount))
totalSpend = len(recipValuePairs)*amount
fee = calcMinSuggestedFees(utxoList, totalSpend, MIN_RELAY_TX_FEE, len(recipValuePairs))[1]
# Get the necessary utxo list
selectedUtxoList = PySelectCoins(utxoList, totalSpend, fee)
# get total value
totalAvailable = sum([u.getValue() for u in selectedUtxoList])
totalChange = totalAvailable - (totalSpend + fee)
# Make sure there are funds to cover the transaction.
if totalChange < 0:
print '***ERROR: you are trying to spend more than your balance!'
raise NegativeValueError
recipValuePairs.append((masterWallet.getNextUnusedAddress().getAddr160(), totalChange ))
# ACR: To support P2SH in general, had to change createFromTxOutSelection
# to take full scripts, not just hash160 values. Convert the list
# before passing it in
scrPairs = [[hash160_to_p2pkhash_script(r), v] for r,v in recipValuePairs]
txdp = PyTxDistProposal().createFromTxOutSelection(selectedUtxoList, scrPairs)
masterWallet.unlock(securePassphrase = SecureBinaryData(getpass('Enter your secret string:')))
# Sign and prepare the final transaction for broadcast
masterWallet.signTxDistProposal(txdp)
pytx = txdp.prepareFinalTx()
print '\nSigned transaction to be broadcast using Armory "offline transactions"...'
print txdp.serializeAscii()
finally:
TheBDM.execCleanShutdown()
return pytx