def parse_send_amount(self, input_send_amount, btcusd_spot):
     if '$' in input_send_amount:
         if btcusd_spot <= 0.0:
             raise Exception('Unable to get exchange rate for local currency. Please specify amount in BTC instead.')
         usd_send_amount = float(input_send_amount.replace('$', ''))
         btc_send_amount = (1.0*usd_send_amount) / btcusd_spot
         sat_send_amount = core.btc_to_satoshi(btc_send_amount)
         btc_send_amount = core.satoshi_to_btc(sat_send_amount)
     else:
         btc_send_amount = float(input_send_amount)
         sat_send_amount = core.btc_to_satoshi(btc_send_amount)
         btc_send_amount = core.satoshi_to_btc(sat_send_amount)
         usd_send_amount = btc_send_amount*btcusd_spot
     
     return btc_send_amount, usd_send_amount
    def sign_tx(self, pw):
        if not self.is_wallet_loaded:
            raise Exception('Tried to spend when wallet not loaded.')

        if not self.is_dest_addr_set:
            raise Exception('Tried to spend when destination address not set.')

        if not self.is_send_amount_set:
            raise Exception('Tried to spend when amount not set.')
        
        if self.send_amount + self.txfee > self.balance:
            raise LowBalanceError("Insufficient funds to send {0} + {1} BTC.".format(core.satoshi_to_btc(self.send_amount), core.satoshi_to_btc(self.txfee)))
            
        try:
            prv = wallet.decrypt_privkey(self.encr_privkey, pw)
            addr = bc.privtoaddr(prv, self.magic_byte)
        except:
            raise PasswordError("Wrong password!")
        
        if addr != self.addr:
            raise Exception('Address from wallet does not match address from private key!')

        tx_ins, tx_outs = core.simple_tx_inputs_outputs(self.addr, self.unspent, self.dest_addr, self.send_amount, self.txfee)
        
        # Make transaction
        tx = bc.mktx(tx_ins, tx_outs)
        
        # Sign transaction
        for i in range(len(tx_ins)):
            tx = bc.sign(tx,i,prv)
        
        return tx_ins, tx_outs, tx, bc.deserialize(tx)
 def get_txfee(self):
     return core.satoshi_to_btc(self.txfee)
 def get_balance(self):
     if not self.is_wallet_loaded:
         raise Exception('Tried getting balance when wallet not loaded.')
             
     return core.satoshi_to_btc(self.balance)