Rebalancing Method and Device Applied to Payment Channel Network
Through the anonymous identity participation and circular transaction sequence construction in the BFlow protocol, the limitations of the payment channel network rebalancing algorithm and insufficient privacy protection are solved, the payment success rate and user experience are improved, and stronger privacy protection is provided.
Patent Information
- Application Number
- CN202411845026.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-16
- Publication Date
- 2025-06-17
- Estimated Expiration
- 2044-12-16
AI Technical Summary
There are limitations in the rebalancing algorithm of the existing payment channel network and insufficient privacy protection, making it difficult to effectively improve payment success rate and user experience.
A on-demand rebalancing protocol called BFlow is proposed. By initiating users to invite participants to generate sub-graphs, negotiate the maximum rebalancing requirements, build a circular transaction sequence, and perform amount allocation and transaction execution to complete the rebalancing operation. The agreement allows participants to participate in anonymously, providing better privacy protection.
It improves payment success rate, improves user experience, and provides stronger privacy protection, effectively improving the imbalance and stability of the payment channel network.
Smart Images

Figure CN119313327B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of blockchain, and particularly to a rebalancing method and device applied to a payment channel network. Background Art
[0002] Payment Channel Networks (PCNs) are an off-chain expansion method aimed at improving the efficiency of blockchain transactions and have become one of the most promising strategies in the field of decentralized digital payments. Payment Channel Networks are based on technologies such as hash time lock contracts and revocable expiration sequence contracts, enabling off-chain payment channels for locking assets to be established between nodes on the chain. PCNs are essentially a two-layer solution, where layer1 is the underlying blockchain protocol or basic layer, and layer2 is the protocol or solution built on top of the underlying blockchain. Layer1 requires steps such as transaction creation, transaction broadcasting, and consensus verification, which take a lot of time. While layer2 only conducts transactions off-chain after the channels are constructed between the two trading parties, eliminating steps such as consensus, enabling the rapid and low-cost circulation of assets off-chain, saving a large amount of time, and greatly improving the throughput of the blockchain. By establishing channels, the two trading parties can avoid the cumbersome operation of uploading each transaction to the chain, thus solving the problem of high handling fees for micropayments.
[0003] The imbalance of a payment channel refers to the deviation of the channel funds between the two nodes that establish the off-chain channel as the PCNs transactions proceed. Rebalancing is the process of restoring the balance of an imbalanced payment channel by transferring the balances of the two nodes that establish the channel, and is an improvement measure to cope with the increasing imbalance degree of the payment channel network. Rebalancing can solve the problem of the decline in payment success rate caused by the deviation of the channel capacity, and thus can maintain the continuous operation of the payment channel network and enhance the overall stability of the network.
[0004] At present, the rebalancing algorithms for payment channel networks are mainly divided into dynamic rebalancing and on-demand rebalancing. Although some routing algorithms such as the Spider algorithm and GCBRS_PCNs (Greedy Channel Balanced Routing Strategy of Payment Channel Networks) consider the imbalance of channels in the way of dynamic rebalancing, the effect is not obvious. Considering the imbalance of channels from the perspective of routing has great limitations. The routing algorithm can preferentially select low-load nodes during transactions to alleviate this situation, but as transactions continue, eventually a certain channel will run out of funds, making all paths related to this channel unusable, which is a waste of resources. Because according to the principle of payment channel networks, if the funds in the off-chain channel are exhausted, it is necessary to reopen the channel to transfer the on-chain funds to the off-chain. The payment channel network needs to have a spontaneous mechanism to make up for this situation as much as possible and improve the imbalance degree of the network to the greatest extent. Khalil first proposed the active rebalancing scheme Revive, but the privacy protection is limited. Summary of the Invention
[0005] The present invention provides a rebalancing method and device applied to a payment channel network, aiming to solve the defects that the rebalancing algorithms of payment channel networks in the prior art have great limitations and limited privacy protection, and to implement a new on-demand rebalancing protocol BFlow to improve the payment success rate, improve the user experience, and provide more privacy protection.
[0006] The present invention provides a rebalancing method applied to a payment channel network, including:
[0007] An invitation is initiated by the initiating user in the payment channel network to obtain users participating in the rebalancing operation, and a subgraph of the payment channel network is generated according to the participating users;
[0008] Users connected by each payment channel in the subgraph negotiate according to their own payment capabilities, and the maximum rebalancing demand is generated as the value on the corresponding edge in the subgraph to obtain a rebalancing demand graph;
[0009] Loops are obtained from the rebalancing demand graph, and a cyclic transaction sequence is constructed according to the loops;
[0010] The transactions in the cyclic transaction sequence are allocated amounts, and the transactions are executed along the loop direction according to the allocated amounts to complete the rebalancing operation.
[0011] According to the rebalancing method applied to a payment channel network provided by the present invention, the step of the initiating user in the payment channel network initiating an invitation to obtain users participating in the rebalancing operation includes:
[0012] Assign an anonymous identity to the initiating user who initiates the invitation, and have the initiating user broadcast the invitation information in the anonymous identity, where the invitation information includes a maximum hop count and a maximum invitation count;
[0013] After a receiving user in the payment channel network receives the invitation information, send an acceptance message or a rejection message to the sending user who sent the invitation information;
[0014] If the receiving user sends an acceptance message, assign a new anonymous identity to the receiving user, add the receiving user to the participant set of the receiving user, and have the receiving user propagate the invitation information to the neighbor nodes of the receiving user in the new anonymous identity according to the maximum hop count and the maximum invitation count;
[0015] Merge the participant set of the receiving user into the corresponding participant set of the sending user, and the final participant set after merging the participant set of the initiating user includes all users participating in the rebalancing operation.
[0016] According to a rebalancing method applied to a payment channel network provided by the present invention, obtaining a loop from the rebalancing demand graph includes:
[0017] Randomly elect a leader from the rebalancing demand graph;
[0018] Have the leader send a transaction request to the outgoing edge corresponding to the leader;
[0019] The receiving user who receives the transaction request processes and forwards according to the transaction request, and gradually constructs a path sequence;
[0020] When it is determined that there is a loop according to the path sequence, construct a loop set, and record the maximum balance demand of each edge of the loop in the loop set.
[0021] According to a rebalancing method applied to a payment channel network provided by the present invention, the receiving user who receives the transaction request processes and forwards according to the transaction request, and gradually constructs a path sequence, including:
[0022] After the receiving user receives the transaction request, locally store the anonymous identity mark in the transaction request in a mark set;
[0023] If the receiving user has no outgoing edge user, send a failure message to the incoming edge user of the receiving user;
[0024] If the receiving user has out-edge users, add the anonymous identity tags of the out-edge users to the path sequence in the transaction request, and after adding the anonymous identity tag of the receiving user to the transaction request, forward the transaction request to the out-edge users.
[0025] According to a rebalancing method applied to a payment channel network provided by the present invention, in the case of determining that there is a loop according to the path sequence, constructing a loop set includes:
[0026] If the anonymous identity tag of the receiving user exists in both the received path sequence of the receiving user and the locally stored tag set, it is determined that there is a loop in the path sequence;
[0027] Construct the loop set according to the tag set locally stored by the receiving user.
[0028] According to a rebalancing method applied to a payment channel network provided by the present invention, performing amount allocation on the transactions in the cyclic transaction sequence includes:
[0029] Starting from the leader in the loop, send the required amount information in the reverse direction of the loop. When the required amount information received by the user is greater than the required amount information corresponding to the user in the local information table, update the local information table;
[0030] In the case where the user has multiple out-edge users, equally allocate the multiple required amount information received by the user;
[0031] In the case where the user receives multiple required amount information from the same user, select to pay the maximum value among the multiple required amount information.
[0032] According to a rebalancing method applied to a payment channel network provided by the present invention, in the case where the user has multiple out-edge users, equally allocating the multiple required amount information received by the user includes:
[0033] In the case where the user has multiple out-edge users, calculate the sum of the multiple required amount information received by the user;
[0034] If the maximum rebalancing requirement corresponding to the in-edge user of the user is greater than or equal to the sum, forward the multiple required amount information to the in-edge user of the user;
[0035] If the maximum rebalancing requirement corresponding to the incoming-edge user of the user is less than the sum, then use the quotient of the maximum rebalancing requirement and the number of outgoing-edge users as the single-allocation amount, and use the remainder as the remaining amount of the maximum rebalancing requirement. Determine the allocation amount for each demand amount information each time, and update the remaining amount to be allocated for each demand amount information after each allocation.
[0036] According to a rebalancing method applied to a payment channel network provided by the present invention, performing transactions along the loop direction according to the allocated amount to complete the rebalancing operation includes:
[0037] If the demand amount information sent by the leader is different from the bill amount that should actually be paid according to the allocated amount, then the leader broadcasts the bill amount that should actually be paid along the loop direction;
[0038] If all users in the loop agree to the amount allocation scheme, start transactions along the loop direction from the leader to complete the rebalancing operation.
[0039] The present invention also provides a rebalancing device applied to a payment channel network, including:
[0040] An acquisition module, configured to be initiated by an initiating user in a payment channel network to acquire users participating in the rebalancing operation, and generate a subgraph of the payment channel network according to the participating users;
[0041] A generation module, configured to negotiate by users connected by each payment channel in the subgraph according to their own payment capabilities, generate a maximum rebalancing requirement as the value corresponding to the edge in the subgraph, and obtain a rebalancing requirement graph;
[0042] A construction module, configured to obtain a loop from the rebalancing requirement graph and construct a cyclic transaction sequence according to the loop;
[0043] A transaction module, configured to allocate amounts for transactions in the cyclic transaction sequence, and perform transactions along the loop direction according to the allocated amounts to complete the rebalancing operation.
[0044] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the program, it implements the rebalancing method applied to a payment channel network as described in any one of the above.
[0045] The present invention also provides a non-transitory computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, it implements the rebalancing method applied to a payment channel network as described in any one of the above.
[0046] The present invention also provides a computer program product, including a computer program which, when executed by a processor, implements the rebalancing method applied to a payment channel network as described in any one of the above.
[0047] The rebalancing method and device applied to a payment channel network provided by the present invention propose a privacy-protecting rebalancing protocol BFlow. The BFlow protocol allows participants to participate anonymously and find a suitable rebalancing loop to achieve the rebalancing operation. The BFlow protocol consists of three parts, namely, the generation of a rebalancing demand graph, the construction of a cyclic transaction sequence, and the fund allocation and transaction payment of loop transactions, so as to achieve the rebalancing of the funds in the payment channel and improve the stability and efficiency of the payment network. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the following drawings are some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0049] Figure 1 is a schematic flowchart of the rebalancing method applied to a payment channel network provided by the present invention;
[0050] Figure 2 is a schematic model diagram of the payment channel network of the rebalancing method applied to a payment channel network provided by the present invention;
[0051] Figure 3 is based on the Figure 2 rebalancing demand graph in the rebalancing method applied to a payment channel network provided by the present invention;
[0052] Figure 4 is a schematic flowchart of the generation of the rebalancing demand graph in the rebalancing method applied to a payment channel network provided by the present invention;
[0053] Figure 5 is a schematic flowchart of the construction of the cyclic transaction sequence in the rebalancing method applied to a payment channel network provided by the present invention;
[0054] Figure 6 is a schematic diagram of the process of constructing the cyclic transaction sequence in the rebalancing method applied to a payment channel network provided by the present invention;
[0055] Figure 7 is a schematic flowchart of the fund allocation and transaction payment of loop transactions in the rebalancing method applied to a payment channel network provided by the present invention;
[0056] Figure 8 It is a schematic diagram of the fund allocation process of the loop in the rebalancing method applied to the payment channel network provided by the present invention;
[0057] Figure 9 It is a schematic diagram of the relationship between the number of transactions and the network imbalance degree G in the rebalancing method applied to the payment channel network provided by the present invention mean ;
[0058] Figure 10 It is a schematic diagram of the relationship between the number of transactions and the payment success rate in the rebalancing method applied to the payment channel network provided by the present invention;
[0059] Figure 11 It is a schematic diagram of the structure of the rebalancing device applied to the payment channel network provided by the present invention;
[0060] Figure 12 It is a schematic diagram of the structure of the electronic device provided by the present invention. Specific embodiments
[0061] To make the objectives, technical solutions and advantages of the present invention clearer, the technical solutions in the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the present invention. Obviously, the described embodiments are some but not all of the embodiments of the present invention. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in the present invention without creative efforts shall fall within the protection scope of the present invention.
[0062] The following will be combined with Figure 1 Describe a rebalancing method applied to a payment channel network of the present invention, including:
[0063] Step 101: An initiating user in the payment channel network initiates an invitation to obtain users participating in the rebalancing operation, and generates a subgraph of the payment channel network according to the participating users;
[0064] Step 102: The users connected by each payment channel in the subgraph negotiate according to their own payment capabilities, and generate the maximum rebalancing demand as the value on the corresponding edge in the subgraph to obtain a rebalancing demand graph;
[0065] Step 103: Obtain loops from the rebalancing demand graph, and construct a cyclic transaction sequence according to the loops;
[0066] Step 104: Allocate the amounts of the transactions in the cyclic transaction sequence, and execute the transactions along the loop direction according to the allocated amounts to complete the rebalancing operation.
[0067] The payment channel network PCNs is defined as an undirected multigraph with a finite number of nodes , each node represents a user in the payment channel network. The node and has an undirected edge representing a payment channel. Let the payment capacity of the node be , representing that node in the payment channel has a maximum payment amount for . The capacity balance of channel is represented as .
[0068] The rebalancing protocol is essentially a process of mobilizing funds in the payment channel network. To ensure the security of funds, it is necessary to guarantee the conservation of the balance in the channel. That is to say, the balance of an honest user remains unchanged before and after participating in the rebalancing operation. As shown in formula (1):
[0069]
[0070] Among them, among them, is represented as the balance of the payment channel between users.
[0071] In the rebalancing operation, the adjustable amount of funds between any two nodes shall not exceed the maximum payment capacity allowed for that node in the payment channel, as shown in formula (2):
[0072]
[0073] Figure 2 shows an example diagram of the payment channel network model. There are 4 users in the figure, and an undirected edge between users represents a payment channel. The number on the right side of the undirected edge represents the payment capacity of the user in this payment channel, that is . For example, the maximum amount that node A can pay to node D is 12 coins.
[0074] It can be seen from the figure that the amount distribution in this network is unbalanced. For example, nodes D and A have a transaction, which ultimately causes all the amount of node D to flow to node A. If node D does not transfer funds off-chain on the chain, then no transactions will occur on the channel between nodes A and D.
[0075] For the entire payment channel network, as many payment channels as possible will improve the payment success rate. Each node has the possibility of acting as a routing node. Therefore, rebalancing measures are needed to improve the imbalance of the payment channel network in order to reduce the premature unusability of the channel due to fund exhaustion.
[0076] First, generate a directed weighted rebalancing demand graph , Denote the users participating in the rebalancing operation, Denote the edges in the rebalancing operation as a set, The subgraph of G represents the maximum rebalancing demand between nodes. Denote the maximum rebalancing demand from user m to n on the payment channel as , which is negotiated between two users.
[0077] Figure 3 Figure Figure 2 shows the rebalancing demand graph, assuming that all users participate in the rebalancing operation. For example, there is a difference of 7 coins between user A and user D, so user A needs to pay 7 coins to user D, and nodes A and D reach balance. However, since users B and C have the same payment ability, they are balanced at this time and no rebalancing demand is generated.
[0078] The process of generating the rebalancing demand graph first has a user initiate an invitation in the graph G = (V, E), communicate with nearby users to find other users interested in participating in the rebalancing operation, generate a subgraph composed of participating users, and then negotiate between users connected by payment channels to finally generate a directed rebalancing demand graph.
[0079] The process of constructing the cyclic trading sequence is, after obtaining the rebalancing demand graph , according to obtain a suitable loop, and then construct a cyclic trading sequence, that is, the payment sequence of users on the loop.
[0080] The process of fund allocation and trading for the loop is, according to the constructed cyclic trading sequence, allocate the most suitable amount for these cyclic trades so as to best meet the rebalancing demand, and finally execute the trades to complete the rebalancing operation.
[0081] In a decentralized payment network (such as the Lightning Network), users conduct transactions through peer-to-peer payment channels. As transactions proceed, the funds in some payment channels may become unbalanced, resulting in some channels running out of funds or having too much funds, affecting the overall efficiency of the payment network. The BFlow protocol finds suitable rebalancing loops through anonymous participants to rebalance the channel funds and improve the stability and efficiency of the payment network.
[0082] In this embodiment, a rebalancing protocol BFlow that can protect privacy is proposed. The BFlow protocol allows participants to participate anonymously and find a suitable rebalancing loop to achieve the rebalancing operation. The BFlow protocol consists of three parts, namely, the generation of the rebalancing demand graph, the construction of the cyclic transaction sequence, and the fund allocation and transaction payment of the loop transaction, so as to achieve the rebalancing of the payment channel funds and improve the stability and efficiency of the payment network.
[0083] Based on the above embodiment, in this embodiment, the initiating user in the payment channel network initiates an invitation to obtain users participating in the rebalancing operation, including:
[0084] Assign an anonymous identity to the initiating user who initiates the invitation. The initiating user broadcasts the invitation information anonymously. The invitation information includes the maximum hop count and the maximum invitation count;
[0085] After the receiving user in the payment channel network receives the invitation information, the receiving user sends an acceptance message or a rejection message to the sending user who sent the invitation information;
[0086] If the receiving user sends an acceptance message, a new anonymous identity is assigned to the receiving user, the receiving user is added to the participant set of the receiving user, and the receiving user spreads the invitation information to the neighbor nodes of the receiving user anonymously according to the maximum hop count and the maximum invitation count;
[0087] Merge the participant set of the receiving user into the corresponding participant set of the sending user. The final participant set after the merger of the participant set of the initiating user contains all users participating in the rebalancing operation
[0088] The generation process of the rebalancing demand graph is as Figure 4 shown, including the following steps:
[0089] 1. Initialization: For the initiating user of the BFlow protocol Assign a randomly generated anonymous identity C M , and broadcast the invitation information through all its adjacent edges E M . The invitation information includes the maximum hop count , the maximum invitation count and the anonymous identity C generated by the node M . represents the farthest distance that a user can invite. Whenever a user sends an invitation information, the value decreases by 1. When is 0, no more invitation information is sent. represents the upper limit of the maximum number of invitation information that a user can send. By setting and Control the participating user U to control the size of the network scale.
[0090] 2. Processing of invitation information: When the current user N receives the invitation information broadcast by the previous user it needs to reply to it.
[0091] (1) If the user is not willing to participate in the rebalancing operation of the BFlow protocol, it can send a rejection message to the user and end the processing.
[0092] (2) If the current user is willing to participate in the BFlow protocol and the current user is not currently participating in an invitation initiated by other users, assign a new anonymous identity to the current user and add it to the set of participating users , and mark the edge receiving the information as the parent edge .
[0093] (3) If the user has not sent an invitation yet and is greater than 0, when the number of adjacent edges of the user is greater than 0, the user will broadcast the updated invitation information to its neighbor nodes other than the parent node (i.e., minus 1). If the above conditions are not met, that is, is 0 or the number of adjacent edges is 0, the user will reply with an acceptance message to the user .
[0094] 3. Processing of acceptance and rejection information: The user updates the participant set according to the received acceptance or rejection information, and finally the initiator collects all participating users and broadcasts the complete set. When the user sends a message to the user and receives an acceptance message reply, the user will add the participant set of the child node user to the participant set of , and add the edge to the set of edges receiving the received information.
[0095] As the users accepting the invitation get closer and closer to the initiator , their participant sets become more and more complete. This is similar to the divide-and-conquer idea, that is, as the number of divisions decreases, the similarity between each sub-problem and the original problem increases. Through the user Send the received information to the parent node The user can obtain a more complete set of participants , and finally the initiator will obtain the set of all participating users. If a rejection message is received, this edge will be removed from the invitation set, and this user will no longer participate in the BFlow protocol.
[0096] 4. Broadcast the set of participants : When the initiator receives all the responses, at this time, it has obtained from the graph the set of all users who are willing to participate in the BFlow protocol under the parameters and constraints. To ensure the security of the protocol, it is necessary to let all participating users know the complete set , so as to facilitate the identification of real participating users. The set of participants can be broadcast to all participating users in a breadth-first search traversal manner . to all participating users.
[0097] 5. Negotiate and generate a rebalancing demand graph: According to the subgraph obtained above, user m and its connected user n negotiate according to their payment capabilities in the payment channel, and finally obtain the maximum balance demand from m to n . is directed, so all connected users in the subgraph can finally obtain a directed maximum balance demand graph after negotiation .
[0098] Based on the above embodiments, in this embodiment, obtaining a loop from the rebalancing demand graph includes:[[]]
[0099] Randomly select a leader from the rebalancing demand graph;
[0100] The leader sends a transaction request to the outgoing edge corresponding to the leader;
[0101] The receiving user who receives the transaction request processes and forwards it according to the transaction request, and gradually constructs a path sequence;
[0102] When it is determined that there is a loop according to the path sequence, construct a loop set, and record the maximum balance demand of each edge of the loop in the loop set.
[0103] Based on the above embodiments, in this embodiment, the receiving user who receives the transaction request processes and forwards it according to the transaction request, and gradually constructs a path sequence, including:[[]]
[0104] After the receiving user receives the transaction request, locally store the anonymous identity tag in the transaction request in a tag set;
[0105] If the receiving user has no outgoing edge users, send a failure message to the incoming edge users of the receiving user;
[0106] If the receiving user has outgoing edge users, add the anonymous identity tags of the outgoing edge users to the path sequence in the transaction request, and after adding the anonymous identity tag of the receiving user to the transaction request, forward the transaction request to the outgoing edge users.
[0107] The construction process of the cyclic transaction sequence is as Figure 5 shown, and specifically includes the following steps:
[0108] 1. Elect a leader: Generate a list by sorting the participant set, and randomly elect a leader to prevent malicious nodes from interfering. Different from the Revive protocol where the node with a smaller fixed ID value is the leader node, the BFlow protocol sorts the participant set to generate a list , and all users may act as the leader and the leader needs to be re-elected every time the protocol is started. This prevents malicious nodes from deliberately creating a user with a smaller ID value to become the leader and disrupting the normal operation of the BFlow protocol.
[0109] 2. Transaction request: The leader sends a transaction request to the outgoing edge, and users process and forward according to the request to gradually construct a path sequence.
[0110] (1) The leader sends a transaction request to its outgoing edge , and the request includes the anonymous identity tag of the leader , the user sequence on the path and the maximum balance requirement . If the number of outgoing edges of the leader is 0, directly wait for the next round to re-elect the leader.
[0111] (2) After receiving the request, the user stores the anonymous identity tag in the request in . If the user who receives the request has no outgoing edges, send a failure message to its incoming edge and return. If there are outgoing edges, add the anonymous identity tag of each edge to respectively, and then forward the transaction request through each outgoing edge.
[0112] (3) If the user Newly received sequence and the locally stored set of tags If it is found through comparison that there are newly added users, then it is necessary to send an out-edge and supplement and send update messages , and synchronize the newly added users to .
[0113] 3. Loop search: The user determines whether there is a loop according to the path sequence, constructs a loop set, and records the maximum balance demand information.
[0114] Based on the above embodiments, in this embodiment, when it is determined that there is a loop according to the path sequence, constructing a loop set includes:
[0115] If the anonymous identity tag of the receiving user exists in both the received path sequence of the receiving user and the locally stored set of tags, it is determined that there is a loop in the path sequence;
[0116] Construct the loop set according to the locally stored set of tags of the receiving user.
[0117] During the loop search process, first judge the path sequence of the received anonymous identity tag and the locally stored set of tags of the user to see if the intersection contains the tag of this user . If it contains, it means that the sent tag has returned to this user, indicating that there is at least one loop. If it does not contain then there is no loop. Finally, the user constructs a loop set according to the user sequence in , record the path information and the maximum balance demand of the loop belonging to this user and other information. The loop set is the cyclic transaction sequence.
[0118] Figure 6 In (a) to (d) in
[0119] Based on the above embodiments, in this embodiment, the amount allocation for the transactions in the cyclic transaction sequence includes:
[0120] Starting from the leader in the loop, send the demand amount information in the reverse direction of the loop. When the demand amount information received by the user is greater than the demand amount information corresponding to the user in the local information table, update the local information table;
[0121] In the case where there are multiple out-edge users for the said user, equally distribute the multiple demand amount information received by the said user;
[0122] In the case where the said user receives multiple demand amount information from the same user, select to pay the maximum value among the multiple demand amount information.
[0123] The fund allocation and transaction payment process for loop transactions are as Figure 7 shown, and include the following steps:
[0124] 1. Send demand amount information: Starting from the loop leader, send the demand amount information in the reverse loop direction and update the local information table.
[0125] (1) According to the loop that has been searched during the construction stage of the cyclic transaction, starting from the loop leader, send the demand amount information , including the actually requested amount .
[0126] (2) The local information table of loop members stores the real-time balance demand amount of loop members during the execution of the protocol, denoted as , with the initial value defaulting to 0. When a user receives an amount message , if it is not the leader or the actually requested amount , then update the value.
[0127] (3) For a user with multiple out-edges, it is necessary to equally distribute the received request amounts.
[0128] (4) When receiving multiple amount information from the same user , then select to pay the edge with the largest demand.
[0129] 2. Equal distribution of amounts: For the case of multiple out-edges, adopt an equal distribution algorithm to ensure that the demands of all parties are satisfied as much as possible. In this process, it is necessary to handle the situation where a user has multiple out-edges, that is, after the user receives a list of multiple demand amount information , it is necessary to send this demand amount information to the next user through the same edge. If the demand of the next edge, that is, the amount to be distributed , continues to forward the amount information according to the list information. If the amount to be distributed is less than the sum of the demanded amounts , then the amount needs to be equally distributed.
[0130] 3. Payment for circular transactions: The leader collects and confirms the payment plan, executes the transaction along the loop direction, and completes the rebalancing operation.
[0131] Based on the above embodiments, in this embodiment, when there are multiple outgoing users for the user, the equal distribution of the multiple demand amount information received by the user includes:
[0132] When there are multiple outgoing users for the user, calculate the sum of the multiple demand amount information received by the user;
[0133] If the maximum rebalancing demand corresponding to the incoming user of the user is greater than or equal to the sum, forward the multiple demand amount information to the incoming user of the user;
[0134] If the maximum rebalancing demand corresponding to the incoming user of the user is less than the sum, take the quotient of the maximum rebalancing demand and the number of outgoing users as the single - time allocation amount, and the remainder as the remaining amount of the maximum rebalancing demand. Determine the allocation amount for each demand amount information each time, and update the remaining amount to be allocated for each demand amount information after each allocation.
[0135] This embodiment proposes an algorithm for equal distribution of amounts to satisfy the demands of all parties as much as possible. If , the algorithm steps are as follows:
[0136] (1) Set an initial value of 0 and a list of the same length as to save the amount allocated to each demand. Each demand in is At the same time, set a temporary list exactly the same as to represent the amount of the remaining unallocated demand. The single - time allocation amount is the quotient of the amount to be allocated and the total number of demands | |, denoted as .
[0137] (2) If there is still an amount to be allocated, that is, , for each demand the allocated amount is , where is the single - time allocation amount and the remaining amount to be allocated for the current demand . Update
[0138] (3) If there is still remaining amount to be allocated after the previous allocation , then the remaining amount will be allocated in the smallest unit .
[0139] Figure 8 Examples of the allocation of the required amount are shown in (a) to (d) of Figure 8 . Since the edge weight of user Q is only 15, but the amount to be allocated is from the circular transactions of users D and E respectively, and the sum of the requirements is 16 + 8 = 24. According to the allocation algorithm 15 / 2 = 7......1, since 7 < 16 and 7 < 8, each path will be allocated 7 coins first, and the remaining 1 coin will be allocated to one of users D or E. Therefore, the demand allocation algorithm needs to be used to evenly allocate the amount for these two loops. Finally, the amount allocated to the loop A→Q→D→C→A is 8 coins, and the amount allocated to the loop A→Q→E→A is 7 coins.
[0140] The smallest unit is the lowest unit value of the coin, which is defaulted to 1 coin. If there are three requirements of 30 respectively, according to the allocation algorithm 80 / 3 = 26....2, since 26 is less than 30, each requirement will be allocated 26 first; finally, the remaining amounts for the three requirements are 4 respectively. Because 1 is less than 4, the first two requirements will each be allocated 1 coin. So the allocated amounts for the three requirements are 27, 27, and 26 respectively.
[0141] If the minimum value of the user's value in step (2) is , it also indicates that the payment request of this user has been completed. Finally, circular allocation will be performed, with the maximum amount allocated each time being 1. For example, the remaining requirements are (1.2, 0, 1.5, 3, 5), = 6, then after the first round of circulation, it is (0.2, 0, 0.5, 2, 4), and after the second round of circulation, it is (0, 0, 0, 1, 3.7).
[0142] Based on the above embodiments, in this embodiment, performing transactions along the loop direction according to the allocated amount to complete the rebalancing operation includes:
[0143] If the required amount information sent by the leader is different from the actual bill amount to be paid according to the allocated amount, then the leader broadcasts the actual bill amount to be paid along the loop direction;
[0144] If all users in the loop agree to the amount allocation plan, start performing transactions along the loop direction from the leader to complete the rebalancing operation.
[0145] When the leader of the cyclic transaction receives the allocated loop demand message, which can also be said to be the actual payment plan, the leader has obtained the complete payment bill. Since the amount of the payment request sent by the leader at the beginning After the allocation of the demand, it may lead to a difference between the amount of the payment request bill information actually received by it and the amount is different. Therefore, the leader also needs to broadcast the actual payable bill amount along the loop direction. If the loop members agree to the latest payment amount after obtaining the latest payment amount, they will continue to forward it to the next member. If all users in the loop finally agree to the latest payment plan, the leader of the cyclic transaction will execute the transaction along the loop direction, and finally complete the rebalancing operation to end the protocol.
[0146] For example, assume that the leader hopes that a certain path can pay him 10 coins, but some nodes do not have enough funds to complete the payment and can only complete 8 coins. At this time, the leader needs to broadcast the bill information of the transaction to other users on the path and tell them that they only need to pay 8 coins and wait for them to finally complete the payment of the bill.
[0147] In the experiment, experimental estimation was carried out by analyzing the historical data of the real-world payment channel network to construct a new payment channel network. In this process, those channels that could not be corresponded to any node were excluded, and finally a PCN containing 3896 nodes and 53211 channels was formed. In order to simulate the unpublicized channel balance distribution in the Lightning network, a strategy of randomly generating balances was adopted.
[0148] In addition, the three key processes of the BFlow protocol were implemented in the Python environment. All these experiments were completed on a desktop computer equipped with an i7-11700 CPU and 16GB of memory. In order to be closer to the workload imbalance phenomenon existing in the PCN, the exponential distribution was used to randomly determine the initiating and receiving nodes of the transaction, ensuring that some nodes play a more frequent sending or receiving role in the network. Such a setting aims to deeply explore the situation of workload imbalance inside the PCNs, so as to more accurately evaluate the BFlow protocol.
[0149] Study the effect of the BFlow protocol on controlling the increase in the imbalance degree and the change in the corresponding payment success rate. Figure 9 Shows the relationship between the number of transactions and the overall network imbalance degree The results show that the overall network imbalance degree increases as the transaction progresses. However, the growth rate of the Baseline without implementing the rebalancing algorithm is significantly faster than that of other algorithms, indicating that the rebalancing algorithm has a great effect on controlling the increase in the imbalance degree of the payment channel network.
[0150] Specifically, the BFlow protocol has the best effect in increasing the imbalance degree of protocol control. During a total of 3,800 transactions, the BFlow protocol can keep the overall network imbalance degree within 0.18. Followed by the Cycle algorithm and the Revive algorithm, whose overall performance is similar. However, after the number of transactions exceeds 3,300, the Cycle algorithm is slightly better than the Revive algorithm in alleviating the growth of imbalance degree.
[0151] Figure 10 Figure shows the relationship between the number of transactions and the payment success rate. It can be seen from the figure that as the number of transactions increases, the payment success rate decreases accordingly. Specifically, since the Baseline has no rebalancing effect, the payment success rate will decrease as the network imbalance degree increases. In the initial stage of the transaction, the payment success rates of each algorithm are stable at the above level. However, as the number of transactions increases, the BFlow protocol shows better performance compared with the Revive algorithm and the Cycle algorithm, and can keep the payment success rate above 50%. Therefore, effectively controlling the overall network imbalance degree is of great significance for improving the payment success rate.
[0152] Next, the rebalancing device provided by the present invention for the payment channel network will be described. The rebalancing device for the payment channel network described below can be correspondingly referred to the rebalancing method for the payment channel network described above.
[0153] As Figure 11 shown, the device includes an acquisition module 1101, a generation module 1102, a construction module 1103 and a transaction module 1104, where:
[0154] The acquisition module 1101 is used to initiate an invitation by the initiating user in the payment channel network, acquire the users participating in the rebalancing operation, and generate a subgraph of the payment channel network according to the participating users;
[0155] The generation module 1102 is used to negotiate by the users connected by each payment channel in the subgraph according to their own payment capabilities, generate the maximum rebalancing demand as the value on the corresponding edge in the subgraph, and obtain a rebalancing demand graph;
[0156] The construction module 1103 is used to obtain loops from the rebalancing demand graph and construct a cyclic transaction sequence according to the loops;
[0157] The transaction module 1104 is used to allocate amounts for the transactions in the cyclic transaction sequence, execute the transactions along the loop direction according to the allocated amounts, and complete the rebalancing operation.
[0158] In this embodiment, a rebalancing protocol BFlow that can protect privacy is proposed. The BFlow protocol allows participants to participate anonymously and find a suitable rebalancing loop to achieve the rebalancing operation. The BFlow protocol consists of three parts: the generation of the rebalancing demand graph, the construction of the cyclic transaction sequence, and the fund allocation and transaction payment of the loop transaction, so as to achieve the rebalancing of the payment channel funds and improve the stability and efficiency of the payment network.
[0159] Figure 12 An example of the physical structure diagram of an electronic device is shown as Figure 12 shown. The electronic device may include: a processor 1210, a communications interface 1220, a memory 1230, and a communication bus 1240. Among them, the processor 1210, the communications interface 1220, and the memory 1230 communicate with each other through the communication bus 1240. The processor 1210 can call the logical instructions in the memory 1230 to execute the rebalancing method applied to the payment channel network. The method includes: an initiating user in the payment channel network initiates an invitation to obtain users participating in the rebalancing operation, and generates a subgraph of the payment channel network according to the participating users; users connected by each payment channel in the subgraph negotiate according to their own payment capabilities to generate the maximum rebalancing demand as the value on the corresponding edge in the subgraph, and obtain the rebalancing demand graph; obtain a loop from the rebalancing demand graph, and construct a cyclic transaction sequence according to the loop; allocate amounts to the transactions in the cyclic transaction sequence, and execute the transactions along the loop direction according to the allocated amounts to complete the rebalancing operation.
[0160] In addition, when the logical instructions in the above-mentioned memory 1230 are implemented in the form of software functional units and sold or used as an independent product, they can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of this technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present invention. The foregoing storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), magnetic disks, or optical discs that can store program codes.
[0161] On the other hand, the present invention also provides a computer program product, which includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the rebalancing method applied to the payment channel network provided by the above-mentioned various methods. The method includes: an initiating user in the payment channel network initiates an invitation to obtain users participating in the rebalancing operation, and generates a subgraph of the payment channel network according to the participating users; users connected by each payment channel in the subgraph negotiate according to their own payment capabilities to generate the maximum rebalancing demand as the value on the corresponding edge in the subgraph, obtaining a rebalancing demand graph; obtain loops from the rebalancing demand graph, and construct a cyclic transaction sequence according to the loops; allocate amounts to the transactions in the cyclic transaction sequence, and execute the transactions along the loop direction according to the allocated amounts to complete the rebalancing operation.
[0162] In yet another aspect, the present invention also provides a non-transitory computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, it is implemented to execute the rebalancing method applied to the payment channel network provided by the above-mentioned various methods. The method includes: an initiating user in the payment channel network initiates an invitation to obtain users participating in the rebalancing operation, and generates a subgraph of the payment channel network according to the participating users; users connected by each payment channel in the subgraph negotiate according to their own payment capabilities to generate the maximum rebalancing demand as the value on the corresponding edge in the subgraph, obtaining a rebalancing demand graph; obtain loops from the rebalancing demand graph, and construct a cyclic transaction sequence according to the loops; allocate amounts to the transactions in the cyclic transaction sequence, and execute the transactions along the loop direction according to the allocated amounts to complete the rebalancing operation.
[0163] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed to multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment. A person of ordinary skill in the art can understand and implement it without creative labor.
[0164] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on such an understanding, the essence of the above technical solution, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0165] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements for some of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A rebalancing method applied to a payment channel network, characterized in that: include: An initiating user in the payment channel network initiates an invitation, obtains users participating in the rebalancing operation, and generates a subgraph of the payment channel network according to the participating users; Users connected to each payment channel in the subgraph negotiate according to their own payment capabilities, generating a maximum rebalancing demand as a value on a corresponding edge in the subgraph, thereby obtaining a rebalancing demand graph; Obtaining a loop from the rebalancing demand graph, and constructing a cyclic transaction sequence according to the loop; Allocating amounts to transactions in the cyclic transaction sequence, executing transactions along the loop direction according to the allocated amounts, and completing the rebalancing operation; The initiating user in the payment channel network initiates an invitation to obtain users participating in the rebalancing operation, including: Assigning an anonymous identity to the initiating user who initiates the invitation, and the initiating user broadcasts the invitation information with the anonymous identity, wherein the invitation information includes a maximum number of hops and a maximum number of invitations; After receiving the invitation information, the receiving user in the payment channel network sends an acceptance message or a rejection message to the sending user who sent the invitation information; If the receiving user sends an acceptance message, a new anonymous identity is assigned to the receiving user, the receiving user is added to the participant set of the receiving user, and the receiving user propagates the invitation information to the neighboring nodes of the receiving user with the new anonymous identity according to the maximum number of hops and the maximum number of invitations; Merging the participant set of the receiving user into the participant set of the corresponding sending user, so that the final participant set after merging the participant set of the initiating user includes all users participating in the rebalancing operation; Obtaining a loop from the rebalancing demand graph includes: Randomly elect a leader from the rebalancing demand graph; The leader sends a transaction request to the outgoing edge corresponding to the leader; The receiving user who receives the transaction request processes and forwards the transaction request according to the transaction request, and gradually builds a path sequence; In the case where it is determined that a loop exists according to the path sequence, a loop set is constructed, and the maximum balance requirement of each edge of the loop is recorded in the loop set; The receiving user who receives the transaction request processes and forwards the transaction request, and gradually builds a path sequence, including: After the receiving user receives the transaction request, the anonymous identity tag in the transaction request is locally stored in a tag set; If the receiving user has no outgoing user, sending a failure message to the incoming user of the receiving user; If the receiving user has an outgoing user, the anonymous identity tag of the outgoing user is added to the path sequence in the transaction request, and the transaction request is forwarded to the outgoing user after the anonymous identity tag of the receiving user is added to the transaction request; When it is determined that a loop exists according to the path sequence, a loop set is constructed, including: If the anonymous identity tag of the receiving user exists in both the path sequence received by the receiving user and the locally stored tag set, it is determined that a loop exists in the path sequence; The loop set is constructed according to the tag set stored locally by the receiving user.
2. The rebalancing method for a payment channel network according to claim 1, characterized in that: Allocating amounts for transactions in the cyclic transaction sequence includes: The leader in the loop starts to send the required amount information in the reverse direction of the loop, and when the required amount information received by the user is greater than the required amount information corresponding to the user in the local information table, the local information table is updated; In the case that the user has multiple outbound users, the multiple required amount information received by the user are equally distributed; When the user receives multiple required amount information from the same user, the user chooses to pay the maximum value of the multiple required amount information.
3. The rebalancing method for a payment channel network according to claim 2, characterized in that: In the case that the user has multiple outbound users, the multiple required amount information received by the user is equally distributed, including: In the case that the user has multiple outbound users, calculating the sum of multiple required amount information received by the user; If the maximum rebalancing demand corresponding to the incoming user of the user is greater than or equal to the sum, forwarding the multiple demand amount information to the incoming user of the user; If the maximum rebalancing demand corresponding to the incoming user of the user is less than the total, the quotient of the maximum rebalancing demand and the number of the outgoing users is used as the single allocation amount, and the remainder is used as the remaining amount of the maximum rebalancing demand. The allocation amount for each demand amount information is determined based on the single allocation amount and the remaining amount, and the remaining amount to be allocated for each demand amount information is updated after each allocation.
4. The rebalancing method for a payment channel network according to claim 2, characterized in that: The executing of transactions along the loop direction according to the allocated amount to complete the rebalancing operation includes: If the required amount information sent by the leader is different from the actual bill amount to be paid according to the allocated amount, the leader broadcasts the actual bill amount to be paid along the loop direction; If all users in the loop agree on the allocation plan of the amount, transactions are executed along the loop direction starting from the leader to complete the rebalancing operation.
5. A rebalancing device applied to a payment channel network, characterized in that: The rebalancing method applied to a payment channel network as claimed in any one of claims 1 to 4 comprises: An acquisition module, configured to initiate an invitation from an initiating user in the payment channel network, acquire users participating in the rebalancing operation, and generate a subgraph of the payment channel network according to the participating users; A generation module, configured to generate a maximum rebalancing demand as a value on a corresponding edge in the subgraph through negotiation by users connected to each payment channel in the subgraph according to their own payment capabilities, thereby obtaining a rebalancing demand graph; A construction module, configured to obtain a loop from the rebalancing demand graph and construct a cyclic transaction sequence according to the loop; The transaction module is used to allocate amounts to transactions in the cyclic transaction sequence, execute transactions along the loop direction according to the allocated amounts, and complete the rebalancing operation.
6. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the rebalancing method applied to the payment channel network as claimed in any one of claims 1 to 4 is implemented.
Citation Information
Patent Citations
Rebalance strategy execution method for off-chain payment in block chain
CN111724257A
Off-chain channel amount balancing method and system
CN111768192A