def get_connection(self): if self._conn is None: self._conn = make_rpc_connection() if settings.DEBUG: logger.info("monapay makes a connection(total balance={0})".format(self._conn.getbalance())) return self._conn else: return self._conn
def handle(self, *args, **kwargs): conn = make_rpc_connection() info = conn.getinfo() print( info_str.format(info.connections, info.errors, info.blocks, info.paytxfee, info.keypoololdest, info.walletversion, info.difficulty, info.testnet, info.version, info.proxy, info.protocolversion, info.timeoffset, info.balance, info.mininput, info.keypoolsize))
def clean_admin_address(self): # check the connection address = self.cleaned_data["admin_address"] try: conn = make_rpc_connection() result = conn.validateaddress(address) if result.isvalid: return address else: raise forms.ValidationError(_("Invalid address specified.")) except socket.error, msg: logger.error("RPC connection refused.") raise forms.ValidationError(_("Internal server error occurred. Please try it again after a few hours."))
def clean(self): try: conn = make_rpc_connection() minconf = get_minconf(self.item.data.natural_price()) received = conn.getreceivedbyaddress( self.wallet.address, minconf=minconf) if received == 0.0: raise forms.ValidationError( _('It seems that your transaction does not spread an entire network.' \ ' Please click "Confirm Payment" button after a few minutes' \ ' ({minconf} confirmations are required).').format(minconf=minconf)) elif received < self.item.data.natural_price(): balance = (self.item.data.natural_price() - received).normalize() error_text = _("{0:f} MONA is required to purchase this product.") raise forms.ValidationError(error_text.format(balance)) return super(PaymentForm, self).clean() except socket.error, msg: logger.error("RPC connection refused.") raise forms.ValidationError(_("Internal server error occurred. Please try it again after a few hours."))
def handle(self, *args, **kwargs): conn = make_rpc_connection() balance = conn.listaccounts(as_dict=True) for key, value in balance.items(): name = u"{empty}" if key == u"" else key print("{0}: {1}".format(name, value))
def handle(self, *args, **kwargs): from_account = args[0] to_account = args[1] amount = float(args[2]) conn = make_rpc_connection() conn.move(from_account, to_account, amount)