Movatterモバイル変換


[0]ホーム

URL:


CN111489156A - Blockchain-based transaction method, electronic device and readable storage medium - Google Patents

Blockchain-based transaction method, electronic device and readable storage medium
Download PDF

Info

Publication number
CN111489156A
CN111489156ACN202010194501.3ACN202010194501ACN111489156ACN 111489156 ACN111489156 ACN 111489156ACN 202010194501 ACN202010194501 ACN 202010194501ACN 111489156 ACN111489156 ACN 111489156A
Authority
CN
China
Prior art keywords
node
transaction
area network
local area
request
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010194501.3A
Other languages
Chinese (zh)
Inventor
董国超
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An International Smart City Technology Co Ltd
Original Assignee
Ping An International Smart City Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An International Smart City Technology Co LtdfiledCriticalPing An International Smart City Technology Co Ltd
Priority to CN202010194501.3ApriorityCriticalpatent/CN111489156A/en
Priority to PCT/CN2020/106004prioritypatent/WO2021184642A1/en
Publication of CN111489156ApublicationCriticalpatent/CN111489156A/en
Pendinglegal-statusCriticalCurrent

Links

Images

Classifications

Landscapes

Abstract

Translated fromChinese

本发明涉及区块链技术,提供了一种基于区块链的交易方法、电子装置及可读存储介质,该方法包括:在广域网中收到第一节点发出的局域网组网请求后,按预设组网规则创建由所述第一节点与第二节点、第三节点组成的局域网;其中,所述广域网由区块链网络中所有节点搭建组成;获取创建的局域网的网段编码,并根据预先设定的网段编码与智能合约的映射关系,确定出与创建的局域网的网段编码相对应的智能合约;在收到所述第一节点发起的与第二节点、第三节点的交易请求后,在创建的局域网中运行确定出的智能合约来对账本进行读写操作,完成所述第一节点与第二节点、第三节点的交易。本发明提高了区块链网络中部分节点交易的安全性。

Figure 202010194501

The invention relates to block chain technology, and provides a block chain-based transaction method, electronic device and readable storage medium. The method includes: after receiving a local area network networking request sent by a first node in a wide area network, according to a preset Set up networking rules to create a local area network composed of the first node, the second node, and the third node; wherein, the wide area network is composed of all nodes in the blockchain network; obtain the network segment code of the created local area network, and according to The mapping relationship between the preset network segment code and the smart contract is determined, and the smart contract corresponding to the network segment code of the created local area network is determined; after receiving the transaction initiated by the first node with the second node and the third node After the request is made, the determined smart contract is run in the created local area network to perform read and write operations on the ledger to complete the transaction between the first node, the second node, and the third node. The invention improves the security of some node transactions in the block chain network.

Figure 202010194501

Description

Translated fromChinese
基于区块链的交易方法、电子装置及可读存储介质Blockchain-based transaction method, electronic device and readable storage medium

技术领域technical field

本发明涉及计算机技术领域,尤其涉及一种基于区块链的交易方法、电子装置及可读存储介质。The present invention relates to the field of computer technology, and in particular, to a blockchain-based transaction method, an electronic device and a readable storage medium.

背景技术Background technique

在现有的区块链技术中,在区块链网络中部分节点之间进行私密交易时,交易是在整个区块链网络中完成的,即该部分节点之间的交易是面向区块链网络中所有成员节点进行的,则区块链网络中的每个成员节点都有包含该部分节点交易内容的完整交易账本。因此,一旦区块链网络中任何一个成员节点的账本发生泄漏,如成员节点上的账本被恶意破解,则会导致该部分节点之间的交易内容被泄漏。在区块链网络中成员节点数量众多的情况下,部分节点之间的交易具有安全风险。In the existing blockchain technology, when a private transaction is performed between some nodes in the blockchain network, the transaction is completed in the entire blockchain network, that is, the transaction between this part of the nodes is oriented to the blockchain All member nodes in the network, each member node in the blockchain network has a complete transaction ledger containing the transaction content of this part of the node. Therefore, once the ledger of any member node in the blockchain network is leaked, if the ledger on the member node is maliciously cracked, the transaction content between this part of the nodes will be leaked. In the case of a large number of member nodes in a blockchain network, transactions between some nodes have security risks.

发明内容SUMMARY OF THE INVENTION

本发明的目的在于提供一种基于区块链的交易方法、电子装置及可读存储介质,旨在提高区块链网络中部分节点交易的安全性。The purpose of the present invention is to provide a transaction method, electronic device and readable storage medium based on blockchain, aiming at improving the security of transaction of some nodes in the blockchain network.

为实现上述目的,本发明提供一种电子装置,所述电子装置包括存储器、处理器,所述存储器上存储有可在所述处理器上运行的基于区块链的交易系统,所述基于区块链的交易系统被所述处理器执行时实现如下步骤:In order to achieve the above object, the present invention provides an electronic device, the electronic device includes a memory and a processor, and the memory stores a blockchain-based transaction system that can run on the processor. When the transaction system of the blockchain is executed by the processor, the following steps are implemented:

当接收到广域网中第一节点发出的局域网组网请求时,按预设组网规则和所述局域网组网请求创建由所述第一节点与第二节点、第三节点组成的局域网;其中,所述广域网由区块链网络中所有节点搭建组成;When receiving a local area network networking request sent by the first node in the wide area network, a local area network consisting of the first node, the second node, and the third node is created according to the preset networking rules and the local area network networking request; wherein, The wide area network is composed of all nodes in the blockchain network;

获取创建的局域网的网段编码,并根据预先设定的网段编码与智能合约的映射关系,确定出与创建的局域网的网段编码相对应的智能合约;Obtain the network segment code of the created local area network, and determine the smart contract corresponding to the network segment code of the created local area network according to the mapping relationship between the preset network segment code and the smart contract;

当收到所述第一节点发起的与第二节点、第三节点的交易请求时,在创建的局域网中运行确定出的智能合约,并根据所述智能合约对账本进行读写操作,完成所述第一节点与第二节点、第三节点的交易。When receiving the transaction request initiated by the first node with the second node and the third node, run the determined smart contract in the created local area network, and perform read and write operations on the ledger according to the smart contract to complete all transactions. Describe the transactions between the first node, the second node, and the third node.

在一个实施例中,所述局域网组网请求包括第一节点创建的成员清单,所述成员清单中包含所述第一节点请求进行局域网组网的第二节点、第三节点;In one embodiment, the local area network networking request includes a member list created by the first node, and the member list includes a second node and a third node that the first node requests to perform local area network networking;

所述按预设组网规则创建由所述第一节点与第二节点、第三节点组成的局域网的步骤包括:The step of creating a local area network composed of the first node, the second node, and the third node according to the preset networking rules includes:

利用所述第二节点、第三节点对应的公钥对所述成员清单进行加密,将加密后的成员清单在所述广域网中进行广播;Encrypt the member list by using the public keys corresponding to the second node and the third node, and broadcast the encrypted member list in the wide area network;

接收所述第二节点、第三节点对广播的成员清单的确认反馈信息,并将所述第二节点、第三节点的确认反馈信息添加到局域网账本中,创建由所述第一节点与第二节点、第三节点组成的局域网。Receive the confirmation feedback information from the second node and the third node to the broadcasted member list, and add the confirmation feedback information of the second node and the third node to the local area network account book, and create a connection between the first node and the third node. A local area network consisting of a second node and a third node.

在一个实施例中,所述当收到所述第一节点发起的与第二节点、第三节点的交易请求时,在创建的局域网中运行确定出的智能合约,并根据所述智能合约对账本进行读写操作,完成所述第一节点与第二节点、第三节点的交易的步骤包括:In one embodiment, when a transaction request initiated by the first node with the second node and the third node is received, the determined smart contract is executed in the created local area network, and the smart contract is executed according to the smart contract. The ledger performs read and write operations, and the steps of completing the transaction between the first node and the second node and the third node include:

当收到所述第一节点发起的与第二节点、第三节点的交易请求时,将所述交易请求发送至所述广域网进行验证;When receiving the transaction request with the second node and the third node initiated by the first node, send the transaction request to the wide area network for verification;

获取所述广域网发送的验证通过反馈信息;所述验证通过反馈信息的生成过程如下,在所述广域网按预设验证规则对所述交易请求验证通过后,获取所述交易请求对应的交易内容中的交易摘要,基于所述交易摘要形成第一交易区块并添加所述第一交易区块到广域网账本中,并生成第一交易区块相关信息作为所述验证通过反馈信息;Obtain the verification passing feedback information sent by the wide area network; the generation process of the verification passing feedback information is as follows, after the wide area network verifies the transaction request according to the preset verification rules and passes, acquire the transaction content corresponding to the transaction request. the transaction summary, form a first transaction block based on the transaction summary and add the first transaction block to the WAN ledger, and generate the first transaction block related information as the verification pass feedback information;

根据所述验证通过反馈信息确认所述交易请求,并在所述局域网中运行确定出的智能合约,基于所述智能合约和所述交易请求对应的交易内容形成第二交易区块;Confirm the transaction request through the feedback information according to the verification, run the determined smart contract in the local area network, and form a second transaction block based on the smart contract and the transaction content corresponding to the transaction request;

将所述第一交易区块相关信息加入至所述第二交易区块中,并将所述第二交易区块添加到局域网账本中,以完成所述第一节点与第二节点、第三节点的交易。Add the relevant information of the first transaction block to the second transaction block, and add the second transaction block to the local area network account book, so as to complete the first node and the second node, the third Node transactions.

在一个实施例中,所述预设验证规则包括:In one embodiment, the preset verification rules include:

计算所述交易请求的哈希值,验证所述交易请求的哈希值是否正确;和/或,验证所述交易请求是否与预先设定的所述局域网对应的交易策略相匹配。Calculate the hash value of the transaction request, and verify whether the hash value of the transaction request is correct; and/or, verify whether the transaction request matches the preset transaction strategy corresponding to the local area network.

此外,为实现上述目的,本发明还提供一种基于区块链的交易方法,所述基于区块链的交易方法包括:In addition, in order to achieve the above object, the present invention also provides a transaction method based on blockchain, the transaction method based on blockchain includes:

当接收到广域网中第一节点发出的局域网组网请求时,按预设组网规则和所述局域网组网请求创建由所述第一节点与第二节点、第三节点组成的局域网;其中,所述广域网由区块链网络中所有节点搭建组成;When receiving a local area network networking request sent by the first node in the wide area network, a local area network consisting of the first node, the second node, and the third node is created according to the preset networking rules and the local area network networking request; wherein, The wide area network is composed of all nodes in the blockchain network;

获取创建的局域网的网段编码,并根据预先设定的网段编码与智能合约的映射关系,确定出与创建的局域网的网段编码相对应的智能合约;Obtain the network segment code of the created local area network, and determine the smart contract corresponding to the network segment code of the created local area network according to the mapping relationship between the preset network segment code and the smart contract;

当收到所述第一节点发起的与第二节点、第三节点的交易请求时,在创建的局域网中运行确定出的智能合约,并根据所述智能合约对账本进行读写操作,完成所述第一节点与第二节点、第三节点的交易。When receiving the transaction request initiated by the first node with the second node and the third node, run the determined smart contract in the created local area network, and perform read and write operations on the ledger according to the smart contract to complete all transactions. Describe the transactions between the first node, the second node, and the third node.

在一个实施例中,所述局域网组网请求包括第一节点创建的成员清单,所述成员清单中包含所述第一节点请求进行局域网组网的第二节点、第三节点;In one embodiment, the local area network networking request includes a member list created by the first node, and the member list includes a second node and a third node that the first node requests to perform local area network networking;

所述按预设组网规则创建由所述第一节点与第二节点、第三节点组成的局域网的步骤包括:The step of creating a local area network composed of the first node, the second node, and the third node according to the preset networking rules includes:

利用所述第二节点、第三节点对应的公钥对所述成员清单进行加密,将加密后的成员清单在所述广域网中进行广播;Encrypt the member list by using the public keys corresponding to the second node and the third node, and broadcast the encrypted member list in the wide area network;

接收所述第二节点、第三节点对广播的成员清单的确认反馈信息,并将所述第二节点、第三节点的确认反馈信息添加到局域网账本中,创建由所述第一节点与第二节点、第三节点组成的局域网。Receive the confirmation feedback information from the second node and the third node to the broadcasted member list, and add the confirmation feedback information of the second node and the third node to the local area network account book, and create a connection between the first node and the third node. A local area network consisting of a second node and a third node.

在一个实施例中,所述当收到所述第一节点发起的与第二节点、第三节点的交易请求时,在创建的局域网中运行确定出的智能合约,并根据所述智能合约对账本进行读写操作,完成所述第一节点与第二节点、第三节点的交易的步骤包括:In one embodiment, when a transaction request initiated by the first node with the second node and the third node is received, the determined smart contract is executed in the created local area network, and the smart contract is executed according to the smart contract. The ledger performs read and write operations, and the steps of completing the transaction between the first node and the second node and the third node include:

当收到所述第一节点发起的与第二节点、第三节点的交易请求时,将所述交易请求发送至所述广域网进行验证;When receiving the transaction request with the second node and the third node initiated by the first node, send the transaction request to the wide area network for verification;

获取所述广域网发送的验证通过反馈信息;所述验证通过反馈信息的生成过程如下,在所述广域网按预设验证规则对所述交易请求验证通过后,获取所述交易请求对应的交易内容中的交易摘要,基于所述交易摘要形成第一交易区块并添加所述第一交易区块到广域网账本中,并生成第一交易区块相关信息作为所述验证通过反馈信息;Obtain the verification passing feedback information sent by the wide area network; the generation process of the verification passing feedback information is as follows, after the wide area network verifies the transaction request according to the preset verification rules and passes, acquire the transaction content corresponding to the transaction request. the transaction summary, form a first transaction block based on the transaction summary and add the first transaction block to the WAN ledger, and generate the first transaction block related information as the verification pass feedback information;

根据所述验证通过反馈信息确认所述交易请求,并在所述局域网中运行确定出的智能合约,基于所述智能合约和所述交易请求对应的交易内容形成第二交易区块;Confirm the transaction request through the feedback information according to the verification, run the determined smart contract in the local area network, and form a second transaction block based on the smart contract and the transaction content corresponding to the transaction request;

将所述第一交易区块相关信息加入至所述第二交易区块中,并将所述第二交易区块添加到局域网账本中,以完成所述第一节点与第二节点、第三节点的交易。Add the relevant information of the first transaction block to the second transaction block, and add the second transaction block to the local area network account book, so as to complete the first node and the second node, the third Node transactions.

在一个实施例中,在所述获取所述广域网发送的验证通过反馈信息的步骤之前,还包括:In one embodiment, before the step of acquiring the verification feedback information sent by the wide area network, the method further includes:

对创建的局域网中的各个节点进行背书处理,将背书处理结果和所述交易请求对应的交易内容中的交易摘要按预设格式发送至所述广域网进行验证。Perform endorsement processing on each node in the created local area network, and send the endorsement processing result and the transaction summary in the transaction content corresponding to the transaction request to the wide area network for verification in a preset format.

在一个实施例中,所述预设验证规则包括:In one embodiment, the preset verification rules include:

计算所述交易请求的哈希值,验证所述交易请求的哈希值是否正确;和/或,验证所述交易请求是否与预先设定的所述局域网对应的交易策略相匹配。Calculate the hash value of the transaction request, and verify whether the hash value of the transaction request is correct; and/or, verify whether the transaction request matches the preset transaction strategy corresponding to the local area network.

进一步地,为实现上述目的,本发明还提供一种计算机可读存储介质,所述计算机可读存储介质存储有基于区块链的交易系统,所述基于区块链的交易系统可被至少一个处理器执行,以使所述至少一个处理器执行如上述的基于区块链的交易方法的步骤。Further, in order to achieve the above object, the present invention also provides a computer-readable storage medium, the computer-readable storage medium stores a blockchain-based transaction system, and the blockchain-based transaction system can be stored by at least one The processor executes to cause the at least one processor to execute the steps of the blockchain-based transaction method as described above.

本发明提出的基于区块链的交易方法、电子装置及可读存储介质,通过区块链网络中所有节点来搭建组成广域网,在广域网中第一节点请求与第二节点、第三节点进行私密交易时,创建由所述第一节点与第二节点、第三节点组成的局域网,并根据预先设定的网段编码与智能合约的映射关系,确定出与创建的局域网的网段编码相对应的智能合约,从而在创建的局域网中运行确定出的智能合约来对账本进行读写操作,完成所述第一节点与第二节点、第三节点的交易。由于是通过基于区块链网络搭建单广域网和多局域网,将需要进行私密交易的部分节点如第一节点与第二节点、第三节点加入至局域网中来完成交易,而不是直接在整个区块链网络中完成交易,因此,不是区块链网络中的每个成员节点都有包含该部分节点私密交易内容的完整交易账本,从而降低了该部分节点私密交易内容的泄露风险,提高了区块链网络中部分节点交易的安全性。The blockchain-based transaction method, electronic device and readable storage medium proposed by the present invention construct a wide area network through all nodes in the blockchain network, and in the wide area network, the first node requests to communicate with the second node and the third node for privacy During the transaction, create a local area network composed of the first node, the second node, and the third node, and determine the corresponding network segment code of the created local area network according to the mapping relationship between the preset network segment code and the smart contract Therefore, the determined smart contract is run in the created local area network to perform read and write operations on the ledger, and the transaction between the first node and the second node and the third node is completed. Since a single wide area network and multiple local area networks are built based on the blockchain network, some nodes that need to conduct private transactions, such as the first node, the second node, and the third node, are added to the local area network to complete the transaction, rather than directly in the entire block. Therefore, not every member node in the blockchain network has a complete transaction ledger containing the private transaction content of this part of the node, thereby reducing the risk of leakage of the private transaction content of this part of the node and improving the block chain. The security of some node transactions in the chain network.

附图说明Description of drawings

图1为本发明基于区块链的交易系统较佳实施例的运行环境示意图;1 is a schematic diagram of the operating environment of a preferred embodiment of the blockchain-based transaction system of the present invention;

图2为本发明基于区块链的交易系统较佳实施例的程序模块图;Fig. 2 is the program module diagram of the preferred embodiment of the blockchain-based transaction system of the present invention;

图3为本发明基于区块链的交易方法较佳实施例的流程示意图;3 is a schematic flowchart of a preferred embodiment of the blockchain-based transaction method of the present invention;

图4为本发明基于区块链的交易方法一实施例中局域网各节点的背书及验证示意图;4 is a schematic diagram of endorsement and verification of each node of the local area network in an embodiment of the blockchain-based transaction method of the present invention;

图5为本发明基于区块链的交易方法一实施例中第一交易区块的生成示意图;5 is a schematic diagram of generating a first transaction block in an embodiment of the blockchain-based transaction method of the present invention;

图6为本发明基于区块链的交易方法一实施例中第二交易区块的生成示意图。FIG. 6 is a schematic diagram of generating a second transaction block in an embodiment of the blockchain-based transaction method of the present invention.

具体实施方式Detailed ways

为了使本发明的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本发明进行进一步详细说明。应当理解,此处所描述的具体实施例仅用以解释本发明,并不用于限定本发明。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。In order to make the objectives, technical solutions and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention, but not to limit the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.

需要说明的是,在本发明中涉及“第一”、“第二”等的描述仅用于描述目的,而不能理解为指示或暗示其相对重要性或者隐含指明所指示的技术特征的数量。由此,限定有“第一”、“第二”的特征可以明示或者隐含地包括至少一个该特征。另外,各个实施例之间的技术方案可以相互结合,但是必须是以本领域普通技术人员能够实现为基础,当技术方案的结合出现相互矛盾或无法实现时应当认为这种技术方案的结合不存在,也不在本发明要求的保护范围之内。It should be noted that the descriptions involving "first", "second", etc. in the present invention are only for the purpose of description, and should not be construed as indicating or implying their relative importance or implying the number of indicated technical features . Thus, a feature delimited with "first", "second" may expressly or implicitly include at least one of that feature. In addition, the technical solutions between the various embodiments can be combined with each other, but must be based on the realization by those of ordinary skill in the art. When the combination of technical solutions is contradictory or cannot be realized, it should be considered that the combination of such technical solutions does not exist. , is not within the scope of protection required by the present invention.

本发明提供一种基于区块链的交易系统。请参阅图1,是本发明基于区块链的交易系统10较佳实施例的运行环境示意图。The present invention provides a blockchain-based transaction system. Please refer to FIG. 1 , which is a schematic diagram of the operating environment of a preferred embodiment of the blockchain-basedtransaction system 10 of the present invention.

在本实施例中,所述的基于区块链的交易系统10安装并运行于电子装置1中。该电子装置1是一种能够按照事先设定或者存储的指令,自动进行数值计算和/或信息处理的设备。所述电子装置1可以是计算机、也可以是单个网络服务器、多个网络服务器组成的服务器组或者基于云计算的由大量主机或者网络服务器构成的云,其中云计算是分布式计算的一种,由一群松散耦合的计算机集组成的一个超级虚拟计算机。In this embodiment, the blockchain-basedtransaction system 10 is installed and run in the electronic device 1 . The electronic device 1 is a device that can automatically perform numerical calculation and/or information processing according to pre-set or stored instructions. The electronic device 1 may be a computer, a single network server, a server group composed of multiple network servers, or a cloud composed of a large number of hosts or network servers based on cloud computing, where cloud computing is a type of distributed computing, A super virtual computer consisting of a collection of loosely coupled computers.

在本实施例中,电子装置1可包括,但不仅限于,可通过系统总线相互通信连接的存储器11、处理器12、网络接口13,存储器11存储有可在处理器12上运行的基于区块链的交易系统10。需要指出的是,图1仅示出了具有组件11-13的电子装置1,但是应当理解的是,并不要求实施所有示出的组件,可以替代的实施更多或者更少的组件。In this embodiment, the electronic device 1 may include, but is not limited to, a memory 11 , a processor 12 , and a network interface 13 that can be communicatively connected to each other through a system bus.Chain transaction system 10. It should be pointed out that FIG. 1 only shows the electronic device 1 having components 11-13, but it should be understood that it is not required to implement all the shown components, and more or less components may be implemented instead.

其中,存储器11包括内存及至少一种类型的可读存储介质。内存为电子装置1的运行提供缓存;可读存储介质可为如闪存、硬盘、多媒体卡、卡型存储器(例如,SD或DX存储器等)、随机访问存储器(RAM)、静态随机访问存储器(SRAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、可编程只读存储器(PROM)、磁性存储器、磁盘、光盘等的非易失性存储介质。在一些实施例中,可读存储介质可以是电子装置1的内部存储单元,例如该电子装置1的硬盘;在另一些实施例中,该非易失性存储介质也可以是电子装置1的外部存储设备,例如电子装置1上配备的插接式硬盘,智能存储卡(Smart Media Card,SMC),安全数字(Secure Digital,SD)卡,闪存卡(Flash Card)等。本实施例中,存储器11的可读存储介质通常用于存储安装于电子装置1的操作系统和各类应用软件,例如存储本发明一实施例中的基于区块链的交易系统10等。此外,存储器11还可以用于暂时地存储已经输出或者将要输出的各类数据。The memory 11 includes a memory and at least one type of readable storage medium. The memory provides a cache for the operation of the electronic device 1; the readable storage medium may be, for example, flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM) ), read only memory (ROM), electrically erasable programmable read only memory (EEPROM), programmable read only memory (PROM), magnetic memory, magnetic disk, optical disk, etc. non-volatile storage media. In some embodiments, the readable storage medium may be an internal storage unit of the electronic device 1, such as a hard disk of the electronic device 1; in other embodiments, the non-volatile storage medium may also be an external storage unit of the electronic device 1 A storage device, such as a pluggable hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash memory card (Flash Card), etc., provided on the electronic device 1 . In this embodiment, the readable storage medium of the memory 11 is generally used to store the operating system and various application software installed in the electronic device 1, such as the blockchain-basedtransaction system 10 in an embodiment of the present invention. In addition, the memory 11 can also be used to temporarily store various types of data that have been output or will be output.

所述处理器12在一些实施例中可以是中央处理器(Central Processing Unit,CPU)、控制器、微控制器、微处理器、或其他数据处理芯片。该处理器12通常用于控制所述电子装置1的总体操作,例如执行与所述其他设备进行数据交互或者通信相关的控制和处理等。本实施例中,所述处理器12用于运行所述存储器11中存储的程序代码或者处理数据,例如基于区块链的交易系统10等。In some embodiments, the processor 12 may be a central processing unit (Central Processing Unit, CPU), a controller, a microcontroller, a microprocessor, or other data processing chips. The processor 12 is generally used to control the overall operation of the electronic device 1, such as performing control and processing related to data interaction or communication with the other devices. In this embodiment, the processor 12 is used to run the program code or process data stored in the memory 11, such as the blockchain-basedtransaction system 10 and the like.

所述网络接口13可包括无线网络接口或有线网络接口,该网络接口13通常用于在所述电子装置1与其他电子设备之间建立通信连接。The network interface 13 may include a wireless network interface or a wired network interface, and the network interface 13 is generally used to establish a communication connection between the electronic device 1 and other electronic devices.

基于区块链的交易系统10包括至少一个存储在所述存储器11中的计算机可读指令,该至少一个计算机可读指令可被所述处理器12执行,以实现本申请各实施例。The blockchain-basedtransaction system 10 includes at least one computer-readable instruction stored in the memory 11, and the at least one computer-readable instruction is executable by the processor 12 to implement various embodiments of the present application.

其中,上述基于区块链的交易系统10被所述处理器12执行时实现如下步骤:Wherein, when the above-mentioned blockchain-basedtransaction system 10 is executed by the processor 12, the following steps are implemented:

步骤S1,当接收到广域网中第一节点发出的局域网组网请求时,按预设组网规则和所述局域网组网请求创建由所述第一节点与第二节点、第三节点组成的局域网;其中,所述广域网由区块链网络中所有节点搭建组成;Step S1, when receiving a local area network networking request sent by the first node in the wide area network, create a local area network consisting of the first node, the second node, and the third node according to preset networking rules and the local area network networking request. ; Wherein, the wide area network is composed of all nodes in the blockchain network;

步骤S2,获取创建的局域网的网段编码,并根据预先设定的网段编码与智能合约的映射关系,确定出与创建的局域网的网段编码相对应的智能合约;Step S2, obtaining the network segment code of the created local area network, and determining the smart contract corresponding to the network segment code of the created local area network according to the preset mapping relationship between the network segment code and the smart contract;

步骤S3,当收到所述第一节点发起的与第二节点、第三节点的交易请求时,在创建的局域网中运行确定出的智能合约,并根据所述智能合约对账本进行读写操作,完成所述第一节点与第二节点、第三节点的交易。Step S3, when receiving the transaction request initiated by the first node with the second node and the third node, run the determined smart contract in the created local area network, and perform read and write operations on the ledger according to the smart contract , to complete the transaction between the first node, the second node, and the third node.

本实施例中基于区块链网络来搭建单广域网和多局域网,本实施例中包含1条主链,定义为广域网,该广域网中包含区块链网络的所有节点;本实施例中还包含多条侧链,定义为局域网,该局域网中包含进行私密交易的至少两个节点。In this embodiment, a single wide area network and multiple local area networks are built based on the blockchain network. This embodiment includes one main chain, which is defined as a wide area network. The wide area network includes all nodes of the blockchain network; this embodiment also includes multiple A side chain is defined as a local area network that contains at least two nodes that conduct private transactions.

当区块链网络中需要建立局域网时,广域网的第一节点创建成员清单,成员清单中包含成员第二节点及第三节点。利用第二节点及第三节点的公钥对创建的成员清单加密形成消息体,将加密后的消息体在广域网进行广播。广域网所有成员收到广播的消息体即可获知第一节点的创建请求,但由于消息体是利用第二节点及第三节点的公钥进行了加密,因此只有第二节点和第三节点才能解开请求内容进而查看到清单列表获知成员清单中包含的成员,其他节点将忽略该请求,只做记录。第二节点和第三节点查看成员清单并同意后,确认和清单中的所有成员缔结联盟,形成局域网。具体的,以第二节点为例:第二节点通过解密广播的消息体获知创建请求,并同意加入与第三节点创建的局域网,将同意加入局域网的请求提交给第一节点,第一节点收到第二节点的同意请求以后,将第二节点的同意请求追加到局域网账本中,并且将账本同步给第二节点。最终,局域网账本中将包含第一节点,第二节点,第三节点成员的同意请求,局域网创建完成。反之,如果第二节点,第三节点中有成员不同意,该局域网将无效,进行删除,因为后续的所有背书都会失败,则局域网创建失败。此外,第一节点在发送广播后,通过广域网的CA中心签发证书,该证书将作为局域网的根证书。When a local area network needs to be established in the blockchain network, the first node of the WAN creates a member list, and the member list includes the second node and the third node of the member. The created member list is encrypted with the public keys of the second node and the third node to form a message body, and the encrypted message body is broadcast on the wide area network. All members of the WAN can know the creation request of the first node after receiving the broadcast message body. However, since the message body is encrypted with the public keys of the second node and the third node, only the second node and the third node can decode the request. Open the request content and then view the list list to learn the members included in the member list. Other nodes will ignore the request and only record. After the second node and the third node check the list of members and agree, they confirm to form an alliance with all the members in the list to form a local area network. Specifically, take the second node as an example: the second node learns the creation request by decrypting the broadcast message body, agrees to join the local area network created with the third node, submits the request for agreeing to join the local area network to the first node, and the first node receives the request. After the consent request of the second node is received, the consent request of the second node is added to the local area network ledger, and the ledger is synchronized to the second node. Finally, the LAN ledger will contain the consent requests of the first node, the second node, and the third node members, and the LAN creation is completed. Conversely, if there are members in the second node and the third node who disagree, the local area network will be invalid and will be deleted, because all subsequent endorsements will fail, and the local area network will fail to be created. In addition, after sending the broadcast, the first node issues a certificate through the CA center of the WAN, and the certificate will be used as the root certificate of the local area network.

在创建完局域网后,为局域网安装对应的智能合约。本实施例中的智能合约包含两种类型:局域网智能合约、广域网智能合约,局域网的智能合约与广域网的智能合约是独立的智能合约。安装在局域网中的智能合约,交易对手只能包含局域网成员列表中的成员。智能合约必须包含该合约适用的网段编码,一份智能合约不能同时安装在多个网段中。因此,针对创建的局域网,选择预先设定好的局域网类型的智能合约,并根据预先设定的网段编码与智能合约的映射关系,选择与创建的局域网的网段编码相对应的智能合约。After creating the local area network, install the corresponding smart contract for the local area network. The smart contracts in this embodiment include two types: local area network smart contracts and wide area network smart contracts. The local area network smart contracts and the wide area network smart contracts are independent smart contracts. For smart contracts installed in the local area network, the counterparty can only include members in the local area network member list. A smart contract must contain the applicable network segment code for the contract. A smart contract cannot be installed in multiple network segments at the same time. Therefore, for the created local area network, select the smart contract of the preset local area network type, and select the smart contract corresponding to the network segment code of the created local area network according to the mapping relationship between the preset network segment code and the smart contract.

当区块链网络中发起交易请求时,分析交易请求是在广域网中进行还是在创建好的局域网中进行,并将交易请求发送到对应的广域网或局域网中。若交易请求是在广域网中进行,则在广域网中运行广域网智能合约来进行对账本的读写操作,在广域网中运行智能合约和传统的区块链运行智能合约相同,在此不作赘述。When a transaction request is initiated in the blockchain network, analyze whether the transaction request is made in the WAN or in the created local area network, and send the transaction request to the corresponding WAN or local area network. If the transaction request is made in the WAN, the WAN smart contract is run in the WAN to perform the read and write operations of the ledger. Running the smart contract in the WAN is the same as running the smart contract in the traditional blockchain, so I will not go into details here.

若交易请求是在局域网中进行,则在局域网中运行该局域网对应的智能合约来进行对账本的读写操作。具体的,首先在创建好的局域网中各个节点例如第一节点、第二节点及第三节点相互通信后,在各个节点之间进行背书处理,局域网中各个节点将背书结果和该交易请求的交易内容或交易内容中的交易摘要按照预先设定好的相同的格式提交给主链即广域网,广域网对每个交易请求进行验证。验证通过后,广域网获取局域网中各个节点发送的交易内容中的交易摘要,并基于该交易摘要形成第一交易区块追加到广域网账本中,同时,反馈该第一交易区块相关信息至局域网中,该第一交易区块相关信息作为验证通过反馈信息,以反馈“已生成主链区块”的结果给局域网。局域网收到广域网反馈的“已生成主链区块”消息后,确认本次交易验证通过,并根据本次交易内容形成第二交易区块,将第一交易区块相关信息加入至第二交易区块中,最后将第二交易区块追加到局域网账本中,从而成功完成本次交易。具体的,在基于该交易摘要形成第一交易区块时,可对交易摘要进行哈希计算,将计算的结果作为一次新的交易形成广域网的区块,并将该区块以及本次交易请求的局域网编码形成交易体追加到广域网账本中。同时,计算形成的广域网的区块的哈希值,将该哈希值返回给局域网中各个节点,以反馈“已生成主链区块”的结果给局域网。局域网收到广域网反馈的“已生成主链区块”消息后,确认本次交易成功,并将计算的广域网的区块的哈希值作为本次交易的一部分,追加到局域网的交易体中,同时重新计算本次交易的hash,将该交易体追加到局域网账本中。If the transaction request is made in the local area network, the smart contract corresponding to the local area network is run in the local area network to read and write the account book. Specifically, first, after each node in the created local area network, such as the first node, the second node and the third node, communicates with each other, endorsement processing is performed between each node, and each node in the local area network will endorse the result and the transaction requested by the transaction. The transaction summary in the content or transaction content is submitted to the main chain, namely the WAN, in the same format as preset, and the WAN verifies each transaction request. After the verification is passed, the WAN obtains the transaction summary in the transaction content sent by each node in the local area network, and forms a first transaction block based on the transaction summary and appends it to the WAN ledger, and at the same time, feeds the relevant information of the first transaction block to the local area network. , the relevant information of the first transaction block is used as the verification feedback information to feed back the result of "the main chain block has been generated" to the local area network. After the LAN receives the "main chain block has been generated" message from the WAN, it confirms that the transaction verification is passed, and forms a second transaction block according to the content of this transaction, and adds the relevant information of the first transaction block to the second transaction. block, and finally append the second transaction block to the LAN ledger, thus successfully completing the transaction. Specifically, when the first transaction block is formed based on the transaction summary, a hash calculation can be performed on the transaction summary, the result of the calculation can be used as a new transaction to form a block of the WAN, and the block and the current transaction request The local area network code of the form transaction body is appended to the WAN ledger. At the same time, the hash value of the formed WAN block is calculated, and the hash value is returned to each node in the local area network to feed back the result of "the main chain block has been generated" to the local area network. After the LAN receives the "Main chain block has been generated" message from the WAN, it confirms that the transaction is successful, and adds the calculated hash value of the WAN block to the transaction body of the LAN as part of this transaction. At the same time, the hash of this transaction is recalculated, and the transaction body is added to the LAN ledger.

其中,广域网对每个交易请求进行验证的具体过程如下:(1)、重新计算每个交易请求的hash,判断局域网的每个请求的hash是否正确;(2)、读取局域网创建时定义好的交易策略,验证交易请求是否符合该定义好的交易策略。Among them, the specific process of verifying each transaction request by the WAN is as follows: (1), recalculate the hash of each transaction request, and judge whether the hash of each request of the local area network is correct; (2), read the definition when the local area network is created The transaction strategy is verified to verify whether the transaction request conforms to the defined transaction strategy.

这样,通过上述方案,在局域网中交易完成以后,主链即广域网中只记录了交易摘要,并没有存储完整的交易体内容,保证了信息的安全。同时,侧链即局域网脱离主链无法单独运行,也无法单独完成交易,保证了安全。In this way, through the above scheme, after the transaction is completed in the local area network, only the transaction summary is recorded in the main chain, that is, the wide area network, and the complete transaction body content is not stored, which ensures the security of information. At the same time, the side chain, that is, the local area network, cannot run independently from the main chain, nor can it complete transactions alone, ensuring security.

本实施例通过区块链网络中所有节点来搭建组成广域网,在广域网中第一节点请求与第二节点、第三节点进行私密交易时,创建由所述第一节点与第二节点、第三节点组成的局域网,并根据预先设定的网段编码与智能合约的映射关系,确定出与创建的局域网的网段编码相对应的智能合约,从而在创建的局域网中运行确定出的智能合约来对账本进行读写操作,完成所述第一节点与第二节点、第三节点的交易。由于是通过基于区块链网络搭建单广域网和多局域网,将需要进行私密交易的部分节点如第一节点与第二节点、第三节点加入至局域网中来完成交易,而不是直接在整个区块链网络中完成交易,因此,不是区块链网络中的每个成员节点都有包含该部分节点私密交易内容的完整交易账本,从而降低了该部分节点私密交易内容的泄露风险,提高了区块链网络中部分节点交易的安全性。In this embodiment, all nodes in the blockchain network are used to construct a wide area network. When the first node requests to conduct private transactions with the second node and the third node in the wide area network, the creation of a network consisting of the first node and the second node and the third node The local area network composed of nodes, and according to the mapping relationship between the preset network segment code and the smart contract, determine the smart contract corresponding to the network segment code of the created local area network, so as to run the determined smart contract in the created local area network. Read and write operations are performed on the ledger to complete the transaction between the first node, the second node, and the third node. Since a single wide area network and multiple local area networks are built based on the blockchain network, some nodes that need to conduct private transactions, such as the first node, the second node, and the third node, are added to the local area network to complete the transaction, rather than directly in the entire block. Therefore, not every member node in the blockchain network has a complete transaction ledger containing the private transaction content of this part of the node, thereby reducing the risk of leakage of the private transaction content of this part of the node and improving the block chain. The security of some node transactions in the chain network.

参照图2所示,为图1中基于区块链的交易系统10较佳实施例的功能模块图。所述基于区块链的交易系统10被分割为一个或者多个功能模块,该一个或者多个功能模块被存储于存储器11中,并由处理器12执行以完成本发明。本发明所称的“模块”是指能够完成特定功能的一系列计算机程序指令集。在本实施例中,所述基于区块链的交易系统10被分割为:创建模块100、获取模块110、交易模块120。应该理解的是:在本实施例中,将所述基于区块链的交易系统10分割成创建模块100、获取模块110、交易模块120,仅仅是为了更清楚的表达出所述基于区块链的交易系统10所能实现的功能,并不用于限定所述基于区块链的交易系统10仅能或者必须分割成创建模块100、获取模块110、交易模块120,对本领域的技术人员来说,可以在其它实施例中,轻易将所述基于区块链的交易系统10分割成与本实施例不同的功能模块,在此不做赘述。Referring to FIG. 2 , it is a functional block diagram of a preferred embodiment of the blockchain-basedtransaction system 10 in FIG. 1 . The blockchain-basedtransaction system 10 is divided into one or more functional modules, and the one or more functional modules are stored in the memory 11 and executed by the processor 12 to complete the present invention. The "module" referred to in the present invention refers to a series of computer program instruction sets capable of performing specific functions. In this embodiment, the blockchain-basedtransaction system 10 is divided into: acreation module 100 , anacquisition module 110 , and atransaction module 120 . It should be understood that: in this embodiment, the blockchain-basedtransaction system 10 is divided into acreation module 100, anacquisition module 110, and atransaction module 120, just to express the blockchain-based transaction more clearly. The functions that can be realized by thetransaction system 10 are not intended to limit that the blockchain-basedtransaction system 10 can only or must be divided into acreation module 100, anacquisition module 110, and atransaction module 120. For those skilled in the art, In other embodiments, the blockchain-basedtransaction system 10 can be easily divided into functional modules different from the present embodiment, which will not be repeated here.

所述创建模块100,用于:当接收到广域网中第一节点发出的局域网组网请求时,按预设组网规则和所述局域网组网请求创建由所述第一节点与第二节点、第三节点组成的局域网;其中,所述广域网由区块链网络中所有节点搭建组成;The creatingmodule 100 is configured to: when receiving a local area network networking request sent by a first node in a wide area network, create a network consisting of the first node and the second node, according to preset networking rules and the local area network networking request. A local area network composed of a third node; wherein, the wide area network is composed of all nodes in the blockchain network;

所述获取模块110,用于:获取创建的局域网的网段编码,并根据预先设定的网段编码与智能合约的映射关系,确定出与创建的局域网的网段编码相对应的智能合约;The obtainingmodule 110 is configured to: obtain the network segment code of the created local area network, and determine the smart contract corresponding to the network segment code of the created local area network according to the preset mapping relationship between the network segment code and the smart contract;

所述交易模块120,用于:当收到所述第一节点发起的与第二节点、第三节点的交易请求时,在创建的局域网中运行确定出的智能合约,并根据所述智能合约对账本进行读写操作,完成所述第一节点与第二节点、第三节点的交易。Thetransaction module 120 is configured to: when receiving a transaction request initiated by the first node with the second node and the third node, run the determined smart contract in the created local area network, and execute the smart contract according to the smart contract Read and write operations are performed on the ledger to complete the transaction between the first node, the second node, and the third node.

上述创建模块100、获取模块110、交易模块120等程序模块被执行时所实现的功能或操作步骤与上述实施例大体相同,在此不再赘述。The functions or operation steps implemented by the above program modules such as the creatingmodule 100 , the acquiringmodule 110 , and thetransaction module 120 when executed are substantially the same as those in the above-mentioned embodiment, which will not be repeated here.

如图3所示,图3为本发明基于区块链的交易方法较佳实施例的流程示意图,该基于区块链的交易方法包括以下步骤:As shown in Figure 3, Figure 3 is a schematic flowchart of a preferred embodiment of the blockchain-based transaction method of the present invention. The blockchain-based transaction method includes the following steps:

步骤S10,当接收到广域网中第一节点发出的局域网组网请求时,按预设组网规则和所述局域网组网请求创建由所述第一节点与第二节点、第三节点组成的局域网;其中,所述广域网由区块链网络中所有节点搭建组成;Step S10, when receiving the local area network networking request sent by the first node in the wide area network, create a local area network consisting of the first node, the second node, and the third node according to the preset networking rules and the local area network networking request. ; Wherein, the wide area network is composed of all nodes in the blockchain network;

步骤S20,获取创建的局域网的网段编码,并根据预先设定的网段编码与智能合约的映射关系,确定出与创建的局域网的网段编码相对应的智能合约;Step S20, obtaining the network segment code of the created local area network, and determining the smart contract corresponding to the network segment code of the created local area network according to the preset mapping relationship between the network segment code and the smart contract;

步骤S30,当收到所述第一节点发起的与第二节点、第三节点的交易请求时,在创建的局域网中运行确定出的智能合约,并根据所述智能合约对账本进行读写操作,完成所述第一节点与第二节点、第三节点的交易。Step S30, when receiving the transaction request initiated by the first node with the second node and the third node, run the determined smart contract in the created local area network, and perform read and write operations on the ledger according to the smart contract , to complete the transaction between the first node, the second node, and the third node.

本实施例中基于区块链网络来搭建单广域网和多局域网,本实施例中包含1条主链,定义为广域网,该广域网中包含区块链网络的所有节点;本实施例中还包含多条侧链,定义为局域网,该局域网中包含进行私密交易的至少两个节点。In this embodiment, a single wide area network and multiple local area networks are built based on the blockchain network. This embodiment includes one main chain, which is defined as a wide area network. The wide area network includes all nodes of the blockchain network; this embodiment also includes multiple A side chain is defined as a local area network that contains at least two nodes that conduct private transactions.

当区块链网络中需要建立局域网时,广域网的第一节点创建成员清单,成员清单中包含成员第二节点及第三节点。利用第二节点及第三节点的公钥对创建的成员清单加密形成消息体,将加密后的消息体在广域网进行广播。广域网所有成员收到广播的消息体即可获知第一节点的创建请求,但由于消息体是利用第二节点及第三节点的公钥进行了加密,因此只有第二节点和第三节点才能解开请求内容进而查看到清单列表获知成员清单中包含的成员,其他节点将忽略该请求,只做记录。第二节点和第三节点查看成员清单并同意后,确认和清单中的所有成员缔结联盟,形成局域网。具体的,以第二节点为例:第二节点通过解密广播的消息体获知创建请求,并同意加入与第三节点创建的局域网,将同意加入局域网的请求提交给第一节点,第一节点收到第二节点的同意请求以后,将第二节点的同意请求追加到局域网账本中,并且将账本同步给第二节点。最终,局域网账本中将包含第一节点,第二节点,第三节点成员的同意请求,局域网创建完成。反之,如果第二节点,第三节点中有成员不同意,该局域网将无效,进行删除,因为后续的所有背书都会失败,则局域网创建失败。此外,第一节点在发送广播后,通过广域网的CA中心签发证书,该证书将作为局域网的根证书。When a local area network needs to be established in the blockchain network, the first node of the WAN creates a member list, and the member list includes the second node and the third node of the member. The created member list is encrypted with the public keys of the second node and the third node to form a message body, and the encrypted message body is broadcast on the wide area network. All members of the WAN can know the creation request of the first node after receiving the broadcast message body. However, since the message body is encrypted with the public keys of the second node and the third node, only the second node and the third node can decode the request. Open the request content and then view the list list to learn the members included in the member list. Other nodes will ignore the request and only record. After the second node and the third node check the list of members and agree, they confirm to form an alliance with all the members in the list to form a local area network. Specifically, take the second node as an example: the second node learns the creation request by decrypting the broadcast message body, agrees to join the local area network created with the third node, submits the request for agreeing to join the local area network to the first node, and the first node receives the request. After the consent request of the second node is received, the consent request of the second node is added to the local area network ledger, and the ledger is synchronized to the second node. Finally, the LAN ledger will contain the consent requests of the first node, the second node, and the third node members, and the LAN creation is completed. Conversely, if there are members in the second node and the third node who disagree, the local area network will be invalid and will be deleted, because all subsequent endorsements will fail, and the local area network will fail to be created. In addition, after sending the broadcast, the first node issues a certificate through the CA center of the WAN, and the certificate will be used as the root certificate of the local area network.

在创建完局域网后,为局域网安装对应的智能合约。本实施例中的智能合约包含两种类型:局域网智能合约、广域网智能合约,局域网的智能合约与广域网的智能合约是独立的智能合约。安装在局域网中的智能合约,交易对手只能包含局域网成员列表中的成员。智能合约必须包含该合约适用的网段编码,一份智能合约不能同时安装在多个网段中。因此,针对创建的局域网,选择预先设定好的局域网类型的智能合约,并根据预先设定的网段编码与智能合约的映射关系,选择与创建的局域网的网段编码相对应的智能合约。After creating the local area network, install the corresponding smart contract for the local area network. The smart contracts in this embodiment include two types: local area network smart contracts and wide area network smart contracts. The local area network smart contracts and the wide area network smart contracts are independent smart contracts. For smart contracts installed in the local area network, the counterparty can only include members in the local area network member list. A smart contract must contain the applicable network segment code for the contract. A smart contract cannot be installed in multiple network segments at the same time. Therefore, for the created local area network, select the smart contract of the preset local area network type, and select the smart contract corresponding to the network segment code of the created local area network according to the mapping relationship between the preset network segment code and the smart contract.

当区块链网络中发起交易请求时,分析交易请求是在广域网中进行还是在创建好的局域网中进行,并将交易请求发送到对应的广域网或局域网中。若交易请求是在广域网中进行,则在广域网中运行广域网智能合约来进行对账本的读写操作,在广域网中运行智能合约和传统的区块链运行智能合约相同,在此不作赘述。When a transaction request is initiated in the blockchain network, analyze whether the transaction request is made in the WAN or in the created local area network, and send the transaction request to the corresponding WAN or local area network. If the transaction request is made in the WAN, the WAN smart contract is run in the WAN to perform the read and write operations of the ledger. Running the smart contract in the WAN is the same as running the smart contract in the traditional blockchain, so I will not go into details here.

若交易请求是在局域网中进行,则在局域网中运行该局域网对应的智能合约来进行对账本的读写操作。具体的,首先在创建好的局域网中各个节点例如第一节点、第二节点及第三节点相互通信后,在各个节点之间进行背书处理,局域网中各个节点将背书结果和该交易请求的交易内容或交易内容中的交易摘要按照预先设定好的相同的格式提交给主链即广域网,广域网对每个交易请求进行验证。验证通过后,广域网获取局域网中各个节点发送的交易内容中的交易摘要,并基于该交易摘要形成第一交易区块追加到广域网账本中,同时,反馈该第一交易区块相关信息至局域网中,该第一交易区块相关信息作为验证通过反馈信息,以反馈“已生成主链区块”的结果给局域网。局域网收到广域网反馈的“已生成主链区块”消息后,确认本次交易验证通过,并根据本次交易内容形成第二交易区块,将第一交易区块相关信息加入至第二交易区块中,最后将第二交易区块追加到局域网账本中,从而成功完成本次交易。具体的,在基于该交易摘要形成第一交易区块时,可对交易摘要进行哈希计算,将计算的结果作为一次新的交易形成广域网的区块,并将该区块以及本次交易请求的局域网编码形成交易体追加到广域网账本中。同时,计算形成的广域网的区块的哈希值,将该哈希值返回给局域网中各个节点,以反馈“已生成主链区块”的结果给局域网。局域网收到广域网反馈的“已生成主链区块”消息后,确认本次交易成功,并将计算的广域网的区块的哈希值作为本次交易的一部分,追加到局域网的交易体中,同时重新计算本次交易的hash,将该交易体追加到局域网账本中。If the transaction request is made in the local area network, the smart contract corresponding to the local area network is run in the local area network to read and write the account book. Specifically, first, after each node in the created local area network, such as the first node, the second node and the third node, communicates with each other, endorsement processing is performed between each node, and each node in the local area network will endorse the result and the transaction requested by the transaction. The transaction summary in the content or transaction content is submitted to the main chain, namely the WAN, in the same format as preset, and the WAN verifies each transaction request. After the verification is passed, the WAN obtains the transaction summary in the transaction content sent by each node in the local area network, and forms a first transaction block based on the transaction summary and appends it to the WAN ledger, and at the same time, feeds the relevant information of the first transaction block to the local area network. , the relevant information of the first transaction block is used as the verification feedback information to feed back the result of "the main chain block has been generated" to the local area network. After the LAN receives the "main chain block has been generated" message from the WAN, it confirms that the transaction verification is passed, and forms a second transaction block according to the content of this transaction, and adds the relevant information of the first transaction block to the second transaction. block, and finally append the second transaction block to the LAN ledger, thus successfully completing the transaction. Specifically, when the first transaction block is formed based on the transaction summary, a hash calculation can be performed on the transaction summary, the result of the calculation can be used as a new transaction to form a block of the WAN, and the block and the current transaction request The local area network code of the form transaction body is appended to the WAN ledger. At the same time, the hash value of the formed WAN block is calculated, and the hash value is returned to each node in the local area network to feed back the result of "the main chain block has been generated" to the local area network. After the LAN receives the "Main chain block has been generated" message from the WAN, it confirms that the transaction is successful, and adds the calculated hash value of the WAN block to the transaction body of the LAN as part of this transaction. At the same time, the hash of this transaction is recalculated, and the transaction body is added to the LAN ledger.

其中,广域网对每个交易请求进行验证的具体过程如下:(1)、重新计算每个交易请求的hash,判断局域网的每个请求的hash是否正确;(2)、读取局域网创建时定义好的交易策略,验证交易请求是否符合该定义好的交易策略。Among them, the specific process of verifying each transaction request by the WAN is as follows: (1), recalculate the hash of each transaction request, and judge whether the hash of each request of the local area network is correct; (2), read the definition when the local area network is created The transaction strategy is verified to verify whether the transaction request conforms to the defined transaction strategy.

这样,通过上述方案,在局域网中交易完成以后,主链即广域网中只记录了交易摘要,并没有存储完整的交易体内容,保证了信息的安全。同时,侧链即局域网脱离主链无法单独运行,也无法单独完成交易,保证了安全。In this way, through the above scheme, after the transaction is completed in the local area network, only the transaction summary is recorded in the main chain, that is, the wide area network, and the complete transaction body content is not stored, which ensures the security of information. At the same time, the side chain, that is, the local area network, cannot run independently from the main chain, nor can it complete transactions alone, ensuring security.

本实施例通过区块链网络中所有节点来搭建组成广域网,在广域网中第一节点请求与第二节点、第三节点进行私密交易时,创建由所述第一节点与第二节点、第三节点组成的局域网,并根据预先设定的网段编码与智能合约的映射关系,确定出与创建的局域网的网段编码相对应的智能合约,从而在创建的局域网中运行确定出的智能合约来对账本进行读写操作,完成所述第一节点与第二节点、第三节点的交易。由于是通过基于区块链网络搭建单广域网和多局域网,将需要进行私密交易的部分节点如第一节点与第二节点、第三节点加入至局域网中来完成交易,而不是直接在整个区块链网络中完成交易,因此,不是区块链网络中的每个成员节点都有包含该部分节点私密交易内容的完整交易账本,从而降低了该部分节点私密交易内容的泄露风险,提高了区块链网络中部分节点交易的安全性。In this embodiment, all nodes in the blockchain network are used to construct a wide area network. When the first node requests to conduct private transactions with the second node and the third node in the wide area network, the creation of a network consisting of the first node and the second node and the third node The local area network composed of nodes, and according to the mapping relationship between the preset network segment code and the smart contract, determine the smart contract corresponding to the network segment code of the created local area network, so as to run the determined smart contract in the created local area network. Read and write operations are performed on the ledger to complete the transaction between the first node, the second node, and the third node. Since a single wide area network and multiple local area networks are built based on the blockchain network, some nodes that need to conduct private transactions, such as the first node, the second node, and the third node, are added to the local area network to complete the transaction, rather than directly in the entire block. Therefore, not every member node in the blockchain network has a complete transaction ledger containing the private transaction content of this part of the node, thereby reducing the risk of leakage of the private transaction content of this part of the node and improving the block chain. The security of some node transactions in the chain network.

进一步的,在一可选的实施例中,如图4所示,图4为本发明基于区块链的交易方法一实施例中局域网各节点的背书及验证示意图。例如,创建好的局域网中各个节点包括A1、A2、A3节点,在局域网的A1、A2、A3节点之间进行背书处理。其中,主链和侧链网络可达,侧链每个节点A1、A2、A3节点将背书结果和交易内容,按照相同的格式提交给主链。主链对每个交易请求进行验证。验证过程如下:Further, in an optional embodiment, as shown in FIG. 4 , FIG. 4 is a schematic diagram of endorsement and verification of each node of the local area network in an embodiment of the blockchain-based transaction method of the present invention. For example, each node in the created local area network includes A1, A2, and A3 nodes, and endorsement processing is performed between A1, A2, and A3 nodes in the local area network. Among them, the main chain and the side chain network are reachable, and each node A1, A2, A3 of the side chain submits the endorsement result and transaction content to the main chain in the same format. The main chain verifies each transaction request. The verification process is as follows:

(1)、重新计算每个交易请求的hash,判断侧链的每个请求的hash是否正确;(1) Recalculate the hash of each transaction request to determine whether the hash of each request of the side chain is correct;

(2)、读取侧链创建时定义好的交易策略,验证交易请求是否符合该定义好的交易策略。(2) Read the transaction strategy defined when the side chain was created, and verify whether the transaction request conforms to the defined transaction strategy.

如图5所示,图5为本发明基于区块链的交易方法一实施例中第一交易区块的生成示意图。主链将侧链提交的交易内容中的交易摘要进行hash计算,将计算的结果,作为一次新的交易,形成主链的区块即第一交易区块。将该第一交易区块追加到主链中。交易体中还包含了本次交易的侧链编码。同时,将结果反馈给侧链,作为侧链验证的一个环节,以反馈“已生成主链区块”的结果给局域网。As shown in FIG. 5 , FIG. 5 is a schematic diagram of generating a first transaction block in an embodiment of the blockchain-based transaction method of the present invention. The main chain performs hash calculation on the transaction summary in the transaction content submitted by the side chain, and uses the calculation result as a new transaction to form the block of the main chain, the first transaction block. Append the first transaction block to the main chain. The transaction body also contains the side chain code of this transaction. At the same time, the result is fed back to the side chain, as a part of the side chain verification, to feed back the result of "the main chain block has been generated" to the local area network.

如图6所示,图6为本发明基于区块链的交易方法一实施例中第二交易区块的生成示意图。侧链除了内部成员之间的策略需要满足以外,还需要得到主链“已生成主链区块”的消息后,才认为本次交易成功。将主链提交的第一交易区块的hashcode即主哈希码作为交易的一部分,追加到交易体中,同时重新计算该次交易的hash即交易哈希值,将该交易追加到侧链中,形成第二交易区块。As shown in FIG. 6 , FIG. 6 is a schematic diagram of generating a second transaction block in an embodiment of the blockchain-based transaction method of the present invention. In addition to satisfying the strategy between internal members, the side chain also needs to get the message that the main chain "main chain block has been generated" before the transaction is considered successful. The hashcode of the first transaction block submitted by the main chain, that is, the main hash code, is added to the transaction body as part of the transaction. At the same time, the hash of the transaction, that is, the transaction hash value, is recalculated, and the transaction is added to the side chain. , forming the second transaction block.

如前所述,交易完成以后,主链中只记录了交易的摘要,并没有存储完整的交易体内容,保证了信息的安全。同时,侧链虽然节点少,但是能得到整个主链的支撑,降低了攻击的可能。而且,侧链脱离主链后,由于无法得到主链的“已生成主链区块”的消息反馈,所以,侧链脱离主链无法单独运行即无法完成交易,保证了安全。As mentioned above, after the transaction is completed, only the summary of the transaction is recorded in the main chain, and the complete transaction body content is not stored, which ensures the security of information. At the same time, although the side chain has fewer nodes, it can be supported by the entire main chain, reducing the possibility of attacks. Moreover, after the side chain is separated from the main chain, since the message feedback of the "main chain block has been generated" of the main chain cannot be obtained, the side chain cannot operate independently from the main chain, that is, the transaction cannot be completed, ensuring security.

此外,本发明还提供一种计算机可读存储介质,所述计算机可读存储介质存储有基于区块链的交易系统,所述基于区块链的交易系统可被至少一个处理器执行,以使所述至少一个处理器执行如下步骤:In addition, the present invention also provides a computer-readable storage medium storing a blockchain-based transaction system, and the blockchain-based transaction system can be executed by at least one processor to enable The at least one processor performs the following steps:

当接收到广域网中第一节点发出的局域网组网请求时,按预设组网规则和所述局域网组网请求创建由所述第一节点与第二节点、第三节点组成的局域网;其中,所述广域网由区块链网络中所有节点搭建组成;When receiving a local area network networking request sent by the first node in the wide area network, a local area network consisting of the first node, the second node, and the third node is created according to the preset networking rules and the local area network networking request; wherein, The wide area network is composed of all nodes in the blockchain network;

获取创建的局域网的网段编码,并根据预先设定的网段编码与智能合约的映射关系,确定出与创建的局域网的网段编码相对应的智能合约;Obtain the network segment code of the created local area network, and determine the smart contract corresponding to the network segment code of the created local area network according to the mapping relationship between the preset network segment code and the smart contract;

当收到所述第一节点发起的与第二节点、第三节点的交易请求时,在创建的局域网中运行确定出的智能合约,并根据所述智能合约对账本进行读写操作,完成所述第一节点与第二节点、第三节点的交易。When receiving the transaction request initiated by the first node with the second node and the third node, run the determined smart contract in the created local area network, and perform read and write operations on the ledger according to the smart contract to complete all transactions. Describe the transactions between the first node, the second node, and the third node.

本发明计算机可读存储介质具体实施方式与上述电子装置1和方法各实施例基本相同,在此不再赘述。The specific implementation manner of the computer-readable storage medium of the present invention is basically the same as the above-mentioned embodiments of the electronic device 1 and the method, and will not be repeated here.

需要说明的是,在本文中,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者装置不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者装置所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括该要素的过程、方法、物品或者装置中还存在另外的相同要素。It should be noted that, herein, the terms "comprising", "comprising" or any other variation thereof are intended to encompass non-exclusive inclusion, such that a process, method, article or device comprising a series of elements includes not only those elements, It also includes other elements not expressly listed or inherent to such a process, method, article or apparatus. Without further limitation, an element qualified by the phrase "comprising a..." does not preclude the presence of additional identical elements in a process, method, article or apparatus that includes the element.

通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到上述实施例方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件来实现,但很多情况下前者是更佳的实施方式。基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质(如ROM/RAM、磁碟、光盘)中,包括若干指令用以使得一台终端设备(可以是手机,计算机,服务器,空调器,或者网络设备等)执行本发明各个实施例所述的方法。From the description of the above embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is better implementation. Based on this understanding, the technical solutions of the present invention can be embodied in the form of software products in essence or the parts that make contributions to the prior art, and the computer software products are stored in a storage medium (such as ROM/RAM, magnetic disk, CD-ROM), including several instructions to make a terminal device (which may be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) execute the methods described in the various embodiments of the present invention.

以上参照附图说明了本发明的优选实施例,并非因此局限本发明的权利范围。上述本发明实施例序号仅仅为了描述,不代表实施例的优劣。另外,虽然在流程图中示出了逻辑顺序,但是在某些情况下,可以以不同于此处的顺序执行所示出或描述的步骤。The preferred embodiments of the present invention have been described above with reference to the accompanying drawings, but are not intended to limit the scope of the rights of the present invention. The above-mentioned serial numbers of the embodiments of the present invention are only for description, and do not represent the advantages or disadvantages of the embodiments. Additionally, although a logical order is shown in the flowchart, in some cases steps shown or described may be performed in an order different from that herein.

本领域技术人员不脱离本发明的范围和实质,可以有多种变型方案实现本发明,比如作为一个实施例的特征可用于另一实施例而得到又一实施例。凡在运用本发明的技术构思之内所作的任何修改、等同替换和改进,均应在本发明的权利范围之内。Those skilled in the art can implement the present invention in various modifications without departing from the scope and spirit of the present invention. For example, features of one embodiment can be used in another embodiment to obtain yet another embodiment. Any modifications, equivalent replacements and improvements made within the technical concept of applying the present invention shall fall within the right scope of the present invention.

Claims (10)

CN202010194501.3A2020-03-182020-03-18 Blockchain-based transaction method, electronic device and readable storage mediumPendingCN111489156A (en)

Priority Applications (2)

Application NumberPriority DateFiling DateTitle
CN202010194501.3ACN111489156A (en)2020-03-182020-03-18 Blockchain-based transaction method, electronic device and readable storage medium
PCT/CN2020/106004WO2021184642A1 (en)2020-03-182020-07-30Blockchain-based transaction method and apparatus, electronic device, and readable storage medium

Applications Claiming Priority (1)

Application NumberPriority DateFiling DateTitle
CN202010194501.3ACN111489156A (en)2020-03-182020-03-18 Blockchain-based transaction method, electronic device and readable storage medium

Publications (1)

Publication NumberPublication Date
CN111489156Atrue CN111489156A (en)2020-08-04

Family

ID=71812578

Family Applications (1)

Application NumberTitlePriority DateFiling Date
CN202010194501.3APendingCN111489156A (en)2020-03-182020-03-18 Blockchain-based transaction method, electronic device and readable storage medium

Country Status (2)

CountryLink
CN (1)CN111489156A (en)
WO (1)WO2021184642A1 (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN111967031A (en)*2020-08-132020-11-20合肥安时智造科技有限公司Data transaction type transmission method
CN113067904A (en)*2021-06-022021-07-02支付宝(杭州)信息技术有限公司Method for building block chain sub-network and block chain system

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN115314374B (en)*2022-07-062024-02-06京东科技信息技术有限公司Block chain node deployment method, device, storage medium and program product
CN115187248A (en)*2022-07-182022-10-14浪潮通用软件有限公司 Collaborative method and device for intra-group business transactions based on blockchain

Citations (5)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN109472572A (en)*2018-11-212019-03-15北京蓝石环球区块链科技有限公司Contract deployment and transaction based on the more subchains of block chain main chain adduction row
CN109816524A (en)*2018-12-272019-05-28链极智能科技(上海)有限公司A method of alliance's chain member is managed by block chain public affairs chain
CN110149335A (en)*2019-05-242019-08-20众安信息技术服务有限公司Establish the method and apparatus of the home zone for the protection of block chain data-privacy
WO2019170167A2 (en)*2019-05-312019-09-12Alibaba Group Holding LimitedSystem and method for providing privacy and security protection in blockchain-based private transactions
US20190286838A1 (en)*2018-12-192019-09-19Alibaba Group Holding LimitedData isolation in a blockchain network

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
US20190109709A1 (en)*2017-10-052019-04-11Wenqing WuSystem and method for creating and transferring digital tokens cryptographically without the need for periodic centralized authorization to record transactions
CN108833081B (en)*2018-06-222021-01-05中国人民解放军国防科技大学Block chain-based equipment networking authentication method
CN109242467B (en)*2018-09-172021-01-01金蝶软件(中国)有限公司Block chain-based networking method and device, computer equipment and storage medium
CN110851496B (en)*2018-12-072023-03-14深圳市智税链科技有限公司Method, apparatus, accounting node and medium for querying transaction information in blockchain network

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN109472572A (en)*2018-11-212019-03-15北京蓝石环球区块链科技有限公司Contract deployment and transaction based on the more subchains of block chain main chain adduction row
US20190286838A1 (en)*2018-12-192019-09-19Alibaba Group Holding LimitedData isolation in a blockchain network
CN109816524A (en)*2018-12-272019-05-28链极智能科技(上海)有限公司A method of alliance's chain member is managed by block chain public affairs chain
CN110149335A (en)*2019-05-242019-08-20众安信息技术服务有限公司Establish the method and apparatus of the home zone for the protection of block chain data-privacy
WO2019170167A2 (en)*2019-05-312019-09-12Alibaba Group Holding LimitedSystem and method for providing privacy and security protection in blockchain-based private transactions

Cited By (3)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN111967031A (en)*2020-08-132020-11-20合肥安时智造科技有限公司Data transaction type transmission method
CN111967031B (en)*2020-08-132024-02-20合肥壹物易证科技有限公司Data transaction type transmission method
CN113067904A (en)*2021-06-022021-07-02支付宝(杭州)信息技术有限公司Method for building block chain sub-network and block chain system

Also Published As

Publication numberPublication date
WO2021184642A1 (en)2021-09-23

Similar Documents

PublicationPublication DateTitle
CN107396360B (en)Block verification method and device
CN111489156A (en) Blockchain-based transaction method, electronic device and readable storage medium
CN108734028B (en) Blockchain-based data management method, blockchain node and storage medium
CN111144881A (en)Selective access to asset transfer data
WO2020207233A1 (en)Permission control method and apparatus for blockchain
EP3779760B1 (en)Blockchain-based data processing method and apparatus, and electronic device
CN111899019A (en)Method and system for cross validation and sharing of blacklist and multiple parties
WO2020037927A1 (en)Negotiable block chain transaction method, apparatus, device, and storage medium
CN114127724A (en) Integrity auditing for multi-replica storage
CN110599175B (en) A block processing method and related equipment
US11626986B1 (en)Method and system of rescinding access to blockchain data
CN103067363A (en)Index conversion method for public data integrity checking
CN114637801A (en) Data import method, apparatus, computer equipment and storage medium
WO2023185862A1 (en)Multi-party computation method and system based on blockchain system
CN110598479B (en) A data processing method, device and computer readable storage medium
EP4348476B1 (en)Method and system of rescinding access to blockchain data
CN111770087A (en) A service node verification method and related equipment
CN111260364B (en)Block chain-based extensible quick payment method and system
CN115220714A (en) Application programming interface development method and device
CN113132459A (en)Distributed storage method, system, storage medium, information data processing terminal
CN111401889B (en)Credit data processing method, device, equipment and medium based on block chain
CN112182009A (en) Data update method and device of blockchain, and readable storage medium
CN111292193A (en)Method, device and storage medium for fund management based on block chain
CN117216061A (en)Processing method, device, equipment and medium for idempotent problem of Web page
CN118802192A (en) Digital certificate management method, device, electronic device and storage medium

Legal Events

DateCodeTitleDescription
PB01Publication
PB01Publication
SE01Entry into force of request for substantive examination
SE01Entry into force of request for substantive examination
RJ01Rejection of invention patent application after publication
RJ01Rejection of invention patent application after publication

Application publication date:20200804


[8]ページ先頭

©2009-2025 Movatter.jp