(self, bid=None)
return r.json()
Bump the order

        Args:
            bid : New bid in msats. If not defined, prompt user.

        Returns:
            Dictionary with order metadata
Bump the order
Bump the order
def bump(self, bid=None):
        """Bump the order

        Args:
            bid : New bid in msats. If not defined, prompt user.

        Returns:
            Dictionary with order metadata

        """
        if (not self.order):
            self._fetch()

        if (self.order["status"] == "transmitting"):
            raise ValueError("Cannot bump order - already in transmission")

        if (self.order["status"] == "sent"
                or self.order["status"] == "received"):
            raise ValueError("Cannot bump order - already transmitted")

        if (self.order["status"] == "cancelled"
                or self.order["status"] == "expired"):
            raise ValueError("Order already {}".format(self.order["status"]))

        if (self.order["unpaid_bid"] > 0):
            unpaid_bid_msg = "(%d msat paid, %d msat unpaid)" % (
                self.order["bid"], self.order["unpaid_bid"])
        else:
            unpaid_bid_msg = ""

        previous_bid = self.order["bid"] + self.order["unpaid_bid"]
        tx_len = pkt.calc_ota_msg_len(self.order["message_size"])

        logger.info("Previous bid was {:d} msat for {:d} bytes {}".format(
            previous_bid, tx_len, unpaid_bid_msg))

        logger.info("Paid bid ratio is currently {:.2f} msat/byte".format(
            self.order["bid_per_byte"]))
        logger.info("Total (paid + unpaid) bid ratio is currently {:.2f} "
                    "msat/byte".format(float(previous_bid) / tx_len))

        if (bid is None):
            # Ask for new bid
            bid = bidding.ask_bid(tx_len, previous_bid)

        assert (isinstance(bid, int))

        # Post bump request
        r = requests.post(self.server + '/order/' + self.uuid + "/bump",
                          data={
                              'bid_increase': bid - previous_bid,
                              'auth_token': self.auth_token
                          },
                          cert=(self.tls_cert, self.tls_key))

        if (r.status_code != requests.codes.ok):
            self._print_errors(r)

        r.raise_for_status()

        # Print the response
        logger.info("Order bumped successfully\n")

        print("--\nNew Lightning Invoice Number:\n%s\n" %
              (r.json()["lightning_invoice"]["payreq"]))
        print("--\nNew Amount Due:\n%s millisatoshis\n" %
              (r.json()["lightning_invoice"]["msatoshi"]))

        logger.debug("API Response:")
        logger.debug(json.dumps(r.json(), indent=4, sort_keys=True))

        return r.json()
def bump ( self , bid = None ) : if ( not self . order ) : self . _fetch ( ) if ( self . order [ "status" ] == "transmitting" ) : raise ValueError ( "Cannot bump order - already in transmission" ) if ( self . order [ "status" ] == "sent" or self . order [ "status" ] == "received" ) : raise ValueError ( "Cannot bump order - already transmitted" ) if ( self . order [ "status" ] == "cancelled" or self . order [ "status" ] == "expired" ) : raise ValueError ( "Order already {}" . format ( self . order [ "status" ] ) ) if ( self . order [ "unpaid_bid" ] > 0 ) : unpaid_bid_msg = "(%d msat paid, %d msat unpaid)" % ( self . order [ "bid" ] , self . order [ "unpaid_bid" ] ) else : unpaid_bid_msg = "" previous_bid = self . order [ "bid" ] + self . order [ "unpaid_bid" ] tx_len = pkt . calc_ota_msg_len ( self . order [ "message_size" ] ) logger . info ( "Previous bid was {:d} msat for {:d} bytes {}" . format ( previous_bid , tx_len , unpaid_bid_msg ) ) logger . info ( "Paid bid ratio is currently {:.2f} msat/byte" . format ( self . order [ "bid_per_byte" ] ) ) logger . info ( "Total (paid + unpaid) bid ratio is currently {:.2f} " "msat/byte" . format ( float ( previous_bid ) / tx_len ) ) if ( bid is None ) : # Ask for new bid bid = bidding . ask_bid ( tx_len , previous_bid ) assert ( isinstance ( bid , int ) ) # Post bump request r = requests . post ( self . server + '/order/' + self . uuid + "/bump" , data = { 'bid_increase' : bid - previous_bid , 'auth_token' : self . auth_token } , cert = ( self . tls_cert , self . tls_key ) ) if ( r . status_code != requests . codes . ok ) : self . _print_errors ( r ) r . raise_for_status ( ) # Print the response logger . info ( "Order bumped successfully\n" ) print ( "--\nNew Lightning Invoice Number:\n%s\n" % ( r . json ( ) [ "lightning_invoice" ] [ "payreq" ] ) ) print ( "--\nNew Amount Due:\n%s millisatoshis\n" % ( r . json ( ) [ "lightning_invoice" ] [ "msatoshi" ] ) ) logger . debug ( "API Response:" ) logger . debug ( json . dumps ( r . json ( ) , indent = 4 , sort_keys = True ) ) return r . json ( )