A method for selecting digital currency from a hardware wallet and a hardware wallet
By arranging and judging the available amount of digital currency in the hardware wallet, selecting digital currency that does not contain or contains a small amount of payment data links, calculating its transaction time, and adjusting the combination to meet the preset time, solving the slow transaction process in offline transactions Problem, improving transaction efficiency.
Patent Information
- Application Number
- CN202110008634.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-01-05
- Publication Date
- 2024-12-17
- Estimated Expiration
- 2041-01-05
AI Technical Summary
During offline transactions of digital currencies, due to the large amount of data in the payment data link, the transaction process becomes slower, and it is difficult for the prior art to design a combination method to obtain optimal performance.
By obtaining the payment amount, the stored digital currency is judged and selected from the available amount from large to small, or the digital currency with the least payment data link, and calculate its transaction time. If the preset time is exceeded, Adjust the selected digital currency combination to determine the optimal digital currency combination with the smallest available amount to ensure that the transaction time is within the preset range.
It effectively avoids the long transaction time and low transaction efficiency caused by the large payment data links in offline state, and improves the user's experience of using hardware wallets.
Smart Images

Figure CN112633876B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of electronic technology, and in particular to a hardware wallet digital currency selection method and a hardware wallet. Background Art
[0002] In the existing digital currency transaction process, in the offline transaction process, due to the inability to settle in real time online, a payment data chain will be generated. In the digital currency transaction process with a payment data chain, due to the large amount of data, it is easy to cause the transaction process to slow down. For different transaction amounts, the payer's hardware wallet needs to combine and withdraw the corresponding amount of digital currency. Under different combinations, the corresponding time for transmission, calculation, and verification is not the same. How to design a combination of digital currency payments so that the transaction process can achieve optimal performance has become an urgent problem to be solved. Summary of the invention
[0003] The present invention aims to solve the above-mentioned problems.
[0004] The main purpose of the present invention is to provide a method for selecting digital currency in a hardware wallet.
[0005] Another object of the present invention is to provide a hardware wallet.
[0006] To achieve the above object, the technical solution of the present invention is specifically implemented as follows:
[0007] On one hand, the present invention provides a method for selecting digital currency of a hardware wallet, comprising: S1, obtaining a payment amount; S2, arranging the stored digital currencies from large to small according to the available amount, wherein the digital currency comprises: an initial digital currency; and / or the digital currency comprises: an initial digital currency and at least one payment data chain; S3, judging whether there is at least one digital currency with an available amount greater than or equal to the payment amount, if so, executing step S4, if not, executing step S9; S4, obtaining all digital currencies greater than or equal to the payment amount, judging whether each digital currency in all digital currencies contains a payment data chain, if there is a digital currency that does not contain a payment data chain, executing S5, if there is no digital currency that does not contain a payment data chain, executing S6, if there is no digital currency that does not contain a payment data chain, executing S7, if there is no digital currency that does not contain a payment data chain, executing S8, if there is no digital currency that does not contain a payment data chain, executing S9 ...10, if there is no digital currency that does not contain a payment data chain, executing S11, if there is no digital currency that does not contain a payment data chain, executing S12, if there is no digital currency that does not contain a payment data chain, executing S13, if there is no digital currency that does not contain a payment data chain, executing S14, if there is no digital currency that does not contain a payment data chain, executing S15, if there is no digital currency that does not contain a payment data chain, executing S16, if there is no digital currency that does not contain a payment data chain, executing S17, if there is no digital currency that does not contain a payment data chain, executing S18, if there is no digital currency that does not contain a payment data chain, executing S19, if there is no digital currency If there is a digital currency with a data link, execute S6S5 to obtain a digital currency that does not contain a payment data link, and execute S7; S6, obtain a digital currency with the least payment data link, and execute S7; S7, the number of selected digital currencies is determined to be one, a digital currency with an available amount closest to the payment amount is determined, and the transaction time of the digital currency with an available amount closest to the payment amount is calculated, where the transaction time includes: the sum of the time spent on transmitting the digital currency with an available amount closest to the payment amount, the time spent on signing the digital currency with an available amount closest to the payment amount, and the time spent on the peer device verifying the signature of the digital currency with an available amount closest to the payment amount; S8, determine whether the transaction time of the digital currency with an available amount closest to the payment amount is large or small. At the preset time, if it is greater than the preset time, execute S9, if it is not greater than the preset time, execute S20; S9, select digital currency from the remaining digital currencies; S10, add one to the number of selected digital currencies, and arrange the remaining digital currencies from large to small; S11, select the digital currency combination with the smallest available amount, and determine whether the digital currency combination with the smallest available amount is greater than or equal to the payment amount. If the digital currency combination with the smallest available amount is less than the payment amount, execute step S12. If the digital currency combination with the smallest available amount is greater than or equal to the payment amount, execute S14; S12, determine whether there is any remaining currency. If there is any remaining currency, execute S13. If there is no remaining currency and the number of selected digital currencies is less than the payment amount, execute S14; If the amount of digital currency selected is less than the total amount of digital currency in the hardware wallet, execute S10. If there is no remaining currency and the amount of digital currency selected is equal to the total amount of digital currency in the hardware wallet, execute S22. S13: remove the digital currency with the smallest available amount and return to execute S11. S14: obtain the digital currency with the most payment data chains. S15: calculate the transaction time of the digital currency with the most payment data chains. S16: determine whether the transaction time of the digital currency with the most payment data chains is greater than the preset time. If the transaction time of the digital currency with the most payment data chains is greater than the preset time, return to execute S10. If the transaction time of the digital currency with the most payment data chains is less than or equal to the preset time, execute S17.S17, determine the optimal digital currency combination with the smallest available amount, and calculate the transaction time of the optimal digital currency combination with the smallest available amount; S18, if there is a digital currency with the closest available amount to the payment amount, determine whether the transaction time of the optimal digital currency combination with the smallest available amount is greater than the transaction time of the digital currency with the closest available amount to the payment amount. If the transaction time of the optimal digital currency combination with the smallest available amount is greater than the transaction time of the digital currency with the closest available amount to the payment amount, return to execute S20; if the transaction time of the digital currency combination with the smallest available amount is not greater than the transaction time of the digital currency with the closest available amount to the payment amount, execute S19; if there is no digital currency with the closest available amount to the payment amount, execute S19; S19, take the optimal digital currency combination with the smallest available amount as the digital currency to be output, and execute S21; S20, take the digital currency with the closest available amount to the payment amount as the digital currency to be output, and execute S21; S21, output the digital currency to be output; S22, end the process. ;
[0008] In addition, after the number of selected digital currencies is increased by one and the remaining digital currencies are arranged from large to small, before selecting the digital currency combination with the smallest available amount, it also includes: judging whether the available amount of all digital currencies is greater than or equal to the payment amount, and if it is judged that the available amount of all digital currencies is greater than or equal to the payment amount, executing the step of selecting the digital currency combination with the smallest available amount.
[0009] In addition, before obtaining the payment amount, it also includes: setting basic information parameters, where the basic information parameters include: the time mX required to transmit the initial digital currency, the time X required to transmit a payment data chain, the time B required to calculate a signature, and the time C required to verify a signature.
[0010] In addition, the preset time is: mX+X+B+3C ms.
[0011] It can be seen from the technical solution provided by the present invention that the present invention provides a hardware wallet, including: an input module, a first judgment module, a second judgment module, a first acquisition module, a second acquisition module, a first transaction time calculation module, a digital currency selection module, a digital currency quantity increase module, a digital currency combination selection module, a remaining currency judgment module, a digital currency removal module, a second transaction time calculation module, a third transaction time calculation module, a second to-be-output digital currency determination module, a first to-be-output digital currency determination module, an output module and a process end module, wherein,
[0012] An input module is used to obtain the payment amount and trigger the first judgment module to perform an operation; the first judgment module is used to arrange the stored digital currencies from large to small according to the available amount, wherein the digital currency includes: initial digital currency; and / or the digital currency includes: initial digital currency and at least one payment data chain; it is determined whether there is at least one digital currency with an available amount greater than or equal to the payment amount, if so, the second judgment module is triggered to perform an operation, if not, the digital currency selection module is triggered to perform an operation; the second judgment module is used to obtain all digital currencies greater than or equal to the payment amount, and determine whether each digital currency in all digital currencies contains a payment data chain, if there is a digital currency that does not contain a payment data chain, the first acquisition module is triggered. The block performs the operation. If there is no digital currency that does not contain the payment data chain, the second acquisition module is triggered to perform the operation; the first acquisition module is used to obtain the digital currency that does not contain the payment data chain, triggering the first transaction time calculation module to perform the operation; the second acquisition module is used to obtain the digital currency that contains the least payment data chain, triggering the first transaction time calculation module to perform the operation; the first transaction time calculation module is used to determine the number of selected digital currencies as one, determine a digital currency whose available amount is closest to the payment amount, and calculate the transaction time of the digital currency whose available amount is closest to the payment amount, wherein the transaction time includes: the time consumed to transmit the digital currency whose available amount is closest to the payment amount, and the time consumed to sign the digital currency whose available amount is closest to the payment amount. The sum of the time consumed by the peer device to verify the signature of the digital currency with the available amount closest to the payment amount; determine whether the transaction time of the digital currency with the available amount closest to the payment amount is greater than the preset time, if it is greater than the preset time, trigger the digital currency selection module to perform an operation, if it is not greater than the preset time, trigger the first digital currency to be output determination module to perform an operation; the digital currency selection module is used to select digital currency from the remaining digital currencies, trigger the digital currency quantity increase module to perform an operation; the digital currency quantity increase module is used to increase the number of selected digital currencies by one, arrange the remaining digital currencies from large to small, and trigger the digital currency combination selection module to perform an operation; the digital currency combination selection module selects the digital currency combination with the smallest available amount, Determine whether the digital currency combination with the smallest available amount is greater than or equal to the payment amount. If the digital currency combination with the smallest available amount is less than the payment amount, trigger the remaining currency judgment module to perform an operation. If the digital currency combination with the smallest available amount is greater than or equal to the payment amount, trigger the second transaction time calculation module to perform an operation. The remaining currency judgment module is used to determine whether there is any remaining currency. If there is any remaining currency, trigger the digital currency removal module to perform an operation. If there is no remaining currency and the number of selected digital currencies is less than the total number of digital currencies in the hardware wallet, trigger the digital currency quantity increase module to perform an operation. If there is no remaining currency and the number of selected digital currencies is equal to the total number of digital currencies in the hardware wallet, trigger the process end module to perform an operation.A digital currency removal module is used to remove the digital currency with the smallest available amount and trigger the digital currency combination selection module to perform operations; a second transaction time calculation module is used to obtain the digital currency with the most payment data chains; calculate the transaction time of the digital currency with the most payment data chains; determine whether the transaction time of the digital currency with the most payment data chains is greater than the preset time. If the transaction time of the digital currency with the most payment data chains is greater than the preset time, the digital currency quantity increase module is triggered to perform operations; if the transaction time of the digital currency with the most payment data chains is less than or equal to the preset time, the third transaction time calculation module is triggered to perform operations; the third transaction time calculation module determines the optimal digital currency combination with the smallest available amount and calculates the transaction time of the optimal digital currency combination with the smallest available amount; if there is a digital currency with an available amount closest to the payment amount, determine whether the transaction time of the optimal digital currency combination with the smallest available amount is greater than the digital currency with the available amount closest to the payment amount The transaction time of the digital currency of the payment amount, if the transaction time of the optimal digital currency combination with the smallest available amount is greater than the transaction time of the digital currency with the closest available amount to the payment amount, the first digital currency determination module to be output is triggered to perform an operation; if the transaction time of the digital currency combination with the smallest available amount is not greater than the transaction time of the digital currency with the closest available amount to the payment amount, the second digital currency determination module to be output is triggered to perform an operation; if there is no digital currency with the closest available amount to the payment amount, the second digital currency determination module to be output is triggered to perform an operation; the second digital currency determination module to be output is used to use the optimal digital currency combination with the smallest available amount as the digital currency to be output, and trigger the output module to perform an operation; the first digital currency determination module to be output is used to use the digital currency with the closest available amount to the payment amount as the digital currency to be output, and trigger the output module to perform an operation; the output module is used to output the digital currency to be output; the process ending module is used to end the process. ;
[0013] In addition, after the number of digital currencies selected by the digital currency quantity increase module is increased by one and the remaining digital currencies are arranged from large to small, it also includes: the digital currency quantity increase module is also used to determine whether the available amount of all digital currencies is greater than or equal to the payment amount. When it is determined that the available amount of all digital currencies is greater than or equal to the payment amount, the digital currency combination selection module is triggered to execute the operation of selecting the digital currency combination with the smallest available amount.
[0014] In addition, it also includes: a basic parameter setting module, wherein the basic parameter setting module is used to set basic information parameters, wherein the basic information parameters include: the time mX required to transmit the initial digital currency, the time X required to transmit a payment data chain, the time B required to calculate a signature, and the time C required to verify a signature.
[0015] In addition, the preset time is: mX+X+B+3C ms.
[0016] Through the hardware wallet digital currency selection method and hardware wallet provided in this embodiment, in the process of the hardware wallet completing the selection of digital currency to participate in the transaction, the digital currency closest to the payment amount is selected, the transaction time of the digital currency is calculated, and the optimal digital currency combination with the smallest available amount is selected, and the transaction time of the digital currency combination is calculated. The digital currency to be output is further determined and output according to the transaction time. Through the above-mentioned digital currency or digital currency combination selection process and the hardware wallet using the process, the digital currency or digital currency combination with the shortest transaction time suitable for the transaction can be selected, thereby avoiding the problem of long transaction time and low transaction efficiency due to multiple payment data chains when using the digital currency in the hardware wallet to complete the transaction in an offline state, thereby improving the user experience of using the hardware wallet in an offline state. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative work.
[0018] Figure 1 A schematic diagram of the hardware wallet structure provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0019] The following is a clear and complete description of the technical solutions in the embodiments of the present invention in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the protection scope of the present invention.
[0020] In the description of the present invention, it should be understood that the terms "center", "longitudinal", "lateral", "upper", "lower", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside" and the like indicate positions or positional relationships based on the positions or positional relationships shown in the drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as limiting the present invention. In addition, the terms "first" and "second" are used for descriptive purposes only, and cannot be understood as indicating or implying relative importance, quantity or position.
[0021] In the description of the present invention, it should be noted that, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, or it can be the internal communication of two components. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0022] The embodiments of the present invention will be described in further detail below with reference to the accompanying drawings.
[0023] Example
[0024] This embodiment provides a hardware wallet 100, which can complete a transaction process using digital currency with other hardware wallets or payment devices in an offline state.
[0025] Figure 1 The schematic diagram of the structure of the hardware wallet 100 provided in this embodiment is as follows: Figure 1 As shown, the hardware wallet 100 mainly includes:
[0026] Input module 101, first judgment module 102, second judgment module 103, first acquisition module 104, second acquisition module 105, first transaction time calculation module 106, digital currency selection module 107, digital currency quantity increase module 108, digital currency combination selection module 109, remaining currency judgment module 110, digital currency removal module 111, second transaction time calculation module 112, third transaction time calculation module 113, second to-be-output digital currency determination module 114, first to-be-output digital currency determination module 115, output module 116 and process end module 117, wherein,
[0027] The input module 101 is used to obtain the payment amount and trigger the first judgment module 102 to perform an operation;
[0028] The first judgment module 102 is used to arrange the stored digital currencies in descending order according to the available amount, wherein the digital currency includes: the initial digital currency; and / or the digital currency includes: the initial digital currency and at least one payment data chain; determine whether there is at least one digital currency with an available amount greater than or equal to the payment amount, and if so, trigger the second judgment module to perform 103 operation, and if not, trigger the digital currency selection module 107 to perform an operation;
[0029] The second judgment module 103 is used to obtain all digital currencies that are greater than or equal to the payment amount, and judge whether each digital currency in all digital currencies contains a payment data chain. If there is a digital currency that does not contain a payment data chain, the first acquisition module 104 is triggered to perform an operation. If there is no digital currency that does not contain a payment data chain, the second acquisition module 105 is triggered to perform an operation;
[0030] The first acquisition module 104 is used to acquire digital currency that does not contain a payment data chain, triggering the first transaction time calculation module 106 to perform an operation;
[0031] The second acquisition module 105 is used to acquire the digital currency containing the least payment data chain, triggering the first transaction time calculation module 106 to perform an operation;
[0032] The first transaction time calculation module 106 is used to determine the number of selected digital currencies to be one, determine a digital currency whose available amount is closest to the payment amount, and calculate the transaction time of the digital currency whose available amount is closest to the payment amount, wherein the transaction time includes: the sum of the time taken to transmit the digital currency whose available amount is closest to the payment amount, the time taken to sign the digital currency whose available amount is closest to the payment amount, and the time taken for the peer device to verify the signature of the digital currency whose available amount is closest to the payment amount; determine whether the transaction time of the digital currency whose available amount is closest to the payment amount is greater than a preset time, and if so, trigger the digital currency selection module 107 to perform an operation, and if not, trigger the first digital currency to be output determination module 115 to perform an operation;
[0033] The digital currency selection module 107 is used to select digital currency from the remaining digital currencies and trigger the digital currency quantity increase module 108 to perform an operation;
[0034] The digital currency quantity increasing module 108 is used to increase the selected digital currency quantity by one, arrange the remaining digital currencies from large to small, and trigger the digital currency combination selecting module 109 to perform an operation;
[0035] The digital currency combination selection module 109 selects the digital currency combination with the smallest available amount, and determines whether the digital currency combination with the smallest available amount is greater than or equal to the payment amount. If the digital currency combination with the smallest available amount is less than the payment amount, the remaining currency determination module 110 is triggered to perform an operation. If the digital currency combination with the smallest available amount is greater than or equal to the payment amount, the second transaction time calculation module 112 is triggered to perform an operation.
[0036] The remaining currency judgment module 110 is used to judge whether there is any remaining currency. If there is any remaining currency, the digital currency removal module 111 is triggered to perform an operation. If there is no remaining currency and the number of selected digital currencies is less than the total number of digital currencies in the hardware wallet, the digital currency amount increase module 108 is triggered to perform an operation. If there is no remaining currency and the number of selected digital currencies is equal to the total number of digital currencies in the hardware wallet, the process end module 117 is triggered to perform an operation.
[0037] The digital currency removal module 111 is used to remove the digital currency with the smallest available amount, triggering the digital currency combination selection module 109 to perform an operation;
[0038] The second transaction time calculation module 112 is used to obtain the digital currency with the most payment data chains; calculate the transaction time of the digital currency with the most payment data chains; determine whether the transaction time of the digital currency with the most payment data chains is greater than a preset time, if the transaction time of the digital currency with the most payment data chains is greater than the preset time, trigger the digital currency quantity increase module 108 to perform an operation, if the transaction time of the digital currency with the most payment data chains is less than or equal to the preset time, trigger the third transaction time calculation module 113 to perform an operation;
[0039] The third transaction time calculation module 113 determines the optimal digital currency combination with the smallest available amount, and calculates the transaction time of the optimal digital currency combination with the smallest available amount; if there is a digital currency with an available amount closest to the payment amount, it is determined whether the transaction time of the optimal digital currency combination with the smallest available amount is greater than the transaction time of the digital currency with an available amount closest to the payment amount. If the transaction time of the optimal digital currency combination with the smallest available amount is greater than the transaction time of the digital currency with an available amount closest to the payment amount, the first digital currency determination module 115 to be output is triggered to perform an operation; if the transaction time of the digital currency combination with the smallest available amount is not greater than the transaction time of the digital currency with an available amount closest to the payment amount, the second digital currency determination module 114 to be output is triggered to perform an operation; if there is no digital currency with an available amount closest to the payment amount, the second digital currency determination module 114 to be output is triggered to perform an operation;
[0040] The second digital currency to be output determining module 114 is used to select the optimal digital currency combination with the smallest available amount as the digital currency to be output, and trigger the output module 116 to perform an operation;
[0041] The first digital currency to be output determining module 115 is used to use the digital currency with the available amount closest to the payment amount as the digital currency to be output, and trigger the output module 116 to perform an operation;
[0042] Output module 116, used for outputting the digital currency to be output;
[0043] The process ending module 117 is used to end the process.
[0044] As an optional implementation of this embodiment, after the number of digital currencies selected by the digital currency amount increasing module 108 is increased by one and the remaining digital currencies are arranged from large to small, the following further includes:
[0045] The digital currency quantity increasing module 108 is also used to determine whether the available amount of all digital currencies is greater than or equal to the payment amount. When it is determined that the available amount of all digital currencies is greater than or equal to the payment amount, the digital currency combination selecting module 109 is triggered to execute the operation of selecting the digital currency combination with the smallest available amount.
[0046] As an optional implementation of this embodiment, the hardware wallet 100 of this embodiment further includes: a basic parameter setting module (not shown), wherein the basic parameter setting module is used to set basic information parameters, wherein the basic information parameters include: the time mX for transmitting the initial digital currency, the time X for transmitting a payment data chain, the time B for calculating a signature, and the time C for verifying a signature. In this optional implementation, the preset time can be: mX+X+B+3C ms.
[0047] Through the hardware wallet provided in this embodiment, in the process of completing the selection of digital currency to participate in the transaction, the digital currency closest to the payment amount is selected, the transaction time of the digital currency is calculated, and the optimal digital currency combination with the smallest available amount is selected, and the transaction time of the digital currency combination is calculated. The digital currency to be output is further determined and output according to the transaction time. Through the above-mentioned digital currency or digital currency combination selection process, the digital currency or digital currency combination with the shortest transaction time suitable for the transaction can be selected, thereby avoiding the problem of long transaction time and low transaction efficiency due to multiple payment data chains when using digital currency in the hardware wallet to complete the transaction in an offline state, thereby improving the user experience of using the hardware wallet in an offline state.
[0048] The following provides a method for selecting digital currency through a hardware wallet, which can be implemented through the hardware wallet 100 described above. The specific implementation and process of each module in the hardware wallet 100 can refer to the following content. Specifically, the method includes the following steps (S201-S222):
[0049] S201, obtaining the payment amount.
[0050] In this step, the payment amount can be obtained by obtaining the payment amount through a terminal used in conjunction with the hardware wallet, and the terminal sends the payment amount to the hardware wallet through a non-networked method such as a short-distance communication method or a medium- and long-distance communication method. Alternatively, the hardware wallet directly obtains the payment amount through user input on the hardware wallet, and this embodiment does not impose any specific restrictions.
[0051] As an optional implementation of this embodiment, before obtaining the payment amount, it also includes: setting basic information parameters, where the basic information parameters include: time consumption mX for transmitting the initial digital currency, time consumption X for transmitting a payment data chain, time consumption B for calculating a signature, and time consumption C for verifying a signature. In this optional implementation, after setting the basic information parameters, the calculation process of the transaction time is more convenient.
[0052] S202, arranging the stored digital currencies in descending order according to the available amounts, wherein the digital currencies include: initial digital currencies; and / or the digital currencies include: initial digital currencies and at least one payment data chain.
[0053] In this embodiment, when digital currency can be settled online, it does not contain a payment data chain. During offline transactions, since it cannot be settled online in real time, a payment data chain will be generated to improve the security of offline transactions of digital currency. In the offline transaction scenario, digital currency that has not participated in offline transactions includes initial digital currency and no payment data chain, and digital currency that has participated in offline transactions includes initial currency and at least one payment data chain.
[0054] S203, determine whether there is at least one digital currency with an available amount greater than or equal to the payment amount, if so, execute step S204, if not, execute step S209.
[0055] S204, obtain all digital currencies that are greater than or equal to the payment amount, and determine whether each digital currency in all digital currencies contains a payment data chain. If there are digital currencies that do not contain a payment data chain, execute S205; if there are no digital currencies that do not contain a payment data chain, execute S206.
[0056] S205, obtain digital currency that does not contain the payment data chain, and execute S207.
[0057] S206, obtain the digital currency containing the least payment data chain, and execute S207.
[0058] In this embodiment, in order to increase the data transmission speed of offline transactions, when transmitting digital currencies, digital currencies with small data volume are preferably used to participate in transactions. Therefore, the hardware wallet will use as few digital currencies as possible to participate in transactions, and digital currencies with no payment data chain or few payment data chains are preferably used to participate in transactions.
[0059] S207, the number of selected digital currencies is determined to be one, a digital currency whose available amount is closest to the payment amount is determined, and the transaction time of the digital currency whose available amount is closest to the payment amount is calculated, wherein the transaction time includes: the sum of the time taken to transmit the digital currency whose available amount is closest to the payment amount, the time taken to sign the digital currency whose available amount is closest to the payment amount, and the time taken for the peer device to verify the signature of the digital currency whose available amount is closest to the payment amount.
[0060] In this embodiment, when there is at least one digital currency with an available amount greater than or equal to the payment amount, the transaction time when the digital currency is used to participate in the transaction is further calculated, so as to decide whether to use the digital currency to participate in the transaction.
[0061] S208, determine whether the transaction time of the digital currency whose available amount is closest to the payment amount is greater than the preset time, if it is greater than the preset time, execute S209, if it is not greater than the preset time, execute S220.
[0062] In an optional implementation of this embodiment, the preset time is: mX+X+B+3C ms. That is, the sum of the time mX required to transmit the initial digital currency, the time X required to transmit a payment data chain, the time B required to calculate a signature, and three times the time C required to verify a signature. The preset time is related to the computing power of the hardware wallet. Different hardware wallets will calculate different preset times according to the above method, which is more practical than the method in which the system directly specifies the preset time.
[0063] S209, selecting a digital currency from the remaining digital currencies.
[0064] In this embodiment, if the transaction time of the digital currency whose available amount is closest to the payment amount is not greater than the preset time, the digital currency is determined to participate in the transaction process, that is, the digital currency whose available amount is closest to the payment amount is used as the digital currency to be output and output. If the transaction time of the digital currency whose available amount is closest to the payment amount is greater than the preset time, the digital currency is reselected to participate in the transaction process, that is, the digital currency is reselected from the remaining digital currencies.
[0065] S210, the number of selected digital currencies is increased by one, and the remaining digital currencies are arranged from large to small.
[0066] S211, select the digital currency combination with the smallest available amount, and determine whether the digital currency combination with the smallest available amount is greater than or equal to the payment amount. If the digital currency combination with the smallest available amount is less than the payment amount, execute step S212; if the digital currency combination with the smallest available amount is greater than or equal to the payment amount, execute S214.
[0067] In an optional implementation of this embodiment, after the number of selected digital currencies is increased by one and the remaining digital currencies are arranged from large to small, before selecting the digital currency combination with the smallest available amount, it also includes: judging whether the available amount of all digital currencies is greater than or equal to the payment amount, and if the available amount of all digital currencies is greater than or equal to the payment amount, executing the step of selecting the digital currency combination with the smallest available amount. In this optional implementation, if the available amount of all digital currencies is less than the payment amount, it means that all digital currencies in the hardware wallet are insufficient to complete the transaction, and the process can be further terminated to improve computing efficiency.
[0068] In this embodiment, if there is no digital currency with an available amount greater than or equal to the payment amount, or the transaction time of the digital currency with an available amount closest to the payment amount is greater than the preset time, it will be further determined whether to select a digital currency combination or which digital currency combination to complete the transaction. For example, if there is no digital currency with an available amount greater than or equal to the payment amount, or the transaction time of the digital currency with an available amount closest to the payment amount is greater than the preset time, the number of selected digital currencies is increased by one, that is, a digital currency combination containing two digital currencies is selected to determine whether the digital currency combination can participate in the transaction.
[0069] S212, determine whether there is any remaining currency. If there is any remaining currency, execute S213. If there is no remaining currency and the number of digital currencies selected is less than the total number of digital currencies in the hardware wallet, execute S210. If there is no remaining currency and the number of digital currencies selected is equal to the number of digital currencies in the hardware wallet, execute S222.
[0070] S213, remove the digital currency with the smallest available amount, and return to execute S211;
[0071] In this embodiment, if the digital currency combination with the smallest available amount is less than the payment amount, it is further determined whether there is any remaining currency. If so, the digital currency with the smallest available amount is removed, and the number of selected digital currencies is increased by one. For example, the number of selected digital currencies becomes 3, and it is determined whether there is a digital currency combination that meets the transaction requirements in each group of digital currency combinations containing 3 digital currencies. If it still does not meet the transaction requirements, the amount of selected digital currencies is changed to 4, until a digital currency combination that meets the transaction requirements is found, or there is no remaining digital currency position. In this embodiment, if there is no remaining currency, it means that the sum of the amounts of all digital currencies does not meet the transaction requirements, then S222 is executed to end the process.
[0072] S214, obtaining the digital currency containing the most payment data chains.
[0073] S215, calculating the transaction time of the digital currency containing the most payment data chains.
[0074] S216, determine whether the transaction time of the digital currency with the most payment data chains is greater than the preset time. If the transaction time of the digital currency with the most payment data chains is greater than the preset time, return to execute S11; if the transaction time of the digital currency with the most payment data chains is less than or equal to the preset time, execute S17.
[0075] In this embodiment, if the digital currency combination with the smallest available amount is greater than or equal to the payment amount, it is determined whether the transaction time of the digital currency with the largest payment chain is greater than the preset time. If it is greater than the preset time, it is necessary to reselect the digital currency combination. If it is less than or equal to the preset time, the transaction time of the digital currency combination is further determined. By calculating the transaction time of the digital currency with the largest payment chain, some digital currency combinations with transaction times greater than the preset time can be excluded, thereby improving transaction efficiency.
[0076] S217, determining the optimal digital currency combination with the smallest available amount, and calculating the transaction time of the optimal digital currency combination with the smallest available amount;
[0077] S218, determine whether the transaction time of the optimal digital currency combination with the smallest available amount is greater than the transaction time of the digital currency with the available amount closest to the payment amount. If the transaction time of the optimal digital currency combination with the smallest available amount is greater than the transaction time of the digital currency with the available amount closest to the payment amount, return to execute S220; if the transaction time of the digital currency combination with the smallest available amount is not greater than the transaction time of the digital currency with the available amount closest to the payment amount, execute S219.
[0078] In this embodiment, the transaction time of the optimal digital currency combination with the smallest available amount is further determined. If it is greater than the transaction time of the digital currency with the available amount closest to the payment amount, it is considered that the digital currency with the available amount closest to the payment amount in the digital wallet is the most suitable digital currency with the shortest transaction time. If it is not greater than the transaction time of the digital currency with the available amount closest to the payment amount, it is considered that the optimal digital currency combination with the smallest available amount is the most suitable digital currency with the shortest transaction time in the digital wallet. By comparing the transaction time of the optimal digital currency combination with the smallest available amount with the transaction time of the digital currency with the available amount closest to the payment amount, it is possible to determine which digital currency or digital currency combination is the most suitable digital currency to be output, which can further reduce the transaction time.
[0079] S219, taking the optimal digital currency combination with the smallest available amount as the digital currency to be output, and executing S221;
[0080] S220, using the digital currency with the available amount closest to the payment amount as the digital currency to be output, and executing S221;
[0081] S221, output the digital currency to be output;
[0082] S222, end the process.
[0083] The following is an example of how the hardware wallet selects digital currency or a combination of digital currencies in the case of different payment amounts, using the digital currency amounts of 1, 2, 5, 7, 10, 13, and 15 in the hardware wallet to briefly describe the selection process of the digital currency of the hardware wallet in the above embodiment.
[0084] (1) The payment amount is 13;
[0085] The payment amount obtained is 13. It is determined that there is at least one digital currency with an available amount greater than or equal to the payment amount. The digital currencies are 13 and 15. The currency to be output is further determined based on the payment data chain and the transaction time.
[0086] (2) The payment amount is 18;
[0087] The payment amount obtained is 18. It is determined that there is no digital currency with an available amount greater than or equal to the payment amount. The number of digital currencies selected is 2. The digital currency combination with the smallest available amount is selected, 1 and 2. It is determined that the digital currency combination is less than the payment amount. It is determined that there are remaining currencies. The digital currency 1 with the smallest available amount is removed. Return to execute the selection of the digital currency combination with the smallest available amount, 2 and 5, and determine that the digital currency combination is less than the payment amount. It is determined that there are remaining currencies. The digital currency 2 with the smallest available amount is removed. This cycle is repeated until the digital currency combination 10 and 13 is found. It is determined that the digital currency combination is greater than or equal to the payment amount. Further, the transaction time is determined through the payment data chain, etc. Whether it is greater than the preset time, if it is greater, reselect, if less, determine the optimal digital currency combination with the smallest available amount, calculate the transaction time, and determine the currency to be output.
[0088] (3) The payment amount is 30;
[0089] The payment amount obtained is 30. It is determined that there is no digital currency with an available amount greater than or equal to the payment amount. The number of digital currencies selected is 2. The digital currency combination with the smallest available amount is selected, 1 and 2. It is determined that the digital currency combination is less than the payment amount. It is determined that there are remaining currencies. The digital currency 1 with the smallest available amount is removed. Return to execute the selection of the digital currency combination with the smallest available amount, 2 and 5, and determine that the digital currency combination is less than the payment amount. It is determined that there are remaining currencies. The digital currency 2 with the smallest available amount is removed. This cycle is repeated until there is no remaining currency. The number of digital currencies is increased by 1. 3 digital currencies are selected until a combination of digital currencies 7, 10 and 13 is selected. It is determined that the digital currency combination is greater than or equal to the payment amount. Further, it is determined through the payment data chain whether the transaction time is greater than the preset time. If it is greater, reselect. If it is less, determine the optimal digital currency combination with the smallest available amount, calculate the transaction time, and determine the currency to be output.
[0090] Through the hardware wallet digital currency selection method provided in this embodiment, the digital currency closest to the payment amount is selected, the transaction time of the digital currency is calculated, and the optimal digital currency combination with the smallest available amount is selected, and the transaction time of the digital currency combination is calculated. The digital currency to be output is further determined and output according to the transaction time. Through the above-mentioned digital currency or digital currency combination selection process, the digital currency or digital currency combination with the shortest transaction time suitable for the transaction can be selected, thereby avoiding the problem of long transaction time and low transaction efficiency due to multiple payment data chains when completing transactions using digital currencies in the hardware wallet in an offline state, thereby improving the user experience of using the hardware wallet in an offline state.
[0091] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, segment or portion of code that includes one or more executable instructions for implementing the steps of a specific logical function or process, and the scope of the preferred embodiments of the present invention includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by those skilled in the art to which the embodiments of the present invention belong.
[0092] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, a plurality of steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0093] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.
[0094] In addition, each functional unit in each embodiment of the present invention may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium.
[0095] The storage medium mentioned above can be a read-only memory, a magnetic disk or an optical disk, etc.
[0096] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "examples", "specific examples", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0097] Although the embodiments of the present invention have been shown and described above, it is understood that the above embodiments are exemplary and cannot be understood as limiting the present invention. Those skilled in the art may change, modify, replace and modify the above embodiments within the scope of the present invention without departing from the principles and purpose of the present invention. The scope of the present invention is defined by the appended claims and their equivalents.
Claims
1. A method for selecting digital currency using a hardware wallet, characterized in that: include: The hardware wallet performs the following operations in an offline state: S1, obtain the payment amount; S2, arranging the stored digital currencies in descending order according to the available amounts, wherein the digital currencies include: initial digital currencies; and / or the digital currencies include: initial digital currencies and at least one payment data chain; S3, determining whether there is at least one digital currency with an available amount greater than or equal to the payment amount, if so, executing step S4, if not, executing step S9; S4, obtaining all digital currencies greater than or equal to the payment amount, and determining whether each digital currency in all digital currencies contains a payment data chain. If there is a digital currency that does not contain a payment data chain, executing S5; if there is no digital currency that does not contain a payment data chain, executing S6; S5, obtaining the digital currency that does not contain the payment data chain, and executing S7; S6, obtaining the digital currency containing the least payment data chain, and executing S7; S7, the number of selected digital currencies is determined to be one, a digital currency whose available amount is closest to the payment amount is determined, and the transaction time of the digital currency whose available amount is closest to the payment amount is calculated, wherein the transaction time includes: the sum of the time taken to transmit the digital currency whose available amount is closest to the payment amount, the time taken to sign the digital currency whose available amount is closest to the payment amount, and the time taken for the opposite end device to verify the signature of the digital currency whose available amount is closest to the payment amount; S8, determining whether the transaction time of the digital currency whose available amount is closest to the payment amount is greater than a preset time, if it is greater than the preset time, executing S9, if it is not greater than the preset time, executing S20; S9, selecting a digital currency from the remaining digital currencies; S10, the number of selected digital currencies is increased by one, and the remaining digital currencies are arranged from large to small; S11, select the digital currency combination with the smallest available amount, and determine whether the digital currency combination with the smallest available amount is greater than or equal to the payment amount. If the digital currency combination with the smallest available amount is less than the payment amount, execute step S12; if the digital currency combination with the smallest available amount is greater than or equal to the payment amount, execute S14; S12, determining whether there is any remaining currency, if there is any remaining currency, executing S13, if there is no remaining currency, and the number of digital currencies selected is less than the total number of digital currencies in the hardware wallet, executing S10, if there is no remaining currency, and the number of digital currencies selected is equal to the total number of digital currencies in the hardware wallet, executing S22; S13, remove the digital currency with the smallest available amount, and return to execute S11; S14, obtaining the digital currency containing the most payment data chains; S15, calculating the transaction time of the digital currency containing the most payment data chains; S16, determining whether the transaction time of the digital currency with the most payment data chains is greater than the preset time, if the transaction time of the digital currency with the most payment data chains is greater than the preset time, returning to execute S10, if the transaction time of the digital currency with the most payment data chains is less than or equal to the preset time, executing S17; S17, determining the optimal digital currency combination with the smallest available amount, and calculating the transaction time of the optimal digital currency combination with the smallest available amount; S18, if there is a digital currency with an available amount closest to the payment amount, determine whether the transaction time of the optimal digital currency combination with the smallest available amount is greater than the transaction time of the digital currency with an available amount closest to the payment amount; if the transaction time of the optimal digital currency combination with the smallest available amount is greater than the transaction time of the digital currency with an available amount closest to the payment amount, return to execute S20; if the transaction time of the digital currency combination with the smallest available amount is not greater than the transaction time of the digital currency with an available amount closest to the payment amount, execute S19; if there is no digital currency with an available amount closest to the payment amount, execute S19; S19, taking the optimal digital currency combination with the smallest available amount as the digital currency to be output, and executing S21; S20, taking the digital currency whose available amount is closest to the payment amount as the digital currency to be output, and executing S21; S21, outputting the digital currency to be output; S22, end the process.
2. The method according to claim 1, characterized in that: After the number of digital currencies selected is increased by one and the remaining digital currencies are arranged from large to small, and before the digital currency combination with the smallest available amount is selected, the method further includes: Determine whether the available amount of all digital currencies is greater than or equal to the payment amount. If it is determined that the available amount of all digital currencies is greater than or equal to the payment amount, execute the step of selecting the digital currency combination with the smallest available amount.
3. The method according to claim 1, characterized in that Also includes: Before obtaining the payment amount, the following steps are also included: Set basic information parameters, where the basic information parameters include: the time mX required to transmit the initial digital currency, the time X required to transmit a payment data chain, the time B required to calculate a signature, and the time C required to verify a signature.
4. The method according to claim 3, characterized in that The preset time is: mX+X+B+3C ms.
5. A hardware wallet, characterized in that: include: An input module, a first judgment module, a second judgment module, a first acquisition module, a second acquisition module, a first transaction time calculation module, a digital currency selection module, a digital currency quantity increase module, a digital currency combination selection module, a remaining currency judgment module, a digital currency removal module, a second transaction time calculation module, a third transaction time calculation module, a second to-be-output digital currency determination module, a first to-be-output digital currency determination module, an output module, and a process end module, wherein the hardware wallet, in an offline state, completes a transaction with other hardware wallets or a payment device in the following manner: The input module is used to obtain the payment amount and trigger the first judgment module to perform an operation; The first judgment module is used to arrange the stored digital currencies in descending order according to the available amount, wherein the digital currency includes: initial digital currency; and / or the digital currency includes: initial digital currency and at least one payment data chain; determine whether there is at least one digital currency with an available amount greater than or equal to the payment amount, and if so, trigger the second judgment module to perform an operation, and if not, trigger the digital currency selection module to perform an operation; The second determination module is used to obtain all digital currencies greater than or equal to the payment amount, and determine whether each digital currency in all digital currencies contains a payment data chain. If there is a digital currency that does not contain a payment data chain, the first acquisition module is triggered to perform an operation; if there is no digital currency that does not contain a payment data chain, the second acquisition module is triggered to perform an operation; The first acquisition module is used to acquire the digital currency that does not contain the payment data chain, and trigger the first transaction time calculation module to perform an operation; The second acquisition module is used to acquire the digital currency containing the least payment data chain, and trigger the first transaction time calculation module to perform an operation; The first transaction time calculation module is used to determine the number of selected digital currencies to be one, determine a digital currency whose available amount is closest to the payment amount, and calculate the transaction time of the digital currency whose available amount is closest to the payment amount, wherein the transaction time includes: the sum of the time taken to transmit the digital currency whose available amount is closest to the payment amount, the time taken to sign the digital currency whose available amount is closest to the payment amount, and the time taken for the peer device to verify the signature of the digital currency whose available amount is closest to the payment amount; determine whether the transaction time of the digital currency whose available amount is closest to the payment amount is greater than a preset time, and if so, trigger the digital currency selection module to perform an operation, and if not, trigger the first to-be-output digital currency determination module to perform an operation; The digital currency selection module is used to select digital currency from the remaining digital currencies and trigger the digital currency quantity increase module to perform an operation; The digital currency quantity increasing module is used to increase the selected digital currency quantity by one, arrange the remaining digital currencies from large to small, and trigger the digital currency combination selecting module to perform an operation; The digital currency combination selection module selects the digital currency combination with the smallest available amount, determines whether the digital currency combination with the smallest available amount is greater than or equal to the payment amount, and triggers the remaining currency determination module to perform an operation if the digital currency combination with the smallest available amount is less than the payment amount; and triggers the second transaction time calculation module to perform an operation if the digital currency combination with the smallest available amount is greater than or equal to the payment amount; The remaining currency judgment module is used to judge whether there is any remaining currency. If there is any remaining currency, the digital currency removal module is triggered to perform an operation. If there is no remaining currency and the number of selected digital currencies is less than the total number of digital currencies in the hardware wallet, the digital currency amount increase module is triggered to perform an operation. If there is no remaining currency and the number of selected digital currencies is equal to the total number of digital currencies in the hardware wallet, the process end module is triggered to perform an operation. The digital currency removal module is used to remove the digital currency with the smallest available amount, triggering the digital currency combination selection module to perform an operation; The second transaction time calculation module is used to obtain the digital currency with the most payment data chains; calculate the transaction time of the digital currency with the most payment data chains; determine whether the transaction time of the digital currency with the most payment data chains is greater than the preset time, if the transaction time of the digital currency with the most payment data chains is greater than the preset time, trigger the digital currency quantity increase module to perform an operation, if the transaction time of the digital currency with the most payment data chains is less than or equal to the preset time, trigger the third transaction time calculation module to perform an operation; The third transaction time calculation module determines the optimal digital currency combination with the smallest available amount, and calculates the transaction time of the optimal digital currency combination with the smallest available amount; if there is a digital currency with an available amount closest to the payment amount, it is determined whether the transaction time of the optimal digital currency combination with the smallest available amount is greater than the transaction time of the digital currency with an available amount closest to the payment amount; if the transaction time of the optimal digital currency combination with the smallest available amount is greater than the transaction time of the digital currency with an available amount closest to the payment amount, the first digital currency determination module to be output is triggered to perform an operation; if the transaction time of the digital currency combination with the smallest available amount is not greater than the transaction time of the digital currency with an available amount closest to the payment amount, the second digital currency determination module to be output is triggered to perform an operation; if there is no digital currency with an available amount closest to the payment amount, the second digital currency determination module to be output is triggered to perform an operation; The second digital currency to be output determining module is used to use the optimal digital currency combination with the smallest available amount as the digital currency to be output, and trigger the output module to perform an operation; The first digital currency to be output determining module is used to use the digital currency with the available amount closest to the payment amount as the digital currency to be output, and trigger the output module to perform an operation; The output module is used to output the digital currency to be output; The process ending module is used to end the process.
6. The hardware wallet according to claim 5, characterized in that: After the number of digital currencies selected by the digital currency amount increasing module is increased by one and the remaining digital currencies are arranged from large to small: The digital currency quantity increasing module is also used to determine whether the available amount of all digital currencies is greater than or equal to the payment amount. When it is determined that the available amount of all digital currencies is greater than or equal to the payment amount, the digital currency combination selection module is triggered to execute the operation of selecting the digital currency combination with the smallest available amount.
7. The hardware wallet according to claim 5, characterized in that: Also includes: Basic parameter setting module, where: The basic parameter setting module is used to set basic information parameters, wherein the basic information parameters include: the time mX required to transmit the initial digital currency, the time X required to transmit a payment data chain, the time B required to calculate a signature, and the time C required to verify a signature.
8. The hardware wallet according to claim 7, characterized in that: The preset time is: mX+X+B+3C ms.
