Blockchain-based transaction method, device, system and readable storage medium
By using a blockchain-based transaction method, the problems of long transaction cycles and low security in existing prepaid card systems are solved, enabling near real-time reconciliation and secure transactions.
Patent Information
- Application Number
- CN202011645345.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-30
- Publication Date
- 2025-01-14
- Estimated Expiration
- 2040-12-30
AI Technical Summary
Existing prepaid card systems require end-of-day reconciliation when dealing with large volumes of transaction data, resulting in long transaction cycles and risks of data hijacking or tampering, as well as insecure transaction processes.
By adopting a blockchain-based transaction method, transaction requests are received, forwarded to a second system for processing, and uploaded to the blockchain. By leveraging the immutability of blockchain and unified ledger technology, near real-time reconciliation and secure transactions can be achieved.
It enables near real-time reconciliation and settlement of transactions, shortens the transaction cycle, and ensures transaction security through the security of blockchain.
Smart Images

Figure CN112669157B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of financial technology (Fintech), and in particular to a transaction method, device, system and computer-readable storage medium based on blockchain. Background Art
[0002] In recent years, with the continuous development of financial technology (Fintech), especially Internet finance, more and more technologies (such as distributed, blockchain, artificial intelligence, etc.) are applied in the financial field, but the financial industry has also put forward higher requirements for them, such as the financial industry has higher requirements for blockchain-based transactions.
[0003] The traditional transaction model requires users to carry cash for transactions, which is inconvenient and unsafe. Therefore, prepaid cards were born. Prepaid cards refer to debt certificates issued by issuing institutions and can be used in the commercial service industry. Specifically, they are shopping coupons or consumption cards, etc., which reflect the creditor's rights enjoyed by the cardholder (voucher) as a consumer against the issuing institution. With the continuous development of Internet finance, physical prepaid cards are gradually being replaced by electronic prepaid cards. Therefore, how to use electronic prepaid cards for transactions is a technical problem that banks and other financial institutions need to solve.
[0004] In the prior art, banks and other financial institutions have built a prepaid card system to facilitate management and realize transactions of electronic prepaid cards. The system includes the management of the entire life cycle of prepaid card business, including card making, issuance, consumption, clearing and settlement, making operations such as card sales, write-offs and reconciliation more convenient than before.
[0005] However, the existing prepaid card system has a large amount of transaction data, and in order not to affect normal business, it needs to be reconciled at the end of the day. Merchants are slow to return payments, resulting in a long transaction cycle. In addition, the existing reconciliation method requires the transmission of reconciliation files, which are easily hijacked and tampered with. The transaction process is not protected and is also at risk of being hijacked and tampered with. Summary of the invention
[0006] The main purpose of the present invention is to propose a transaction method, device, system and computer-readable storage medium based on blockchain, aiming to achieve quasi-real-time secure transactions and shorten the transaction cycle.
[0007] To achieve the above object, the present invention provides a transaction method based on blockchain, and the transaction method based on blockchain comprises the following steps:
[0008] If a transaction request triggered by the first system is received, the transaction request is forwarded to the second system, and the transaction request is processed based on the second system to obtain a processing result;
[0009] Determine the data subject of the first system, and based on the second system and the data subject, publish the transaction event corresponding to the processing result to the target blockchain;
[0010] Based on the target blockchain and the first system, the transaction event is obtained to complete the reconciliation of the transaction request.
[0011] Preferably, before the step of forwarding the transaction request to the second system if a transaction request triggered by the first system is received and processing the transaction request based on the second system to obtain a processing result, the blockchain-based transaction method further includes:
[0012] Determine the node information corresponding to the target blockchain, and generate a contract address based on the node information and the first system;
[0013] Based on the node information and the contract address, the first system is connected to the target blockchain.
[0014] Preferably, the step of connecting the first system to the target blockchain based on the node information and the contract address includes:
[0015] Obtain a prepackaged resource package, and embed the prepackaged resource package into the first system, wherein the prepackaged resource package includes an on-chain API for establishing a connection with the target blockchain;
[0016] Based on the node information, the IP and port of the configuration file in the prepackaged resource package are modified, and the default address in the configuration file is modified to the contract address to complete the first system accessing the target blockchain.
[0017] Preferably, the step of determining the data subject of the first system and publishing the transaction event corresponding to the processing result to the target blockchain based on the second system and the data subject includes:
[0018] Acquire ID information of the first system and a transaction type of the transaction request, and determine a data subject of the first system based on the ID information and the transaction type;
[0019] Determining a public key of the first system, and encrypting the processing result based on the public key;
[0020] The encrypted processing result is bound to the data subject to generate a transaction event, and based on the second system, the transaction event is published to the target blockchain.
[0021] Preferably, the target blockchain includes multiple business chains, and the step of publishing the transaction event corresponding to the processing result to the target blockchain based on the second system and the data subject includes:
[0022] Based on the data subject, determining a target service chain corresponding to the first system in the service chain;
[0023] Based on the second system, a transaction event corresponding to the processing result is published to a target business chain.
[0024] Preferably, the step of publishing the transaction event corresponding to the processing result to the target blockchain based on the second system and the data subject includes:
[0025] Based on the second system and the data subject, cache the transaction event corresponding to the processing result into the on-chain data table, and mark the processing status of the transaction event as being processed;
[0026] Based on the processing status, the transaction event in the on-chain data table is polled and the transaction event is published to the target blockchain.
[0027] Preferably, the step of polling and acquiring the transaction event in the on-chain data table based on the processing status, and publishing the transaction event to the target blockchain includes:
[0028] Mark the number of times the transaction event is uploaded to the chain;
[0029] Based on the number of on-chain times and the processing status, the transaction event in the on-chain data table is polled and obtained, and the transaction event is published to the target blockchain.
[0030] Preferably, the blockchain-based transaction method further includes:
[0031] Check the processing status of all transaction events in the on-chain data table at a preset time;
[0032] If there are still transaction events with the processing status being processed in the on-chain data table, an alarm message is generated.
[0033] Preferably, the step of processing the transaction request based on the second system to obtain a processing result includes:
[0034] determining a transaction type of the transaction request, and determining a processing flow of the second system based on the transaction type;
[0035] The transaction parameters of the transaction request are obtained, and based on the processing flow and the transaction parameters, the transaction request is processed to obtain a processing result.
[0036] In addition, to achieve the above-mentioned purpose, the present invention also provides a transaction device based on blockchain, and the transaction device based on blockchain includes:
[0037] A receiving and processing module, configured to forward the transaction request to the second system if a transaction request triggered by the first system is received, and process the transaction request based on the second system to obtain a processing result;
[0038] A publishing module is determined, which is used to determine the data subject of the first system, and based on the second system and the data subject, publish the transaction event corresponding to the processing result to the target blockchain;
[0039] and obtaining a reconciliation module, configured to obtain the transaction event based on the target blockchain and the first system to complete the reconciliation of the transaction request.
[0040] Preferably, the blockchain-based transaction device further includes an access module for:
[0041] Determine the node information corresponding to the target blockchain, and generate a contract address based on the node information and the first system;
[0042] Based on the node information and the contract address, the first system is connected to the target blockchain.
[0043] Preferably, the access module is also used for:
[0044] Obtain a prepackaged resource package, and embed the prepackaged resource package into the first system, wherein the prepackaged resource package includes an on-chain API for establishing a connection with the target blockchain;
[0045] Based on the node information, the IP and port of the configuration file in the prepackaged resource package are modified, and the default address in the configuration file is modified to the contract address to complete the first system accessing the target blockchain.
[0046] Preferably, the publishing determination module is further used for:
[0047] Acquire ID information of the first system and a transaction type of the transaction request, and determine a data subject of the first system based on the ID information and the transaction type;
[0048] Determining a public key of the first system, and encrypting the processing result based on the public key;
[0049] The encrypted processing result is bound to the data subject to generate a transaction event, and based on the second system, the transaction event is published to the target blockchain.
[0050] Preferably, the publishing determination module is further used for:
[0051] Based on the data subject, determining a target service chain corresponding to the first system in the service chain;
[0052] Based on the second system, a transaction event corresponding to the processing result is published to a target business chain.
[0053] Preferably, the publishing determination module is further used for:
[0054] Based on the second system and the data subject, cache the transaction event corresponding to the processing result into the on-chain data table, and mark the processing status of the transaction event as being processed;
[0055] Based on the processing status, the transaction event in the on-chain data table is polled and the transaction event is published to the target blockchain.
[0056] Preferably, the publishing determination module is further used for:
[0057] Mark the number of times the transaction event is uploaded to the chain;
[0058] Based on the number of on-chain times and the processing status, the transaction event in the on-chain data table is polled and obtained, and the transaction event is published to the target blockchain.
[0059] Preferably, the blockchain-based transaction device further includes an access module for:
[0060] Check the processing status of all transaction events in the on-chain data table at a preset time;
[0061] If there are still transaction events with the processing status being processed in the on-chain data table, an alarm message is generated.
[0062] Preferably, the receiving and processing module is further used for:
[0063] determining a transaction type of the transaction request, and determining a processing flow of the second system based on the transaction type;
[0064] The transaction parameters of the transaction request are obtained, and based on the processing flow and the transaction parameters, the transaction request is processed to obtain a processing result.
[0065] In addition, to achieve the above-mentioned purpose, the present invention also provides a blockchain-based transaction system, which includes: a memory, a processor, and a blockchain-based transaction program stored in the memory and executable on the processor, and the blockchain-based transaction program, when executed by the processor, implements the steps of the blockchain-based transaction method described above.
[0066] In addition, to achieve the above-mentioned purpose, the present invention also provides a computer-readable storage medium, on which a blockchain-based transaction program is stored, and when the blockchain-based transaction program is executed by a processor, the steps of the blockchain-based transaction method as described above are implemented.
[0067] The transaction method based on blockchain proposed in the present invention, if a transaction request triggered by a first system is received, the transaction request is forwarded to the second system, and the transaction request is processed based on the second system to obtain a processing result; the data subject of the first system is determined, and based on the second system and the data subject, the transaction event corresponding to the processing result is published to the target blockchain; based on the target blockchain and the first system, the transaction event is obtained to complete the reconciliation of the transaction request. The present invention also discloses a transaction device, system and computer-readable storage medium based on blockchain. In the process of processing transactions, the present invention distinguishes the transaction events of each system where the transaction occurs according to the data subject, and then uploads the transaction event to the chain, so that the system where the transaction occurs can obtain the transaction event in quasi-real time through the blockchain, and based on the unified ledger technology of the blockchain, the transaction event obtained by the system where the transaction occurs is consistent with the transaction event on the chain, and the system where the transaction occurs does not need to perform additional reconciliation operations, and the reconciliation is completed, realizing quasi-real-time reconciliation and settlement between systems, and at the same time, based on the tamper-proof characteristics of the blockchain, the security of the transaction is guaranteed, and the transaction cycle is effectively shortened. BRIEF DESCRIPTION OF THE DRAWINGS
[0068] Figure 1 It is a schematic diagram of the system structure of the hardware operating environment involved in the embodiment of the present invention;
[0069] Figure 2 This is a flowchart of the first embodiment of the blockchain-based transaction method of the present invention;
[0070] Figure 3 This is a schematic diagram of an architecture in which a target blockchain includes multiple business chains in the first embodiment of the blockchain-based transaction method of the present invention.
[0071] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0072] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.
[0073] like Figure 1 As shown, Figure 1 It is a schematic diagram of the system structure of the hardware operating environment involved in the embodiment of the present invention.
[0074] like Figure 1 As shown, the system may include: a processor 1001, such as a CPU, a network interface 1004, a user interface 1003, a memory 1005, and a communication bus 1002. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), an input unit such as a keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface). The memory 1005 may be a high-speed RAM memory, or a stable memory (non-volatile memory), such as a disk memory. The memory 1005 may also be a storage device independent of the aforementioned processor 1001.
[0075] Those skilled in the art will understand that Figure 1 The system structure shown in the figure does not constitute a limitation of the system, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.
[0076] like Figure 1 As shown, the memory 1005 as a computer storage medium may include an operating system, a network communication module, a user interface module, and a blockchain-based transaction program.
[0077] Among them, the operating system is a program that manages and controls the blockchain-based transaction system and software resources, and supports the operation of the network communication module, the user interface module, the blockchain-based transaction program and other programs or software; the network communication module is used to manage and control the network interface 1002; the user interface module is used to manage and control the user interface 1003.
[0078] exist Figure 1 In the blockchain-based transaction system shown, the blockchain-based transaction system calls the blockchain-based transaction program stored in the memory 1005 through the processor 1001, and executes the operations in each embodiment of the following blockchain-based transaction method.
[0079] Based on the above hardware structure, an embodiment of a transaction method based on blockchain of the present invention is proposed.
[0080] Reference Figure 2 , Figure 2 The flowchart of the first embodiment of the transaction method based on blockchain of the present invention is as follows:
[0081] Step S10: if a transaction request triggered by the first system is received, the transaction request is forwarded to the second system, and the transaction request is processed based on the second system to obtain a processing result;
[0082] Step S20, determining the data subject of the first system, and based on the second system and the data subject, publishing the transaction event corresponding to the processing result to the target blockchain;
[0083] Step S30: Based on the target blockchain and the first system, the transaction event is obtained to complete the reconciliation of the transaction request.
[0084] The blockchain-based transaction method of this embodiment is applied to the blockchain-based transaction system of financial institutions such as financial institutions or banks. For the convenience of description, the blockchain-based transaction system is referred to as the transaction system. In this embodiment, the transaction system includes a merchant system (first system), a prepaid card system (second system) and an alliance chain (target blockchain) jointly participated by merchants and banking institutions. Among them, users can initiate transactions on the front end such as the mini-program / public account / APP corresponding to the merchant system, and the merchant system backend forwards the transaction request of the transaction to the prepaid card system. After receiving the transaction request and completing the corresponding business processing, the prepaid card system uploads the corresponding processing result to the alliance chain through WeEvent. The merchant system obtains the transaction event from the alliance chain by subscribing to the notification of the transaction event corresponding to the processing result, thereby ensuring the consistency of transaction data. Relying on the unified ledger technology of blockchain, it helps banking institutions and merchants to conduct online real-time reconciliation, breaking the traditional end-of-day reconciliation mode and effectively shortening the transaction cycle.
[0085] Among them, WeEvent is a distributed event-driven architecture that realizes a credible, reliable and efficient cross-institutional and cross-platform event notification mechanism. It is independently developed by WeBank and is fully open source. Adhering to the design concept of peer-to-peer cooperation, intelligent collaboration, and value sharing in distributed business models, it is committed to improving the efficiency of cooperation among institutions and reducing the cost of cooperation. At the same time, it connects different platforms such as applications, the Internet of Things, cloud services, and private services. Ultimately, without changing the development language and access protocol of existing business systems, it can achieve cross-institutional and cross-platform event notification and processing.
[0086] The following is a detailed description of each step:
[0087] Step S10: if a transaction request triggered by the first system is received, the transaction request is forwarded to the second system, and the transaction request is processed based on the second system to obtain a processing result.
[0088] In this embodiment, for ease of understanding, the first system refers to the merchant system, and the second system refers to the prepaid card system. First, the user can trigger a transaction request through a mini-program / public account / APP at the front end of the first system. After the transaction system receives the transaction request in the first system, it will forward the transaction request to the second system through the first system. Among them, the second system takes the prepaid card system as an example in this embodiment, specifically including account management, recharge, consumption, transaction information chain, data query and other functional modules. Therefore, the transaction system can process the transaction request through each functional module in the second system to obtain the processing result.
[0089] Specifically, in one embodiment, the step of obtaining a processing result based on processing the transaction request by the second system includes:
[0090] Step a1, determining the transaction type of the transaction request, and based on the transaction type, determining the processing flow of the second system;
[0091] In one embodiment, the transaction type of the transaction request is first determined, wherein the transaction type includes account management, recharge, consumption, inquiry, etc. Then, the nursing process corresponding to the second system is determined according to the transaction type, that is, the processing process of transaction requests of different transaction types is different.
[0092] Step a2: acquiring transaction parameters of the transaction request, and processing the transaction request based on the processing flow and the transaction parameters to obtain a processing result.
[0093] Next, the transaction parameters of the transaction request are obtained, and the transaction request is processed according to the determined processing flow and transaction parameters, thereby obtaining a processing result.
[0094] For example, when the transaction type of the transaction request is account management, such as account opening, the transaction parameters obtained include the ID information of the first system, user ID, etc., and then the transaction request is processed. Specifically, the account is opened according to the user ID, so as to obtain the account opening serial number, account opening status, etc. The ID information, user ID, account opening serial number and account opening status of the first system are the processing results. Finally, the account opening event is asynchronously written through the second system and published to the target blockchain, so that the first system can obtain the account opening event through the subscription mechanism later.
[0095] For another example, when the transaction type of the transaction request is recharge, the acquired transaction parameters include the ID information, user ID and recharge amount of the first system, and then the transaction request is processed by the second system. Specifically, according to the user ID and the recharge amount, the relevant account is added with money to obtain the balance after recharge, the recharge serial number and the recharge status, etc. The ID information, user ID, balance after recharge, recharge serial number and recharge status of the first system are the processing results. Finally, the recharge event is asynchronously written through the second system and published to the target blockchain, so that the first system can obtain the recharge event through the subscription mechanism later.
[0096] The processing procedures for other transaction types are similar and will not be elaborated here.
[0097] Step S20, determine the data subject of the first system, and based on the second system and the data subject, publish the transaction event corresponding to the processing result to the target blockchain.
[0098] In this embodiment, the first system, as a participant in the alliance chain, can be both the sender and the receiver of the chain message. During the message transmission process, the message sender and the receiver need to define the data topic of both parties, and call the message upload or receiving method according to the agreed topic to carry out message transmission.
[0099] Therefore, it is necessary to first determine the data subject of the agreed first system, and then publish the transaction event corresponding to the processing result to the target blockchain based on the second system and the data subject.
[0100] Furthermore, after the transaction event is uploaded to the blockchain, the corresponding business data is on the blockchain, and the data of each node on the blockchain will reach a consensus. Therefore, it is particularly important to protect the business data of each merchant from being obtained by other merchants. In other words, it is necessary that the business data of the first system is not obtained by other systems connected to the second system. Therefore, it is necessary to isolate the business data. In one embodiment, step S20 includes:
[0101] Step b1, obtaining the ID information of the first system and the transaction type of the transaction request, and determining the data subject of the first system based on the ID information and the transaction type;
[0102] In one embodiment, data logic isolation is adopted. Specifically, ID information of the first system and the transaction type of the transaction request are obtained, and a data topic of the first system is generated according to the ID information and the transaction type.
[0103] In specific implementation, the fixed prefix + partner appId (ID information of the first system) + transaction type is used as the data topic format, that is, topic: "com.webank." + appId + transType, where "com.webank." is an example of a fixed prefix. For example, the appId of the first system, that is, the ID information is W123456; the transaction type is account opening, transType: 0, so the topic at this time is: com.webank.W1234560.
[0104] Step b2, determining the public key of the first system, and encrypting the processing result based on the public key;
[0105] Then determine the public key of the first system, and use the public key to encrypt the processing result to obtain an encrypted processing result. That is, agree on a data encryption mechanism with the first system, encrypt the on-chain data using the public key, and keep the data transmitted in ciphertext. The first system parses the data through an independent private key to ensure that the data is not known to merchants in other systems.
[0106] Step b3: Bind the encrypted processing result to the data subject to generate a transaction event, and publish the transaction event to the target blockchain based on the second system.
[0107] Finally, the encrypted processing result is bound to the data subject, so that the generated transaction event contains the data subject to distinguish the data of other merchant systems, and then the transaction event is published to the target blockchain through the second system.
[0108] Furthermore, for merchants with extremely high data privacy requirements, a multi-chain deployment method can be provided for physical isolation. Therefore, in one embodiment, the target blockchain includes multiple business chains, and the step of publishing the transaction event corresponding to the processing result to the target blockchain based on the second system and the data topic includes:
[0109] Step b3, based on the data subject, determining a target business chain corresponding to the first system in the business chain;
[0110] In one embodiment, the target blockchain includes multiple business chains, such as Figure 3 As shown, the prepaid card alliance chain (target blockchain) includes multiple independent business chains, including the merchant A chain composed of merchant C and the bank, the merchant B chain composed of merchant B and the bank, and the merchant business chain composed of merchant C, merchant D, merchant E, merchant X and the bank. The topic agreed upon by each business chain is different. Therefore, the target business chain corresponding to the first system can be determined in the business chain according to the data topic.
[0111] Step b4: Based on the second system, publish the transaction event corresponding to the processing result to the target business chain.
[0112] Finally, through the second system, the transaction events corresponding to the processing results are published to the target business chain, which is invisible to other business chains, thus achieving physical isolation of data.
[0113] Step S30: Based on the target blockchain and the first system, the transaction event is obtained to complete the reconciliation of the transaction request.
[0114] In this embodiment, the first system obtains notification of transaction events based on the subscription mechanism of the target blockchain, thereby completing the reconciliation between the first system and the second system. That is, in this embodiment, merchants do not need to reconcile themselves, and the trust problem between banks and merchants is solved by relying on the unified ledger technology of the blockchain. Therefore, online real-time reconciliation and clearing can be supported, and no end-of-day reconciliation processing is required. That is, after the first system obtains the transaction event through the subscription mechanism, it completes the reconciliation of the transaction request, because the obtained transaction event must be consistent with the transaction event on the target blockchain, and the transaction event on the target blockchain is uploaded by the second system. Therefore, the transaction event on the first system is consistent with the transaction event on the second system, that is, no additional reconciliation operation is required to ensure the consistency of the data of the two.
[0115] If this embodiment receives a transaction request triggered by the first system, the transaction request is forwarded to the second system, and the transaction request is processed based on the second system to obtain a processing result; the data subject of the first system is determined, and based on the second system and the data subject, the transaction event corresponding to the processing result is published to the target blockchain; based on the target blockchain and the first system, the transaction event is obtained to complete the reconciliation of the transaction request. In the process of processing transactions, the present invention distinguishes the transaction events of each system where the transaction occurs according to the data subject, and then uploads the transaction event to the chain, so that the system where the transaction occurs can obtain the transaction event in quasi-real time through the blockchain, and based on the unified ledger technology of the blockchain, the transaction event obtained by the system where the transaction occurs is consistent with the transaction event on the chain, and the system where the transaction occurs does not need to perform additional reconciliation operations, and the reconciliation is completed, realizing quasi-real-time reconciliation and settlement between systems, and at the same time, based on the tamper-proof characteristics of the blockchain, the security of the transaction is guaranteed, effectively shortening the transaction cycle.
[0116] Furthermore, based on the first embodiment of the transaction method based on blockchain of the present invention, a second embodiment of the transaction method based on blockchain of the present invention is proposed.
[0117] The difference between the second embodiment of the transaction method based on blockchain and the first embodiment of the transaction method based on blockchain is that before step S10, the transaction method based on blockchain further includes:
[0118] Step d, determining the node information corresponding to the target blockchain, and generating a contract address based on the node information and the first system;
[0119] Step e: connecting the first system to the target blockchain based on the node information and the contract address.
[0120] In order to allow the first system to successfully access the target blockchain, this embodiment uses the WeEvent component to support data on-chain in an API manner to complete the communication processing between the first system and the target blockchain, specifically using the node information and contract address of the target blockchain to build a data bridge.
[0121] The following is a detailed description of each step:
[0122] Step d: determine the node information corresponding to the target blockchain, and generate a contract address based on the node information and the first system.
[0123] In this embodiment, the node information corresponding to the target blockchain is first determined, where the node information includes an IP address and port information, and a contract address is generated based on the node information and the first system.
[0124] It can be generated according to the contract generation tool of the blockchain. Since it is a common technology of the blockchain, it will not be described in detail here.
[0125] Step e: connecting the first system to the target blockchain based on the node information and the contract address.
[0126] In this embodiment, the first system can be connected to the target blockchain according to the node information and the contract address. Specifically, in one embodiment, step e includes:
[0127] Step e1, obtaining a prepackaged resource package and embedding the prepackaged resource package into the first system, wherein the prepackaged resource package includes an on-chain API for establishing a connection with the target blockchain;
[0128] Step e2: based on the node information, modify the IP and port of the configuration file in the prepackaged resource package, and modify the default address in the configuration file to the contract address to complete the first system accessing the target blockchain.
[0129] In one embodiment, in order to reduce the difficulty for merchants to access blockchain nodes, a resource package can be packaged in advance, that is, a pre-packaged resource package. After the merchant is allocated the pre-packaged resource package, it is embedded in the application end of the original merchant system, that is, the application end of the first system. Taking Java as an example, the general mainstream development language is Java, and the pre-packaged resource package is a JAVA client resource package, which specifically includes web3sdk.jar and weevent-sdk.jar, where weevent-sdk.jar is a jar package generated by the source code of the target blockchain project, web3sdk is an important local dependency package, and the pre-packaged resource package contains an on-chain API for establishing a connection with the target blockchain. In this way, the connection between the application and the blockchain node can be achieved without invading the existing application code of the first system.
[0130] In the specific implementation, after the pre-packaged resource package is embedded in the application end of the first system, it is only necessary to modify the IP address and port information in the configuration file in the pre-packaged resource package to the IP address and port information of the target blockchain, and then run com.webank.weevent.contract.deploy.DeployContract (contract generation tool) to generate the contract address. In this process, it is necessary to configure the path of the generated contract address, such as defining it as / data / app / weevent / contract-addrss.txt, so that a contract address will be generated in the contract-addrss.txt file. Then take out the generated contract address and replace the default address demo in the above configuration file, so that the merchant system does not need to make any changes to open up the connection between the application layer and the blockchain, and modify the default address demo (the default address can be empty) of the configuration file in the pre-packaged resource package to the generated contract address, so that the currently connected first system can follow the transaction protocol of the entire target block, which is convenient for subsequent transactions. At this time, the first system is connected to the target blockchain.
[0131] It should be noted that for contract deployment, a blockchain network only needs to be executed once, and all systems connected to the same chain must be configured with the same contract address and follow the same set of transaction protocols to facilitate fair transactions.
[0132] This embodiment connects the first system to the target blockchain through the node information and contract address of the target block, thereby completing the communication between the merchant and the blockchain, reducing the difficulty of access, and eliminating the need to develop a personalized interface for each access.
[0133] Furthermore, based on the first and second embodiments of the transaction method based on blockchain of the present invention, a third embodiment of the transaction method based on blockchain of the present invention is proposed.
[0134] The third embodiment of the transaction method based on blockchain is different from the first and second embodiments of the transaction method based on blockchain in that the step of publishing the transaction event corresponding to the processing result to the target blockchain based on the second system and the data subject includes:
[0135] Step f, based on the second system and the data subject, caching the transaction event corresponding to the processing result into the on-chain data table, and marking the processing status of the transaction event as being processed;
[0136] Step g: based on the processing status, poll to obtain the transaction event in the on-chain data table, and publish the transaction event to the target blockchain.
[0137] In order to ensure that data is 100% successfully uploaded to the chain, this embodiment persists each uploaded data in the database, which contains the uploaded data table, and then polls the chain.
[0138] The following is a detailed description of each step:
[0139] Step f: based on the second system and the data subject, cache the transaction event corresponding to the processing result into the on-chain data table, and mark the processing status of the transaction event as being processed.
[0140] In this embodiment, it is understandable that due to various objective reasons, such as network jitter, application anomalies, etc., some business data may not be pushed to the blockchain. In order to deal with these abnormal scenarios, the transaction system first stores the business data in the asynchronous chain. Specifically, through the data topics of the second system and the first system, the transaction events corresponding to the processing results are cached in the chain data table in the data, and the processing status of the transaction events is marked as processing.
[0141] In the specific implementation, the transaction system provides a transaction interface, through which the asynchronous method weEventNoticeRecord can be called to record the data that needs to be uploaded to the chain, that is, the transaction event. The asynchronous method determines whether the merchant needs to be uploaded to the chain based on the configuration wlt_pas_notice_conf_info data. If it is not configured, the data will be discarded. If it is configured, it will be recorded in the chain data table: wlt_pas_we_event_notice_record, the status is in processing, and the asynchronous upload method is triggered and the upload result is recorded.
[0142] Step g: based on the processing status, poll to obtain the transaction event in the on-chain data table, and publish the transaction event to the target blockchain.
[0143] In this embodiment, according to the processing status, multiple task threads are started for chain-up. Specifically, according to the processing status of the chain data table wlt_pas_we_event_notice_record, a batch of data (such as 50 transaction events, configurable) is polled every 1 minute, that is, a batch of data is processed each time, published to the target blockchain, and the processing results are updated.
[0144] Further, in one embodiment, the step of polling and acquiring the transaction event in the on-chain data table based on the processing status, and publishing the transaction event to the target blockchain includes:
[0145] Step g1, marking the number of times the transaction event is uploaded to the chain;
[0146] In one embodiment, the transaction system provides a timed re-linking function. For data that fails to be uploaded to the chain in different time periods, multiple timed tasks are started to perform re-linking processing. To ensure that device resources are not wasted, the number of re-linking is limited. Therefore, the number of times the transaction event is uploaded to the chain needs to be marked. The first time it is uploaded to the chain is marked as 0, and the number of subsequent times is increased by one.
[0147] Step g2: based on the number of on-chain transactions and the processing status, poll and obtain the transaction events in the on-chain data table, and publish the transaction events to the target blockchain.
[0148] In one embodiment, the transaction system polls and obtains the transaction events in the chain data table according to the number of times the transaction event is uploaded and the processing status. In the specific implementation, in principle, each transaction event attempts to be uploaded up to 6 times. The specific number of times can be modified by configuring the wlt_pas_notice_conf_info data to modify the merchant's chain interval and the number of times. Before the maximum number is reached, the transaction event can be pushed again.
[0149] Furthermore, to ensure the integrity and consistency of the local data of the merchant system and the data on the target blockchain, in one embodiment, the blockchain-based transaction method further includes:
[0150] Step h, checking the processing status of all transaction events in the on-chain data table at a preset time;
[0151] In one embodiment, the processing status of all transaction events in the on-chain data table is checked at a preset time, wherein the processing status includes being processed and processed.
[0152] Step i: if there are still transaction events with a processing status of "in progress" in the on-chain data table, an alarm message is generated.
[0153] If there are still transaction events with the processing status of "in progress" in the on-chain data table at this time, it is considered that the transaction event cannot be pushed to the chain through retry, and an alarm message is generated to notify the operation and maintenance personnel to intervene and handle it.
[0154] In the specific implementation, end-of-day monitoring can be adopted, that is, the preset time is midnight every day. Through monitoring, it is ensured that all data that need to be uploaded to the chain in the chain data table have been uploaded to the chain, and the data in the merchant system is complete and consistent with the data on the blockchain. For the data that has not been uploaded to the chain, manual intervention is required.
[0155] This embodiment uses a hierarchical compensation mechanism to distribute compensation for transaction events on the chain, which can ensure that transaction events are 100% successful on the chain and achieve consistency between the merchant system and the data on the blockchain.
[0156] The present invention also provides a blockchain-based transaction device. The blockchain-based transaction device of the present invention includes:
[0157] A receiving and processing module, configured to forward the transaction request to the second system if a transaction request triggered by the first system is received, and process the transaction request based on the second system to obtain a processing result;
[0158] A publishing module is determined, which is used to determine the data subject of the first system, and based on the second system and the data subject, publish the transaction event corresponding to the processing result to the target blockchain;
[0159] and obtaining a reconciliation module, configured to obtain the transaction event based on the target blockchain and the first system to complete the reconciliation of the transaction request.
[0160] Preferably, the blockchain-based transaction device further includes an access module for:
[0161] Determine the node information corresponding to the target blockchain, and generate a contract address based on the node information and the first system;
[0162] Based on the node information and the contract address, the first system is connected to the target blockchain.
[0163] Preferably, the access module is also used for:
[0164] Obtain a prepackaged resource package, and embed the prepackaged resource package into the first system, wherein the prepackaged resource package includes an on-chain API for establishing a connection with the target blockchain;
[0165] Based on the node information, the IP and port of the configuration file in the prepackaged resource package are modified, and the default address in the configuration file is modified to the contract address to complete the first system accessing the target blockchain.
[0166] Preferably, the publishing determination module is further used for:
[0167] Acquire ID information of the first system and a transaction type of the transaction request, and determine a data subject of the first system based on the ID information and the transaction type;
[0168] Determining a public key of the first system, and encrypting the processing result based on the public key;
[0169] The encrypted processing result is bound to the data subject to generate a transaction event, and based on the second system, the transaction event is published to the target blockchain.
[0170] Preferably, the publishing determination module is further used for:
[0171] Based on the data subject, determining a target service chain corresponding to the first system in the service chain;
[0172] Based on the second system, a transaction event corresponding to the processing result is published to a target business chain.
[0173] Preferably, the publishing determination module is further used for:
[0174] Based on the second system and the data subject, cache the transaction event corresponding to the processing result into the on-chain data table, and mark the processing status of the transaction event as being processed;
[0175] Based on the processing status, the transaction event in the on-chain data table is polled and the transaction event is published to the target blockchain.
[0176] Preferably, the publishing determination module is further used for:
[0177] Mark the number of times the transaction event is uploaded to the chain;
[0178] Based on the number of on-chain times and the processing status, the transaction event in the on-chain data table is polled and obtained, and the transaction event is published to the target blockchain.
[0179] Preferably, the blockchain-based transaction device further includes an access module for:
[0180] Check the processing status of all transaction events in the on-chain data table at a preset time;
[0181] If there are still transaction events with the processing status being processed in the on-chain data table, an alarm message is generated.
[0182] Preferably, the receiving and processing module is further used for:
[0183] determining a transaction type of the transaction request, and determining a processing flow of the second system based on the transaction type;
[0184] The transaction parameters of the transaction request are obtained, and based on the processing flow and the transaction parameters, the transaction request is processed to obtain a processing result.
[0185] The present invention also provides a computer-readable storage medium.
[0186] A blockchain-based transaction program is stored on the computer-readable storage medium of the present invention, and when the blockchain-based transaction program is executed by a processor, the steps of the blockchain-based transaction method described above are implemented.
[0187] Among them, the method implemented when the blockchain-based transaction program running on the processor is executed can refer to the various embodiments of the blockchain-based transaction method of the present invention, and will not be repeated here.
[0188] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or system including the element.
[0189] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0190] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present invention.
[0191] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A transaction method based on blockchain, characterized in that: The blockchain-based transaction method comprises the following steps: If a transaction request triggered by the first system is received, the transaction request is forwarded to the second system, and the transaction request is processed based on the second system to obtain a processing result; wherein the first system is a merchant system; and the second system is a prepaid card system; Determine the data subject of the first system, and based on the second system and the data subject, publish the transaction event corresponding to the processing result to the target blockchain; Based on the target blockchain and the first system, obtaining the transaction event to complete the reconciliation of the transaction request; The step of determining the data subject of the first system and publishing the transaction event corresponding to the processing result to the target blockchain based on the second system and the data subject includes: Acquire ID information of the first system and a transaction type of the transaction request, and determine a data subject of the first system based on the ID information and the transaction type; Determining a public key of the first system, and encrypting the processing result based on the public key; The encrypted processing result is bound to the data subject to generate a transaction event, and based on the second system, the transaction event is published to the target blockchain.
2. The blockchain-based transaction method according to claim 1, characterized in that: Before the step of forwarding the transaction request to the second system if a transaction request triggered by the first system is received and processing the transaction request based on the second system to obtain a processing result, the blockchain-based transaction method further includes: Determine the node information corresponding to the target blockchain, and generate a contract address based on the node information and the first system; Based on the node information and the contract address, the first system is connected to the target blockchain.
3. The blockchain-based transaction method according to claim 2, characterized in that: The step of connecting the first system to the target blockchain based on the node information and the contract address includes: Obtain a prepackaged resource package, and embed the prepackaged resource package into the first system, wherein the prepackaged resource package includes an on-chain API for establishing a connection with the target blockchain; Based on the node information, the IP and port of the configuration file in the prepackaged resource package are modified, and the default address in the configuration file is modified to the contract address to complete the first system accessing the target blockchain.
4. The blockchain-based transaction method according to claim 1, characterized in that: The target blockchain includes multiple business chains, and the step of publishing the transaction event corresponding to the processing result to the target blockchain based on the second system and the data subject includes: Based on the data subject, determining a target service chain corresponding to the first system in the service chain; Based on the second system, a transaction event corresponding to the processing result is published to a target business chain.
5. The blockchain-based transaction method according to claim 1, characterized in that: The step of publishing the transaction event corresponding to the processing result to the target blockchain based on the second system and the data subject includes: Based on the second system and the data subject, cache the transaction event corresponding to the processing result into the on-chain data table, and mark the processing status of the transaction event as being processed; Based on the processing status, the transaction event in the on-chain data table is polled and the transaction event is published to the target blockchain.
6. The blockchain-based transaction method according to claim 5, characterized in that: The step of polling and acquiring the transaction event in the on-chain data table based on the processing status, and publishing the transaction event to the target blockchain includes: Mark the number of times the transaction event is uploaded to the chain; Based on the number of on-chain times and the processing status, the transaction event in the on-chain data table is polled and obtained, and the transaction event is published to the target blockchain.
7. The blockchain-based transaction method according to claim 5, characterized in that: The blockchain-based transaction method further includes: Check the processing status of all transaction events in the on-chain data table at a preset time; If there are still transaction events with the processing status being processed in the on-chain data table, an alarm message is generated.
8. The blockchain-based transaction method according to any one of claims 1 to 7, characterized in that: The step of processing the transaction request based on the second system to obtain a processing result comprises: determining a transaction type of the transaction request, and determining a processing flow of the second system based on the transaction type; The transaction parameters of the transaction request are obtained, and based on the processing flow and the transaction parameters, the transaction request is processed to obtain a processing result.
9. A transaction device based on blockchain, characterized in that: The blockchain-based transaction device includes: A receiving and processing module, configured to forward the transaction request to a second system if a transaction request triggered by a first system is received, and process the transaction request based on the second system to obtain a processing result; wherein the first system is a merchant system; and the second system is a prepaid card system; A publishing module is determined, which is used to determine the data subject of the first system, and based on the second system and the data subject, publish the transaction event corresponding to the processing result to the target blockchain; An acquisition reconciliation module is used to acquire the transaction event based on the target blockchain and the first system to complete the reconciliation of the transaction request; The determination and publishing module is used to obtain the ID information of the first system and the transaction type of the transaction request, and determine the data subject of the first system based on the ID information and the transaction type; determine the public key of the first system, and encrypt the processing result based on the public key; bind the encrypted processing result with the data subject to generate a transaction event, and publish the transaction event to the target blockchain based on the second system.
10. A transaction system based on blockchain, characterized in that: The blockchain-based transaction system includes: a memory, a processor, and a blockchain-based transaction program stored in the memory and executable on the processor. When the blockchain-based transaction program is executed by the processor, the steps of the blockchain-based transaction method as described in any one of claims 1 to 8 are implemented.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a blockchain-based transaction program, and when the blockchain-based transaction program is executed by a processor, the steps of the blockchain-based transaction method as described in any one of claims 1 to 8 are implemented.
Citation Information
Patent Citations
SDK rapid integration method, device and apparatus based on block chain and storage medium
CN110209381A
Data processing method and device based on block chain, terminal and storage medium
CN110675145A
Block chain data uploading method and device, storage medium and server
CN111274252A
Platform docking method based on blockchain, electronic device and storage medium
CN112003858A
Systems and methods for account reconciliation using a distributed ledger
US20180046992A1