本文整理汇总了Python中armoryengine.BDM.TheBDM.beginCleanShutdown方法的典型用法代码示例。如果您正苦于以下问题:Python TheBDM.beginCleanShutdown方法的具体用法?Python TheBDM.beginCleanShutdown怎么用?Python TheBDM.beginCleanShutdown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类armoryengine.BDM.TheBDM
的用法示例。
在下文中一共展示了TheBDM.beginCleanShutdown方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: distributeBtc
# 需要导入模块: from armoryengine.BDM import TheBDM [as 别名]
# 或者: from armoryengine.BDM.TheBDM import beginCleanShutdown [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))
# 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]
# we're providing a key map for the inputs.
pubKeyMap = {}
for utxo in selectedUtxoList:
scrType = getTxOutScriptType(utxo.getScript())
if scrType in CPP_TXOUT_STDSINGLESIG:
scrAddr = utxo.getRecipientScrAddr()
a160 = scrAddr_to_hash160(scrAddr)[1]
addrObj = masterWallet.getAddrByHash160(a160)
if addrObj:
pubKeyMap[scrAddr] = addrObj.binPublicKey65.toBinStr()
ustx = UnsignedTransaction().createFromTxOutSelection(selectedUtxoList, scrPairs, pubKeyMap)
masterWallet.unlock(securePassphrase = SecureBinaryData(getpass('Enter your secret string:')))
# Sign and prepare the final transaction for broadcast
masterWallet.signUnsignedTx(ustx)
pytx = ustx.getPyTxSignedIfPossible()
print '\nSigned transaction to be broadcast using Armory "offline transactions"...'
print ustx.serializeAscii()
finally:
TheBDM.beginCleanShutdown()
return pytx
示例2: tearDownClass
# 需要导入模块: from armoryengine.BDM import TheBDM [as 别名]
# 或者: from armoryengine.BDM.TheBDM import beginCleanShutdown [as 别名]
def tearDownClass(self):
def tiabBDMShutdownCallback(action, arg):
global doneShuttingDownBDM
if action == STOPPED_ACTION:
doneShuttingDownBDM = True
TheBDM.registerCppNotification(tiabBDMShutdownCallback)
TheBDM.beginCleanShutdown()
i = 0
while not doneShuttingDownBDM:
time.sleep(0.5)
i += 1
if i >= 40:
raise RuntimeError("Timeout waiting for TheBDM to shutdown.")
self.tiab.clean()