Ejemplo n.º 1
0
 def get(self, callback = None):
     accounts = []
     # Account Types
     standard = []
     multisig = []
     atomicswap = []
     for account in Accounts.getAccounts():
         confirmedBalance = Accounts.getConfirmedBalanceByAddress(account.address)
         confirmedBalance = Units.toValue(confirmedBalance)
         confirmedBalance = DataType.asFloat(confirmedBalance)
         address = Address.to0xAddress(account.address)
         accountInfo = {
             'address': address,
             'type': account.type,
             'balance': confirmedBalance
         }
         if account.type == AccountType.STANDARD:
             standard.append(accountInfo)
         elif account.type == AccountType.MULTISIGNATURE:
             multisig.append(accountInfo)
         elif account.type == AccountType.ATOMIC_SWAP:
             atomicswap.append(accountInfo)
     accounts.extend(standard)
     accounts.extend(multisig)
     accounts.extend(atomicswap)
     callback(
         JSONRPC.createResultObject(accounts, self.id)
     )
Ejemplo n.º 2
0
 def add(self, callback = None):
     account = CoreAccount()
     Accounts.addAccount(account)
     address = Address.to0xAddress(account.address)
     callback(
         JSONRPC.createResultObject(address, self.id)
     )
Ejemplo n.º 3
0
 def get(self, callback = None):
     sidechains = []
     for sidechain in Sidechains.getSidechains():
         address = Address.to0xAddress(sidechain.address)
         sidechains.append({
             'address': address
         })
     callback(
         JSONRPC.createResultObject(sidechains, self.id)
     )
Ejemplo n.º 4
0
    def __init__(self, blockchain, account, enabled):
        Thread.__init__(self,
                        name=Address.to0xAddress(account.address),
                        daemon=True)
        self.blockchain = blockchain
        self.account = account
        self.enabled = enabled

        self.blkValidator = ValidatorFactory.getInstance(ValidatorType.BLOCK)
        self.MINING_KEY = 'MINING'
Ejemplo n.º 5
0
 def createNewMultiSigAccountType(self, accountType, privateKey, callback = None):
     multiSigAddressBytes = bytearray()
     for publicKey in self.publicKeys:
         multiSigAddressBytes.extend(publicKey)
     multiSigAddress = Crypto.generateAddress(multiSigAddressBytes)
     account = CoreAccount(multiSigAddress, self.publicKeys, privateKey, accountType)
     Accounts.addAccount(account)
     multiSigAddress = Address.to0xAddress(multiSigAddress)
     callback(
         JSONRPC.createResultObject(multiSigAddress, self.id)
     )
Ejemplo n.º 6
0
 def get(self, callback=None):
     contracts = []
     for contract in Contracts.getContracts():
         confirmedBalance = 0
         unspentTransactionScript = UXTO.getUnspentTransactionScript(
             contract.address)
         if unspentTransactionScript != None:
             txOut = unspentTransactionScript.output
             confirmedBalance = txOut.value
         confirmedBalance = Units.toValue(confirmedBalance)
         confirmedBalance = DataType.asFloat(confirmedBalance)
         address = Address.to0xAddress(contract.address)
         contracts.append({'address': address, 'balance': confirmedBalance})
     callback(JSONRPC.createResultObject(contracts, self.id))