CN114372879A - Transaction method, computer device and storage medium - Google Patents

Transaction method, computer device and storage medium Download PDF

Info

Publication number
CN114372879A
CN114372879A CN202110731098.8A CN202110731098A CN114372879A CN 114372879 A CN114372879 A CN 114372879A CN 202110731098 A CN202110731098 A CN 202110731098A CN 114372879 A CN114372879 A CN 114372879A
Authority
CN
China
Prior art keywords
transaction
complete
script
temporary
public key
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
CN202110731098.8A
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.)
Hangzhou Fuzamei Technology Co Ltd
Original Assignee
Hangzhou Fuzamei 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 Hangzhou Fuzamei Technology Co Ltd filed Critical Hangzhou Fuzamei Technology Co Ltd
Priority to CN202110731098.8A priority Critical patent/CN114372879A/en
Publication of CN114372879A publication Critical patent/CN114372879A/en
Pending legal-status Critical Current

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
    • G06Q40/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/04Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange

Abstract

The invention provides a transaction method, computer equipment and a storage medium, which relate to the technical field of block chains and the like, and the method comprises the following steps: responding to a first transaction rule determined by a current user and a second user, generating a first locking script, and generating a first transaction address according to the first locking script; generating an unsigned first transaction and calculating a first transaction hash for the unsigned first transaction; generating a first temporary transaction; calling a bitcoin block link port to generate a first unlocking script according to the first locking script, the first temporary transaction and a private key held by the current user; generating a public key of a first transaction sender according to the first locking script, and constructing first signature information of the first transaction without signature; and generating a complete first transaction according to the unsigned first transaction and the first signature information and sending the complete first transaction to the blockchain network. The method and the device enable integration of the non-bit currency block chain to be adapted to the bit currency script.

Description

Transaction method, computer device and storage medium
Technical Field
The present application relates to the field of blockchain technology, and in particular, to a transaction method, a computer device, and a storage medium.
Background
The bit currency script is a stack type script language, and the bit currency transaction verification is composed of a locking script and an unlocking script. A UTXO, with a corresponding lock script, must provide the correct unlock script before the UTXO can be legally spent.
Because the bit currency script is based on the original technology of the bit currency chain, and is bound with the transaction of the bit currency block chain, the UTXO model and the like, the bit currency script cannot be simply transferred to other block chain systems.
Disclosure of Invention
In view of the above-mentioned deficiencies or inadequacies in the prior art, it would be desirable to provide a transaction method, computer device, and storage medium that integrate bitcoin scripts.
In a first aspect, the present invention provides a transaction method applicable to a client, where the client and a block link point can both call a bitcoin block link interface, and the method includes:
responding to a first transaction rule determined by a current user and a second user, generating a first locking script, and generating a first transaction address according to the first locking script;
generating an unsigned first transaction and calculating a first transaction hash for the unsigned first transaction; wherein the first transaction initiator address of the unsigned first transaction is the first transaction address;
generating a first temporary transaction; wherein, the first temporary transaction only comprises one input UTXO, and the first index hash of the input UTXO of the first temporary transaction is the first transaction hash;
calling a bitcoin block link port to generate a first unlocking script according to the first locking script, the first temporary transaction and a private key held by the current user;
generating a public key of a first transaction sender according to the first locking script, and constructing first signature information of the first transaction without signature; the first signature information comprises a first identifier, a first transaction sender public key, a first locking script and a first unlocking script, wherein the first identifier is a bitcoin script verification type;
generating a complete first transaction according to the unsigned first transaction and the first signature information, and sending the complete first transaction to the blockchain network, so that the blockchain node:
when the complete first transaction is judged to be a transaction of a bitcoin script verification type according to the first identifier in the complete first transaction, judging whether a first transaction sender public key in the complete first transaction is matched with a first transaction initiator address in the complete first transaction, and judging whether a first locking script in the complete first transaction is matched with a first transaction sender public key in the complete first transaction;
when the judgment is yes, generating a second temporary transaction; wherein the second temporary transaction only comprises one input UTXO, and the second index hash of the input UTXO of the second temporary transaction is the first transaction hash;
calling a bitcoin block link interface to judge whether the second temporary transaction is legal or not according to the first locking script in the complete first transaction, the first unlocking script in the complete first transaction and the second temporary transaction: if it is legal, the complete first transaction is executed.
In a second aspect, the present invention provides a transaction method applicable to a blockchain node, where a client and the blockchain node can both call a bitcoin blockchain interface, the method including:
receiving a complete first transaction; the method comprises the steps that a first client of a first user generates and sends a complete first transaction to a blockchain network according to unsigned first transaction and first signature information of the unsigned first transaction, the first transaction initiator address of the unsigned first transaction is a first transaction address, the first transaction address is generated according to a first locking script, the first locking script is generated according to a first transaction rule determined by the first user and a second user, the first signature information is constructed according to the unsigned first transaction, the first signature information comprises a first identifier which is identified as a bitcoin script verification type, a first transaction sender public key, a first locking script and a first unlocking script, the first transaction sender public key is generated according to the first locking script, and the first unlocking script is generated by the first client by calling a bitcoin blockchain port according to the first locking script, the first temporary transaction, Generating a private key held by a first user, wherein the first temporary transaction only comprises one input UTXO, and a first index hash of the input UTXO of the first temporary transaction is a first transaction hash of an unsigned first transaction;
when the complete first transaction is judged to be a transaction of a bitcoin script verification type according to the first identifier in the complete first transaction, judging whether a first transaction sender public key in the complete first transaction is matched with a first transaction initiator address in the complete first transaction, and judging whether a first locking script in the complete first transaction is matched with a first transaction sender public key in the complete first transaction;
when the judgment is yes, generating a second temporary transaction; wherein the second temporary transaction only comprises one input UTXO, and the second index hash of the input UTXO of the second temporary transaction is the first transaction hash;
calling a bitcoin block link interface to judge whether the second temporary transaction is legal or not according to the first locking script in the complete first transaction, the first unlocking script in the complete first transaction and the second temporary transaction: if it is legal, the complete first transaction is executed.
In a third aspect, the present invention also provides an apparatus comprising one or more processors and a memory, wherein the memory contains instructions executable by the one or more processors to cause the one or more processors to perform a transaction method provided in accordance with embodiments of the present invention.
In a fourth aspect, the present invention also provides a storage medium storing a computer program that causes a computer to execute a transaction method provided according to embodiments of the present invention.
The transaction method, the computer device and the storage medium provided by the embodiments of the present invention generate a first locked script by determining a first transaction rule in response to a current user and a second user, and generate a first transaction address according to the first locked script; generating an unsigned first transaction and calculating a first transaction hash for the unsigned first transaction; generating a first temporary transaction; calling a bitcoin block link port to generate a first unlocking script according to the first locking script, the first temporary transaction and a private key held by the current user; generating a public key of a first transaction sender according to the first locking script, and constructing first signature information of the first transaction without signature; and generating a complete first transaction according to the unsigned first transaction and the first signature information and sending the complete first transaction to the blockchain network, so that the non-bitcoin blockchain integration is matched with the bitcoin script.
Drawings
Other features, objects and advantages of the present application will become more apparent upon reading of the following detailed description of non-limiting embodiments thereof, made with reference to the accompanying drawings in which:
fig. 1 is a flowchart of a transaction method according to an embodiment of the present invention.
Fig. 2 is a flow chart of another transaction method according to an embodiment of the invention.
Fig. 3 is a schematic structural diagram of a computer device according to an embodiment of the present invention.
Detailed Description
The present application will be described in further detail with reference to the following drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the relevant invention and not restrictive of the invention. It should be noted that, for convenience of description, only the portions related to the present invention are shown in the drawings.
It should be noted that the embodiments and features of the embodiments in the present application may be combined with each other without conflict. The present application will be described in detail below with reference to the embodiments with reference to the attached drawings.
Fig. 1 is a flowchart of a transaction method according to an embodiment of the present invention. As shown in fig. 1, in this embodiment, the present invention provides a transaction method applicable to a client, where both the client and a chunk link point can call a bitcoin chunk chain interface, and the method includes:
s12: responding to a first transaction rule determined by a current user and a second user, generating a first locking script, and generating a first transaction address according to the first locking script;
s13: generating an unsigned first transaction and calculating a first transaction hash for the unsigned first transaction; wherein the first transaction initiator address of the unsigned first transaction is the first transaction address;
s14: generating a first temporary transaction; wherein, the first temporary transaction only comprises one input UTXO, and the first index hash of the input UTXO of the first temporary transaction is the first transaction hash;
s15: calling a bitcoin block link port to generate a first unlocking script according to the first locking script, the first temporary transaction and a private key held by the current user;
s16: generating a public key of a first transaction sender according to the first locking script, and constructing first signature information of the first transaction without signature; the first signature information comprises a first identifier, a first transaction sender public key, a first locking script and a first unlocking script, wherein the first identifier is a bitcoin script verification type;
s17: generating a complete first transaction according to the unsigned first transaction and the first signature information, and sending the complete first transaction to the blockchain network, so that the blockchain node:
when the complete first transaction is judged to be a transaction of a bitcoin script verification type according to the first identifier in the complete first transaction, judging whether a first transaction sender public key in the complete first transaction is matched with a first transaction initiator address in the complete first transaction, and judging whether a first locking script in the complete first transaction is matched with a first transaction sender public key in the complete first transaction;
when the judgment is yes, generating a second temporary transaction; wherein the second temporary transaction only comprises one input UTXO, and the second index hash of the input UTXO of the second temporary transaction is the first transaction hash;
calling a bitcoin block link interface to judge whether the second temporary transaction is legal or not according to the first locking script in the complete first transaction, the first unlocking script in the complete first transaction and the second temporary transaction: if it is legal, the complete first transaction is executed.
Specifically, generating the first transaction address according to the first locking script includes performing hash operation on the first locking script twice to generate the first transaction address, generating the first transaction sender public key according to the first locking script includes performing hash operation on the first locking script once to generate the first transaction sender public key, determining whether the first transaction sender public key in the complete first transaction matches the first transaction initiator address in the complete first transaction, determining whether the first locking script in the complete first transaction matches the first transaction sender public key in the complete first transaction includes performing hash operation on the first transaction sender public key in the complete first transaction once, and determining whether a value after the hash operation is the same as the first transaction initiator address in the complete first transaction; performing a hash operation on the first locking script in the complete first transaction, and judging whether a value after the hash operation is the same as a public key of a first transaction sender in the complete first transaction; before generating the first transaction without signature, generating a first transfer transaction for transferring to the first transaction address and sending the first transfer transaction to the blockchain network, so that when the blockchain node successfully executes the first transfer transaction, transfer a pass-certificate specified by the first transfer transaction from the first user address of the first user to the first transaction address;
suppose user a and user b determine a transaction rule (user a transfers 0.1btc to user b);
in response to the determination of the transaction rule by the user a and the user b, the client of the user a executes step S12, generates a lock script S1(OP _ DUP OP _ HASH160< a' S public address > OP _ equal value OP _ check ksig), and generates a first transaction address addr (x) according to S1, where addr (x) is HASH (HASH (S1));
the client of the user a generates a transfer transaction tx0 transferred to addr (X) and sends the transfer transaction tx0 to the blockchain network, and when the execution of tx0 is successful, the blockchain node transfers 0.1btc in addr (a) to addr (X) (assuming that the certificate designated by tx0 is 0.1 btc);
the client of the user a performs the step S13, generates unsigned tx1, and calculates a transaction hash of unsigned tx1 (tx 1); the transaction initiator address of unsigned tx1 is addr (x);
the client of the user a executes the step S14 to generate a temporary transaction tx 2; tx2 includes only one input UTXO, the index of the input UTXO for tx2 is hashed to hash (tx 1); it should be understood by those skilled in the art that the lock script and the unlock script are based on transactions of bitcoin blockchains, but not transactions of bitcoin blockchains, when the lock script and the unlock script are constructed, a temporary transaction tx2 and a subsequent temporary transaction tx3 are constructed to constrain unsigned tx1, tx2 and tx3 are transactions conforming to rules of bitcoin blockchains, so tx2 and tx3 both need to be uniquely input to UTXO, and the index hash of the UTXO is hash (tx1) so that a piece of tx2 and tx3 includes unsigned tx1 (also ensuring the corresponding relationship between tx2 and tx3 and unsigned tx1), ensuring that unsigned tx1 cannot be tampered, ensuring that "whether a first sender in a complete first transaction matches a first public key in a complete first transaction of a complete first transaction sender in a complete first transaction, and whether a first public key in a complete transaction initiator of a first transaction can be matched with a first public key in a complete transaction" judgment whether a complete first public key of a first transaction in a complete transaction can be matched with a first public key of a first transaction initiation party "judgment All are judged to be yes; assuming that the index hash of the unique input UTXO for tx2 or tx3 is not a hash (tx1), this indicates that unsigned tx1 was tampered with, resulting in a failure of tx1 execution;
the client of the user a executes the step S15, invokes the bitcoin block link port to generate an unlocking script S2(< a 'S signature > < a' S public key >) according to S1, tx2 and private (a);
the client of the user a executes the step S16, generates a transaction sender public key P1, where P1 is hash (S1), and constructs signature information of unsigned tx 1; the signature information of the tx1 comprises identifications btcgcript, P1, S1 and S2 which are identified as bitcoin script verification types;
the client of the user a executes the step S17, generates complete tx1 according to the unsigned tx1 and the signature information, and sends the complete tx1 to the blockchain network;
the blockchain node judges that the complete tx1 is the transaction of the bitcoin script verification type according to the btcscript in the tx 1;
carrying out hash operation on P1 in the complete tx1 by the block chain node, and judging whether the hash (P1) is the same as the addr (X); performing hash operation on S1 in the complete tx1, and judging whether the hash (S1) is the same as the P1;
since addr (x) is hash (hash (S1)), P1 is hash (S1), and all the above judgments are yes, the block link point generates a temporary transaction tx 3; tx3 includes only one input UTXO, the index of the input UTXO for tx3 is hashed to hash (tx 1); those skilled in the art will appreciate that when the above determinations are not all yes, the tx1 execution fails; those skilled in the art will also appreciate that the locking script S1 is constrained to cost 0.1btc, the unlocking script S2 is constrained to cost 0.1btc, and on the basis of ensuring that S1 and S2 are correct, if the transaction sender address of tx1 is not defined, the sender address may be any address, corresponding to the money that can be spent at any address, although S1 and S2 are correct; therefore, the transaction sender address of tx1 needs to be defined and must be generated according to S1;
the blockchain node calls the bitcoin blockchain port to judge whether tx3 is legal according to S1, S2 and tx3 in the complete tx1, namely, the blockchain node executes < a ' S signature > < a ' S public key > OP _ DUP OP _ HASH160< a ' S public address > OP _ EQUALV ERIFOP _ CHECKSKIG;
when the judgment is legal, complete tx1 is executed, and 0.1btc is divided from addr (X) to addr (b). It will be understood by those skilled in the art that if there is not at least 0.1btc in addr (x), then execution of the complete tx1 fails.
In further embodiments, the "generating the first transaction address according to the first locking script" may also be configured according to actual requirements, for example, performing three times of hash on the first locking script to generate the first transaction address, and correspondingly, the "generating the first transaction sender public key according to the first locking script" should be configured to perform two times of hash operations on the first locking script to generate the first transaction sender public key; correspondingly, "judging whether a first transaction sender public key in the complete first transaction is matched with a first transaction initiator address in the complete first transaction, and judging whether a first locking script in the complete first transaction is matched with a first transaction sender public key in the complete first transaction" should be configured to perform a hash operation on the first transaction sender public key in the complete first transaction, and judging whether a value after the hash operation is the same as the first transaction initiator address in the complete first transaction; performing two times of hash operation on the first locking script in the complete first transaction, and judging whether the value after the hash operation is the same as the public key of a first transaction sender in the complete first transaction; the same technical effect can be achieved.
In further embodiments, the user a may also delegate other clients to generate the above-mentioned transfer transaction, and as long as the user a notifies the delegated client of addr (x), the same technical effect may be achieved.
In further embodiments, the client of the user a may also configure the condition for generating the unsigned first transaction according to the actual demand; for example, the client of user a generates an unsigned first transaction only if it detects at least 0.1btc in addr (x); the same technical effect can be achieved.
The above embodiments enable non-bitcoin blockchain integration to be adapted to bitcoin scripts.
Preferably, after generating a complete first transaction according to the unsigned first transaction and the first signature information and sending the complete first transaction to the blockchain network, the method further includes:
deleting the first temporary transaction after the first period of time;
after the complete first transaction is executed, the method further comprises the following steps:
after a second length of time, the second temporary transaction is deleted.
The first temporary transaction and the second temporary transaction are not really uplink-required transactions and should be deleted to release the cache; when the cached first temporary transaction is used for recovering after the shutdown of the client, the first temporary transaction does not need to be generated again, and when the cached second temporary transaction is used for recovering after the shutdown of the blockchain node, the second temporary transaction does not need to be generated again; in further embodiments, the first duration may be the same as the second duration; in addition, in further embodiments, a mechanism for deleting the temporary transaction may be configured according to actual requirements, for example, the mechanism is configured to delete the first temporary transaction after the first block height, and delete the second temporary transaction after the second block height; or, the first temporary transaction is directly deleted after the complete first transaction is generated, and the second temporary transaction is directly deleted after the complete first transaction is executed, so that the same technical effect can be realized.
Preferably, generating the first transaction address according to the first locking script comprises:
performing two times of hash operation on the first locking script to generate a first transaction address;
generating the first transaction sender public key according to the first locking script comprises:
performing a hash operation on the first locking script to generate a public key of a first transaction sender;
determining whether the first transaction sender public key in the complete first transaction matches the first transaction initiator address in the complete first transaction, and determining whether the first locking script in the complete first transaction matches the first transaction sender public key in the complete first transaction comprises:
performing one-time Hash operation on the public key of the first transaction sender in the complete first transaction, and judging whether the value after the Hash operation is the same as the address of the first transaction initiator in the complete first transaction;
and performing one-time Hash operation on the first locking script in the complete first transaction, and judging whether the value after the Hash operation is the same as the public key of the first transaction sender in the complete first transaction.
The transaction principle of the above embodiment can refer to the method shown in fig. 1, and is not described herein again.
Preferably, before generating the first unsigned transaction, the method further comprises:
and generating a first transfer transaction transferring to the first transaction address and sending the first transfer transaction to the blockchain network, so that when the blockchain node successfully executes the first transfer transaction, the block chain node transfers the evidence specified by the first transfer transaction from the first user address of the first user to the first transaction address.
The transaction principle of the above embodiment can refer to the method shown in fig. 1, and is not described herein again.
Fig. 2 is a flow chart of another transaction method according to an embodiment of the invention. The method shown in fig. 2 may be used in conjunction with the method shown in fig. 1. As shown in fig. 2, in this embodiment, the present invention provides a transaction method applicable to a blockchain node, where a client and the blockchain node can both call a bitcoin blockchain interface, and the method includes:
s22: receiving a complete first transaction; the method comprises the steps that a first client of a first user generates and sends a complete first transaction to a blockchain network according to unsigned first transaction and first signature information of the unsigned first transaction, the first transaction initiator address of the unsigned first transaction is a first transaction address, the first transaction address is generated according to a first locking script, the first locking script is generated according to a first transaction rule determined by the first user and a second user, the first signature information is constructed according to the unsigned first transaction, the first signature information comprises a first identifier which is identified as a bitcoin script verification type, a first transaction sender public key, a first locking script and a first unlocking script, the first transaction sender public key is generated according to the first locking script, and the first unlocking script is generated by the first client by calling a bitcoin blockchain port according to the first locking script, the first temporary transaction, Generating a private key held by a first user, wherein the first temporary transaction only comprises one input UTXO, and a first index hash of the input UTXO of the first temporary transaction is a first transaction hash of an unsigned first transaction;
s23: when the complete first transaction is judged to be a transaction of a bitcoin script verification type according to the first identifier in the complete first transaction, judging whether a first transaction sender public key in the complete first transaction is matched with a first transaction initiator address in the complete first transaction, and judging whether a first locking script in the complete first transaction is matched with a first transaction sender public key in the complete first transaction;
s24: when the judgment is yes, generating a second temporary transaction; wherein the second temporary transaction only comprises one input UTXO, and the second index hash of the input UTXO of the second temporary transaction is the first transaction hash;
s25: calling a bitcoin block link interface to judge whether the second temporary transaction is legal or not according to the first locking script in the complete first transaction, the first unlocking script in the complete first transaction and the second temporary transaction: if it is legal, the complete first transaction is executed.
The transaction principle of the above embodiment can refer to the method shown in fig. 1, and is not described herein again.
Fig. 3 is a schematic structural diagram of a computer device according to an embodiment of the present invention.
As shown in fig. 3, as another aspect, the present application also provides a computer apparatus including one or more Central Processing Units (CPUs) 301 that can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM)302 or a program loaded from a storage section 308 into a Random Access Memory (RAM) 303. In the RAM303, various programs and data necessary for the operation of the computer apparatus are also stored. The CPU301, ROM302, and RAM303 are connected to each other via a bus 304. An input/output (I/O) interface 305 is also connected to bus 304.
The following components are connected to the I/O interface 305: an input portion 306 including a keyboard, a mouse, and the like; an output section 307 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage section 308 including a hard disk and the like; and a communication section 309 including a network interface card such as a LAN card, a modem, or the like. The communication section 309 performs communication processing via a network such as the internet. A drive 310 is also connected to the I/O interface 305 as needed. A removable medium 311 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 310 as necessary, so that a computer program read out therefrom is mounted into the storage section 308 as necessary.
In particular, according to an embodiment of the present disclosure, the method described in any of the above embodiments may be implemented as a computer software program. For example, embodiments of the present disclosure include a computer program product comprising a computer program tangibly embodied on a machine-readable medium, the computer program comprising program code for performing any of the methods described above. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 309, and/or installed from the removable medium 311.
As yet another aspect, the present application also provides a computer-readable storage medium, which may be the computer-readable storage medium included in the apparatus of the above-described embodiment; or it may be a computer-readable storage medium that exists separately and is not assembled into a computer device. The computer readable storage medium stores one or more programs for use by one or more processors in performing the methods described in the present application.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units or modules described in the embodiments of the present application may be implemented by software or hardware. The described units or modules may also be provided in a processor, for example, each of the described units may be a software program provided in a computer or a mobile intelligent device, or may be a separately configured hardware device. Wherein the designation of a unit or module does not in some way constitute a limitation of the unit or module itself.
The above description is only a preferred embodiment of the application and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the invention herein disclosed is not limited to the particular combination of features described above, but also encompasses other arrangements formed by any combination of the above features or their equivalents without departing from the spirit of the present application. For example, the above features may be replaced with (but not limited to) features having similar functions disclosed in the present application.

Claims (9)

1. A transaction method, wherein a client and a block link point can both call a bitcoin block link interface, the method being applicable to the client, the method comprising:
responding to a first transaction rule determined by a current user and a second user, generating a first locking script, and generating a first transaction address according to the first locking script;
generating an unsigned first transaction and calculating a first transaction hash for the unsigned first transaction; wherein a first transaction initiator address of the unsigned first transaction is the first transaction address;
generating a first temporary transaction; wherein the first temporary transaction only includes one input UTXO, and a first indexed hash of the input UTXO of the first temporary transaction is the first transaction hash;
calling a bitcoin block link port to generate a first unlocking script according to the first locking script, the first temporary transaction and a private key held by a current user;
generating a public key of a first transaction sender according to the first locking script, and constructing first signature information of the unsigned first transaction; the first signature information comprises a first identifier which is identified as a bitcoin script verification type, a public key of the first transaction sender, the first locking script and the first unlocking script;
generating a complete first transaction according to the unsigned first transaction and the first signature information, and sending the complete first transaction to a block chain network, so that a block chain node:
when the complete first transaction is judged to be a transaction of a bitcoin script verification type according to the first identifier in the complete first transaction, judging whether a first transaction sender public key in the complete first transaction is matched with a first transaction initiator address in the complete first transaction, and judging whether a first locking script in the complete first transaction is matched with the first transaction sender public key in the complete first transaction;
when the judgment is yes, generating a second temporary transaction; wherein the second temporary transaction only includes one input UTXO, a second indexed hash of the input UTXO of the second temporary transaction being the first transaction hash;
calling a bitcoin block link interface to judge whether the second temporary transaction is legal or not according to the first locking script in the complete first transaction, the first unlocking script in the complete first transaction and the second temporary transaction: if the transaction is legal, the complete first transaction is executed.
2. The method of claim 1, wherein after generating the complete first transaction from the unsigned first transaction and the first signature information and sending the complete first transaction to a blockchain network, the method further comprises:
deleting the first temporary transaction after a first length of time;
after the performing the complete first transaction, further comprising:
deleting the second temporary transaction after a second length of time.
3. The method of claim 1, wherein generating a first transaction address according to the first locking script comprises:
performing two times of hash operation on the first locking script to generate a first transaction address;
the generating a first transaction sender public key according to the first locking script comprises:
performing a hash operation on the first locking script to generate a first transaction sender public key;
the determining whether the first transaction sender public key in the complete first transaction matches a first transaction initiator address in the complete first transaction, and the determining whether the first locking script in the complete first transaction matches the first transaction sender public key in the complete first transaction comprises:
performing a hash operation on the public key of the first transaction sender in the complete first transaction, and judging whether the value after the hash operation is the same as the address of the first transaction initiator in the complete first transaction;
and performing one-time hash operation on the first locking script in the complete first transaction, and judging whether the value after the hash operation is the same as the public key of the first transaction sender in the complete first transaction.
4. The method of claim 1, wherein prior to generating the unsigned first transaction, further comprising:
and generating a first transfer transaction transferring to the first transaction address and sending the first transfer transaction to a block chain network, so that when the block chain node successfully executes the first transfer transaction, the block chain node transfers the evidence specified by the first transfer transaction from the first user address of the first user to the first transaction address.
5. A transaction method, wherein a client and a blockchain node can both call a bitcoin blockchain interface, the method being applicable to blockchain nodes, the method comprising:
receiving a complete first transaction; the complete first transaction is generated by a first client of a first user according to an unsigned first transaction and first signature information of the unsigned first transaction and sent to a blockchain network, a first transaction initiator address of the unsigned first transaction is a first transaction address, the first transaction address is generated according to a first locking script, the first locking script is generated according to a first transaction rule determined by the first user and a second user, the first signature information is constructed according to the unsigned first transaction, the first signature information comprises a first identifier which is identified as a bitcoin script verification type, a first transaction sender public key, a first locking script and a first unlocking script, the first transaction sender is generated according to the first locking script, and the first unlocking script is generated by the first client calling a bitcoin blockchain interface according to the first locking script, A first temporary transaction, a private key held by the first user being generated, the first temporary transaction comprising only one input UTXO, a first indexed hash of the input UTXO of the first temporary transaction being a first transaction hash of the unsigned first transaction;
when the complete first transaction is judged to be a transaction of a bitcoin script verification type according to the first identifier in the complete first transaction, judging whether a first transaction sender public key in the complete first transaction is matched with a first transaction initiator address in the complete first transaction, and judging whether a first locking script in the complete first transaction is matched with the first transaction sender public key in the complete first transaction;
when the judgment is yes, generating a second temporary transaction; wherein the second temporary transaction only includes one input UTXO, a second indexed hash of the input UTXO of the second temporary transaction being the first transaction hash;
calling a bitcoin block link interface to judge whether the second temporary transaction is legal or not according to the first locking script in the complete first transaction, the first unlocking script in the complete first transaction and the second temporary transaction: if the transaction is legal, the complete first transaction is executed.
6. The method of claim 1, wherein the first temporary transaction is deleted after a first length of time that the complete first transaction is sent to a blockchain network;
after the performing the complete first transaction, further comprising:
deleting the second temporary transaction after a second length of time.
7. The method of claim 5, wherein the first transaction address is obtained by hashing the first locked script twice; the public key of the first transaction sender is obtained by carrying out hash operation on the first locking script for one time;
the determining whether the first transaction sender public key in the complete first transaction matches a first transaction initiator address in the complete first transaction, and the determining whether the first locking script in the complete first transaction matches the first transaction sender public key in the complete first transaction comprises:
performing a hash operation on the public key of the first transaction sender in the complete first transaction, and judging whether the value after the hash operation is the same as the address of the first transaction initiator in the complete first transaction;
and performing one-time hash operation on the first locking script in the complete first transaction, and judging whether the value after the hash operation is the same as the public key of the first transaction sender in the complete first transaction.
8. A computer device, the device comprising:
one or more processors;
a memory for storing one or more programs,
the one or more programs, when executed by the one or more processors, cause the one or more processors to perform the method recited in any of claims 1-7.
9. A storage medium storing a computer program, characterized in that the program, when executed by a processor, implements the method according to any one of claims 1-7.
CN202110731098.8A 2021-06-29 2021-06-29 Transaction method, computer device and storage medium Pending CN114372879A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110731098.8A CN114372879A (en) 2021-06-29 2021-06-29 Transaction method, computer device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110731098.8A CN114372879A (en) 2021-06-29 2021-06-29 Transaction method, computer device and storage medium

Publications (1)

Publication Number Publication Date
CN114372879A true CN114372879A (en) 2022-04-19

Family

ID=81138614

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110731098.8A Pending CN114372879A (en) 2021-06-29 2021-06-29 Transaction method, computer device and storage medium

Country Status (1)

Country Link
CN (1) CN114372879A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116051088A (en) * 2023-04-03 2023-05-02 布比(北京)网络技术有限公司 Transaction method and device based on non-spent transaction output model and electronic equipment

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116051088A (en) * 2023-04-03 2023-05-02 布比(北京)网络技术有限公司 Transaction method and device based on non-spent transaction output model and electronic equipment

Similar Documents

Publication Publication Date Title
US11336465B2 (en) Sending cross-chain authenticatable messages
US11343103B2 (en) Sending cross-chain authenticatable messages
CN111461723B (en) Data processing system, method and device based on block chain
US11949789B2 (en) Blockchain-enabled computing
CN110958110B (en) Block chain private data management method and system based on zero knowledge proof
US11336451B2 (en) Cross-blockchain resource transmission
CN110321735B (en) Business handling method, system and storage medium based on zero knowledge certification
CN109951546B (en) Transaction request processing method, device, equipment and medium based on intelligent contract
CN112583811B (en) Wallet finding method, equipment and storage medium
US20200169389A1 (en) Creating a blockchain account and verifying blockchain transactions
US20200366486A1 (en) Method and apparatus for inter-blockchain transmission of authenticable message
CN114255031A (en) System for executing cross block chain of transaction, cross chain transaction method and equipment
CN111447069B (en) Low-frequency access data processing method based on block chain
CN110930153A (en) Block chain privacy data management method and system based on hidden third-party account
CN114372879A (en) Transaction method, computer device and storage medium
CN111260475A (en) Data processing method, block chain node point equipment and storage medium
KR20210033846A (en) Blockchain transaction method with reduced transaction size using cryptographic hash algorithm
CN111586013B (en) Network intrusion detection method, device, node terminal and storage medium
CN113225348B (en) Request anti-replay verification method and device
CN115310974A (en) Processing method, computer equipment and medium for cross-chain transaction
CN113706303B (en) Universal time delay transaction method, computer equipment and storage medium
CN113592651B (en) Delay transaction method, computer device and storage medium
CN111931210A (en) Access control method, device, equipment and computer storage medium
CN113205336B (en) Multiple signature transaction method, computer device and storage medium
CN113902441A (en) Multiple signature method, computer device, and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination