本文整理汇总了Python中armoryengine.BDM.TheBDM类的典型用法代码示例。如果您正苦于以下问题:Python TheBDM类的具体用法?Python TheBDM怎么用?Python TheBDM使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TheBDM类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
def setUp(self):
self.verifyBlockHeight()
# Load the primary file from the test net in a box
self.fileA = os.path.join(self.tiab.tiabDirectory, 'tiab\\armory\\armory_%s_.wallet' % TEST_WALLET_ID)
self.wlt = PyBtcWallet().readWalletFile(self.fileA, doScanNow=True)
self.jsonServer = Armory_Json_Rpc_Server(self.wlt)
TheBDM.registerWallet(self.wlt)
示例2: stopBitcoind
def stopBitcoind(self):
LOGINFO('Called stopBitcoind')
if self.bitcoind == False:
self.bitcoind = None
return
try:
if not self.isRunningBitcoind():
LOGINFO('...but bitcoind is not running, to be able to stop')
return
from armoryengine.BDM import TheBDM
cookie = TheBDM.getCookie()
TheBDM.bdv().shutdownNode(cookie);
#poll the pid until it's gone, for as long as 2 minutes
total = 0
while self.bitcoind.poll()==None:
time.sleep(0.1)
total += 1
if total > 1200:
LOGERROR("bitcoind failed to shutdown in less than 2 minutes."
" Terminating.")
return
self.bitcoind = None
except Exception as e:
LOGERROR(e)
return
示例3: setUpClass
def setUpClass(self):
# This is not a UI so no need to worry about the main thread being blocked.
# Any UI that uses this Daemon can put the call to the Daemon on it's own thread.
TheBDM.setBlocking(True)
TheBDM.setOnlineMode(True)
while not TheBDM.getBDMState()=='BlockchainReady':
time.sleep(2)
示例4: createNewWalletFromWizard
def createNewWalletFromWizard(self):
self.newWallet = PyBtcWallet().createNewWallet( \
securePassphrase=self.setPassphrasePage.pageFrame.getPassphrase(), \
kdfTargSec=self.walletCreationPage.pageFrame.getKdfSec(), \
kdfMaxMem=self.walletCreationPage.pageFrame.getKdfBytes(), \
shortLabel=self.walletCreationPage.pageFrame.getName(), \
longLabel=self.walletCreationPage.pageFrame.getDescription(), \
doRegisterWithBDM=False, \
extraEntropy=self.main.getExtraEntropyForKeyGen())
self.newWallet.unlock(securePassphrase=
SecureBinaryData(self.setPassphrasePage.pageFrame.getPassphrase()))
# We always want to fill the address pool, right away.
fillPoolProgress = DlgProgress(self, self.main, HBar=1, \
Title="Creating Wallet")
fillPoolProgress.exec_(self.newWallet.fillAddressPool, doRegister=False,
Progress=fillPoolProgress.UpdateHBar)
# Reopening from file helps make sure everything is correct -- don't
# let the user use a wallet that triggers errors on reading it
wltpath = self.newWallet.walletPath
walletFromDisk = PyBtcWallet().readWalletFile(wltpath)
self.main.addWalletToApplication(walletFromDisk, walletIsNew=True)
if TheBDM.getBDMState() in ('Uninitialized', 'Offline'):
TheBDM.registerWallet(walletFromDisk, isFresh=True, wait=False)
else:
self.main.newWalletList.append([walletFromDisk, True])
示例5: setUp
def setUp(self):
self.verifyBlockHeight()
self.fileA = os.path.join(self.armoryHomeDir, 'armory_%s_.wallet' % TEST_WALLET_ID)
self.fileB = os.path.join(self.armoryHomeDir, 'armory_%s_backup.wallet' % TEST_WALLET_ID)
self.fileAupd = os.path.join(self.armoryHomeDir, 'armory_%s_backup_unsuccessful.wallet' % TEST_WALLET_ID)
self.fileBupd = os.path.join(self.armoryHomeDir, 'armory_%s_update_unsuccessful.wallet' % TEST_WALLET_ID)
self.removeFileList([self.fileA, self.fileB, self.fileAupd, self.fileBupd])
# We need a controlled test, so we script the all the normally-random stuff
self.privKey = SecureBinaryData('\xaa'*32)
self.privKey2 = SecureBinaryData('\x33'*32)
self.chainstr = SecureBinaryData('\xee'*32)
theIV = SecureBinaryData(hex_to_binary('77'*16))
self.passphrase = SecureBinaryData('A self.passphrase')
self.passphrase2 = SecureBinaryData('A new self.passphrase')
self.wallet = PyBtcWallet().createNewWallet(withEncrypt=False, \
plainRootKey=self.privKey, \
chaincode=self.chainstr, \
IV=theIV, \
shortLabel=TEST_WALLET_NAME, \
longLabel=TEST_WALLET_DESCRIPTION,
armoryHomeDir = self.armoryHomeDir)
self.jsonServer = Armory_Json_Rpc_Server(self.wallet)
TheBDM.registerWallet(self.wallet)
示例6: distributeBtc
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
示例7: setupTheBDM
def setupTheBDM():
TheBDM.setBlocking(True)
if not TheBDM.isInitialized():
TheBDM.registerWallet(masterWallet)
TheBDM.setOnlineMode(True)
# Only executed on the first call if blockchain not loaded yet.
LOGINFO('Blockchain loading')
while not TheBDM.getBDMState()=='BlockchainReady':
LOGINFO('Blockchain Not Ready Yet %s' % TheBDM.getBDMState())
time.sleep(2)
示例8: __init__
def __init__(self, parent, main):
super(WalletWizard, self).__init__(parent, main)
self.newWallet = None
self.isBackupCreated = False
self.setWindowTitle(tr("Wallet Creation Wizard"))
self.setOption(QWizard.HaveFinishButtonOnEarlyPages, on=True)
self.setOption(QWizard.IgnoreSubTitles, on=True)
# Page 1: Create Wallet
self.walletCreationPage = WalletCreationPage(self)
self.addPage(self.walletCreationPage)
# Page 2: Set Passphrase
self.setPassphrasePage = SetPassphrasePage(self)
self.addPage(self.setPassphrasePage)
# Page 3: Verify Passphrase
self.verifyPassphrasePage = VerifyPassphrasePage(self)
self.addPage(self.verifyPassphrasePage)
# Page 4: Create Paper Backup
self.walletBackupPage = WalletBackupPage(self)
self.addPage(self.walletBackupPage)
# Page 5: Create Watching Only Wallet -- but only if expert, or offline
self.hasCWOWPage = False
if self.main.usermode == USERMODE.Expert or TheBDM.getState() == BDM_OFFLINE:
self.hasCWOWPage = True
self.createWOWPage = CreateWatchingOnlyWalletPage(self)
self.addPage(self.createWOWPage)
self.setButtonLayout([QWizard.BackButton, QWizard.Stretch, QWizard.NextButton, QWizard.FinishButton])
示例9: updateOnCoinControl
def updateOnCoinControl(self):
useAllAddr = (self.altBalance == None)
wlt = self.main.walletMap[self.getSelectedWltID()]
fullBal = wlt.getBalance('Spendable')
if useAllAddr:
self.dispID.setText(wlt.uniqueIDB58)
self.dispName.setText(wlt.labelName)
self.dispDescr.setText(wlt.labelDescr)
if fullBal == 0:
self.dispBal.setText('0.0', color='TextRed', bold=True)
else:
self.dispBal.setValueText(fullBal, wBold=True)
else:
self.dispID.setText(wlt.uniqueIDB58 + '*')
self.dispName.setText(wlt.labelName + '*')
self.dispDescr.setText('*Coin Control Subset*', color='TextBlue', bold=True)
self.dispBal.setText(coin2str(self.altBalance, maxZeros=0), color='TextBlue')
rawValTxt = str(self.dispBal.text())
self.dispBal.setText(rawValTxt + ' <font color="%s">(of %s)</font>' % \
(htmlColor('DisableFG'), coin2str(fullBal, maxZeros=0)))
if not TheBDM.getState() == BDM_BLOCKCHAIN_READY:
self.dispBal.setText('(available when online)', color='DisableFG')
self.repaint()
if self.coinControlCallback:
self.coinControlCallback(self.sourceAddrList, self.altBalance)
示例10: searchItem
def searchItem():
searchString = str(self.searchEntry.text())
if len(searchString) > 0:
likelyDataType = isLikelyDataType(searchString)
for wltID, wlt in self.main.walletMap.iteritems():
if wlt.hasAddr(searchString):
searchHash = searchString if likelyDataType == DATATYPE.Hex \
else addrStr_to_hash160(searchString)[1]
dialog = DlgAddressInfo(wlt, searchHash, main=self.main)
dialog.exec_()
break
if likelyDataType == DATATYPE.Hex:
walletLedger = wlt.cppWallet.getTxLedger()
txHashToFind = hex_to_binary(searchString, endOut=BIGENDIAN)
txFound = False
for entry in walletLedger:
if entry.getTxHash() == txHashToFind:
cppTx = TheBDM.getTxByHash(txHashToFind)
serializedCppTx = cppTx.serialize()
pytx = PyTx().unserialize(serializedCppTx)
DlgDispTxInfo(pytx, wlt, self.main, self.main).exec_()
txFound = True
break
if txFound:
break
示例11: distributeBtc
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
示例12: getTxFee
def getTxFee(tx):
btcIn, btcOut = 0,0
for i in range(tx.getNumTxIn()):
btcIn += TheBDM.getSentValue(tx.getTxIn(i))
for i in range(tx.getNumTxOut()):
btcOut += tx.getTxOut(i).getValue()
return (btcIn - btcOut)
示例13: tearDownClass
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()
示例14: setUpClass
def setUpClass(self):
global doneShuttingDownBDM
doneShuttingDownBDM = False
# Handle both calling the this test from the context of the test directory
# and calling this test from the context of the main directory.
# The latter happens if you run all of the tests in the directory
if os.path.exists(TIAB_ZIPFILE_NAME):
tiabZipPath = TIAB_ZIPFILE_NAME
elif os.path.exists(os.path.join('pytest',TIAB_ZIPFILE_NAME)):
tiabZipPath = (os.path.join('pytest',TIAB_ZIPFILE_NAME))
else:
self.fail(NEED_TIAB_MSG)
self.tiab = TiabSession(tiabZipPath=tiabZipPath)
newTheBDM()
self.armoryHomeDir = os.path.join(self.tiab.tiabDirectory,'tiab','armory')
TheBDM.setSatoshiDir(os.path.join(self.tiab.tiabDirectory,'tiab','1','testnet3'))
TheBDM.setArmoryDBDir(os.path.join(self.tiab.tiabDirectory,'tiab','armory','databases'))
TheBDM.goOnline(armoryDBDir=self.armoryHomeDir)
i = 0
while not TheBDM.getState()==BDM_BLOCKCHAIN_READY:
time.sleep(2)
i += 1
if i >= 60:
raise RuntimeError("Timeout waiting for TheBDM to get into BlockchainReady state.")
示例15: setUp
def setUp(self):
self.verifyBlockHeight()
# Load the primary file from the test net in a box
self.fileA = os.path.join(self.tiab.tiabDirectory, 'tiab', 'armory', \
'armory_%s_.wallet' % FIRST_WLT_NAME)
self.wltA = PyBtcWallet().readWalletFile(self.fileA, doScanNow=True)
self.fileB = os.path.join(self.tiab.tiabDirectory, 'tiab', 'armory', \
'armory_%s_.wallet' % SECOND_WLT_NAME)
self.wltB = PyBtcWallet().readWalletFile(self.fileB, doScanNow=True)
self.fileC = os.path.join(self.tiab.tiabDirectory, 'tiab', 'armory', \
'armory_%s_.wallet' % THIRD_WLT_NAME)
self.wltC = PyBtcWallet().readWalletFile(self.fileC, doScanNow=True)
self.jsonServer = Armory_Json_Rpc_Server(self.wltA, \
inWltMap={SECOND_WLT_NAME : self.wltB, \
THIRD_WLT_NAME : self.wltC}, \
armoryHomeDir=os.path.join(self.tiab.tiabDirectory, \
'tiab','armory'))
TheBDM.registerWallet(self.wltA)