A trading method, an electronic device, and a storage medium
By using smart contracts to process transaction data in the blockchain network, generating and sending second transaction information, accounts that do not have transaction initiation qualification can initiate transactions through accounts that have transaction initiation qualifications, solving the problem of transaction initiation qualification restrictions in the blockchain network and realizing transaction execution.
Patent Information
- Application Number
- CN202010361455.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-04-29
- Publication Date
- 2025-07-18
- Estimated Expiration
- 2040-04-29
AI Technical Summary
In the blockchain network, users who do not have the qualification to initiate transactions cannot directly initiate transactions to node devices with the qualification to execute transactions, resulting in the transaction problem being unable to be solved.
Retrieve request information through the first node device, find the target smart contract in the smart contract database, generate and send the second transaction information, and enable the second node device to execute the transaction to realize the transaction initiation of the first account that does not have the qualification to initiate the transaction.
The transaction problem of accounts that do not have transaction initiation qualifications is solved, and the possibility of node devices that have transaction execution qualifications execute transactions for the first account is realized.
Smart Images

Figure CN111553671B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of communication technologies, and in particular, to a transaction method, an electronic device, and a storage medium. Background Art
[0002] In a blockchain network, a user with the qualification to initiate a transaction can directly initiate a transaction to a node device with the qualification to execute a transaction. Then, the node device with the qualification to execute a transaction executes the transaction according to the transaction data. Before executing the transaction, the node device with the qualification to execute a transaction deducts the fees required for executing the transaction from the user account where the transaction is initiated. A user without the qualification to initiate a transaction cannot initiate a transaction to a node device with the qualification to execute a transaction.
[0003] Currently, the transaction problem of users without the qualification to initiate a transaction in a blockchain network has become a research focus. Summary of the Invention
[0004] Embodiments of the present invention provide a transaction method, an electronic device, and a storage medium, which can solve the transaction problem of a first account without the qualification to initiate a transaction.
[0005] In a first aspect, an embodiment of the present invention provides a transaction method, which is applied to a first node device. The first node device is any node device in a blockchain network. The method includes:
[0006] The first node device obtains request information of a first account. The request information includes service requirement information and first transaction information. The first account is an account that requests a second account to initiate a transaction. The second account is an account with the qualification to initiate a transaction. The first transaction information includes a first digital signature and transaction data. The first digital signature is obtained by the first account processing the transaction data. Search for a target smart contract in the smart contract database in the first node device according to the service requirement information, and call the target smart contract. Process the transaction data according to the target smart contract to obtain a second digital signature, and generate second transaction information. The second transaction information includes the first transaction information and the second digital signature. Send the second transaction information to a second node device according to the target smart contract, so that the second node device processes the transaction data according to the second transaction information. The second node device is a node device with the qualification to execute a transaction in the blockchain network.
[0007] In this technical solution, the first node device obtains the request information of the first account, searches for the target smart contract in the smart contract database in the first node device according to the service requirement information included in the request information, and calls the target smart contract. Then, according to the target smart contract, the second digital signature of the second account is attached to the transaction data in the first transaction information included in the request information to generate the second transaction information. Finally, according to the target smart contract, the second transaction information is sent to the second node device. This method realizes the process of the second account initiating a transaction on behalf of the first account, and solves the problem of the first account initiating a transaction.
[0008] Second, an embodiment of the present invention provides a transaction method, which is applied to a second node device. The second node device is any node device in the blockchain network. The method includes:
[0009] The second node device receives the second transaction information of the first account and the second virtual resource sent by the first node device. The first account is the account that requests the second account to initiate a transaction. The second account is the account with the qualification to initiate a transaction. The second virtual resource is the virtual resource required to execute the transaction. The second transaction information includes the first transaction information and the second digital signature. The first transaction information includes the first digital signature and the transaction data. The first digital signature is obtained by the first account processing the transaction data, and the second digital signature is obtained by the second account processing the transaction data; the transaction data is verified respectively according to the first digital signature and the second digital signature; if the verification of the transaction data passes, the transaction data is processed according to the second transaction information and the second virtual resource.
[0010] In this technical solution, the second node device receives the second transaction information of the first account and the second virtual resource from the first node device, and then processes the transaction data after the verification of the transaction data in the second transaction information passes, that is, executes the transaction for the first account. This method enables the second node device with the qualification to execute the transaction to execute the transaction for the first account, and can solve the transaction problem of the first account.
[0011] Third, an embodiment of the present invention provides an electronic device, which includes a memory, a processor and a communication interface. The memory stores a set of program codes, and the processor calls the program codes stored in the memory to execute the method related to the first node device in the first aspect.
[0012] Fourth, an embodiment of the present invention provides another electronic device, which includes a memory, a processor and a communication interface. The memory stores a set of program codes, and the processor calls the program codes stored in the memory to execute the method related to the second node device in the second aspect.
[0013] Fifth aspect, an embodiment of the present invention provides a transaction device, which includes:
[0014] An acquisition device, configured to acquire request information of a first account, where the request information includes service requirement information and first transaction information. The first account is an account that requests a second account to initiate a transaction, the second account is an account with transaction initiation qualification, the first transaction information includes a first digital signature and transaction data, and the first digital signature is obtained by the first account processing the transaction data;
[0015] A processing device, configured to search for a target smart contract in the smart contract database of the first node device according to the service requirement information, and call the target smart contract;
[0016] The processing device is further configured to process the transaction data according to the target smart contract to obtain a second digital signature, and generate second transaction information, where the second transaction information includes the first transaction information and the second digital signature;
[0017] A sending device, configured to send the second transaction information to a second node device according to the target smart contract, so that the second node device processes the transaction data according to the second transaction information. The second node device is a node device in the blockchain network with transaction execution qualification.
[0018] Sixth aspect, an embodiment of the present invention provides another transaction device, which includes:
[0019] A receiving device, configured to receive the second transaction information and a second virtual resource of the first account sent by the first node device. The first account is an account that requests a second account to initiate a transaction, the second account is an account with transaction initiation qualification, the second virtual resource is a virtual resource required for executing the transaction, the second transaction information includes the first transaction information and a second digital signature, the first transaction information includes a first digital signature and transaction data, the first digital signature is obtained by the first account processing the transaction data, and the second digital signature is obtained by the second account processing the transaction data;
[0020] A processing device, configured to verify the transaction data according to the first digital signature and the second digital signature respectively;
[0021] The processing device is further configured to, if the verification of the transaction data passes, process the transaction data according to the second transaction information and the second virtual resource.
[0022] Seventh aspect, an embodiment of the present invention provides a computer-readable storage medium, used to store computer program instructions for the first node device, which includes programs for executing the content involved in the above first aspect.
[0023] In an eighth aspect, an embodiment of the present invention provides another computer-readable storage medium for storing computer program instructions for a second node device, which includes instructions for executing the program involved in the above-mentioned second aspect.
[0024] By implementing the example of the present invention, the first node device obtains the request information of the first account, searches for the target smart contract in the smart contract database in the first node device according to the business demand information included in the request information, and calls the target smart contract, and then processes the transaction data in the first transaction information included in the request information according to the target smart contract, obtains the second digital signature, generates the second transaction information, and finally sends the second transaction information to the second node device, that is, the second account logged in on the first node device determines the target smart contract in the smart contract data of the first node device after obtaining the request information of the first account, and initiates a transaction to the second node device for the first account by calling the target smart contract, so that the second node device executes the transaction for the first account. This method solves the transaction problem of the first account that does not have the qualification to initiate a transaction. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the background technology, the drawings required for use in the embodiments of the present invention or the background technology will be described below.
[0026] Figure 1 A schematic diagram of the architecture of a blockchain network provided by an embodiment of the present invention;
[0027] Figure 2 A flowchart of a transaction method provided by an embodiment of the present invention;
[0028] Figure 3 A flowchart of another transaction method provided by an embodiment of the present invention;
[0029] Figure 4 A flowchart of another transaction method provided by an embodiment of the present invention;
[0030] Figure 5 A flowchart of another transaction method provided by an embodiment of the present invention;
[0031] Figure 6 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention;
[0032] Figure 7 A schematic diagram of the structure of another electronic device provided by an embodiment of the present invention;
[0033] Figure 8 A schematic diagram of the structure of a transaction device provided in an embodiment of the present application;
[0034] Figure 9 This is a schematic structural diagram of another trading device provided by an embodiment of the present application. Detailed implementation manners
[0035] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.
[0036] In a blockchain network, only large users with virtual resources can initiate a transaction to a node device with transaction execution qualifications, while small users without virtual resources do not have the qualification to initiate a transaction. Regarding the transaction problem of small users without virtual resources, an embodiment of the present application proposes a transaction method, an electronic device, and a storage medium. In this method, a first node device obtains request information of a first account, where the request information includes service requirement information and first transaction information. The first account is an account requesting a second account to initiate a transaction, and the second account is an account with transaction initiation qualifications. The first transaction information includes a first digital signature and transaction data, and the first digital signature is obtained by the first account processing the transaction data. Then, the first node device searches for a target smart contract in the smart contract database in the first node device according to the service requirement information and calls the target smart contract. Furthermore, the first node device processes the transaction data according to the target smart contract to obtain a second digital signature and generates second transaction information, where the second transaction information includes the first transaction information and the second digital signature. Finally, the first node device sends the second transaction information to the second node device according to the target smart contract, so that the second node device processes the transaction data according to the second transaction information. In this method, after receiving the request information of the first account, the first node device determines the target smart contract in the smart contract database and makes the second account logged on the first node device initiate a transaction on behalf of the first account through calling the target smart contract, thereby solving the problem of the first account without transaction initiation qualifications initiating a transaction.
[0037] Please refer to Figure 1 , Figure 1 which is a schematic structural diagram of a blockchain network disclosed in an embodiment of the present invention. As Figure 1 shown, the blockchain network includes a first node device 101, a second node device 102, a third node device 103, and a fourth node device 104. By way of example Figure 1The number of the first node device 101, the second node device 102, the third node device 103, and the fourth node device 104 included in the blockchain network shown is one. Optionally, the number of the first node device 101, the second node device 102, the third node device 103, and the fourth node device 104 included in the blockchain network can be two, three, four, etc., which is not limited herein. The first node device 101 can obtain the first transaction information of the first account. The second node device 102 can receive the second transaction information and the second virtual resource sent by the first node device 101. The third node device 103 can send the digital resource of the first account to the fourth node device 104. The fourth node device can send the second virtual resource of the first account to the first node device 101. Figure 1 The blockchain network shown is composed of four node devices for illustration only and does not constitute a limitation on the embodiments of the present application.
[0038] Blockchain is a new application mode of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, and encryption algorithm. Blockchain, in essence, is a decentralized database, a string of data blocks generated by using cryptographic methods. Each data block contains information about a batch of network transactions, which is used to verify the validity (anti-counterfeiting) of the information and generate the next block. A blockchain can include a blockchain underlying platform, a platform product service layer, and an application service layer.
[0039] Smart contracts are stored on each node device on the blockchain, and each smart contract is deployed according to different business requirements. In this solution, the first node device can search for the target smart contract in the smart contract database and process the transaction data according to the target smart contract to obtain the second digital signature. Among them, a smart contract is a computer protocol designed to spread, verify, or execute a contract in an informatized manner, allowing for trusted transactions without a third party. These transactions are traceable and irreversible. A smart contract is a set of commitments defined in digital form, including the protocol on which the contract parties can execute these commitments, and is a piece of code written on the blockchain.
[0040] The first account is an account without the qualification to initiate transactions, and the second account is an account with the qualification to initiate transactions. The first node device is a node device in the blockchain network without the qualification to execute transactions, and the second node device is a node device in the blockchain network with the qualification to execute transactions. The first account and the second account can be logged in on the same node device, or they can also be logged in on different node devices. For example, both the first account and the second account are logged in on the first node device, or the first account is logged in on the first node device and the second account is logged in on the second node device, or the first account is logged in on the first node device and the second account is logged in on the third node device, etc., which are not limited herein. In the embodiment of the present application, the second account is logged in on the first node device, and the first account is logged in on the third node device. The first node device, the third node device, and the fourth node device are node devices without the qualification to execute transactions. The fourth node device is a node device with virtual resources, and the fourth node device can purchase and sell virtual resources.
[0041] Based on the above description, an embodiment of the present application proposes a transaction method as Figure 2 shown, and the transaction method may include the following steps S201 - S203:
[0042] S201: The first node device obtains the request information of the first account, and the request information includes service requirement information and first transaction information.
[0043] The first account is the account that requests the second account to initiate a transaction. The first node device is the node device where the second account is logged in. The request information includes service requirement information and first transaction information. The first transaction information includes a first digital signature and transaction data, and the first digital signature is obtained by the first account processing the transaction data.
[0044] Since the first account is an account without the qualification to initiate transactions, when the first account needs to initiate a transaction, it processes the transaction data to obtain a first data signature, generates first transaction information, and then sends the request information to the first node device, entrusting the second account with the qualification to initiate transactions logged in on the first node device to initiate a transaction on behalf of the first account. The first transaction information includes the digital signature of the first account, enabling the second account logged in on the first node device to decrypt the digital signature subsequently, determine the first account that entrusts to initiate the transaction, and then initiate a transaction for the first account according to the transaction data.
[0045] S202: The first node device searches for a target smart contract in the smart contract database in the first node device according to the service requirement information and calls the target smart contract.
[0046] Deploy each smart contract in the first node device, and the smart contracts together form a smart contract database. The first node device searches for a target smart contract corresponding to the service requirement in the smart contract database of the first node device. If the service requirement is a requirement to request a proxy-initiated transaction, then the smart contract in the smart contract database for executing the proxy-initiated transaction service is determined as the target smart contract, and then the target smart contract is called.
[0047] S203: The first node device processes the transaction data according to the target smart contract to obtain a second digital signature and generates second transaction information.
[0048] The second transaction information includes the first transaction information and the second digital signature. The first node device processes the transaction data according to the target smart contract, including: the first node device uses a hashing algorithm to perform a hashing operation on the transaction data according to the target smart contract to obtain a hash value, and the hash value is the second digital signature. Among them, the hashing algorithm may include, but is not limited to, the SHA512 algorithm, the SHA224 algorithm, the SHA384 algorithm, etc.
[0049] The first node device processes the transaction data according to the target smart contract to obtain a second digital signature and generates second transaction information for initiating a transaction for the first account, that is, attaching the second digital signature of the second account to the first transaction information of the first account, which can enable the second node device to verify the second account according to the second digital signature after receiving the second transaction information subsequently, and determine whether the second account is an account with the qualification to initiate a transaction, thereby ensuring that the second node device smoothly executes the transaction for the first account, that is, processes the transaction data.
[0050] Meanwhile, in the blockchain network, there are many second accounts with transaction initiation qualifications logged in node devices that do not have transaction execution qualifications. It is not just the second account logged in to the first node device. Therefore, the first node device processes the transaction data according to the smart contract to obtain the second digital signature, which can indicate that the second account logged in to the first node device initiates a transaction for the first account. The second node device can subsequently find the second account logged in to the first node device through the second digital signature, that is, determine which second account initiates the transaction for the first account. For example, in the blockchain network, the second accounts logged in to node devices are: the second account A logged in to the first node device, the second account B logged in to the third node device, and the second account C logged in to the fourth node device. The first account entrusts the second account A to initiate a transaction on its behalf. Therefore, the first node device signs the transaction data in the first transaction information received to obtain the second digital signature A. Subsequently, the second node device with transaction execution qualifications processes the second digital signature A and can learn that among the second account A, the second account B, and the second account C, it is the second account A that initiates the transaction for the first account.
[0051] S204: The first node device sends the second transaction information to the second node device according to the target smart contract.
[0052] The second node device is a node device with transaction execution qualifications in the blockchain network. The first node device sends the second transaction information to the second node device according to the target smart contract, which enables the second account logged in to the first node device to initiate a transaction for the first account to the second node device. The first node device sending the second transaction information to the second node device according to the target smart contract can also enable the second node device to execute the transaction for the first account after receiving the second transaction information, thereby completing the transaction initiation and transaction execution of the first account and realizing the transaction problem of the first account that does not have transaction initiation qualifications.
[0053] In the embodiment of the present application, the first node device obtains the request information of the first account, determines the target smart contract according to the service requirement information included in the request information, and invokes the target smart contract. Then, the first node device processes the transaction data in the first transaction information according to the target smart contract to obtain the first digital signature, generates the second transaction information, and finally sends the second transaction information to the second node device according to the target smart contract, that is, the first node device initiates a transaction for the first account to the second node device on behalf of the first account according to the target smart contract. In this method, the second account with transaction initiation qualifications logged in to the first node device initiates a transaction for the first account that does not have transaction initiation qualifications by invoking the target smart contract, making it possible for the first account to have the transaction executed by the second node device and solving the transaction problem of the first account that does not have transaction initiation qualifications.
[0054] Please refer to Figure 3 , Figure 3 which is another transaction method proposed in the embodiments of the present application. This transaction method may include, but is not limited to: S301 - S304.
[0055] S301: The first node device obtains the request information of the first account. The request information includes service requirement information and first transaction information.
[0056] S302: The first node device searches for the target smart contract in the smart contract database in the first node device according to the service requirement information and calls the target smart contract.
[0057] For the specific implementation of steps S301 - S302 in the embodiments of the present application, please refer to the execution process of steps S201 - S202 in the above embodiments, and the embodiments of the present invention will not be repeated.
[0058] S303: The first node device obtains the first virtual resource and the second virtual resource of the first account according to the target smart contract.
[0059] In one implementation, the first account entrusts multiple second accounts to initiate transactions for this account, and each of the second accounts is logged in on the first node device. Then the first node device will obtain multiple request information, multiple first virtual resources, and multiple second virtual resources according to the target smart contract. Each request information includes one first transaction information, and each first transaction information, each first virtual resource, and each second virtual resource correspond to one second account. That is, each second account entrusted by the first account will receive one first virtual resource and one second virtual resource corresponding to one request information.
[0060] The first virtual resource is used for the second account to initiate a transaction for the first account, and the second virtual resource is used for the second node device to process the transaction data according to the second transaction information. That is, the first virtual resource is the intermediate fee required for the second account to initiate a transaction for the first account, and the second virtual resource is the fee required for the second node device to execute the transaction for the second account. The first virtual resource and the second virtual resource are represented by Token, and Token is the electronic currency available for transactions in the blockchain network.
[0061] Only after the second account obtains the first virtual resource for initiating a transaction for the first account and the second virtual resource for the second node device to execute the transaction for the first account, will it initiate a transaction for the first account to the second node device. Only after the second node device receives the second virtual resource from the first node device, will it process the transaction data. Therefore, the first node device needs to obtain the first virtual resource and the second virtual resource of the first account.
[0062] The first account does not have the qualification to initiate transactions. Therefore, there is no virtual resource in the first account. The first account needs to use its own digital resources to purchase virtual resources at the node device that can sell virtual resources. If the first account is logged in to the third node device and the node device that can sell virtual resources is the fourth node device, when the first account needs to purchase virtual resources, the third node device sends the digital resources of the first account to the fourth node device. After receiving the digital resources from the third node device, the fourth node device assigns the target virtual resources of this node device to the first account. The value of the target virtual resources is equal to the value of the digital resources, and the target virtual resources include the first virtual resource and the second virtual resource. Therefore, the first virtual resource and the second virtual resource of the first account are included on the fourth node device, and the first node device obtains the first virtual resource and the second virtual resource of the first account on the fourth node device.
[0063] S304: The first node device verifies the transaction data according to the target smart contract and the first digital signature.
[0064] The first node device invokes the target smart contract, and the target smart contract executes the process of verifying the transaction data according to the first digital signature. This method can improve the reliability of the transaction data. The verification of the transaction data by the first node device according to the target smart contract and the first digital signature includes: The first node device performs a hash operation on the first digital signature using the hash algorithm according to the target smart contract to obtain the first target hash value. The hash algorithm used by the first node device according to the target smart contract is informed to the first node device in advance by the first account. Then, according to the one-to-one correspondence between the hash values stored in this node device and the accounts, the first account is determined. If the first account is determined in the one-to-one correspondence between the hash values stored in this node device and the accounts, then the first account is the sender of the transaction data, and the first node device passes the verification of the transaction data according to the target smart contract.
[0065] S305: If the verification of the transaction data passes, trigger the first node device to process the transaction data according to the target smart contract to obtain the second digital signature and generate the second transaction information.
[0066] If the verification of the transaction data passes, trigger the first node device to process the transaction data according to the target smart contract to obtain the second digital signature. The specific steps for the first node device to process the transaction data according to the target smart contract to obtain the second digital signature and generate the second transaction information can refer to the execution process of S203 in the embodiments of this application and will not be elaborated here.
[0067] S306: The second node device sends the second transaction information and the second virtual resource to the second node device according to the target smart contract.
[0068] The second transaction information includes the first transaction information of the first account. The second node device sends the second transaction information to the second node device according to the target smart contract to initiate a transaction for the first account. At the same time, the second node device sends the second virtual resource to the second node device according to the target smart contract to pay on behalf of the first account the transaction fee for the second node device to execute the transaction, so that the second node device can process the transaction data according to the second transaction information in the future, that is, the second node device can execute the transaction for the first account. This method realizes the process of the second account initiating a transaction for the first account.
[0069] In the embodiment of the present application, the first node device obtains the request information of the first account. After determining the target smart contract in the smart contract database according to the service requirement information in the request information, the first node device calls the target smart contract, and then obtains the first virtual resource and the second virtual resource according to the target smart contract. The first virtual resource is used as the transaction fee for the second account to initiate a transaction for the first account, that is, the first virtual resource is attributed to the second account. When the first node device passes the verification of the transaction data, it generates the second transaction information and sends the second transaction information and the second virtual resource to the second node device according to the target smart contract, realizing the requirement of the first account to initiate a transaction. The second account initiates a transaction for the first account to the second node device on behalf of the first account, so that the first account without the qualification to initiate a transaction initiates a transaction through the second account with the qualification to initiate a transaction.
[0070] Please refer to Figure 4 , Figure 4 Another transaction method proposed in the embodiment of the present application, which may include but is not limited to: S401 - S403.
[0071] S401: The second node device receives the second transaction information and the second virtual resource of the first account sent by the first node device.
[0072] The second node device is a node device with the qualification to execute transactions in the blockchain network. The first node device is the node device logged in by the first account. The first account is the account requesting the second account to initiate a transaction. The second account is the account with the qualification to initiate a transaction. The second virtual resource is the virtual resource required to execute the transaction. The second transaction information includes the first transaction information and the second digital signature. The first transaction information includes the first digital signature and the transaction data. The first digital signature is obtained by the first account processing the transaction data, and the second digital signature is obtained by the second account processing the transaction data.
[0073] The first node device sends the second transaction information that the first account wants to transact and the second virtual resources required to execute the transaction to the second node device, indicating that the second account logged in to the first node device has initiated a transaction for the first account. The second node device can execute the transaction for the first account according to the second transaction information and the second virtual resources.
[0074] S402: The second node device verifies the transaction data according to the first digital signature and the second digital signature respectively.
[0075] After receiving the second virtual resources, the second node device uses the second virtual resources as the virtual resources required for the transaction execution of this node device and stores them in the account of this node device. Then, the second node device can execute the transaction for the first account according to the second transaction information. However, to improve the reliability of the transaction data, the second node device verifies the transaction data according to the first digital signature and the second digital signature respectively.
[0076] S403: If the verification of the transaction data passes, the second node device processes the transaction data according to the second transaction information and the second virtual resources.
[0077] If the verification of the transaction data passes, it indicates that the transaction data is the transaction data of the first account and is sent by the first node device, and there is no problem with the authenticity of the transaction data and the identity of the sender of the transaction data. Therefore, the second node device can process the transaction data according to the second transaction information and the second virtual resources. Only when the verification of the transaction data passes, the second node device processes the transaction data according to the second transaction information and the second virtual resources, which can ensure the reliability of the transaction execution.
[0078] In the embodiments of the present application, the second node device receives the second transaction information and the second virtual resources of the first account sent by the first node device. After the verification of the transaction data in the second transaction information passes, the second node device processes the transaction data according to the second transaction information and the second virtual resources, that is, the second node device executes the transaction for the first account, solving the transaction problem of the first account that does not have the qualification to initiate a transaction and does not have the qualification to execute a transaction.
[0079] Figure 5 Another data transaction method proposed in the embodiments of the present application, this transaction method may include but is not limited to: S501 - S505.
[0080] S501: The second node device receives the second transaction information and the second virtual resources of the first account sent by the first node device.
[0081] For the specific implementation of step S501 in the embodiments of the present application, reference may be made to the execution process of step S401 in the above - mentioned embodiments, and the embodiments of the present invention will not be elaborated here.
[0082] S502: The second node device determines the magnitude relationship between the resource amount of the second virtual resource and the resource amount of the target virtual resource.
[0083] The target virtual resource is the virtual resource required for the second node device to process the transaction data according to the transaction information. The second node device will only process the transaction data according to the second transaction information when it determines that the resource amount of the second virtual resource is the same as the resource amount of the target resource. Therefore, before processing the transaction data, the second node device determines the magnitude relationship between the resource amount of the second virtual resource and the resource amount of the target virtual resource.
[0084] S503: If the resource amount of the second virtual resource is greater than or equal to the resource amount of the target virtual resource, the second node device triggers the verification of the transaction data respectively according to the first digital signature and the second digital signature.
[0085] If the resource amount of the second virtual resource is greater than or equal to the resource amount of the target virtual resource, it indicates that the second virtual resource sent from the first node device to the second node device is sufficient for the second node device to execute the transaction for the first account. Then the second node device triggers the verification of the transaction data respectively according to the first digital signature and the second digital signature.
[0086] In one implementation, if the resource amount of the second virtual resource is greater than the resource amount of the target virtual resource, the second node device sends the third virtual resource to the first node device. The third virtual resource is the virtual resource corresponding to the difference between the resource amount of the second virtual resource and the resource amount of the target virtual resource. That is, the second node device returns the redundant virtual resource in the second virtual resource except for the target virtual resource required to execute the transaction to the first node device, and the second node device only charges the target virtual resource required to execute the transaction for the first account in the second virtual resource.
[0087] In one implementation, the second virtual resource comes from multiple second accounts, that is, the first account entrusts multiple second accounts to initiate transactions on behalf of the first account. Then the first node device obtains multiple second virtual resources. After receiving the multiple second virtual resources, the first node device determines whether the sum of the resource amounts of each second virtual resource is equal to the resource amount of the target virtual resource. If the sum of the resource amounts of each second virtual resource is equal to the resource amount of the target virtual resource, it indicates that the second virtual resources received by the second node device are sufficient for the second node device to execute the transaction for the first account. Then the second node device triggers the verification of the transaction data respectively according to the first digital signature and the second digital signature.
[0088] S504: If the resource amount of the second virtual resource is less than the resource amount of the target virtual resource, the second node device sends the indication information to the first node device.
[0089] The indication information is used to indicate that the second virtual resource is insufficient, and the second node device processes the transaction data according to the transaction information. If the resource amount of the second virtual resource is less than the resource amount of the target virtual resource, it indicates that the second virtual resource sent by the first node device is insufficient to enable the second node device to execute the transaction for the first account. Therefore, the second node device generates indication information and sends the indication information to the first node device to prompt the first node device that the second virtual resource sent by this node device does not meet the conditions for executing the transaction, and a new virtual resource needs to be sent to the second node device.
[0090] S505: The second node device verifies the transaction data according to the first digital signature and the second digital signature respectively.
[0091] Specifically, the second node device performs a hash operation on the first digital signature to determine whether the first account is the account that requests to initiate the transaction; the second node device performs a hash operation on the second digital signature to determine whether the second account is the account with the qualification to initiate the transaction.
[0092] The second node device performs a hash operation on the first digital signature to obtain a first target hash value, compares the first target hash value with the one-to-one correspondence between the hash values and the accounts stored in this node device to determine the first account corresponding to the first target hash value, and then verifies whether the determined first account is the account without the qualification to initiate the transaction, that is, whether the first account is the account that requests to initiate the transaction. The second node device performs a hash operation on the second digital signature to obtain a second target hash value, compares the second target hash value with the one-to-one correspondence between the hash values and the accounts stored in this node device to determine the second account corresponding to the second target hash value, and then verifies whether the determined second account is the account with the qualification to initiate the transaction. If the first account is the account that requests to initiate the transaction and the second account is the account with the qualification to initiate the transaction, the second node device passes the verification of the transaction data.
[0093] S506: If the verification of the transaction data passes, the second node device processes the transaction data according to the second transaction information and the second virtual resource.
[0094] For the specific execution process of step S506 in the embodiments of this application, reference can be made to the execution process of step S403 in the above embodiments, and the embodiments of the present invention will not be elaborated here.
[0095] In an embodiment of the present application, after receiving the second virtual resource of the first account, the second node device compares the resource amount of the second virtual resource with the resource amount of the target virtual resource. Only when the resource amount of the second virtual resource is greater than or equal to the resource amount of the target virtual resource, the transaction data is verified according to the first digital signature and the second digital signature. This method can ensure that the second node device processes the transaction data smoothly when the verification of the transaction data is passed. In this method, the second node device processes the transaction data of the first account according to the transaction initiated by the first node device, that is, executes the transaction on the first account, and solves the transaction problem of the first account that does not have the qualification to initiate a transaction and the qualification to execute a transaction.
[0096] Please refer to Figure 6 , Figure 6 FIG. is a schematic structural diagram of an electronic device provided by an embodiment of the present invention. The electronic device can be applied to the first node device. The electronic device 60 includes a processor 601, a memory 602, and a communication interface 603. The processor 601, the memory 602, and the communication interface 603 are connected through one or more communication buses.
[0097] The processor 601 is configured to support the first node device to execute Figures 2 - 5 the corresponding functions of the first node device in the embodiment shown. The processor 601 can be a central processing unit (CPU), a network processor (NP), a hardware chip, or any combination thereof.
[0098] The memory 602 is used to store program codes and the like. The memory 602 may include volatile memory, such as random access memory (RAM); the memory 602 may also include non-volatile memory, such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid-state drive (SSD); the memory 602 may further include a combination of the above types of memories.
[0099] The communication interface 603 is used to receive and send data. For example, the communication interface 603 is used to obtain the first transaction information of the first account, or the communication interface 603 is used to send the second transaction information to the second node device.
[0100] In an embodiment of the present invention, the electronic device 60 includes a plurality of communication interfaces. Among them, the communication interface for sending data and the communication interface for receiving data may not be the same communication interface.
[0101] The processor 601 may call the program code stored in the memory 602 to perform the following operations:
[0102] The processor 601 obtains the request information of the first account. The request information includes service requirement information and first transaction information. The first account is the account that requests the second account to initiate a transaction. The second account is the account with the qualification to initiate a transaction. The first transaction information includes a first digital signature and transaction data. The first digital signature is obtained by the first account processing the transaction data;
[0103] The processor 601 searches for a target smart contract in the smart contract database of the first node device according to the service requirement information and calls the target smart contract;
[0104] The processor 601 processes the transaction data according to the target smart contract to obtain a second digital signature and generates second transaction information. The second transaction information includes the first transaction information and the second digital signature;
[0105] The processor 601 sends the second transaction information to the second node device according to the target smart contract, so that the second node device processes the transaction data according to the second transaction information. The second node device is a node device in the blockchain network with the qualification to execute transactions.
[0106] In one implementation, before the processor 601 processes the transaction data according to the target smart contract to obtain the second digital signature, the following operations may also be performed: The processor 601 obtains the first virtual resource and the second virtual resource of the first account according to the target smart contract. The first virtual resource is used for the second account to initiate a transaction for the first account. The second virtual resource is used for the second node device to process the transaction data according to the second transaction information. The processor 601 sends the second virtual resource to the second node device according to the target smart contract, so that the second node device processes the transaction data according to the second transaction information.
[0107] In one implementation, before the second digital signature obtained by the processor 601 processing the transaction data according to the target smart contract, the following operations may also be performed: The processor 601 verifies the transaction data according to the target smart contract and the first digital signature; If the verification of the transaction data passes, the processor 601 triggers processing the transaction data according to the target smart contract to obtain the second digital signature.
[0108] Please refer to Figure 7 , Figure 7It is a schematic structural diagram of another electronic device provided by an embodiment of the present invention. This electronic device can be applied to a second node device. The electronic device 70 includes a processor 701, a memory 702, and a communication interface 703. The processor 701, the memory 02, and the communication interface 703 are connected through one or more communication buses.
[0109] The processor 701 is configured to support the second node device to execute Figures 2 - 5 the corresponding functions of the second node device in the illustrated embodiment. The processor 701 can be a central processing unit (CPU), a network processor (NP), a hardware chip, or any combination thereof.
[0110] The memory 702 is used to store program codes, etc. The memory 702 can include volatile memory, such as random access memory (RAM); the memory 702 can also include non-volatile memory, such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid-state drive (SSD); the memory 702 can also include a combination of the above types of memories.
[0111] The communication interface 703 is used to receive and send data. For example, the communication interface 703 is used to receive the second transaction information and the second virtual resource of the first account sent by the first node device.
[0112] In the embodiment of the present invention, the electronic device 70 includes multiple communication interfaces. Among them, the communication interface for sending data and the communication interface for receiving data may not be the same communication interface.
[0113] The processor 701 can call the program code stored in the memory 702 to perform the following operations:
[0114] The processor 701 receives the second transaction information and the second virtual resource of the first account sent by the first node device. The first account is the account that requests the second account to initiate a transaction. The second account is the account with the qualification to initiate a transaction. The second virtual resource is the virtual resource required to execute the transaction. The second transaction information includes the first transaction information and the second digital signature. The first transaction information includes the first digital signature and the transaction data. The first digital signature is obtained by the first account processing the transaction data. The second digital signature is obtained by the second account processing the transaction data.
[0115] The processor 701 verifies the transaction data according to the first digital signature and the second digital signature respectively;
[0116] If the processor 701 passes the verification of the transaction data, it processes the transaction data according to the second transaction information and the second virtual resource.
[0117] In one implementation, before the processor 701 verifies the transaction data according to the first digital signature and the second digital signature respectively, it may also perform the following operations: the processor 701 determines the relationship between the resource amount of the second virtual resource and the resource amount of the target virtual resource, and the target virtual resource is the virtual resource required by the second node device to process the transaction data according to the transaction information; if the resource amount of the second virtual resource is less than the resource amount of the target virtual resource, the processor 701 sends an indication information to the first node device, and the indication information is used to indicate that the second virtual resource is insufficient for the second node device to process the transaction data according to the transaction information; if the resource amount of the second virtual resource is greater than or equal to the resource amount of the target virtual resource, the processor 701 triggers the verification of the transaction data according to the first digital signature and the second digital signature respectively.
[0118] In one implementation, the second virtual resource comes from multiple second accounts. Before the processor 701 verifies the transaction data according to the first digital signature and the second digital signature, it can also perform the following operations: the processor 701 determines whether the total amount of resources of each second virtual resource is equal to the amount of resources of the target virtual resource; if the total amount of resources of each second virtual resource is equal to the amount of resources of the target virtual resource, the processor 701 triggers the verification of the transaction data according to the first digital signature and the second digital signature.
[0119] In one implementation, the specific operations of the processor 701 to verify the transaction data according to the first digital signature and the second digital signature are as follows: the processor 701 performs a hash operation on the first digital signature to determine whether the first account is an account requesting to initiate a transaction; the processor 701 performs a hash operation on the second digital signature to determine whether the second account is an account eligible to initiate a transaction; if it is determined that the first account is an account requesting to initiate a transaction and the second account is eligible to initiate a transaction, the processor 701 triggers the processing of the transaction data according to the second transaction information and the second virtual resource.
[0120] See also Figure 8 , Figure 8 : is a schematic diagram of the structure of a transaction device provided by an embodiment of the present invention. The transaction device may be run in a first node device. The transaction device 80 may include:
[0121] An acquisition device 801, configured to acquire request information of a first account, where the request information includes service requirement information and first transaction information, the first account is an account that requests a second account to initiate a transaction, the second account is an account with transaction initiation qualification, the first transaction information includes a first digital signature and transaction data, and the first digital signature is obtained by the first account processing the transaction data;
[0122] A processing device 802, configured to search for a target smart contract in a smart contract database in a first node device according to the service requirement information, and call the target smart contract;
[0123] A processing device 802, configured to process the transaction data according to the target smart contract to obtain a second digital signature, and generate second transaction information, where the second transaction information includes the first transaction information and the second digital signature;
[0124] A sending device 803, configured to send the second transaction information to a second node device according to the target smart contract, so that the second node device processes the transaction data according to the second transaction information, and the second node device is a node device in the blockchain network with transaction execution qualification.
[0125] In an implementation manner, the acquisition device 801 is further configured to acquire a first virtual resource and a second virtual resource of the first account according to the target smart contract, where the first virtual resource is used for the second account to initiate a transaction for the first account, and the second virtual resource is used for the second node device to process the transaction data according to the second transaction information; the sending device 803 is further configured to send the second virtual resource to the second node device according to the target smart contract, so that the second node device processes the transaction data according to the second transaction information.
[0126] In an implementation manner, the processing device 802 is further configured to verify the transaction data according to the target smart contract and the first digital signature; the processing device 802 is further configured to, if the verification of the transaction data passes, trigger processing the transaction data according to the target smart contract to obtain a second digital signature.
[0127] Please refer to Figure 9 , Figure 9 which is a schematic structural diagram of another transaction device provided by an embodiment of the present invention. The transaction device may be disposed in the second node device, and the transaction device 90 may include:
[0128] A receiving device 901, configured to receive second transaction information and second virtual resources of a first account sent by a first node device, where the first account is an account that requests a second account to initiate a transaction, the second account is an account with transaction initiation qualifications, the second virtual resources are virtual resources required to execute the transaction, the second transaction information includes first transaction information and a second digital signature, the first transaction information includes a first digital signature and transaction data, the first digital signature is obtained by the first account processing the transaction data, and the second digital signature is obtained by the second account processing the transaction data;
[0129] A processing device 902, configured to verify the transaction data according to the first digital signature and the second digital signature respectively;
[0130] The processing device 902 is further configured to, if the verification of the transaction data passes, process the transaction data according to the second transaction information and the second virtual resources.
[0131] In one implementation, the processing device 902 is further configured to determine the magnitude relationship between the resource amount of the second virtual resources and the resource amount of target virtual resources, where the target virtual resources are virtual resources required for a second node device to process the transaction data according to the transaction information; the processing device 902 is further configured to, if the resource amount of the second virtual resources is less than the resource amount of the target virtual resources, send indication information to the first node device, where the indication information is used to indicate that the second virtual resources are not sufficient for the second node device to process the transaction data according to the transaction information; the processing device 902 is further configured to, if the resource amount of the second virtual resources is greater than or equal to the resource amount of the target virtual resources, trigger the verification of the transaction data according to the first digital signature and the second digital signature respectively.
[0132] In one implementation, the processing device 902 is further configured to determine whether the sum of the resource amounts of each second virtual resource is equal to the resource amount of the target virtual resources; the processing device 902 is further configured to, if the sum of the resource amounts of each second virtual resource is equal to the resource amount of the target virtual resources, trigger the verification of the transaction data according to the first digital signature and the second digital signature respectively.
[0133] In one implementation, the processing device 902 is further configured to perform a hash operation on the first digital signature to determine whether the first account is the account that requests to initiate the transaction; the processing device 902 is further configured to perform a hash operation on the second digital signature to determine whether the second account has transaction initiation qualifications; the processing device 902 is further configured to, if it is determined that the first account is the account that requests to initiate the transaction and the second account has transaction initiation qualifications, the processor triggers the processing of the transaction data according to the second transaction information and the second virtual resources.
[0134] The specific implementation of each unit included in the information push device proposed in the embodiments of the present invention can refer to the descriptions of the relevant content in the foregoing embodiments, which will not be elaborated here. And, Figure 8 and Figure 9 Each module in the information push device shown can be separately or all combined into one or several other modules to form, or a certain one (or some) of the modules can be further split into multiple smaller modules with more functions to form, which can achieve the same operation without affecting the realization of the technical effects of the embodiments of the present application. The above modules are divided based on logical functions. In actual applications, the function of one module can also be realized by multiple modules, or the functions of multiple modules can be realized by one module. In other embodiments of the present application, other modules may also be included. In actual applications, these functions can also be assisted by other modules and can be realized by the cooperation of multiple modules. The present application does not make any limitations.
[0135] The embodiments of the present invention also provide a computer-readable storage medium, which can be used to store Figures 2 - 5 The computer software instructions used by the first node device in the shown embodiments, which include the programs designed for the first node device in the above embodiments.
[0136] The embodiments of the present invention also provide another computer-readable storage medium, which can be used to store Figures 2 - 5 The computer software instructions used by the second node device in the shown embodiments, which include the programs designed for the second node device in the above embodiments.
[0137] The above computer-readable storage medium includes but is not limited to flash memory, hard disk, and solid-state drive.
[0138] As mentioned above, the above are only the specific implementation manners of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art within the technical scope disclosed by the present invention can easily think of changes or substitutions, which should all be covered by the protection scope of the present invention. Therefore, the protection scope of the present invention should be subject to the protection scope of the claims.
Claims
1. A trading method, which is applied to a first node device, and the first node device is any node device in a blockchain network, characterized in that Including: Obtaining request information of a first account, where the request information includes service requirement information and first transaction information. The first account is the account that requests a second account to initiate a transaction. The second account is an account with transaction initiation qualification, and the second account is logged in the first node device. The first transaction information includes a first digital signature and transaction data, and the first digital signature is obtained by the first account processing the transaction data. The first account purchases virtual resources at a node device for selling virtual resources in a blockchain network by using digital resources, and pays the purchased virtual resources to the second account, triggering the second account to initiate a transaction for the first account to a second node device; Searching for a target smart contract in the smart contract database in the first node device according to the service requirement information, and invoking the target smart contract through the second account; Processing the transaction data according to the target smart contract to obtain a second digital signature of the second account, and generating second transaction information for initiating a transaction for the first account. The second transaction information includes the first transaction information and the second digital signature; Sending the second transaction information to the second node device according to the target smart contract, so that the second node device processes the transaction data according to the second transaction information. The second node device is a node device in the blockchain network with transaction execution qualification.
2. The method according to claim 1, wherein Before processing the transaction data according to the target smart contract to obtain the second digital signature of the second account, it further includes: Obtaining a first virtual resource and a second virtual resource of the first account according to the target smart contract. The first virtual resource is used for the second account to initiate a transaction for the first account, and the second virtual resource is used for the second node device to process the transaction data according to the second transaction information; Sending the second virtual resource to the second node device according to the target smart contract, so that the second node device processes the transaction data according to the second transaction information.
3. The method according to claim 1, wherein Before processing the transaction data according to the target smart contract to obtain the second digital signature of the second account, it further includes: Verifying the transaction data according to the target smart contract and the first digital signature; If the verification of the transaction data passes, triggering the processing of the transaction data according to the target smart contract to obtain the second digital signature.
4. A trading method, the method is applied to a second node device, and the second node device is any node device in a blockchain network, characterized in that, Including: Receive the second transaction information and the second virtual resource for initiating a transaction for the first account sent by the first node device. The first account is the account that requests the second account to initiate a transaction. The second account is the account with the qualification to initiate a transaction, and the second account is logged in the first node device in the blockchain network. The first account purchases the virtual resource at the node device that sells virtual resources in the blockchain network by using digital resources and pays the purchased virtual resource to the second account, triggering the second account to initiate a transaction for the first account to the second node device. The second virtual resource is the virtual resource required for executing the transaction. The second transaction information includes the first transaction information and the second digital signature of the second account. The first transaction information includes the first digital signature and the transaction data. The first digital signature is obtained by the first account processing the transaction data. The second digital signature is obtained by the second account invoking the target smart contract and processing the transaction data according to the target smart contract. Verify the transaction data respectively according to the first digital signature and the second digital signature. If the verification of the transaction data passes, process the transaction data according to the second transaction information and the second virtual resource.
5. The method according to claim 4, wherein Before verifying the transaction data respectively according to the first digital signature and the second digital signature, it further includes: Determine the size relationship between the resource amount of the second virtual resource and the resource amount of the target virtual resource. The target virtual resource is the virtual resource required for the second node device to process the transaction data according to the transaction information. If the resource amount of the second virtual resource is less than the resource amount of the target virtual resource, send an indication message to the first node device. The indication message is used to indicate that the second virtual resource is not sufficient for the second node device to process the transaction data according to the transaction information. If the resource amount of the second virtual resource is greater than or equal to the resource amount of the target virtual resource, trigger the verification of the transaction data respectively according to the first digital signature and the second digital signature.
6. The method according to claim 5, wherein The second virtual resource comes from multiple second accounts. Before verifying the transaction data respectively according to the first digital signature and the second digital signature, it further includes: Determine whether the total resource amount of each second virtual resource is equal to the resource amount of the target virtual resource. If the total resource amount of each second virtual resource is equal to the resource amount of the target virtual resource, trigger the verification of the transaction data respectively according to the first digital signature and the second digital signature.
7. The method according to claim 4, wherein Verifying the transaction data respectively according to the first digital signature and the second digital signature includes: Perform a hash operation on the first digital signature to determine whether the first account is the account that requests to initiate a transaction. Perform a hash operation on the second digital signature to determine whether the second account is the account with the qualification to initiate a transaction. If it is determined that the first account is the account that initiated the transaction request and the second account has the qualification to initiate a transaction, then trigger the processing of the transaction data according to the second transaction information and the second virtual resource.
8. An electronic device, characterized in that, It includes a processor and a memory, the processor is connected to the memory, wherein the memory is used to store a computer program, the computer program includes program instructions, and the processor is configured to call the program instructions to execute the method according to any one of claims 1-3 or 4-7.
9. A trading device, characterized in that, The transaction device includes: An acquisition device, configured to acquire, by a first node device, request information of a first account, the request information including service requirement information and first transaction information, the first account being the account that requests a second account to initiate a transaction, the second account being an account with the qualification to initiate a transaction, and the second account being logged in the first node device; the first transaction information includes a first digital signature and transaction data, the first digital signature being obtained by the first account processing the transaction data; the first account purchases virtual resources at a node device for selling virtual resources in a blockchain network by using digital resources and pays the purchased virtual resources to the second account, triggering the second account to initiate a transaction for the first account to a second node device; A processing device, configured to search, by the first node device, for a target smart contract in a smart contract database in the first node device according to the service requirement information and call the target smart contract through the second account; process the transaction data according to the target smart contract to obtain a second digital signature of the second account, and generate second transaction information for initiating a transaction for the first account, the second transaction information including the first transaction information and the second digital signature; A sending device, configured to send, by the first node device, the second transaction information to a second node device according to the target smart contract, so that the second node device processes the transaction data according to the second transaction information, and the second node device is a node device in the blockchain network with the qualification to execute transactions.
10. A computer storage medium, characterized in that, The computer storage medium stores a computer program, the computer program includes program instructions, and when the program instructions are executed by a processor, the processor is caused to execute the method according to any one of claims 1-3 or 4-7.
11. A trading device, characterized in that, The transaction device includes: A receiving device, configured to receive second transaction information and a second virtual resource for initiating a transaction for a first account sent by a first node device, where the first account is an account that requests a second account to initiate a transaction, the second account is an account with transaction initiation qualifications, and the second account is logged in the first node device in a blockchain network. The first account purchases the virtual resource at a node device that sells virtual resources in the blockchain network by using a digital resource, and pays the purchased virtual resource to the second account, triggering the second account to initiate a transaction for the first account to a second node device; the second virtual resource is a virtual resource required for executing the transaction, the second transaction information includes first transaction information and a second digital signature of the second account, the first transaction information includes a first digital signature and transaction data, the first digital signature is obtained by the first account processing the transaction data, and the second digital signature is obtained by the second account invoking a target smart contract and processing the transaction data according to the target smart contract; A processing device, configured to respectively verify the transaction data according to the first digital signature and the second digital signature; The processing device is further configured to, if the verification of the transaction data is passed, process the transaction data according to the second transaction information and the second virtual resource.
Citation Information
Patent Citations
Transaction verification method and related equipment
CN110599177A