Disclosure of Invention
Based on the technical problem, the application provides a method and a system for promoting transaction commission charge in a block chain based on a UTXO (unified transform and encryption) architecture, so as to solve the problem that the transaction cannot be packed into a block in time and only can be waited for a long time after being broadcasted and legally stored in a memory transaction pool by being checked by other nodes.
In a first aspect, the present application provides a method for increasing transaction commission in a blockchain based on a UTXO architecture, the method including:
a transaction commission promotion method in a blockchain based on UTXO architecture, the method comprises the following steps:
traversing the unspent output based on the UTXO architecture for creating an original transaction, the original transaction including the replaceable token and the pre-set packed minimum time;
signing and broadcasting the original transaction;
verifying the validity of the original transaction and storing the original transaction passing the verification into a memory transaction pool;
creating a replacement transaction;
finding the original transaction that corresponds to the replacement transaction that is not packaged;
copying the input of the original transaction into the input of the replacement transaction such that the input of the original transaction equals the input of the corresponding replacement transaction;
adjusting the replaceable indicia and preset packaged minimum time for the replacement transaction as needed;
modifying the received address and commission at the output of the replacement transaction;
signing and broadcasting the replacement transaction;
verifying the validity of the replacement transaction according to a preset transaction replacement rule;
if the verification is passed, deleting the original transaction in the memory transaction pool, and storing the replacement transaction passing the verification into the memory transaction pool;
deleting the original transaction at the wallet file, and crediting the wallet file with the replacement transaction.
Further, the method also comprises the steps of checking the legal original transactions in the memory transaction pool, packaging the legal original transactions into a block, generating a transaction block, and sending the transaction block to other full nodes participating in mining;
and the full node checks the transaction blocks, enumerates the transaction blocks passing the check as candidate blocks and identifies the candidate blocks.
Further, the preset packed minimum time usage rule is that the original transaction cannot be packed into the block until the original transaction for which the preset packed minimum time is set does not reach the minimum time.
Further, the method further comprises broadcasting the block after the original transaction is packed into the block, and checking the block according to a block checking rule;
and if the original transaction sets the minimum time for presetting the package but does not reach the minimum time, judging the block to be an illegal block.
Further, the step of checking the validity of the replacement transaction according to a preset transaction replacement rule includes:
verifying the validity of the replacement transaction by the replaceable mark and judging whether the input of the original transaction and the input of the replacement transaction are consistent;
if the replaceable indicia is present and the input of the original transaction equals the input of the replacement transaction, the replacement transaction is legitimate.
Further, the commission of the replacement transaction is not less than the sum of the commission of the original transaction and the network broadband fee.
Further, the method may include reducing change at the output of the replacement transaction to increase the commission for the replacement transaction.
Further, the method may further comprise setting a specific field of the replacement transaction input to a preset function code to make the replacement transaction replaceable.
In a second aspect, the present application further provides a system for promoting transaction commission charge in a block chain based on a UTXO architecture, which includes a transaction creator and a plurality of full nodes, wherein:
the transaction creator is configured to perform the steps of:
traversing the unspent output based on the UTXO architecture for creating an original transaction, the original transaction including the replaceable token and the pre-set packed minimum time;
signing and broadcasting the original transaction;
verifying the validity of the original transaction and storing the original transaction passing the verification into a memory transaction pool;
creating a replacement transaction;
finding the original transaction that corresponds to the replacement transaction that is not packaged;
copying the input of the original transaction into the input of the replacement transaction such that the input of the original transaction equals the input of the corresponding replacement transaction;
adjusting the replaceable indicia and preset packaged minimum time for the replacement transaction as needed;
modifying the received address and commission at the output of the replacement transaction;
signing and broadcasting the replacement transaction;
the plurality of full nodes are configured to perform the steps of:
verifying the validity of the replacement transaction according to a preset transaction replacement rule;
if the verification is passed, deleting the original transaction in the memory transaction pool, and storing the replacement transaction passing the verification into the memory transaction pool;
the transaction creator is further configured to perform the steps of:
deleting the original transaction at the wallet file, and crediting the wallet file with the replacement transaction.
Further, the plurality of said full nodes are further configured to perform the steps of:
broadcasting the block after the original transaction is packed into the block, and checking the block according to a block checking rule;
and if the original transaction sets the minimum time for presetting the package but does not reach the minimum time, judging the block to be an illegal block.
From the above technical solutions, the present application discloses a method and a system for increasing transaction commission in a blockchain based on a UTXO architecture, including: traversing the unspent output based on the UTXO framework for creating an original transaction, the original transaction including the replaceable token and the pre-set packed minimum time; signing and broadcasting the original transaction; verifying the validity of the original transaction and storing the verified original transaction into a memory transaction pool; creating a replacement transaction; finding an unpackaged original transaction corresponding to the replacement transaction; copying the input of the original transaction into the input of the replacement transaction such that the input of the original transaction equals the input of the corresponding replacement transaction; adjusting the replaceable indicia of the replacement transaction and the preset packaged minimum time as needed; modifying the receive address and the commission at the output of the replacement transaction; signing and broadcasting the replacement transaction; verifying the validity of the replacement transaction according to a preset transaction replacement rule; if the verification is passed, deleting the original transaction in the memory transaction pool, and storing the replacement transaction passing the verification into the memory transaction pool; the original transaction is deleted at the wallet file and the replacement transaction is credited to the wallet file. The transaction creator achieves the effect of being packaged more quickly by improving the handling fee of the replacement transaction, so that the problem that the transaction cannot be packaged into a block in time and can only wait for a long time after being broadcast and legally stored into the memory transaction pool by being verified by other nodes is solved.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the technical solutions of the present application will be described in detail and completely with reference to the following specific embodiments of the present application and the accompanying drawings. It should be apparent that the described embodiments are only some of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application. The technical solutions provided by the embodiments of the present application are described in detail below with reference to the accompanying drawings.
The main objective of the present application is to provide a method and a system for increasing transaction commission in a blockchain based on a UTXO architecture, in which the output of transactions that have been broadcast to a network but not packed into a block and in a memory transaction pool is modified, so as to achieve the purpose of increasing transaction commission and replacing transaction output.
Utxo (outstanding Transaction outputs) is an inexpensive Transaction output, which is a core concept for bitcoin Transaction generation and verification. The transactions form a set of chain structures, all legal bitcoin transactions can be traced back to the output of one or more previous transactions, the source of the chains is mining rewards, the tail end of the chains is the current unspent transaction output, and all unspent outputs are UTXO of the whole bitcoin network. The bit currency specifies that the input of each new transaction must be the output which is not spent by a certain transaction, each input also needs the private key corresponding to the last output to carry out signature, and the node of each bit currency stores the UTXO on the current whole block chain, and the node on the whole network verifies the validity of the new transaction through the UTXO and the signature algorithm.
In the blockchain, a certain commission is paid to complete a transaction. On one hand, because the capacity of the block for accommodating the transaction records is limited, miners can pack transactions with high transaction commission preferentially, and if the transaction commission is not paid, the transactions can be packed for a long time; on the other hand, if no handling fee exists, malicious transactions or non-cost transactions may exist, a large number of malicious transactions may cause waste of networks, CPUs, computing power and the like, more efficient contract codes may be encouraged by paying a certain handling fee, unnecessary computing is reduced, and the system is prevented from being attacked and the like.
Referring to fig. 1, fig. 1 is a schematic flow chart of a transaction commission fee promotion method in a blockchain based on a UTXO architecture, as can be seen from fig. 1, the method specifically includes:
s1: traversing the unspent output based on the UTXO framework for creating an original transaction, the original transaction including the replaceable token and the pre-set packed minimum time;
in the block chain based on the UTXO architecture, assuming that a node a creates an alternative original transaction T through unconsumed output, the node a is the transaction creator, and adds an alternative tag field to a specific field of the transaction input as needed, for example, referring to table 1, table 1 is a schematic diagram of a transaction input structure (the table structure is only an exemplary illustration and does not represent an actual table structure), table 1 lists the transaction type, the transaction ID, the output of the previous transaction (i.e. the source of the money), the public key and unlock information of the sender, and the alternative tag, etc. of the original transaction input, and the node a sets the "alternative tag" field of the original transaction input to 0 xfffffffff-1-1, which represents the tag of the alternative transaction, i.e. if the original transaction is to be replaced, the field must be filled.
TABLE 1 transaction input architecture
The preset packed minimum time is a minimum time for which the transaction creator sets the original transaction to be packed on the incidental information of the original transaction when creating the original transaction, and the preset packed minimum time usage rule is that the original transaction cannot be packed into the block until the original transaction with the set preset packed minimum time does not reach the minimum time, which will be described in detail below.
S2: signing and broadcasting the original transaction;
the transaction creator may sign the original transaction using the private key and then broadcast the original transaction to the entire network.
S3: verifying the validity of the original transaction and storing the verified original transaction into a memory transaction pool;
the node of the whole network can check the validity of the original transaction and store the original transaction into the memory transaction pool, namely, the original transaction is broadcast and then enters the memory transaction pool through legal check. In the next round of mining, the miners will select a portion of the trade packages in the in-memory trade pool. The usage rule of the preset packed minimum time is to be followed when packing, for convenience of description, the preset packed minimum time may be referred to as a locking time, for convenience of understanding of the usage rule, referring to fig. 2, fig. 2 is a schematic diagram of the preset packed minimum time and the usage rule set for the original transaction, and fig. 2 is now explained as follows:
t is an original transaction created by a transaction creator, thread indicates that T is broadcasted, Miner indicates a Miner, CreateBlock indicates a created Block, now () indicates a current time, nLockTime indicates a lock time, i.e., 2 preset minimum time to pack, Block indicates a Block, then the preset minimum time to pack, i.e., the lock time usage rule shown in fig. 2 is that a transaction set to the minimum time to pack must not be packed into a Block until the corresponding time is not reached, i.e., if the current time > the lock time, the Miner may pack the original transaction T; if the current time is less than the locking time, the Miner cannot pack the original transaction T, and actually, the preset minimum packing time is set to optimize the duration of the original transaction stored in the memory transaction pool.
After the original transaction is packaged into the block, broadcasting the block, checking the block according to the block checking rule, if the minimum time for presetting and packaging is set for the original transaction but the minimum time is not reached, judging the block to be an illegal block, and setting the minimum time for presetting and packaging can ensure that the original transaction is replaced within the effective time. Specifically, after the blocks are excavated, the blocks are broadcast to the whole network, when other nodes receive and check the blocks, the following check items are added to the validity of the original transaction, and if the transaction which sets the locking time but does not reach the corresponding time is judged to be an illegal block, the effective time for replacing the original transaction which the transaction creator wants to create can be ensured.
Furthermore, when the block is packed, the miners check legal original transactions in the memory transaction pool and pack the legal original transactions into the block to generate a transaction block, and send the transaction block to other full nodes participating in mining; and checking the transaction blocks by the whole nodes, listing the transaction blocks passing the check as candidate blocks and identifying the candidate blocks. The full nodes are nodes with complete block chain accounts, need to occupy memory to synchronize all block chain data, can independently check all transactions on the block chain and update data in real time, and are mainly responsible for broadcasting and verifying transactions of the block chain. The block legal verification comprises the legal verification of the original transaction in the block, the block is listed as a candidate block and is identified after the verification is passed, and the process does not affect the safety of the whole transaction system.
S4: creating a replacement transaction;
a replacement transaction is a new transaction created by the transaction creator to replace the original transaction. When the node for creating the original transaction marks the original transaction as an alternative transaction when the original transaction is created, the original transaction is stored in a memory transaction pool by other miner nodes after being broadcasted, and at the moment, 1 replacement transaction for replacing the original transaction, namely a new transaction, is created by the node for creating the original transaction.
S5: finding an unpackaged original transaction corresponding to the replacement transaction;
the transaction creator finds the original transaction that it wishes to replace, i.e., the original transaction that was originally created without packaging.
S6: copying the input of the original transaction into the input of the replacement transaction such that the input of the original transaction equals the input of the corresponding replacement transaction;
the input of the original transaction is copied into the input of the replacement transaction, i.e. the input must be equal before and after the transaction replacement. Specifically, the implementation may be implemented by program codes, and in order to visually represent this link, for example, part of the implemented program codes may be (for a clearer description, a schematic description of concise codes is directly used here):
if (replaceable rule, if replacement condition (original transaction) is satisfied)
{
Alternate transaction = new transaction (·);
input = original transaction input;
at least the amount that needs to be increased = calculate the commission (original transaction) that the replacement must increase;
for (output member: original transaction output)
{
if (wallet. recipient Address container. Contains (output member. recipient address))
{
Amount of members- = amount of at least required to be promoted;
}
push _ back (output member);
}
it should be noted that the above codes do not represent actual real codes, but are merely exemplary lists for visual presentation without considering the writing rules.
S7: adjusting the replaceable indicia of the replacement transaction and the preset packaged minimum time as needed;
the transaction creator adjusts the minimum time for the replaceable indicia and the pre-set packaging as needed.
S8: modifying the receive address and the commission at the output of the replacement transaction;
the receiving address and the handling fee are modified at the output of the replacement transaction for canceling the transaction or raising the handling fee, the handling fee of the replacement transaction is not less than the sum of the handling fee of the original transaction and the network broadband fee, and in addition, change is reduced at the output of the replacement transaction so that the handling fee of the replacement transaction is raised.
It should be noted that the replacement of the original transaction may be performed more than once, assuming that the original transaction T successfully enters the memory transaction pool after being broadcasted, at this time, the transaction amount in the network is sent very frequently, and miners cannot ensure that the original transaction T is packed and confirmed in the next block in consideration of the benefit maximization that the packing sequence of the transactions starts from the highest commission charge, at this time, the node a creates a new transaction, i.e., the replacement transaction T ', and may find the input of the original transaction T again and copy the input to the input of the replacement transaction T', at this time, a specific field of the input of the replacement transaction is set to a preset function code, so that the replacement transaction may also be performed, that is, the replacement of the original transaction may be performed more than once. For example, according to actual requirements, the preset rule can be that if the value of the replaceable mark field of the replacement transaction is smaller than that of the replaceable mark of the original transaction, this represents that this is the latest replacement transaction, and if the above condition is met, the filling of the replaceable mark field content can be set to std:: numeric _ limits < signaled int >: max () -3, which represents the latest transaction of the replacement transaction.
The transaction creator achieves the effect of being packaged more quickly by improving the handling fee of the replacement transaction, and the specific implementation mode is that change making is reduced in the output of the replacement transaction, the change making is basically filled with the receiving address and the amount of money of the transaction creator at the output position, the amount of money is reduced from the position of the output change making, and the reduced amount of money can become the transaction handling fee, so that the purpose of improving the handling fee is achieved.
S9: signing and broadcasting the replacement transaction;
after the receiving address and the commission charge of the replacement transaction are modified, the replacement transaction is signed and broadcast, and other miners can receive the replacement transaction. And after the original transaction is broadcasted, the original transaction enters a memory transaction pool after legal verification of miners, and when the replacement transaction created by the transaction creator is broadcasted, the miners replace the original transaction after receiving the replacement transaction and performing replacement rule and legal verification.
S10: verifying the validity of the replacement transaction according to a preset transaction replacement rule;
after receiving the replacement transaction, the other mineworker nodes check the validity of the replacement transaction according to a preset transaction replacement rule, for example, the replacement rule may include the following aspects that the validity of the replacement transaction is checked through the replaceable mark and whether the input of the original transaction and the input of the replacement transaction are consistent, if the replaceable mark exists in the original transaction and the input of the original transaction is equal to the input of the replacement transaction, and the commission of the replacement transaction reaches the minimum standard in the replacement rule, if the commission of the replacement transaction is not less than the sum of the commission of the original transaction and the network broadband fee, the replacement transaction is legal, and the replacement rule is not specifically limited by the present application.
S11: if the verification is passed, deleting the original transaction in the memory transaction pool, and storing the replacement transaction passing the verification into the memory transaction pool;
referring to fig. 3, fig. 3 is a schematic diagram of a replacement validity check flow and a replacement process of an original transaction and a replacement transaction, where T is still the original transaction, after rule verification is performed on a validity rule (rule) of the original transaction after broadcasting, the original transaction and the replacement transaction are stored in a memory transaction pool txMemoryPool by a Miner, T ' is a replacement transaction created according to the replacement rule, and according to a preset transaction replacement rule, if the replacement check of the original transaction and the replacement transaction passes, that is, the replacement rule is met after the verification, as shown in fig. 3, the original transaction T is deleted in the memory transaction pool, a cross in the diagram represents deletion, and the verified replacement transaction T ' is stored in the memory transaction pool, and the replacement of the original transaction T by the replacement transaction T ' is completed according to the rule, and Replace is replacement operation.
S12: the original transaction is deleted at the wallet file and the replacement transaction is credited to the wallet file.
The wallet file comprises all the output which is not spent and the transaction records related to the wallet file, in the embodiment of the application, the wallet file has the function of counting information required by a user, such as balance and the like, at a user level, and deleting the original transaction in the wallet file and storing the replaced transaction in the wallet file after the original transaction and the replaced transaction are replaced in the internal transaction pool according to the transaction replacement rule, so that the update is carried out.
In actual work, there are cases that a legal transaction is recorded in a memory transaction pool of other nodes once being broadcast and is finally packaged into a block, but at least the time for waiting for at least a long time to be confirmed (namely, being packaged into a block) after the transaction is broadcast cannot be set to be at least the required time, in this case, all transfers made cannot be withdrawn, for example, a transfers money to B, but before the transaction is not packaged into a block after being broadcast, a repels the transfer to be withdrawn, and at this time, the function can be realized by using the application for replacing the transaction.
From the above technical solutions, the present application discloses a method for increasing transaction commission in a blockchain based on a UTXO architecture, including: traversing the unspent output based on the UTXO framework for creating an original transaction, the original transaction including the replaceable token and the pre-set packed minimum time; signing and broadcasting the original transaction; verifying the validity of the original transaction and storing the verified original transaction into a memory transaction pool; creating a replacement transaction; finding an unpackaged original transaction corresponding to the replacement transaction; copying the input of the original transaction into the input of the replacement transaction such that the input of the original transaction equals the input of the corresponding replacement transaction; adjusting the replaceable indicia of the replacement transaction and the preset packaged minimum time as needed; modifying the receive address and the commission at the output of the replacement transaction; signing and broadcasting the replacement transaction; verifying the validity of the replacement transaction according to a preset transaction replacement rule; if the verification is passed, deleting the original transaction in the memory transaction pool, and storing the replacement transaction passing the verification into the memory transaction pool; the original transaction is deleted at the wallet file and the replacement transaction is credited to the wallet file. The transaction creator achieves the effect of being packaged more quickly by improving the handling fee of the replacement transaction, so that the problem that the transaction cannot be packaged into a block in time and can only wait for a long time after being broadcast and legally stored into the memory transaction pool by being verified by other nodes is solved.
In addition, the application also provides a transaction commission charge promotion system in a block chain based on the UTXO architecture corresponding to the above method, which includes a transaction creator and a plurality of full nodes, wherein:
the transaction creator is configured to perform the steps of:
traversing the unspent output based on the UTXO framework for creating an original transaction, the original transaction including the replaceable token and the pre-set packed minimum time;
signing and broadcasting the original transaction;
verifying the validity of the original transaction and storing the verified original transaction into a memory transaction pool;
creating a replacement transaction;
finding an unpackaged original transaction corresponding to the replacement transaction;
copying the input of the original transaction into the input of the replacement transaction such that the input of the original transaction equals the input of the corresponding replacement transaction;
adjusting the replaceable indicia of the replacement transaction and the preset packaged minimum time as needed;
modifying the receive address and the commission at the output of the replacement transaction;
signing and broadcasting the replacement transaction;
the plurality of full nodes are configured to perform the steps of:
verifying the validity of the replacement transaction according to a preset transaction replacement rule;
if the verification is passed, deleting the original transaction in the memory transaction pool, and storing the replacement transaction passing the verification into the memory transaction pool;
the transaction creator is further configured to perform the steps of:
the original transaction is deleted at the wallet file and the replacement transaction is credited to the wallet file.
Further, the plurality of full nodes are further configured to perform the steps of:
broadcasting the block after the original transaction is packed into the block, and checking the block according to the block checking rule;
and if the preset packed minimum time is set for the original transaction but the minimum time is not reached, judging the block as an illegal block.
Other embodiments of the invention will be apparent to those skilled in the art from consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the invention following, in general, the principles of the invention and including such departures from the present disclosure as come within known or customary practice within the art to which the invention pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the invention being indicated by the following claims.
It will be understood that the invention is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the invention is limited only by the appended claims.