WO2021134424A1 - 一种基于区块链的数字货币交易方法、装置及系统 - Google Patents

一种基于区块链的数字货币交易方法、装置及系统 Download PDF

Info

Publication number
WO2021134424A1
WO2021134424A1 PCT/CN2019/130379 CN2019130379W WO2021134424A1 WO 2021134424 A1 WO2021134424 A1 WO 2021134424A1 CN 2019130379 W CN2019130379 W CN 2019130379W WO 2021134424 A1 WO2021134424 A1 WO 2021134424A1
Authority
WO
WIPO (PCT)
Prior art keywords
transaction
utxo
digital currency
currency
account
Prior art date
Application number
PCT/CN2019/130379
Other languages
English (en)
French (fr)
Inventor
张骁
辛佳骏
李武璐
来鑫
陈磊
Original Assignee
深圳市网心科技有限公司
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 深圳市网心科技有限公司 filed Critical 深圳市网心科技有限公司
Priority to PCT/CN2019/130379 priority Critical patent/WO2021134424A1/zh
Priority to CN201980059593.XA priority patent/CN112740250A/zh
Publication of WO2021134424A1 publication Critical patent/WO2021134424A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • G06Q20/383Anonymous user system
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • G06Q20/381Currency conversion
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • G06Q20/382Payment protocols; Details thereof insuring higher security of transaction
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q40/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/04Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange

Definitions

  • the present invention relates to the technical field of block chains, and more specifically, to a method, device and system for digital currency transactions based on block chains.
  • Digital currency is a kind of virtual currency based on node network and digital encryption algorithm. It is usually issued and managed by developers and accepted and used by members of specific virtual communities.
  • the current digital currency transaction system is mainly divided into an off-chain centralized digital currency transaction system and an on-chain decentralized data currency transaction system.
  • the off-chain centralized digital currency transaction system is centralized so that the data center collects digital currency conversion applications from different users under the chain, and then matches and matches in the off-chain centralized digital currency transaction system, and finally matches the successful digital currency transactions On the chain.
  • the off-chain centralized digital currency transaction system is usually constructed through smart contracts, and the rationality of the digital currency transaction is restricted by the contract code. Due to the decentralized nature of the blockchain and the open nature of the contract code, the off-chain centralized digital currency transaction system Every transaction in can be checked by any node of the blockchain.
  • every transaction is sent to a centralized exchange, which is responsible for the execution of the transaction, and finally releases the successful transaction to the chain. Due to the centralized system The data department is open. Although the privacy of the transaction initiator can be protected, the exchange may include the transaction in its own account, causing the asset of the transaction initiator to be embezzled. In the decentralized digital currency transaction system on the chain, since every transaction is public, the transaction can be inquired through the node, so that the privacy of the transaction participants will be leaked while the transaction is public, which will lead to privacy leakage risks of.
  • the present invention provides a blockchain-based digital currency transaction method, device, and system to achieve the purpose of protecting the transaction amount of digital currency transactions and the privacy of transaction participants.
  • the first aspect of the present invention discloses a blockchain-based digital currency transaction method, the method includes:
  • the digital currency transaction contract receives the first transaction request sent by the first account, and receives X first UTXO currencies transferred from the first account; wherein, the first transaction request is used to request the first account to transfer the first UTXO currency.
  • UTXO currency is converted into a second UTXO currency at a first exchange rate, and the first account is a privacy account;
  • the digital currency transaction contract matches and records the first transaction request and the second transaction request
  • the digital currency transaction contract is executed to convert the first UTXO currency transferred from the first account into a second UTXO currency.
  • the method further includes:
  • the second UTXO currency obtained by the exchange is sent to the receiving address specified in advance in the first transaction request.
  • the digital currency transaction contract matching and recording the first transaction request and the second transaction request includes:
  • the digital currency transaction contract matches and records the first transaction request and the second transaction request.
  • the method further includes:
  • the digital currency transaction contract receives the second transaction request sent by the second account and the Y second UTXO currency transferred from the second account; wherein, the second transaction request is used to request the second account to transfer into the second UTXO currency.
  • the UTXO currency is converted into the first UTXO currency at a second exchange rate, and the second account is a privacy account.
  • it also includes:
  • the second aspect of the present invention discloses a blockchain-based digital currency transaction device.
  • the device includes a memory and a processor.
  • the memory stores a blockchain-based digital currency that can run on the processor.
  • a transaction program when the blockchain-based digital currency transaction program is executed by the processor, the method as disclosed in any one of the first aspects of the present invention is implemented.
  • the third aspect of the present invention discloses a blockchain-based digital currency transaction system, which includes:
  • the first receiving unit is configured to receive the first transaction request sent by the first account in the digital currency transaction contract, and receive the x first UTXO currency transferred from the first account; wherein, the first transaction request is used to request the first transaction
  • the first UTXO currency transferred into an account is converted into a second UTXO currency at a first exchange rate, and the first account is a privacy account;
  • a matching unit configured to match and record the first transaction request and the second transaction request by the digital currency transaction contract when there is a second transaction request that matches the first transaction request
  • the first execution unit is configured to execute the digital currency transaction contract to convert the first UTXO currency transferred from the first account into a second UTXO currency.
  • it also includes:
  • the sending unit is configured to send the second UTXO currency obtained by the exchange to the receiving address pre-specified in the first transaction request.
  • a computer-readable storage medium stores a blockchain-based digital currency transaction program.
  • the blockchain-based digital currency transaction program can be used by one or A plurality of processors are executed to implement the blockchain-based digital currency transaction method as disclosed in any one of the first aspect of the present invention.
  • the fifth aspect of the present invention discloses a computer program product, including computer instructions, which when run on a computer, enable the computer to execute any one of the above-mentioned blockchain-based digital currency transactions disclosed in the first aspect of the present invention method.
  • the digital currency transaction contract receives the first transaction request sent by the first account, and receives X number of first UTXO currencies transferred from the first account, when there is a second transaction request matching the first transaction request At the time, the digital currency transaction contract matches and records the first transaction request and the second transaction request, and executes the digital currency transaction contract to convert the first UTXO currency transferred from the first account into the second UTXO currency.
  • the digital currency transaction contract matches and records the first transaction request and the second transaction request, and executes the digital currency transaction contract to convert the first UTXO currency transferred from the first account into the second UTXO currency, which is achieved The purpose of protecting the transaction amount of digital currency transactions and the privacy of transaction participants.
  • FIG. 1 is a schematic flowchart of a digital currency transaction method based on blockchain disclosed in an embodiment of the present invention
  • FIG. 2 is a flow diagram of a digital currency transaction contract matching and recording the first transaction request and the second transaction request when there is a second transaction request that matches the first transaction request according to an embodiment of the present invention
  • FIG. 3 is a schematic structural diagram of a digital currency transaction device based on blockchain disclosed in an embodiment of the present invention.
  • Fig. 4 is a schematic structural diagram of a blockchain-based digital currency transaction system disclosed in an embodiment of the present invention.
  • each transaction is sent to a centralized exchange, which is responsible for the execution of the transaction, and finally publishes the successful transaction to the chain.
  • the data department of the centralized system is open.
  • the exchange may include the transaction in its own account, causing the asset of the transaction initiator to be embezzled.
  • the decentralized digital currency transaction system on the chain since every transaction is public, the transaction can be inquired through the node, so that the privacy of the transaction participants will be leaked while the transaction is public, which will lead to privacy leakage risks of.
  • the present invention discloses a blockchain-based digital currency transaction method, device, and system.
  • the first transaction request and the second transaction request are matched and recorded through a digital currency transaction contract, and the digital currency transaction contract is executed. Convert the first UTXO currency transferred from the first account to the second UTXO currency to achieve the purpose of protecting the transaction amount of digital currency transactions and the privacy of transaction participants.
  • FIG. 1 it is a schematic flow diagram of a blockchain-based digital currency transaction method disclosed in an embodiment of the present invention, which specifically includes the following steps:
  • Step S101 The digital currency transaction contract receives the first transaction request sent by the first account, and receives X first UTXO currencies transferred from the first account.
  • the first transaction request is used to request that the first UTXO currency transferred from the first account be converted into the second UTXO currency at a first exchange rate, and the first account is a privacy account.
  • X can be any number, it can be an integer or a decimal.
  • the account amount and account address of the first account are subject to privacy protection.
  • those skilled in the art can choose an appropriate method according to the situation, and there is no specific restriction here.
  • Step S102 When there is a second transaction request that matches the first transaction request, the digital currency transaction contract matches and records the first transaction request and the second transaction request.
  • step S102 there is a pending order request meeting the first exchange rate in the initiated pending order transaction, the first transaction request matches the second transaction request, and the digital currency transaction contract performs the first transaction request with the second transaction request. Match and record.
  • the exchange rate refers to the ratio of exchange between two currencies.
  • the digital currency transaction contract Before the digital currency transaction contract matches and records the first transaction request and the second transaction request, the digital currency transaction contract receives the second transaction request sent by the second account, and receives Y second UTXO currency transferred from the second account .
  • Y can be any number, it can be an integer or a decimal.
  • the second transaction request is used to request that the second UTXO currency transferred into the second account be converted into the first UTXO currency at a second exchange rate, and the second account is a privacy account.
  • the account amount and account address of the second account are protected by privacy.
  • Step S103 Execute the digital currency transaction contract to convert the first UTXO currency transferred from the first account into the second UTXO currency.
  • step S103 when the block producer node of the blockchain executes the digital currency transaction contract through the Account model, it converts the first UTXO currency transferred from the first account into the second UTXO currency based on the first exchange rate.
  • the digital currency transaction contract can be publicly calculated, execute the contract code, and the input and output information needs to pass the temporary storage address and the user's real identity isolation.
  • the converted second UTXO currency is sent to the receiving address pre-specified in the first transaction request.
  • the corresponding amount in the contract account is transferred to the corresponding UTXO address is the pre-designated receiving address.
  • the converted second UTXO currency is deposited into the receiving address pre-designated in the first transaction request.
  • the invention discloses a blockchain-based digital currency transaction method.
  • the digital currency transaction contract receives a first transaction request sent by a first account, and receives X first UTXO currencies transferred from the first account.
  • a transaction request matches a second transaction request
  • the digital currency transaction contract matches and records the first transaction request and the second transaction request, and executes the digital currency transaction contract to exchange the first UTXO currency transferred from the first account Into the second UTXO currency.
  • the digital currency transaction contract matches and records the first transaction request and the second transaction request, and executes the digital currency transaction contract to convert the first UTXO currency transferred from the first account into the second UTXO currency, which is achieved The purpose of protecting the transaction amount of digital currency transactions and the privacy of transaction participants.
  • step S102 when there is a second transaction request that matches the first transaction request, the digital currency transaction contract matches and records the first transaction request and the second transaction request, as shown in Figure 2. Specifically include the following steps:
  • Step S201 Query whether there is a transaction request satisfying the first exchange rate among the pending order transaction requests. If there is a transaction request satisfying the first exchange rate among the pending order transaction requests, perform step S202, if there is no transaction request satisfying the pending order For the transaction request of the first exchange rate, step S203 is executed.
  • step S201 when a digital currency contract transaction is initiated through the UTXO model, the function of the cross-digital currency transaction contract is called to match the pending order matching function in the ordinary digital currency transaction contract, and the pending order transaction is executed.
  • the pending order transaction refers to the submission of a digital currency conversion application transaction.
  • the objects involved in the pending order transaction include the sender, the receiver and the transaction amount.
  • the digital transaction contract executes the matching and matching pending order function, and matches and matches the new pending order transaction based on the existing pending order records.
  • the block node that packs the block in the same block packs the transaction in the digital currency transaction contract called by the pending order and the transaction transferred from the digital currency transaction contract , And use the private key to sign the transaction in the digital currency transaction contract called by the pending order and the transaction transferred out of the digital currency transaction contract.
  • the verification node After the verification node successfully verifies the digital currency transaction contract, it verifies whether the transaction transferred from the digital currency transaction contract is correctly packaged into the block. The digital currency transaction contract and the transaction transferred out of the digital currency transaction contract are verified successfully before they will be accepted by other verification nodes.
  • the Unspent Transaction Output (UTXO) model is a data structure containing transaction data and execution code, and is the earliest account model adopted by Bitcoin.
  • the UTXO model realizes the privacy protection of the transaction sender, transaction receiver and transaction amount.
  • the UTXO model is used to protect the privacy of digital assets.
  • the privacy protection method can be a ring signature, a ring-signature confidential transaction RingCT, or a zero-knowledge proof.
  • the privacy protection method of digital assets using the UTXO model is not specifically limited in the present invention, and the selection is made by the technicians according to the actual situation.
  • the maximum value of the ring size of the ring signature is the total number of accounts in the entire network, and the value range of the value of the ring size of the ring signature is a positive integer greater than or equal to 1.
  • the privacy protection transaction can be realized through ring signature, and the UTXO address can be blinded, that is, the UTXO address can be hidden.
  • the blinding method takes the public UTXO address as input to initiate a privacy protection transaction, and the output is a ring composed of multiple UTXO addresses.
  • the UTXO model calculates the consumption of gas value according to the complexity of contract deployment and execution, the consumption of the gas value can be set to a fixed value, and the specific setting of the consumption of the gas value Certainly depends on the operational strategy of the blockchain.
  • the gas value is the resource consumed by the execution of the digital currency transaction contract, that is, the cost of the execution of the digital currency transaction contract. Its role is to provide the power for the execution of the contract on the one hand, and on the other hand to prevent the attacker from unlimited access to the digital currency transaction contract. Called attack.
  • the gas value of the function consumed during the contract deployment process through the UTXO model will be deducted during the transaction process.
  • the deduction operation is performed based on the gas consumption value of the function to obtain the UTXO value.
  • the UTXO value is equivalent to the face value of UTXO currency.
  • the UTXO value is transferred to the balance of the contract account of the digital currency trading contract through the UTXO model.
  • the amount of the UTXO value transferred to the contract account through the UTXO model is the pending order amount.
  • the input of the digital currency transaction contract includes the currency type to be exchanged, the expected SGD amount, and the SGD UTXO receiving address.
  • HEADER is the block header
  • UTXOa ⁇ SC123456, SC123456 ⁇ UTXOb, SC123456 ⁇ UTXOc and SC123456 ⁇ UTXOd are transactions in the block body.
  • the user uses the UTXO model to initiate a contract deployment transaction, which takes the user's UTXO as input and outputs a digital currency transaction contract.
  • the address of the digital currency transaction contract is automatically generated during deployment, and the address of the digital currency transaction contract starts with "SC".
  • the method of contract deployment can use tools to generate bytecode from the contract code, and generate contracts through instructions or tools.
  • the address "SC” is identified as a reserved field of the Smart Contract (Smart Contract). Smart contracts are equivalent to digital currency trading contracts.
  • a smart contract is a computer protocol that is used to spread, verify or execute the contract in an information-based way. It allows a credible transaction without a third party, and the transaction is traceable and irreversible.
  • the contract address starting with "SC” is the smart contract address, and the contract address starting with “SC” is the ordinary UTXO address.
  • nonce is a random number, the identifier of the transaction, which is used to prevent the transaction from being replayed.
  • Balance is the contract account balance.
  • Contract_code is the contract code.
  • Storage is the data stored in the contract.
  • Step S202 It is determined that the second transaction request that satisfies the first exchange rate matches the first transaction request, and the digital currency transaction contract matches and records the first transaction request and the second transaction request.
  • Step S203 It is determined that the second transaction request satisfying the first exchange rate does not match the first transaction request.
  • the first transaction request is matched with the second transaction request, and the first transaction request is matched with the second transaction request.
  • the withdrawal transaction operation is executed and recorded, the order cancellation result is obtained, and the pending order record in the digital currency transaction contract is updated according to the order cancellation result.
  • the block packaging node packs the cancellation transaction in the digital currency transaction contract, and transfers the corresponding amount in the contract account of the digital currency transaction contract to the UTXO account that initiated the cancellation request.
  • the block node responsible for packaging the transaction needs to package the transaction calling the digital currency transaction contract and the transaction transferred out of the UTXO in the same one In the block, the transactionality of the whole process is guaranteed.
  • the order cancellation result is obtained based on the order cancellation transaction in the digital currency transaction contract, and the purpose of updating the pending order record in the digital currency transaction contract according to the order cancellation result is realized.
  • User Alice holds a privacy currency A
  • user Bob holds b privacy currency B
  • User Alice and user Bob want to exchange two currencies, suppose that a privacy currency A is equivalent to b privacy currency B.
  • User Alice and user Bob first call the cross-digital currency transaction contract to place an order, and transfer their UTXO to the digital currency transaction contract to record.
  • the pending order matching function in the digital currency transaction contract will be matched successfully, and then the result of the successful match will be recorded in the digital currency transaction contract.
  • the block node executes the digital currency transaction contract, it initiates two UTXO transactions through the records in the digital currency transaction contract, and signs the transaction with its own private key.
  • the sender of the transfer is the contract address
  • the receiver is the user Alice and User Bob’s pre-designated receiving address.
  • the block node broadcasts the block, other verification nodes will verify the execution of the contract and the legitimacy of the transaction initiated by the block node. After the block consensus is reached, the user Alice and user Bob’s Successful cross-digital currency transaction.
  • the embodiment of the present invention also provides a block chain-based digital currency transaction device.
  • the block chain-based digital currency transaction device includes a memory and a processor.
  • the memory stores a block-based transaction device that can run on the processor.
  • a blockchain-based digital currency transaction program which implements a blockchain-based digital currency transaction method when the blockchain-based digital currency transaction program is executed by the processor.
  • the blockchain-based digital currency transaction device 3 may be a PC (Personal Computer, personal computer), or a smart phone, a tablet computer, a palmtop computer, a portable computer, or a terminal device.
  • PC Personal Computer
  • smart phone a tablet computer, a palmtop computer, a portable computer, or a terminal device.
  • the blockchain-based digital currency transaction device 3 may be a node of a blockchain network.
  • the blockchain-based digital currency transaction device 3 may include a memory 11, a processor 12, and a bus 13.
  • the memory 11 includes at least one type of readable storage medium, the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), magnetic memory, magnetic disk, optical disk, and the like.
  • the memory 11 may be an internal storage unit of the digital currency transaction device 3 based on the blockchain, such as the hard disk of the digital currency transaction device 3.
  • the memory 11 may also be an external storage device of the blockchain-based digital currency transaction device 3, such as a plug-in hard disk equipped on the blockchain-based digital currency transaction device 3, and a smart memory card (Smart Memory Card). Media Card, SMC, Secure Digital (SD) card, Flash Card, etc.
  • the memory 11 may also include both an internal storage unit of the blockchain-based digital currency transaction device 3 and an external storage device.
  • the memory 11 can be used not only to store application software and various data installed in the blockchain-based digital currency transaction device 3, such as the code of a blockchain-based digital currency transaction program, etc., but also to temporarily store the output that has been output. Or the data to be output.
  • the processor 12 may be a central processing unit (CPU), controller, microcontroller, microprocessor, or other data processing chip, for running program codes or processing stored in the memory 11 Data, such as execution of blockchain-based digital currency transaction programs, etc.
  • CPU central processing unit
  • controller microcontroller
  • microprocessor or other data processing chip, for running program codes or processing stored in the memory 11 Data, such as execution of blockchain-based digital currency transaction programs, etc.
  • the bus 13 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus.
  • PCI peripheral component interconnect
  • EISA extended industry standard architecture
  • the bus can be divided into address bus, data bus, control bus and so on. For ease of presentation, only a thick line is used in FIG. 3 to represent it, but it does not mean that there is only one bus or one type of bus.
  • the blockchain-based digital currency transaction device may also include a network interface 14.
  • the network interface 14 may optionally include a wired interface and/or a wireless interface (such as a WI-FI interface, a Bluetooth interface, etc.), which is usually used in
  • the blockchain-based digital currency transaction device 3 establishes a communication connection with other electronic devices.
  • the blockchain-based digital currency transaction device 3 may also include a user interface
  • the user interface may include a display (Display), an input unit such as a keyboard (Keyboard), and the optional user interface may also include a standard wired interface , Wireless interface.
  • the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode, organic light-emitting diode) touch device, etc.
  • the display can also be appropriately called a display screen or a display unit, which is used to display the information processed in the blockchain-based digital currency transaction device 3 and to display a visualized user interface.
  • the embodiment of the present invention also correspondingly discloses a block chain-based digital currency transaction system, as shown in FIG. 4, the block chain-based digital currency transaction
  • the system mainly includes:
  • the first receiving unit 401 is configured to receive the first transaction request sent by the first account in the digital currency transaction contract, and receive the x first UTXO currency transferred from the first account; wherein, the first transaction request is used to request the The first UTXO currency transferred into the first account is converted into the second UTXO currency at a first exchange rate, and the first account is a privacy account.
  • the matching unit 402 is configured to, when there is a second transaction request matching the first transaction request, the digital currency transaction contract matches and records the first transaction request and the second transaction request.
  • the first execution unit 403 is configured to execute the digital currency transaction contract to convert the first UTXO currency transferred from the first account into a second UTXO currency.
  • it also includes:
  • the sending unit is used to send the second UTXO currency obtained by the exchange to the receiving address pre-specified in the first transaction request.
  • the matching unit 402 includes:
  • the query module is used to query whether there is a transaction request that satisfies the first exchange rate among the transaction requests for pending orders.
  • the first determining module is configured to determine that the second transaction request that satisfies the first exchange rate matches the first transaction request if it exists, and the digital currency transaction contract matches and records the first transaction request and the second transaction request.
  • the second determining module is configured to determine that the second transaction request that satisfies the first exchange rate does not match the first transaction request if it does not exist.
  • it also includes:
  • the second receiving unit is used for the digital currency transaction contract to receive the second transaction request sent by the second account and receive the y second UTXO currency transferred from the second account; wherein, the second transaction request is used to request to transfer the second account
  • the transferred second UTXO currency is converted into the first UTXO currency at the second exchange rate, and the second account is a privacy account.
  • it also includes:
  • the second execution unit is used to execute and record the withdrawal transaction operation based on the withdrawal transaction request initiated in the digital currency transaction contract to obtain the order withdrawal result.
  • the update unit is used to update the pending order record in the digital currency transaction contract according to the order cancellation result.
  • the invention discloses a blockchain-based digital currency transaction system.
  • the digital currency transaction contract receives a first transaction request sent by a first account, and receives X first UTXO currencies transferred from the first account.
  • a transaction request matches a second transaction request
  • the digital currency transaction contract matches and records the first transaction request and the second transaction request, and executes the digital currency transaction contract to exchange the first UTXO currency transferred from the first account Into the second UTXO currency.
  • the digital currency transaction contract matches and records the first transaction request and the second transaction request, and executes the digital currency transaction contract to convert the first UTXO currency transferred from the first account into the second UTXO currency, which is achieved The purpose of protecting the transaction amount of digital currency transactions and the privacy of transaction participants.
  • the embodiment of the present invention also provides a computer-readable storage medium, the computer-readable storage medium stores a blockchain-based digital currency transaction program, and the blockchain-based digital currency transaction program can be used by one or more Each processor executes to implement the above-mentioned blockchain-based digital currency transaction method.
  • the computer program product includes one or more computer instructions.
  • the computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices.
  • the computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium.
  • the computer instructions may be transmitted from a website, computer, server, or data center. Transmission to another website, computer, server or data center via wired (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.).
  • wired such as coaxial cable, optical fiber, digital subscriber line (DSL)
  • wireless such as infrared, wireless, microwave, etc.
  • the computer-readable storage medium may be any available medium that can be stored by a computer or a data storage device such as a server or a data center integrated with one or more available media.
  • the usable medium may be a magnetic medium (for example, a floppy disk, a hard disk, and a magnetic tape), an optical medium (for example, a DVD), or a semiconductor medium (for example, a solid state disk (SSD)).
  • the disclosed system, device, and method can be implemented in other ways.
  • the device embodiments described above are merely illustrative.
  • the division of the units is only a logical function division, and there may be other divisions in actual implementation, for example, multiple units or components may be combined It can be integrated into another system, or some features can be ignored or not implemented.
  • the displayed or discussed mutual coupling or direct coupling or communication connection may be indirect coupling or communication connection through some interfaces, devices or units, and may be in electrical, mechanical or other forms.
  • the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units can be selected according to actual needs to achieve the objectives of the solutions of the embodiments.
  • the functional units in the various embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units may be integrated into one unit.
  • the above-mentioned integrated unit can be implemented in the form of hardware or software functional unit.
  • the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer readable storage medium.
  • the technical solution of this application essentially or the part that contributes to the existing technology or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium.
  • a computer device which may be a personal computer, a server, or a network device, etc.
  • the aforementioned storage media include: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), magnetic disks or optical disks and other media that can store program codes. .

Landscapes

  • Business, Economics & Management (AREA)
  • Accounting & Taxation (AREA)
  • Finance (AREA)
  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Strategic Management (AREA)
  • General Business, Economics & Management (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Development Economics (AREA)
  • Economics (AREA)
  • Computer Security & Cryptography (AREA)
  • Marketing (AREA)
  • Technology Law (AREA)
  • Financial Or Insurance-Related Operations Such As Payment And Settlement (AREA)

Abstract

一种基于区块链的数字货币交易方法、装置及系统,数字货币交易合约接收第一账户发送的第一交易请求,以及接收第一账户转入的x个第一UTXO货币(S101),当存在于第一交易请求相匹配的第二交易请求时,数字货币交易合约将第一交易请求与第二交易请求进行匹配并记录(S102),执行数字货币交易合约,以将第一账户转入的第一UTXO货币兑换成第二UTXO货币(S103)。通过上述方案,数字货币交易合约将第一交易请求与第二交易请求进行匹配并记录,并执行数字货币交易合约,以将第一账户转入的第一UTXO货币兑换成第二UTXO货币,实现保护数字货币交易的交易金额和交易参与方的隐私的目的。

Description

一种基于区块链的数字货币交易方法、装置及系统 技术领域
本发明涉及区块链技术领域,更具体地说,涉及一种基于区块链的数字货币交易方法、装置及系统。
背景技术
随着区块链技术的进步与数字货币的发展,使用数字货币作为网络上交易的凭证,已广泛地应用于网络上的交易、消费等活动。数字货币是一种基于节点网络和数字加密算法的虚拟货币,通常由开发者发行和管理,被特定的虚拟社区的成员所接受和使用。
当前的数字货币交易系统主要分为链下中心化数字货币交易系统和链上去中心化数据货币交易系统。链下中心化数字货币交易系统由中心化使得数据中心在链下收集来自不同用户提交数字货币转换申请,然后在链下中心化数字货币交易系统内进行匹配撮合,最后将撮合成功的数字货币交易上链。链下去中心化数字货币交易系统通常是通过智能合约构建,由合约代码约束数字货币交易的合理性,由于区块链的去中心化性质和合约代码公开的性质,链下去中心化数字货币交易系统中的每一笔交易都可以被区块链的任意节点查到。但是,链下中心化数字货币交易系统中,每一笔交易都是发送到一个中心化的交易所,由该交易所负责交易的执行,最后将成功的交易发布到链上,由于中心化系统数据部公开,虽然可以保护交易发起者的隐私,但是交易所可能将交易纳入自己的账户中,导致交易发起者资产被侵占。链上的去中心化数字货币交易系统中由于每一笔交易都是公开的,通过节点可以对交易进行查询,使得交易参与方的隐私会在公开交易的同时遭到泄露,从而带来隐私泄露的风险。
发明内容
有鉴于此,本发明提供了一种基于区块链的数字货币交易方法、装置及系统,实现保护数字货币交易的交易金额和交易参与方的隐私的目的。
为了实现上述目的,现提出的方案如下:
本发明第一方面公开了一种基于区块链的数字货币交易方法,所述方法包括:
数字货币交易合约接收第一账户发送的第一交易请求,以及接收第一账户转入的X个第一UTXO货币;其中,所述第一交易请求用于请求将第一账户转入的第一UTXO货币以第一汇率兑换成第二UTXO货币,所述第一账户为隐私账户;
当存在于所述第一交易请求相匹配的第二交易请求时,所述数字货币交易合约将所述第一交易请求与所述第二交易请求进行匹配并记录;
执行所述数字货币交易合约,以将所述第一账户转入的第一UTXO货币兑换成第二UTXO货币。
优选的,在所述将所述第一账户转入的第一UTXO货币兑换成第二UTXO货币之后,还包括:
将兑换得到的第二UTXO货币发送至所述第一交易请求预先指定的接收地址。
优选的,所述当存在于所述第一交易请求相匹配的第二交易请求时,所述数字货币交易合约将所述第一交易请求与所述第二交易请求进行匹配并记录,包括:
查询已挂单的交易请求中是否存在满足所述第一汇率的的交易请求;
若存在,确定满足第一汇率的第二交易请求与所述第一交易请求相匹配,所述数字货币交易合约将所述第一交易请求与所述第二交易请求进行匹配并记录。
优选的,在所述数字货币交易合约将所述第一交易请求与所述第二交易请求进行匹配并记录之前,所述方法还包括:
数字货币交易合约接收第二账户发送的第二交易请求,以及接收第二账户转入的Y个第二UTXO货币;其中,所述第二交易请求用于请求将第二账户转入的第二UTXO货币以第二汇率兑换成第一UTXO货币,所述第二账户为隐私账户。
优选的,还包括:
基于所述数字货币交易合约中的发起的撤回交易请求,执行撤回交易操作并记录,得到撤单结果;
根据所述撤单结果更新所述数字货币交易合约中的挂单记录。
本发明第二方面公开了一种基于区块链的数字货币交易装置,所述装置包括存储器和处理器,所述存储器上存储有可在所述处理器上运行的基于区块链的数字货币交易程序,所述基于区块链的数字货币交易程序被所述处理器执行时实现如本发明第一方面公开的任一项所述的方法。
本发明第三方面公开了一种基于区块链的数字货币交易系统,所述系统包括:
第一接收单元,用于数字货币交易合约接收第一账户发送的第一交易请求,以及接收第一账户转入的x个第一UTXO货币;其中,所述第一交易请求用于请求将第一账户转入的第一UTXO货币以第一汇率兑换成第二UTXO货币,所述第一账户为隐私账户;
匹配单元,用于当存在于所述第一交易请求相匹配的第二交易请求时,所述数字货币交易合约将所述第一交易请求与所述第二交易请求进行匹配并记录;
第一执行单元,用于执行所述数字货币交易合约,以将所述第一账户转入的第一UTXO货币兑换成第二UTXO货币。
优选的,还包括:
发送单元,用于将兑换得到的第二UTXO货币发送至所述第一交易请求预先指定的接收地址。
本发明第四方面公开了一种计算机可读存储介质,所述计算机可读存储介质上存储有基于区块链的数字货币交易程序,所述基于区块链的数字货币交易程序可被一个或者多个处理器执行,以实现如本发明第一方面公开的任一项所述基于区块链的数字货币交易方法。
本发明第五方面公开了一种计算机程序产品,包括计算机指令,当其在计算机上运行时,使得计算机可以执行上述本发明第一方面公开的任一项所述基于区块链的数字货币交易方法。
经由上述技术方案可知,数字货币交易合约接收第一账户发送的第一交易请求,以及接收第一账户转入的X个第一UTXO货币,当存在于第一交易请求相匹配的第二交易请求时,数字货币交易合约将第一交易请求与第二交易请求进行匹配并记录,执行数字货币交易合约,以将第一账户转入的第一UTXO 货币兑换成第二UTXO货币。通过上述方案,数字货币交易合约将第一交易请求与第二交易请求进行匹配并记录,并执行数字货币交易合约,以将第一账户转入的第一UTXO货币兑换成第二UTXO货币,实现保护数字货币交易的交易金额和交易参与方的隐私的目的。
上述说明仅是本申请技术方案的概述,为了能够更清楚了解本申请的技术手段,而可依照说明书的内容予以实施,并且为了让本申请的上述和其它目的、特征和优点能够更明显易懂,以下特举本申请的具体实施方式。
附图说明
为了更清楚地说明本申请实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1为本发明实施例公开的一种基于区块链的数字货币交易方法的流程示意图;
图2为本发明实施例公开的当存在于第一交易请求相匹配的第二交易请求时,数字货币交易合约将第一交易请求与第二交易请求进行匹配并记录的流程示意图;
图3为本发明实施例公开的一种基于区块链的数字货币交易装置的结构示意图;
图4为本发明实施例公开的一种基于区块链的数字货币交易系统的结构示意图。
具体实施方式
为了使本发明的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本发明进行进一步详细说明。应当理解,此处所描述的具体实施例仅用以解释本发明,并不用于限定本发明。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。
本申请的说明书和权利要求书及上述附图中的术语“第一”、“第二”、“第三”、“第四”等(如果存在)是用于区别类似的对象,而不必用于描述特定的顺序 或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便这里描述的实施例能够以除了在这里图示或描述的内容以外的顺序实施。此外,术语“包括”和“具有”以及他们的任何变形,意图在于覆盖不排他的包含,例如,包含了一系列步骤或单元的过程、方法、系统、产品或设备不必限于清楚地列出的那些步骤或单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它步骤或单元。
需要说明的是,在本发明中涉及“第一”、“第二”等的描述仅用于描述目的,而不能理解为指示或暗示其相对重要性或者隐含指明所指示的技术特征的数量。由此,限定有“第一”、“第二”的特征可以明示或者隐含地包括至少一个该特征。另外,各个实施例之间的技术方案可以相互结合,但是必须是以本领域普通技术人员能够实现为基础,当技术方案的结合出现相互矛盾或无法实现时应当认为这种技术方案的结合不存在,也不在本发明要求的保护范围之内。
现有技术中,链下中心化数字货币交易系统中,每一笔交易都是发送到一个中心化的交易所,由该交易所负责交易的执行,最后将成功的交易发布到链上,由于中心化系统数据部公开,虽然可以保护交易发起者的隐私,但是交易所可能将交易纳入自己的账户中,导致交易发起者资产被侵占。链上的去中心化数字货币交易系统中由于每一笔交易都是公开的,通过节点可以对交易进行查询,使得交易参与方的隐私会在公开交易的同时遭到泄露,从而带来隐私泄露的风险。
因此,本发明公开了一种基于区块链的数字货币交易方法、装置及系统,通过数字货币交易合约将第一交易请求与第二交易请求进行匹配并记录,并执行数字货币交易合约,以将第一账户转入的第一UTXO货币兑换成第二UTXO货币,实现保护数字货币交易的交易金额和交易参与方的隐私的目的。
如图1所示,为本发明实施例公开的一种基于区块链的数字货币交易方法的流程示意图,具体包括如下步骤:
步骤S101:数字货币交易合约接收第一账户发送的第一交易请求,以及接收第一账户转入的X个第一UTXO货币。
在具体实现步骤S101的过程中,第一交易请求用于请求将第一账户转入的第一UTXO货币以第一汇率兑换成第二UTXO货币,第一账户为隐私账户。
需要说明的是,X可以是任意数值,可以是整数,也可以是小数。
由于第一账户为隐私账户,因此第一账户的账户金额和账户地址都受到隐私保护,具体采用的隐私保护方式,本领域技术人员可以根据情况选择合适的方式,在此不做具体限制。
步骤S102:当存在于第一交易请求相匹配的第二交易请求时,数字货币交易合约将第一交易请求与第二交易请求进行匹配并记录。
在具体实现步骤S102的过程中,发起的挂单交易中存在满足第一汇率的挂单请求,第一交易请求与第二交易请求相匹配,数字货币交易合约将第一交易请求与第二交易请求进行匹配并记录。
需要说明的是,汇率是指两种货币之间的兑换的比例。
在数字货币交易合约将第一交易请求与第二交易请求进行匹配并记录之前,数字货币交易合约接收第二账户发送的第二交易请求,以及接收第二账户转入的Y个第二UTXO货币。
Y可以是任意数值,可以是整数,也可以是小数。
第二交易请求用于请求将第二账户转入的第二UTXO货币以第二汇率兑换成第一UTXO货币,第二账户为隐私账户。
由于第二账户为隐私账户,因此第二账户的账户金额和账户地址都受到隐私保护。
步骤S103:执行数字货币交易合约,以将第一账户转入的第一UTXO货币兑换成第二UTXO货币。
在具体实现步骤S103的过程中,区块链的出块节点通过Account模型执行数字货币交易合约时,基于第一汇率将第一账户转入的第一UTXO货币兑换成第二UTXO货币。
需要说明的是,区块链的出块节点通过Account模型执行数字货币交易合约时,该数字货币交易合约可以进行公开计算,执行合约代码,输入输出的信息需要通过暂存地址与用户的真实身份隔离。
通过Account模型基于智能合约实现去中心化的数字货币交易,保证了数字货币交易的自动化、公平和公正。
在第一账户转入的第一UTXO货币兑换成第二UTXO之后,将兑换得到的 第二UTXO货币发送至第一交易请求预先指定的接收地址。
需要说明的是,在第一账户转入的第一UTXO货币兑换成第二UTXO时,即挂单撮合函数成功撮合数字货币交易合约中的交易,则将合约账户中的相应金额转出给对应的UTXO地址,即预先指定的接收地址。
当第一账户无法接收到兑换得到的第二UTXO货币时,即出现不兼容货币的情况,则将兑换得到的第二UTXO货币存入第一交易请求中预先指定的接收地址。
本发明公开了一种基于区块链的数字货币交易方法,数字货币交易合约接收第一账户发送的第一交易请求,以及接收第一账户转入的X个第一UTXO货币,当存在于第一交易请求相匹配的第二交易请求时,数字货币交易合约将第一交易请求与第二交易请求进行匹配并记录,执行数字货币交易合约,以将第一账户转入的第一UTXO货币兑换成第二UTXO货币。通过上述方案,数字货币交易合约将第一交易请求与第二交易请求进行匹配并记录,并执行数字货币交易合约,以将第一账户转入的第一UTXO货币兑换成第二UTXO货币,实现保护数字货币交易的交易金额和交易参与方的隐私的目的。
在上述步骤S102中涉及到当存在于第一交易请求相匹配的第二交易请求时,数字货币交易合约将第一交易请求与第二交易请求进行匹配并记录的过程,如图2所示,具体包括如下步骤:
步骤S201:查询已挂单的交易请求中是否存在满足第一汇率的交易请求,若已挂单的交易请求中存在满足第一汇率的交易请求,执行步骤S202,若已挂单的交易请求中不存在满足第一汇率的交易请求,执行步骤S203。
在具体实现步骤S201的过程中,通过UTXO模型发起数字货币合约交易时,调用跨数字货币交易合约的函数匹配普通数字货币交易合约中的挂单撮合函数,并执行挂单交易。
需要说明的是,挂单交易是指提交数字货币转换申请交易。
挂单交易涉及的对象包括发送方,接收方和交易金额。
挂单交易成功后,数字交易合约执行匹配撮合挂单函数,根据现有的挂单记录对新挂单交易进行匹配撮合。
挂单撮合函数成功撮合数字货币交易合约中的交易后,在同一个区块内打 包区块的区块节点将挂单调用的数字货币交易合约中的交易和该数字货币交易合约转出的交易进行打包,并用私钥对该挂单调用的数字货币交易合约中的交易和该数字货币交易合约转出的交易进行签名。
在本发明的一种应用场景中,当区块节点将区块广播出去后,其他验证节点会验证数字货币交易合约的执行以及区块节点发起的数字货币交易的合法性。达成区块共识后,该数字货币交易成功。
验证节点验证数字货币交易合约成功后,验证该数字货币交易合约转出的交易是否被正确打包进入区块。数字货币交易合约和该数字货币交易合约转出的交易都验证成功,才会被其他验证节点接受。
未花费的交易输出(Unspent Transaction Output,UTXO)模型是一个包含交易数据和执行代码的数据结构,是比特币最早采用的账户模型。
通过UTXO模型实现对交易发送方、交易接收方和交易金额的隐私保护。
利用UTXO模型进行数字资产的隐私保护,隐私保护方法可以是环签名,可以是环签保密交易RingCT,可以是零知识证明等。利用UTXO模型进行数字资产的隐私保护方法本发明不做具体的限定,根据实际情况由技术人员进行选择。
通过UTXO模型发起数字货币交易合约时,调用数字货币交易合约的函数匹配数字货币交易为普通数字货币交易,无法匹配隐私保护数字货币交易。
当环签名的环size的数值为1时,为普通数字货币交易,当环签名的环size的数值不为1时,为隐私数字货币交易。
环签名的环size的最大值为全网账户总数,该环签名的环size的数值的取值范围为大于等于1的正整数。
在本发明的另一种应用场景中,对于新加入系统的UTXO地址或者被公开过的UTXO地址,可以通过环签名实现隐私保护交易,对UTXO地址进行盲化,即把UTXO地址进行隐藏。
盲化的方法以公开的UTXO地址作为输入,发起一笔隐私保护交易,输出为由多个UTXO地址组成的环。
其他用户区块或区块节点无法判断真实的UTXO地址是环中的哪一个成员,以此实现对数字交易合约的合约账户金额和合约账户地址的隐私保护。为 了实现更好的难以追踪性质,可以采用更大规模的环,或增加盲化操作的轮数。
在本发明的另一种应用场景中,UTXO模型根据合约部署和执行的复杂程度计算gas值的消耗量,该gas值的消耗量可以设定为固定值,具体该gas值的消耗量的设定取决于区块链的运营策略。需要说明的是,gas值是数字货币交易合约执行所消耗的资源,即数字货币交易合约执行的成本,其作用一方面提供执行合约的动力,另一方面防止攻击者对数字货币交易合约进行无限调用的攻击。
通过UTXO模型在合约部署过程中消耗的函数消耗gas值将在交易过程中被扣除。
通过UTXO模型执行数字货币合约交易时,基于函数消耗gas值执行扣除操作,得到UTXO数值。
UTXO数值相当于UTXO货币的面值。
通过UTXO模型将UTXO数值转入数字货币交易合约的合约账户的余额中。
通过UTXO模型将UTXO数值转入合约账户的金额为挂单金额。
在数字货币交易合约输入中包括兑换的货币类型、期待的新币金额、新币UTXO接收地址。
涉及区块中数字货币交易合约交易的过程,如表1所示。
表1:
HEADER
UTXOa→SC123456
SC123456→UTXOb
SC123456→UTXOc
SC123456→UTXOd
......
需要说明的是,HEADER为区块头,UTXOa→SC123456、SC123456→UTXOb、SC123456→UTXOc和SC123456→UTXOd为区块体中的交易。
用户利用UTXO模型发起一笔合约部署交易,该合约部署交易以用户的UTXO作为输入,输出一个数字货币交易合约。该数字货币交易合约的地址在部署时自动生成,该数字货币交易合约的地址以“SC”开头。
合约部署的方式可以利用工具将合约代码生成字节码,通过指令或工具生成合约。
地址“SC”标识为智能合约(Smart Contract)的保留字段。智能合约相当于数字货币交易合约。
智能合约是一种皆在以信息化方式传播、验证或执行合同的计算机协议,允许在没有第三方的情况下进行可信交易,该交易可追踪且不可逆转。
以“SC”开头的合约地址为智能合约地址,以非“SC”开头的合约地址为普通UTXO地址。
智能合约的结构,如表2所示。
表2:
nonce
balance
Contract_code
storage
需要说明的是,nonce为随机数,交易的标识,用于防止交易受到重放攻击。
Balance为合约账户余额。
Contract_code为合约代码。
Storage为合约中存储的数据。
步骤S202:确定满足第一汇率的第二交易请求与第一交易请求相匹配,数字货币交易合约将第一交易请求与第二交易请求进行匹配并记录。
步骤S203:确定满足第一汇率的第二交易请求与第一交易请求不匹配。
需要说明的是,UTXO模型查询挂单交易的挂单列表中不存在满足汇率的挂单请求,则第一交易请求与第二交易请求不匹配,挂单撮合函数不成功撮合数字货币交易合约中的交易,则结束数字货币交易合约中的交易。
本发明实施例中,通过查询发起的挂单交易中是否存在满足汇率的挂单请求,当发起的挂单交易中存在满足汇率的挂单请求时,实现第一交易请求与第二交易请求相匹配,将第一交易请求与第二交易请求进行匹配并记录的目的
在本发明的另一种应用场景中,基于数字货币交易合约中发起的撤回交易请求,执行撤回交易操作并记录,得到撤单结果,根据撤单结果更新数字货币交易合约中的挂单记录。
需要说明的是,区块打包节点打包数字货币交易合约中的撤单交易,将该数字货币交易合约的合约账户中相应的金额转出至发起撤单请求的UTXO账户中。
基于数字货币交易合约逻辑中需要将数字货币交易合约的合约账户余额转出至UTXO的情况,负责打包交易的区块节点需要将调用数字货币交易合约的交易和UTXO转出的交易打包在同一个区块中,保证整个过程的事务性。
在本发明的应用场景中,基于数字货币交易合约中的撤单交易,得到撤单结果,实现根据撤单结果更新数字货币交易合约中的挂单记录的目的。
为了方便理解上述的数字货币交易方法的过程,这里举例进行说明:
用户Alice持有a个隐私货币A,用户Bob持有b个隐私货币B。用户Alice和用户Bob希望做两个货币的交换,假设a个隐私货币A等价于b个隐私货币B。用户Alice和用户Bob首先分别调用跨数字货币交易合约进行挂单,将自己的UTXO转入数字货币交易合约记录下来。当后面的一个数字货币交易合约调用成功后,数字货币交易合约内的挂单撮合函数会匹配成功,然后将匹配成功的结果记录在数字货币交易合约内。当区块节点执行完数字货币交易合约之后,通过数字货币交易合约中的记录发起两笔UTXO交易,并用自己 的私钥对交易进行签名,转账的发送方是合约地址,接收方为用户Alice和用户Bob预先指定的接收地址,当区块节点将区块广播出去后,其他验证节点会验证合约的执行以及区块节点发起的交易的合法性,达成区块共识后,用户Alice和用户Bob的跨数字货币交易成功。
本发明实施例还提供了一种基于区块链的数字货币交易装置,该基于区块链的数字货币交易装置包括存储器和处理器,该存储器上存储有可在该处理器上运行的基于区块链的数字货币交易程序,该基于区块链的数字货币交易程序被该处理器执行时实现基于区块链的数字货币交易方法。
在本实施例中,基于区块链的数字货币交易装置3可以是PC(Personal Computer,个人电脑),也可以是智能手机、平板电脑、掌上电脑、便携计算机、终端设备。
该基于区块链的数字货币交易装置3可以是区块链网络的节点。
该基于区块链的数字货币交易装置3可以包括存储器11、处理器12和总线13。
其中,存储器11至少包括一种类型的可读存储介质,该可读存储介质包括闪存、硬盘、多媒体卡、卡型存储器(例如,SD或DX存储器等)、磁性存储器、磁盘、光盘等。存储器11在一些实施例中可以是基于区块链的数字货币交易装置3的内部存储单元,例如该数字货币交易装置3的硬盘。存储器11在另一些实施例中也可以是基于区块链的数字货币交易装置3的外部存储设备,例如基于区块链的数字货币交易装置3上配备的插接式硬盘,智能存储卡(Smart Media Card,SMC),安全数字(Secure Digital,SD)卡,闪存卡(Flash Card)等。进一步地,存储器11还可以既包括基于区块链的数字货币交易装置3的内部存储单元也包括外部存储设备。存储器11不仅可以用于存储安装于基于区块链的数字货币交易装置3的应用软件及各类数据,例如基于区块链的数字货币交易程序的代码等,还可以用于暂时地存储已经输出或者将要输出的数据。
处理器12在一些实施例中可以是一中央处理器(Central Processing Unit,CPU)、控制器、微控制器、微处理器或其他数据处理芯片,用于运行存储器11中存储的程序代码或处理数据,例如执行基于区块链的数字货币交易程序 等。
该总线13可以是外设部件互连标准(peripheral component interconnect,简称PCI)总线或扩展工业标准结构(extended industry standard architecture,简称EISA)总线等。该总线可以分为地址总线、数据总线、控制总线等。为便于表示,图3中仅用一条粗线表示,但并不表示仅有一根总线或一种类型的总线。
进一步地,基于区块链的数字货币交易装置还可以包括网络接口14,网络接口14可选的可以包括有线接口和/或无线接口(如WI-FI接口、蓝牙接口等),通常用于在该基于区块链的数字货币交易装置3与其他电子设备之间建立通信连接。
可选地,该基于区块链的数字货币交易装置3还可以包括用户接口,用户接口可以包括显示器(Display)、输入单元比如键盘(Keyboard),可选的用户接口还可以包括标准的有线接口、无线接口。可选地,在一些实施例中,显示器可以是LED显示器、液晶显示器、触控式液晶显示器以及OLED(Organic Light-Emitting Diode,有机发光二极管)触摸器等。其中,显示器也可以适当的称为显示屏或显示单元,用于显示在基于区块链的数字货币交易装置3中处理的信息以及用于显示可视化的用户界面。
基于上述本发明实施公开的基于区块链的数字货币交易方法,本发明实施例还对应公开了基于区块链的数字货币交易系统,如图4所示,该基于区块链的数字货币交易系统,主要包括:
第一接收单元401,用于数字货币交易合约接收第一账户发送的第一交易请求,以及接收第一账户转入的x个第一UTXO货币;其中,所述第一交易请求用于请求将第一账户转入的第一UTXO货币以第一汇率兑换成第二UTXO货币,所述第一账户为隐私账户。
匹配单元402,用于当存在于所述第一交易请求相匹配的第二交易请求时,所述数字货币交易合约将所述第一交易请求与所述第二交易请求进行匹配并记录。
第一执行单元403,用于执行所述数字货币交易合约,以将所述第一账户转入的第一UTXO货币兑换成第二UTXO货币。
可选的,还包括:
发送单元,用于将兑换得到的第二UTXO货币发送至第一交易请求预先指定的接收地址。
进一步的,匹配单元402,包括:
查询模块,用于查询已挂单的交易请求中是否存在满足第一汇率的交易请求。
第一确定模块,用于若存在,确定满足第一汇率的第二交易请求与第一交易请求相匹配,数字货币交易合约将第一交易请求与第二交易请求进行匹配并记录。
第二确定模块,用于若不存在,确定满足第一汇率的第二交易请求与第一交易请求不匹配。
可选的,还包括:
第二接收单元,用于数字货币交易合约接收第二账户发送的第二交易请求,以及接收第二账户转入的y个第二UTXO货币;其中,第二交易请求用于请求将第二账户转入的第二UTXO货币以第二汇率兑换成第一UTXO货币,第二账户为隐私账户。
可选的,还包括:
第二执行单元,用于基于数字货币交易合约中发起的撤回交易请求,执行撤回交易操作并记录,得到撤单结果。
更新单元,用于根据撤单结果更新数字货币交易合约中的挂单记录。
本发明公开了一种基于区块链的数字货币交易系统,数字货币交易合约接收第一账户发送的第一交易请求,以及接收第一账户转入的X个第一UTXO货币,当存在于第一交易请求相匹配的第二交易请求时,数字货币交易合约将第一交易请求与第二交易请求进行匹配并记录,执行数字货币交易合约,以将第一账户转入的第一UTXO货币兑换成第二UTXO货币。通过上述方案,数字货币交易合约将第一交易请求与第二交易请求进行匹配并记录,并执行数字货币交易合约,以将第一账户转入的第一UTXO货币兑换成第二UTXO货币,实现保护数字货币交易的交易金额和交易参与方的隐私的目的。本发明实施例还提供了一种计算机可读存储介质,所述计算机可读存储介质上存储有基于区块链的数字货币交易程序,该基于区块链的数字货币交易程序可被一个或者多 个处理器执行,以实现上述基于区块链的数字货币交易方法。
在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。
所述计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行所述计算机程序指令时,全部或部分地产生按照本发明实施例所述的流程或功能。所述计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。所述计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一计算机可读存储介质传输,例如,所述计算机指令可以从一个网站站点、计算机、服务器或数据中心通过有线(例如同轴电缆、光纤、数字用户线(DSL))或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。所述计算机可读存储介质可以是计算机能够存储的任何可用介质或者是包含一个或多个可用介质集成的服务器、数据中心等数据存储设备。所述可用介质可以是磁性介质,(例如,软盘、硬盘、磁带)、光介质(例如,DVD)、或者半导体介质(例如固态硬盘Solid State Disk(SSD))等。
所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统,装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。
在本申请所提供的几个实施例中,应该理解到,所揭露的系统,装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部 单元来实现本实施例方案的目的。
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。
所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、磁碟或者光盘等各种可以存储程序代码的介质。
需要说明的是,上述本发明实施例序号仅仅为了描述,不代表实施例的优劣。并且本文中的术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、装置、物品或者方法不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、装置、物品或者方法所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括该要素的过程、装置、物品或者方法中还存在另外的相同要素。
以上仅为本发明的优选实施例,并非因此限制本发明的专利范围,凡是利用本发明说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本发明的专利保护范围内。

Claims (10)

  1. 一种基于区块链的数字货币交易方法,其特征在于,所述方法包括:
    数字货币交易合约接收第一账户发送的第一交易请求,以及接收第一账户转入的X个第一UTXO货币;其中,所述第一交易请求用于请求将第一账户转入的第一UTXO货币以第一汇率兑换成第二UTXO货币,所述第一账户为隐私账户;
    当存在于所述第一交易请求相匹配的第二交易请求时,所述数字货币交易合约将所述第一交易请求与所述第二交易请求进行匹配并记录;
    执行所述数字货币交易合约,以将所述第一账户转入的第一UTXO货币兑换成第二UTXO货币。
  2. 根据权利要求1所述的方法,其特征在于,在所述将所述第一账户转入的第一UTXO货币兑换成第二UTXO货币之后,还包括:
    将兑换得到的第二UTXO货币发送至所述第一交易请求预先指定的接收地址。
  3. 根据权利要求1所述的方法,其特征在于,所述当存在于所述第一交易请求相匹配的第二交易请求时,所述数字货币交易合约将所述第一交易请求与所述第二交易请求进行匹配并记录,包括:
    查询已挂单的交易请求中是否存在满足所述第一汇率的交易请求;
    若存在,确定满足第一汇率的第二交易请求与所述第一交易请求相匹配,所述数字货币交易合约将所述第一交易请求与所述第二交易请求进行匹配并记录。
  4. 根据权利要求1所述的方法,其特征在于,在所述数字货币交易合约将所述第一交易请求与所述第二交易请求进行匹配并记录之前,所述方法还包括:
    数字货币交易合约接收第二账户发送的第二交易请求,以及接收第二账户转入的Y个第二UTXO货币;其中,所述第二交易请求用于请求将第二账户转入的第二UTXO货币以第二汇率兑换成第一UTXO货币,所述第二账户为隐私账户。
  5. 根据权利要求1所述的方法,其特征在于,还包括:
    基于所述数字货币交易合约中发起的撤回交易请求,执行撤回交易操作并记录,得到撤单结果;
    根据所述撤单结果更新所述数字货币交易合约中的挂单记录。
  6. 一种基于区块链的数字货币交易装置,其特征在于,所述设备包括存储器和处理器,所述存储器上存储有可在所述处理器上运行的基于区块链的数字货币交易程序,所述基于区块链的数字货币交易程序被所述处理器执行时实现如权利要求1至5任一项所述的方法。
  7. 一种基于区块链的数字货币交易系统,其特征在于,所述系统包括:
    第一接收单元,用于数字货币交易合约接收第一账户发送的第一交易请求,以及接收第一账户转入的X个第一UTXO货币;其中,所述第一交易请求用于请求将第一账户转入的第一UTXO货币以第一汇率兑换成第二UTXO货币,所述第一账户为隐私账户;
    匹配单元,用于当存在于所述第一交易请求相匹配的第二交易请求时,所述数字货币交易合约将所述第一交易请求与所述第二交易请求进行匹配并记录;
    第一执行单元,用于执行所述数字货币交易合约,以将所述第一账户转入的第一UTXO货币兑换成第二UTXO货币。
  8. 根据权利要求7所述的系统,其特征在于,还包括:
    发送单元,用于将兑换得到的第二UTXO货币发送至所述第一交易请求预先指定的接收地址。
  9. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质上存储有基于区块链的数字货币交易程序,所述基于区块链的数字货币交易程序可被一个或者多个处理器执行,以实现如权利要求1至5中任一项所述的基于区块链的数字货币交易方法。
  10. 一种计算机程序产品,其特征在于,包括计算机指令,当其在计算机上运行时,使得计算机可以执行上述权利要求1至5中任一项所述的基于区块链的数字货币交易方法。
PCT/CN2019/130379 2019-12-31 2019-12-31 一种基于区块链的数字货币交易方法、装置及系统 WO2021134424A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
PCT/CN2019/130379 WO2021134424A1 (zh) 2019-12-31 2019-12-31 一种基于区块链的数字货币交易方法、装置及系统
CN201980059593.XA CN112740250A (zh) 2019-12-31 2019-12-31 一种基于区块链的数字货币交易方法、装置及系统

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2019/130379 WO2021134424A1 (zh) 2019-12-31 2019-12-31 一种基于区块链的数字货币交易方法、装置及系统

Publications (1)

Publication Number Publication Date
WO2021134424A1 true WO2021134424A1 (zh) 2021-07-08

Family

ID=75589256

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/130379 WO2021134424A1 (zh) 2019-12-31 2019-12-31 一种基于区块链的数字货币交易方法、装置及系统

Country Status (2)

Country Link
CN (1) CN112740250A (zh)
WO (1) WO2021134424A1 (zh)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113570464B (zh) * 2021-09-07 2022-06-03 北京科技大学 一种数字货币交易社区识别方法、系统、设备及存储介质
CN116029825B (zh) * 2022-12-29 2024-02-02 胖迪科技(深圳)有限公司 区块链的交易方法、装置、系统、电子设备及存储介质

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107679857A (zh) * 2017-10-10 2018-02-09 马晶瑶 区块链的跨链交易方法和存储介质
WO2018142259A1 (en) * 2017-01-31 2018-08-09 nChain Holdings Limited Computer-implemented system and method for determining the state of a machine executable contract implemented using a blockchain
CN109035029A (zh) * 2018-07-27 2018-12-18 阿里巴巴集团控股有限公司 基于区块链的资产转移方法及装置、电子设备
CN110322346A (zh) * 2019-04-02 2019-10-11 武汉天喻信息产业股份有限公司 一种支持uxto模型的条件可设定支付方法及系统

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2018142259A1 (en) * 2017-01-31 2018-08-09 nChain Holdings Limited Computer-implemented system and method for determining the state of a machine executable contract implemented using a blockchain
CN107679857A (zh) * 2017-10-10 2018-02-09 马晶瑶 区块链的跨链交易方法和存储介质
CN109035029A (zh) * 2018-07-27 2018-12-18 阿里巴巴集团控股有限公司 基于区块链的资产转移方法及装置、电子设备
CN110322346A (zh) * 2019-04-02 2019-10-11 武汉天喻信息产业股份有限公司 一种支持uxto模型的条件可设定支付方法及系统

Also Published As

Publication number Publication date
CN112740250A (zh) 2021-04-30

Similar Documents

Publication Publication Date Title
TWI701623B (zh) 基於區塊鏈的物流資訊傳輸方法、系統和裝置
TWI724391B (zh) 基於區塊鏈的節點管理方法和裝置
TWI735820B (zh) 資產管理方法及裝置、電子設備
TWI710979B (zh) 跨區塊鏈的互動方法及裝置、系統、電子設備
CN110612697B (zh) 用于高效信息检索的数据存储层索引的方法和系统
CN109862041A (zh) 一种数字身份认证方法、设备、装置、系统及存储介质
US10972448B2 (en) Technologies for data broker assisted transfer of device ownership
CN110189121B (zh) 数据处理方法、装置、区块链客户端和区块链节点
CN109951489A (zh) 一种数字身份认证方法、设备、装置、系统及存储介质
TW201935383A (zh) 資產管理方法及裝置、電子設備
TW202016818A (zh) 區塊鏈的交易方法和裝置
TW201935375A (zh) 資產管理方法及裝置、電子設備
CN111899012B (zh) 基于区块链的汇款方法及装置
TW201935377A (zh) 資產管理方法及裝置、電子設備
US20210344500A1 (en) Computer-implemented system and method for transferring access to digital resource
CN110517147A (zh) 交易数据处理方法、装置、系统及计算机可读存储介质
WO2021057168A1 (zh) 基于fpga实现虚拟机运算的方法及装置
TW202011312A (zh) 區塊鏈交易的認證伺服器及認證方法
WO2021134424A1 (zh) 一种基于区块链的数字货币交易方法、装置及系统
CN111476573A (zh) 一种账户数据处理方法、装置、设备及存储介质
CN110210863A (zh) 区块链安全交易方法、装置、电子设备及存储介质
WO2022237558A1 (zh) 一种基于区块链的用户要素认证的方法及装置
CN113132459B (zh) 分布式存储方法、系统、存储介质、信息数据处理终端
US20230259930A1 (en) Cross-chain transaction processing method and apparatus, electronic device, and storage medium
JP2022549777A (ja) ブロックチェーンのトランザクションへの要求のパーティション

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 19958418

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 19958418

Country of ref document: EP

Kind code of ref document: A1