Asset transaction method, storage medium, and computer device
In a transaction method, transaction information is obtained. The transaction information includes a type identifier and quantity of first assets, and a type identifier and quantity of second assets. Transaction records, corresponding to a transaction in a block, are stored upon verification of the transaction information. The transaction records include first and second transaction records. The first transaction record includes first input and output items corresponding to the first assets, and the first input and output items each includes the type identifier of the first assets. The second transaction record includes second input and output items corresponding to the second assets, and the second input and output items each includes the type identifier of the second assets. The block is broadcasted to other nodes in the blockchain network, and verification results are received. The block is added to a blockchain of a current node based on the verification results.
1 . An asset transaction method for implementing a transaction of cryptocurrencies of different types on a single blockchain, comprising:
receiving, by circuitry of a current node of a blockchain network, a first transaction request that includes a first type identifier and a first quantity of first cryptocurrency;
receiving, by the circuitry of the current node, a second transaction request that includes a second type identifier of second cryptocurrency, the first type identifier and the second type identifier being different numbers that identify different asset types such that the transaction involves exchange of the cryptocurrencies of different types that include the first cryptocurrency and the second cryptocurrency;
obtaining, by the circuitry of the current node, a transaction exchange rate between the first cryptocurrency and the second cryptocurrency according to the first type identifier of the first cryptocurrency and the second type identifier of the second cryptocurrency;
determining a second quantity of the second cryptocurrency based on the first quantity of the first cryptocurrency and the transaction exchange rate;
verifying, by the circuitry of the current node, transaction information of the transaction, the transaction information including at least the first type identifier, the first quantity of the first cryptocurrency, the second type identifier, and the second quantity of the second cryptocurrency;
recording, by the circuitry of the current node and after the transaction information is successfully verified, transaction record information corresponding to the transaction involving the cryptocurrencies of different types in a new block of the current node of the blockchain network, the transaction record information indicating at least a first transaction record and a second transaction record, the first transaction record including a first input item and a first output item corresponding to the first cryptocurrency, and the second transaction record including a second input item and a second output item corresponding to the second cryptocurrency
broadcasting, by the circuitry of the current node, the new block to other nodes in the blockchain network;
receiving, by the circuitry of the current node, verification results of the other nodes; and
adding the new block to the single blockchain of the current node according to the verification results, wherein
the single blockchain is configured to store a plurality of blocks of different transactions of the cryptocurrencies of the different types;
the new block added to the single blockchain includes:
a timestamp indicative of a time when the new block is created,
transaction exchange rate information indicating the transaction exchange rate,
the transaction record information indicating the first transaction record and the second transaction record, and
a unique identifier generated based on a hash calculation of at least a combination of the first transaction record and the second transaction record in the transaction record information;
the first input item includes a first source of the first cryptocurrency, the first type identifier of the first cryptocurrency, the first quantity of the first cryptocurrency, and a proof of expense of the first cryptocurrency that includes a first signature generated with a first private key;
the second input item includes a second source of the second cryptocurrency, the second type identifier of the second cryptocurrency, the second quantity of the second cryptocurrency, and a proof of expense of the second cryptocurrency that includes a second signature generated with a second private key;
the first output item includes a first output account address corresponding to the first cryptocurrency, the first type identifier of the first cryptocurrency, the first quantity of the first cryptocurrency, and a first expense condition of the first cryptocurrency that includes first public key information; and
the second output item includes a second output account address corresponding to the second cryptocurrency, the second type identifier of the second cryptocurrency, the second quantity of the second cryptocurrency, and a second expense condition of the second cryptocurrency that includes second public key information.
2 . The method according to claim 1 , wherein the recording the transaction record information comprises:
determining the first input item according to the first source of the first cryptocurrency and the proof of expense of the first cryptocurrency;
determining the first output item according to the first output account address corresponding to the first cryptocurrency, the first type identifier and the first quantity of the first cryptocurrency, and the first expense condition corresponding to the first output account address;
recording the first input item and the first output item as the first transaction record in the new block of the current node in the blockchain network;
determining the second input item according to the second source of the second cryptocurrency and the proof of expense of the second cryptocurrency;
determining the second output item according to the second output account address corresponding to the second cryptocurrency, the second type identifier and the second quantity of the second cryptocurrency, and the second expense condition corresponding to the second output account address; and
recording the second input item and the second output item as the second transaction record in the new block of the current node in the blockchain network.
3 . The method according to claim 1 , wherein the verifying the transaction information of the transaction comprises:
verifying the first cryptocurrency according to the first source of the first cryptocurrency and the proof of expense of the first cryptocurrency;
verifying the second cryptocurrency according to the second source of the second cryptocurrency and the proof of expense of the second cryptocurrency; and
determining that the transaction information is successfully verified in a case that the first cryptocurrency and the second cryptocurrency are both successfully verified.
4 . The method according to claim 3 , wherein
the verifying the first cryptocurrency includes:
searching for the first expense condition of the first cryptocurrency according to the first source of the first cryptocurrency; and
verifying the first cryptocurrency according to the first expense condition of the first cryptocurrency and the proof of expense of the first cryptocurrency; and
the verifying the second cryptocurrency includes:
searching for the second expense condition of the second cryptocurrency according to the second source of the second cryptocurrency; and
verifying the second cryptocurrency according to the second expense condition of the second cryptocurrency and the proof of expense of the second cryptocurrency.
5 . The method according to claim 4 , wherein
the verifying the first cryptocurrency includes:
verifying the first signature according to the first public key information; and
the verifying the second cryptocurrency includes:
verifying the second signature according to the second public key information.
6 . The method according to claim 1 , wherein the transaction exchange rate is obtained from
contract information associated with two parties of the transaction, or
a third-party server device.
7 . A processing apparatus of a current node of a blockchain network for implementing a transaction of cryptocurrencies of different types on a single blockchain, comprising:
circuitry configured to:
receive a first transaction request that includes a first type identifier and a first quantity of first cryptocurrency;
receive a second transaction request that includes a second type identifier of second cryptocurrency, the first type identifier and the second type identifier being different numbers that identify different asset types such that the transaction involves exchange of the cryptocurrencies of different types that include the first cryptocurrency and the second cryptocurrency;
obtain a transaction exchange rate between the first cryptocurrency and the second cryptocurrency according to the first type identifier of the first cryptocurrency and the second type identifier of the second cryptocurrency;
determine a second quantity of the second cryptocurrency based on the first quantity of the first cryptocurrency and the transaction exchange rate;
verify transaction information of the transaction, the transaction information including at least the first type identifier, the first quantity of the first cryptocurrency, the second type identifier, and the second quantity of the second cryptocurrency;
record, after the transaction information is successfully verified, transaction record information corresponding to the transaction involving the cryptocurrencies of different types in a new block of the current node of the blockchain network, the transaction record information indicating at least a first transaction record and a second transaction record, the first transaction record including a first input item and a first output item corresponding to the first cryptocurrency, and the second transaction record including a second input item and a second output item corresponding to the second cryptocurrency;
broadcast the new block to other nodes in the blockchain network;
receive verification results of the other nodes; and
add the new block to the single blockchain of the current node according to the verification results, wherein
the single blockchain is configured to store a plurality of blocks of different transactions of the cryptocurrencies of the different types; and
the new block added to the single blockchain includes:
a timestamp indicative of a time when the new block is created,
transaction exchange rate information indicating the transaction exchange rate,
the transaction record information indicating the first transaction record and the second transaction record, and
a unique identifier generated based on a hash calculation of at least a combination of the first transaction record and the second transaction record in the transaction record information;
the first input item includes a first source of the first cryptocurrency, the first type identifier of the first cryptocurrency, the first quantity of the first cryptocurrency, and a proof of expense of the first cryptocurrency that includes a first signature generated with a first private key;
the second input item includes a second source of the second cryptocurrency, the second type identifier of the second cryptocurrency, the second quantity of the second cryptocurrency, and a proof of expense of the second cryptocurrency that includes a second signature generated with a second private key;
the first output item includes a first output account address corresponding to the first cryptocurrency, the first type identifier of the first cryptocurrency, the first quantity of the first cryptocurrency, and a first expense condition of the first cryptocurrency that includes first public key information; and
the second output item includes a second output account address corresponding to the second cryptocurrency, the second type identifier of the second cryptocurrency, the second quantity of the second cryptocurrency, and a second expense condition of the second cryptocurrency that includes second public key information.
8 . The processing apparatus according to claim 7 , wherein the circuitry is configured to:
determine the first input item according to the first source of the first cryptocurrency and the proof of expense of the first cryptocurrency;
determine the first output item according to the first output account address corresponding to the first cryptocurrency, the first type identifier and the first quantity of the first cryptocurrency, and the first expense condition corresponding to the first output account address;
record the first input item and the first output item as the first transaction record in the new block of the current node in the blockchain network;
determine the second input item according to the second source of the second cryptocurrency and the proof of expense of the second cryptocurrency;
determine the second output item according to the second output account address corresponding to the second cryptocurrency, the second type identifier and the second quantity of the second cryptocurrency, and the second expense condition corresponding to the second output account address; and
record the second input item and the second output item as the second transaction record in the new block of the current node in the blockchain network.
9 . The processing apparatus according to claim 7 , wherein the circuitry is configured to:
verify the first cryptocurrency according to the first source of the first cryptocurrency and the proof of expense of the first cryptocurrency;
verify the second cryptocurrency according to the second source of the second cryptocurrency and the proof of expense of the second cryptocurrency; and
determine that the transaction information is successfully verified in a case that the first cryptocurrency and the second cryptocurrency are both successfully verified.
10 . The processing apparatus according to claim 9 , wherein the circuitry is configured to:
search for the first expense condition of the first cryptocurrency according to the first source of the first cryptocurrency;
verify the first cryptocurrency according to the first expense condition of the first cryptocurrency and the proof of expense of the first cryptocurrency;
search for the second expense condition of the second cryptocurrency according to the second source of the second cryptocurrency; and
verify the second cryptocurrency according to the second expense condition of the second cryptocurrency and the proof of expense of the second cryptocurrency.
11 . The processing apparatus according to claim 10 , wherein
the first cryptocurrency is verified based on verification of the first signature according to the first public key information; and
the second cryptocurrency is verified based on verification of the second signature according to the second public key information.
12 . The processing apparatus according to claim 7 , wherein the transaction exchange rate is obtained from
contract information associated with two parties of the transaction, or
a third-party server device.
13 . A non-transitory computer-readable storage medium for implementing a transaction of cryptocurrencies of different types on a single blockchain, storing computer-readable instructions thereon, the computer-readable instructions, when executed by processing circuitry of a current node of a blockchain network, cause the processing circuitry to perform:
receiving a first transaction request that includes a first type identifier and a first quantity of first cryptocurrency;
receiving a second transaction request that includes a second type identifier of second cryptocurrency, the first type identifier and the second type identifier being different numbers that identify different asset types such that the transaction involves exchange of the cryptocurrencies of different types that include the first cryptocurrency and the second cryptocurrency;
obtaining a transaction exchange rate between the first cryptocurrency and the second cryptocurrency according to the first type identifier of the first cryptocurrency and the second type identifier of the second cryptocurrency;
determining a second quantity of the second cryptocurrency based on the first quantity of the first cryptocurrency and the transaction exchange rate;
verifying transaction information of the transaction, the transaction information including at least the first type identifier, the first quantity of the first cryptocurrency, the second type identifier, and the second quantity of the second cryptocurrency;
recording, after the transaction information is successfully verified, transaction record information corresponding to the transaction involving the cryptocurrencies of different types in a new block of the current node of the blockchain network, the transaction record information indicating at least a first transaction record and a second transaction record, the first transaction record including a first input item and a first output item corresponding to the first cryptocurrency, and the second transaction record including a second input item and a second output item corresponding to the second cryptocurrency;
broadcasting the new block to other nodes in the blockchain network;
receiving verification results of the other nodes; and
adding the new block to the single blockchain of the current node according to the verification results, wherein the single blockchain is configured to store a plurality of blocks of different transactions of the cryptocurrencies of the different types;
the new block added to the single blockchain includes:
a timestamp indicative of a time when the new block is created,
transaction exchange rate information indicating the transaction exchange rate,
the transaction record information indicating the first transaction record and the second transaction record, and
a unique identifier generated based on a hash calculation of at least a combination of the first transaction record and the second transaction record in the transaction record information;
the first input item includes a first source of the first cryptocurrency, the first type identifier of the first cryptocurrency, the first quantity of the first cryptocurrency, and a proof of expense of the first cryptocurrency that includes a first signature generated with a first private key;
the second input item includes a second source of the second cryptocurrency, the second type identifier of the second cryptocurrency, the second quantity of the second cryptocurrency, and a proof of expense of the second cryptocurrency that includes a second signature generated with a second private key;
the first output item includes a first output account address corresponding to the first cryptocurrency, the first type identifier of the first cryptocurrency, the first quantity of the first cryptocurrency, and a first expense condition of the first cryptocurrency that includes first public key information; and
the second output item includes a second output account address corresponding to the second cryptocurrency, the second type identifier of the second cryptocurrency, the second quantity of the second cryptocurrency, and a second expense condition of the second cryptocurrency that includes second public key information.
14 . The non-transitory computer-readable storage medium according to claim 13 , wherein the computer-readable instructions, when executed by the processing circuitry, further cause the processing circuitry to perform:
determining the first input item according to the first source of the first cryptocurrency and the proof of expense of the first cryptocurrency;
determining the first output item according to the first output account address corresponding to the first cryptocurrency, the first type identifier and the first quantity of the first cryptocurrency, and the first expense condition corresponding to the first output account address;
recording the first input item and the first output item as the first transaction record in the new block of the current node in the blockchain network;
determining the second input item according to the second source of the second cryptocurrency and the proof of expense of the second cryptocurrency;
determining the second output item according to the second output account address corresponding to the second cryptocurrency, the second type identifier and the second quantity of the second cryptocurrency, and the second expense condition corresponding to the second output account address; and
recording the second input item and the second output item as the second transaction record in the new block of the current node in the blockchain network.
15 . The non-transitory computer-readable storage medium according to claim 13 , wherein the computer-readable instructions, when executed by the processing circuitry, cause the processing circuitry to perform:
verifying the first cryptocurrency according to the first source of the first cryptocurrency and the proof of expense of the first cryptocurrency;
verifying the second cryptocurrency according to the second source of the second cryptocurrency and the proof of expense of the second cryptocurrency; and
determining that the transaction information is successfully verified in a case that the first cryptocurrency and the second cryptocurrency are both successfully verified.
16 . The non-transitory computer-readable storage medium according to claim 15 , wherein the computer-readable instructions, when executed by the processing circuitry, cause the processing circuitry to perform:
searching for the first expense condition of the first cryptocurrency according to the first source of the first cryptocurrency;
verifying the first cryptocurrency according to the first expense condition of the first cryptocurrency and the proof of expense of the first cryptocurrency;
searching for the second expense condition of the second cryptocurrency according to the second source of the second cryptocurrency; and
verifying the second cryptocurrency according to the second expense condition of the second cryptocurrency and the proof of expense of the second cryptocurrency.
17 . The non-transitory computer-readable storage medium according to claim 16 , wherein
the verifying the first cryptocurrency includes:
verifying the first signature according to the first public key information; and
the verifying the second cryptocurrency includes:
verifying the second signature according to the second public key information.
18 . The non-transitory computer-readable storage medium according to claim 13 , wherein the transaction exchange rate is obtained from
contract information associated with two parties of the transaction, or
a third-party server device.