CN110322346B - Settable payment method and system supporting utxo model - Google Patents

Settable payment method and system supporting utxo model Download PDF

Info

Publication number
CN110322346B
CN110322346B CN201910262508.1A CN201910262508A CN110322346B CN 110322346 B CN110322346 B CN 110322346B CN 201910262508 A CN201910262508 A CN 201910262508A CN 110322346 B CN110322346 B CN 110322346B
Authority
CN
China
Prior art keywords
input
transaction
address
type
utxo
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.)
Active
Application number
CN201910262508.1A
Other languages
Chinese (zh)
Other versions
CN110322346A (en
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.)
Wuhan Tianyu Information Industry Co Ltd
Original Assignee
Wuhan Tianyu Information Industry 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 Wuhan Tianyu Information Industry Co Ltd filed Critical Wuhan Tianyu Information Industry Co Ltd
Priority to CN201910262508.1A priority Critical patent/CN110322346B/en
Publication of CN110322346A publication Critical patent/CN110322346A/en
Application granted granted Critical
Publication of CN110322346B publication Critical patent/CN110322346B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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 discloses a condition settable payment method and system supporting a uxto model, which relate to the technical field of block chains and comprise a transaction initiator end, a transaction application request is constructed for spending money transaction, the transaction application comprises input utxos, output utxos and constructed unlocking chain code names and parameters according to the type of a collection address of the input utxos; the constructed transaction application request is sent to the fabric network; the fabric chain code analyzes and verifies the transaction application request to form the standard output readsets and writesets of the fabric, wherein the readsets represent the state set which needs to be read from the account book for the transaction, and the writesets represent the state set which needs to be written to the account book. The invention can set different payment conditions according to different application scenes.

Description

Settable payment method and system supporting utxo model
Technical Field
The invention relates to the technical field of block chains, in particular to a settable payment method and system for supporting a utxo model.
Background
The blockchain originates from the book-to-peer electronic case system, which is a continuously growing distributed database that is commonly maintained by multiple parties, and has attracted wide attention due to the characteristics of decentralization, collective maintenance, public transparency, non-tampering, traceability, and the like.
In bitchoice, there are four payment types, P2PK (path to public key), P2PKH (path to public key hash), ms (multiple signature), and P2SH (path to script hash), among which P2SH is the most flexible, and takes the hash value of the lock script as the recipient address, and when spending money, the unlock script and the lock script are put together and interpreted by the virtual machine, and when the result is true, the unlock script may spend money, and if the result is false, the unlock script may not spend money. The existence of the lock script allows a user to set various types of transaction scenarios, but has a problem in that the unlock script needs to be saved in the transaction as an input of the transaction. UTXO refers to an open Transaction Output, which is a concept proposed in the bitjoin network, and in a Transaction, one or more inputs are required to generate one or more outputs, which are "Unspent Transaction outputs", i.e., UTXO.
Hyperhedger Fabric is a block chain scheme with pluggable functional module architecture, aims to create an open-source super account book which is jointly maintained by a community, is convenient for a user to build an enterprise-level block chain network, and can update and inquire a transaction account book in real time by utilizing the network, and the account book can not be modified. There is no token, nor payment function in the Fabric system. But may implement the token functionality itself based on the Fabric architecture, with both the account model and the UTXO model. The following problems exist based on the account model: since it is not acceptable for retail companies to trade at high frequency because two tokens cannot be driven into the same account during the block generation time, UTXO model is currently widely adopted and IBM provides a UTXO model solution in one paper that can satisfy basic payments but lacks support for complex payment scenarios.
Disclosure of Invention
Aiming at the defects in the prior art, the invention aims to provide a condition-settable payment method supporting an utxo model, which can set different payment conditions according to different application scenes.
In order to achieve the above purposes, the technical scheme adopted by the invention is as follows:
the transaction initiator side constructs a transaction application request for the spending money transaction, wherein the transaction application comprises each input utxo, each output utxo, and an unlocking chain code name and parameters constructed according to the collection address type of the input utxo;
the constructed transaction application request is sent to the fabric network;
the fabric chain code analyzes and verifies the transaction application request to form the standard output readsets and the writings of the fabric, wherein the readsets represent the state set which needs to be read from the account book for the transaction, and the writings represent the state set which needs to be written to the account book.
On the basis of the technical scheme, the transaction application request specifically comprises the following steps:
request=(inputs;outputs;unlockcodeandpara)
wherein inputs is [ in ]1;in2;…;ini;…]Represents each utxo input; iniIs (txid. j), representing the jth output of the transaction txid; outputs [ [ (amount; owner; label); (amount; owner; label); …, respectively; (atmospheric; owner; label)]Each utxo representing an output; (account; ower; label) indicates that ower owns an amount of label money, ower refers to the shipping address, amount refers to the amount, and label refers to the money label; unlockcodeandpara [ unlockcodeandpara ]1;…;unlockcodeandparai;…]Wherein the unlockcodeandpara represents the name and parameters of the unlocking chain code constructed according to the type of the collection address input to utxoiAccording to the corresponding input iniIs constructed.
On the basis of the technical proposal, the device comprises a shell,
the collection address type comprises a publickeyhash type collection address and a scripthhash type collection address;
the public key hash type collection address takes the hash value of the public key as an address;
the script hash type collection address takes a hash value of the lock chain code as an address, and the script hash type collection address contains a name of the unlock chain code, specifically, scrpthash | | | hash (lock chain code) | the name of the unlock chain code.
On the basis of the technical scheme, each unlockcodeandparaiAccording to the corresponding input iniThe collection address type of (1) is constructed, and specifically comprises:
when iniIf the type of the collection address is publickeyhash type, then the collection address is unlockcodeandparaiContaining only iniA signature corresponding to a private key pair (inputs, outputs, nonce), wherein nonce is a random number;
when iniIf the collection address type is script hash type collection address, then unlockcodeandparaiContains iniAnd the name of the unlocking chain code specified by the address and the corresponding input parameter.
On the basis of the technical scheme, the fabric chain code analyzes and verifies the transaction application request to form the standard output reads and writes of the fabric, and the specific steps comprise:
the fabric chain code executes the GetState (in) function to obtain each input in of inputs in the transaction requestiJudging whether the state is over-flowering or not, if so, ending; if not, the program is put into readsets and is continuously executed,
judgment input iniIf the type of the gathering address is public key hash type gathering address, verifying whether sigs is correct or not; if the script hash type collection address is the script hash type collection address, the invokechainkcode function is operated to call the input iniThe method comprises the steps of specifying an unlocking script unlockcode and parameters, and judging whether the operation result of the unlocking script unlockcode is true or not; when sigs is verified to be correct and all inputs iniWhen the operation result of the unlocking script unlockcode is true, the execution is continued,
detecting whether the input value sum is equal to the output value sum, and the label of the input and output are matched, if and only if the input value sum is equal to the output value sum, and the label of the input and output are matched, continuing the execution,
running DelState (in) function to input iniAdding to writes, adding to input in writesiChanges the input state of the transaction request into spent state, and deletes the original input in the transaction requestiAnd the execution is continued,
for each output utxo of outputs in the transaction application request, the fabric chain code executes a PutState (txid j; out) function that writes (txid j, out) into the state book of the block chain, where out is (amount; owner; label).
The invention also provides a condition settable payment system supporting the utxo model, comprising:
the transaction initiator end is used for constructing a transaction application request for the spending money transaction and sending the constructed transaction application request to the fabric network end, wherein the transaction application comprises input utxo, output utxo, and an unlocking chain code name and parameters constructed according to the type of a collection address of the input utxo;
the fabric network end is used for driving the fabric chain code to analyze and verify the transaction application request to form fabric standard output readsets and writes, wherein the readsets represent the state set which needs to be read from the account book for the transaction, and the writes represent the state set which needs to be written to the account book.
On the basis of the above technical solution, the transaction application request constructed by the transaction initiator specifically includes:
request=(inputs;outputs;unlockcodeandpara)
wherein inputs is [ in ]1;in2;…;ini;…]Represents each utxo input; iniIs (txid. j), representing the jth output of the transaction txid; outputs [ [ (amount; owner; label); (amount; owner; label); …, respectively; (atmospheric; owner; label)]Each utxo representing an output; (account; ower; label) indicates that ower owns an amount of label money, ower refers to the shipping address, amount refers to the amount, and label refers to the money label; unlockcodeandpara [ unlockcodeandpara ]1;…;unlockcodeandparai;…]Wherein the unlockcodeandpara represents the name and parameters of the unlocking chain code constructed according to the type of the collection address input to utxoiAccording to the corresponding input iniIs constructed.
On the basis of the technical proposal, the device comprises a shell,
the collection address type comprises a publickeyhash type collection address and a scripthhash type collection address;
the public key hash type collection address takes the hash value of the public key as an address;
the script hash type collection address takes a hash value of the lock chain code as an address, and the script hash type collection address contains a name of the unlock chain code, specifically, scrpthash | | | hash (lock chain code) | the name of the unlock chain code.
On the basis of the technical scheme, each unlockcodeandparaiAccording to the corresponding input iniThe collection address type of (1) is constructed, and specifically comprises:
when iniIf the type of the collection address is publickeyhash type, then the collection address is unlockcodeandparaiContaining only iniA signature corresponding to a private key pair (inputs, outputs, nonce), wherein nonce is a random number;
when iniIf the collection address type is script hash type collection address, then unlockcodeandparaiContains iniAnd the name of the unlocking chain code specified by the address and the corresponding input parameter.
On the basis of the technical scheme, the fabric chain code analyzes and verifies the transaction application request to form the standard output reads and writes of the fabric, and the specific steps comprise:
the fabric chain code executes the GetState (in) function to obtain each input in of inputs in the transaction requestiJudging whether the state is over-flowering or not, if so, ending; if not, the program is put into readsets and is continuously executed,
judgment input iniIf the type of the gathering address is public key hash type gathering address, verifying whether sigs is correct or not; if the script hash type collection address is the script hash type collection address, the invokechainkcode function is operated to call the input iniThe method comprises the steps of specifying an unlocking script unlockcode and parameters, and judging whether the operation result of the unlocking script unlockcode is true or not; when sigs is verified to be correct and/or all inputs iniWhen the operation result of the unlocking script unlockcode is true, the execution is continued,
detecting whether the input value sum is equal to the output value sum, and the label of the input and output are matched, if and only if the input value sum is equal to the output value sum, and the label of the input and output are matched, continuing the execution,
running DelState (in) function to input iniAdding to writes, adding to input in writesiChanges the input state of the transaction request into spent state, and deletes the original input in the transaction requestiAnd the execution is continued,
for each output utxo of outputs in the transaction application request, the fabric chain code executes a PutState (txid j; out) function that writes (txid j, out) into the state book of the block chain, where out is (amount; owner; label).
Compared with the prior art, the invention has the advantages that: by constructing a transaction application request, each input utxo, each output utxo and an unlocking chain code constructed according to the type of a collection address are added into the transaction application, different unlocking chain codes can be independently developed for different service scenes, so that payment can be realized by using a uniform payment process, different payment conditions can be set according to different application scenes, and compared with Bitcoin, because an unlocking contract is installed in a channel, the unlocking contract is not required to be placed in a transaction every time, and the account book storage overhead is saved.
Drawings
Fig. 1 is a flowchart of a condition settable payment method supporting an utxo model according to an embodiment of the present invention.
Detailed Description
The embodiment of the invention provides a condition settable payment method supporting an utxo model, which not only can realize payment by using a uniform payment process, but also can set different payment conditions according to different application scenes. The embodiment of the invention also correspondingly provides a condition settable payment system supporting the utxo model.
Referring to fig. 1, a condition settable payment method supporting an utxo model according to an embodiment of the present invention includes the following steps:
s1: and the transaction initiator side constructs a transaction application request for the spending money transaction, wherein the transaction application comprises each input utxo, each output utxo, and the name and the parameter of the constructed unlocking chain code according to the type of the collection address of the input utxo.
In the embodiment of the invention, an operation carrier of a transaction initiator end is an application program, when a money-spending transaction occurs, a transaction application request is constructed, and the constructed transaction application request specifically comprises the following steps:
request=(inputs;outputs;unlockcodeandpara)
wherein inputs is [ in ]1;in2;…;ini;…]Represents each utxo input; iniIs (txid. j), representing the jth output of the transaction txid, i and j both being positive integers; outputs [ [ (amount; owner; label); (amount; owner; label); …, respectively; (atmospheric; owner; label)]Each utxo representing an output; (amount; ower; label) indicates that ower owns an amount of label currency, ower refers to the shipping address, amount refers to the amount, and label refers to a currency identifier, such as a RMB, USD, Ether, etc. identifier; unlockcodeandpara [ unlockcodeandpara ]1;…;unlockcodeandparai;…]Wherein the unlockcodeandpara represents the name and parameters of the unlocking chain code constructed according to the type of the collection address input to utxoiAccording to the corresponding input iniIs constructed.
In Fabric, its account book includes a state database, and one state database is defined as a (key, value) structure combination, and when utxo is implemented by using the structure combination, it may be defined that (txid.j), (amount, own, label)) and (txid.j) represent the j-th output of transaction txid.
The collection address type comprises a public key hash type collection address and a script hash type collection address, the public key hash type collection address takes the hash value of a public key as an address, the script hash type collection address takes the hash value of a locking chain code as an address, and the script hash type collection address contains the name of an unlocking chain code, namely, the script hash is the name of the unlocking chain code.
Each of the unlockcodeandparaiAccording to the corresponding input iniThe collection address type of (1) is constructed, and specifically comprises: when iniIf the type of the collection address is publickeyhash type, then the collection address is unlockcodeandparaiContaining only iniA signature corresponding to a private key pair (inputs, outputs, nonce), wherein nonce is a random number; when iniIf the collection address type is script hash type collection address, then unlockcodeandparaiContains iniAnd the name of the unlocking chain code specified by the address and the corresponding input parameter. And writing the specific logic of the unlocking chain code according to the service type.
S2: the constructed transaction request is sent to the fabric network, namely, the application program sends the transaction request to the fabric network.
S3: the fabric chain code analyzes and verifies the transaction application request to form standard output reads and writes of the fabric, wherein the reads represent a state set which needs to be read from an account book for the transaction, and the writes represent a state set which needs to be written to the account book.
The method comprises the following steps that the fabric chain code analyzes and verifies a transaction application request to form standard output reads and writes of the fabric, and the specific steps comprise:
s301: the fabric chain code executes the GetState (in) function to obtain each input in of inputs in the transaction requestiJudging whether the state is over-flowering or not, if so, ending; if not, putting the files into readsets, and turning to the step S302;
s302: judgment input iniIf the type of the gathering address is public key hash type gathering address, verifying whether sigs is correct or not; if the script hash type collection address is the script hash type collection address, the invokechainkcode function is operated to call the input iniThe method comprises the steps of specifying an unlocking script unlockcode and parameters, and judging whether the operation result of the unlocking script unlockcode is true or not; when sigs is verified to be correct and all inputs iniWhen the operation result of the unlocking script unlockcode is true, the step is switched to the step S303;
unlock script unlockcode is input iniAn unlock script specified by the collection address, in which a cost in is definediThe utxo needs to satisfy the condition, and the invokechainkcode function is a function provided by the fabric network api.
S303: detecting whether the input value sum is equal to the output value sum and the label of the input and output are matched, and if and only if the input value sum is equal to the output value sum and the label of the input and output are matched, turning to the step S304;
s304: running DelState (in) function to input iniAdding to writes, adding to input in writesiChanges the input state of the transaction request into spent state, and deletes the original input in the transaction requestiGo to step S305;
s305: for each output utxo of outputs in the transaction application request, the fabric chain code executes a PutState (txid j; out) function that writes (txid j, out) into the state book of the block chain, where out is (amount; owner; label).
In the embodiment of the invention, the chain code processing flows of the money transaction are consistent, namely whether the input of the transaction is legal or not is verified, whether a signature is legal or not is checked for the input of a public key hash type collection address, and when the signature is legal, an output result is true; for the input of a scripthhash type payee address, it is checked that the incoming unlockcode is iniThe chain code specified by the address, then runs the unlockcodeandpara and checks if the result of the run is true. And if the checking result of the unlocking script corresponding to all the inputs is true, the output is true, and then putstate is executed, and the output is stored in the account book. Different unlockcodes can be independently developed for different service scenes, compared with a Bitcin script, unlockcodeandpara is not required to be stored in utxo, and only the unlockcodes are required to be installed in channel once, so that account book storage is saved.
The condition settable payment method supporting the utxo model is realized by constructing a transaction application request, adding each input utxo, each output utxo and an unlocking chain code constructed according to the type of the collection address in the transaction application, and independently developing different unlocking chain codes for different service scenes, so that payment can be realized by using a uniform payment process, different payment conditions can be set according to different application scenes, and compared with Bitcoin, because the unlocking contract is installed in a channel, the unlocking contract is not required to be placed in a transaction every time, and the account book storage overhead is saved.
The following describes, in conjunction with an example, a method for supporting the utxo model and setting the payment condition according to the present invention. Assume that the set condition is a cash-in-delivery application scenario.
In the prepayment transaction, an application program of an orderer generates a prepayment address hash (a supplier public key I orderer public key I cargo information hash I time1) I unlockonReceive, money transaction is constructed according to the defined script type address transaction rule, prepayment is sent to the prepayment address, wherein time1 represents preset cargo delivery time, if time1 is not set, a certain default time is started, and the unlockonReceive represents an unlocking script name for spending the money.
In order transaction, the orderer application generates a composite key ck1 ═ (supplier public key | | orderer public key | | | goods information hash | | | time1| | | prepaid transaction number) and links up, and the orderer remembers its order transaction number orderTxNo.
In the delivery process, the supplier application program subscribes to the event, verifies that the data of the ck1 is matched with the prepaid address of the prepaid transaction, namely the hash value of the related data in the ck1 is equal to the prepaid address, and then delivers the goods.
In the goods delivery transaction, after the goods are received by the orderer before the appointed time1, the composite key ck1 is assigned with a value (true | | | signature), wherein the signature is the signature sig of the ordererprk(Whole composite Key. true) the driver carries the delivery transaction number deliverrokTxNO, at which point the supplier has the advance payment and can later spend. If the supplier does not send the goods before time1, the function of the chain code will be such that the orderer still has the money; to reduce the need for the supplier to send the order after time1, the advance payment transaction and order transaction process would need to be reissued, and the original advance payment would be automatically returned to the order, time1 could be set larger.
For the supplier to spend the money, the processing flow of the application program is as follows:
the supplier application program obtains the corresponding state (ck1, value) according to the delivery transaction number deliverytxno of the goods owned by the supplier application program ((supplier public key | | | orderer public key | | | goods information hash | | | | | time1| | | | | prepaid transaction number), (true | | signature)), finds out the prepaid transaction number txid, thereby finding out the own utxo, takes txid _ i as the content of input, constructs output according to the actual situation, specifies an unlocking script unlockonreceiveand a delivery transaction number parameter deliverytxno of the goods, and the signature of the supplier pair (inputs, outputs, unlockonreceivetney, nonce), and then submits the request ═ to the network for transaction.
How the orderer spends the money when the orderer does not receive the goods, the processing flow of the application program is as follows:
the application program of the orderer obtains a ck1 composite key according to the order transaction number oderTxNo owned by the application program of the orderer, finds out the pre-payment transaction number txid, finds out utxo of the pre-payment transaction, and takes txid _ i as the content of input; constructing output according to actual conditions, designating an unlocking script unlockonReceive and an order transaction number orderTxNO, and signing a orderer pair (inputs, outputs, unlockonReceive, nonce), and submitting a request (signatures of inputs, outputs, orderTxNO and orderers) to a fabric network to realize money transaction.
In the transaction implementation process, the processing process of the fabric network side is as follows: for the request of the money transaction application, firstly checking whether the input utxo is spent, then executing an unlocking script unlockonReceive, if the operation result is true, executing other conventional checks, and finally calling putstate to write each money to an account book.
The execution logic of the unlock script UnlockonReceive is as follows:
according to the input transaction number, a composite key ck1 is obtained, whether the orderer costs money or the supplier costs money is judged according to the value of the composite key ck1, and if the composite key ck1 is (true | | orderer signature), the supplier costs money; otherwise, checking that the current time exceeds the set time1 is that the orderer spends money.
When spending money for a supplier, then it is ensured that the delivery of the goods to the transaction number and the money spent are related: extracting data (supplier public key | | | orderer public key | | | cargo information hash | | | time1) from (ck1, true | | sig) according to the delivery transaction number of the cargo, calculating the hash value of the data, and enabling the hash value to be equal to the input address of utxo; the prepaid transaction number is extracted and compared to the input txid of utxo for equality. If the checks are all passed, then based on the entered transaction number, the time of delivery of the good is obtained, compared to time1 of the compound key ck 1: ensure delivery time is before time1, verify that the vendor's public key in ck1 and the public key provided in the input signature are the same, then verify that the vendor signature is correct, and then output true.
If the orderer spends money, the public key of the orderer in ck1 is verified to be the same as the public key provided in the input signature, the signature of the orderer is verified to be correct, and true is output.
The condition-settable payment system supporting the utxo model provided by the embodiment of the invention comprises a transaction initiator side and a fabric network side.
The transaction initiator side is used for constructing a transaction application request for the spending money transaction and sending the constructed transaction application request to the fabric network side, wherein the transaction application comprises input utxo, output utxo, and an unlocking chain code name and parameters constructed according to the collection address type of the input utxo; the fabric network end is used for driving the fabric chain code to analyze and verify the transaction application request, and standard output reads and writes of the fabric are formed, wherein the reads represent the state set which needs to be read from the account book for the transaction, and the writes represent the state set which needs to be written to the account book.
The transaction application request constructed by the transaction initiator side specifically comprises the following steps:
request=(inputs;outputs;unlockcodeandpara)
wherein inputs is [ in ]1;in2;…;ini;…]Represents each utxo input; iniIs (txid. j), representing the jth output of the transaction txid; outputs [ [ (amount; owner; label); (amount; owner; label); …, respectively; (atmospheric; owner; label)]Each utxo representing an output; (account; ower; label) indicates that ower owns an amount of label money, ower refers to the shipping address, amount refers to the amount, and label refers to the money label; unlockcodeandpara [ unlockcodeandpara ]1;…;unlockcodeandparai;…]Wherein the unlockcodeandpara represents the name and parameters of the unlocking chain code constructed according to the type of the collection address input to utxoiAccording to the corresponding input iniIs constructed.
The recipient address types include public key hash type recipient addresses and scripthhash type recipient addresses. The public key hash type recipient address has a hash value of a public key as an address. The script hash type collection address takes a hash value of the lock chain code as an address, and the script hash type collection address contains a name of the unlock chain code, specifically, scrpthash | | | hash (lock chain code) | the name of the unlock chain code.
Each of the unlockcodeandparaiAccording to the corresponding input iniThe collection address type of (1) is constructed, and specifically comprises:
when iniIf the type of the collection address is publickeyhash type, then the collection address is unlockcodeandparaiContaining only iniA signature corresponding to a private key pair (inputs, outputs, nonce), wherein nonce is a random number;
when iniIf the collection address type is script hash type collection address, then unlockcodeandparaiContains iniAnd the name of the unlocking chain code specified by the address and the corresponding input parameter.
The method comprises the following steps that the fabric chain code analyzes and verifies a transaction application request to form standard output reads and writes of the fabric, and the specific steps comprise:
the fabric chain code executes the GetState (in) function to obtain each input in of inputs in the transaction requestiJudging whether the state is over-flowering or not, if so, ending; if not, the program is put into readsets and is continuously executed,
judgment input iniIf the type of the gathering address is public key hash type gathering address, verifying whether sigs is correct or not; if the script hash type collection address is the script hash type collection address, the invokechainkcode function is operated to call the input iniThe method comprises the steps of specifying an unlocking script unlockcode and parameters, and judging whether the operation result of the unlocking script unlockcode is true or not; when sigs is verified to be correct and all inputs iniWhen the operation result of the unlocking script unlockcode is true, the execution is continued,
detecting whether the input value sum is equal to the output value sum, and the label of the input and output are matched, if and only if the input value sum is equal to the output value sum, and the label of the input and output are matched, continuing the execution,
operation ofDelState (in) function, which inputs iniAdding to writes, adding to input in writesiChanges the input state of the transaction request into spent state, and deletes the original input in the transaction requestiAnd the execution is continued,
for each output utxo of outputs in the transaction application request, the fabric chain code executes a PutState (txid j; out) function that writes (txid j, out) into the state book of the block chain, where out is (amount; owner; label).
The present invention is not limited to the above-described embodiments, and it will be apparent to those skilled in the art that various modifications and improvements can be made without departing from the principle of the present invention, and such modifications and improvements are also considered to be within the scope of the present invention. Those not described in detail in this specification are within the skill of the art.

Claims (10)

1. A conditionally settable payment method supporting an utxo model, comprising the steps of:
the transaction initiator side constructs a transaction application request for the spending money transaction, wherein the transaction application comprises each input utxo, each output utxo, and an unlocking chain code name and parameters constructed according to the collection address type of the input utxo;
the constructed transaction application request is sent to the fabric network;
the fabric chain code analyzes and verifies the transaction application request to form the standard output readsets and the writings of the fabric, wherein the readsets represent the state set which needs to be read from the account book for the transaction, and the writings represent the state set which needs to be written to the account book.
2. The method for conditionally settable payment supporting utxo model according to claim 1, wherein the transaction application request is specifically:
request=(inputs;outputs;unlockcodeandpara)
wherein inputs is [ in ]1;in2;…;ini;…]Represents each utxo input; iniIs (txid. j), representing the jth output of the transaction txid; outputs [ [ (amount; owner; label); (amount; owner; label); …, respectively; (atmospheric; owner; label)]Each utxo representing an output; (account; ower; label) indicates that ower owns an amount of label money, ower refers to the shipping address, amount refers to the amount, and label refers to the money label; unlockcodeandpara [ unlockcodeandpara ]1;…;unlockcodeandparai;…]Wherein the unlockcodeandpara represents the name and parameters of the unlocking chain code constructed according to the type of the collection address input to utxoiAccording to the corresponding input iniIs constructed.
3. The method of claim 2, wherein the conditional settable payment method in support of the utxo model comprises:
the collection address type comprises a publickeyhash type collection address and a scripthhash type collection address;
the public key hash type collection address takes the hash value of the public key as an address;
the script hash type collection address takes a hash value of the lock chain code as an address, and the script hash type collection address contains a name of the unlock chain code, specifically, scrpthash | | | hash (lock chain code) | the name of the unlock chain code.
4. The method of claim 3, wherein each of the unlockcodeandpara is a conditional settable payment method that supports the utxo modeliAccording to the corresponding input iniThe collection address type of (1) is constructed, and specifically comprises:
when iniIf the type of the collection address is publickeyhash type, then the collection address is unlockcodeandparaiContaining only iniA signature corresponding to a private key pair (inputs, outputs, nonce), wherein nonce is a random number;
when iniIf the collection address type is script hash type collection address, then unlockcodeandparaiContains iniSolutions to address assignmentThe name of the chain code and the corresponding input parameters.
5. The method of claim 4, wherein the fabric chain code parses and verifies the transaction application request to form fabric standard output reads and writes, and the method comprises the following steps:
the fabric chain code executes the GetState (in) function to obtain each input in of inputs in the transaction requestiJudging whether the state is over-flowering or not, if so, ending; if not, the program is put into readsets and is continuously executed,
judgment input iniIf the type of the gathering address is public key hash type gathering address, verifying whether sigs is correct or not; if the script hash type collection address is the script hash type collection address, the invokechainkcode function is operated to call the input iniThe method comprises the steps of specifying an unlocking script unlockcode and parameters, and judging whether the operation result of the unlocking script unlockcode is true or not; when sigs is verified to be correct and all inputs iniWhen the operation result of the unlocking script unlockcode is true, the execution is continued,
detecting whether the input value sum is equal to the output value sum, and the label of the input and output are matched, if and only if the input value sum is equal to the output value sum, and the label of the input and output are matched, continuing the execution,
running DelState (in) function to input iniAdding to writes, adding to input in writesiChanges the input state of the transaction request into spent state, and deletes the original input in the transaction requestiAnd the execution is continued,
for each output utxo of outputs in the transaction application request, the fabric chain code executes a PutState (txid j; out) function that writes (txid j, out) into the state book of the block chain, where out is (amount; owner; label).
6. A conditionally settable payment system supporting an utxo model, comprising:
the transaction initiator end is used for constructing a transaction application request for the spending money transaction and sending the constructed transaction application request to the fabric network end, wherein the transaction application comprises input utxo, output utxo, and an unlocking chain code name and parameters constructed according to the type of a collection address of the input utxo;
the fabric network end is used for driving the fabric chain code to analyze and verify the transaction application request to form fabric standard output readsets and writes, wherein the readsets represent the state set which needs to be read from the account book for the transaction, and the writes represent the state set which needs to be written to the account book.
7. The system of claim 6, wherein the transaction application request constructed by the transaction initiator side is specifically:
request=(inputs;outputs;unlockcodeandpara)
wherein inputs is [ in ]1;in2;…;ini;…]Represents each utxo input; iniIs (txid. j), representing the jth output of the transaction txid; outputs [ [ (amount; owner; label); (amount; owner; label); …, respectively; (atmospheric; owner; label)]Each utxo representing an output; (account; ower; label) indicates that ower owns an amount of label money, ower refers to the shipping address, amount refers to the amount, and label refers to the money label; unlockcodeandpara [ unlockcodeandpara ]1;…;unlockcodeandparai;…]Wherein the unlockcodeandpara represents the name and parameters of the unlocking chain code constructed according to the type of the collection address input to utxoiAccording to the corresponding input iniIs constructed.
8. The system of claim 7, wherein the conditional settable payment system supports the utxo model, further comprising:
the collection address type comprises a publickeyhash type collection address and a scripthhash type collection address;
the public key hash type collection address takes the hash value of the public key as an address;
the script hash type collection address takes a hash value of the lock chain code as an address, and the script hash type collection address contains a name of the unlock chain code, specifically, scrpthash | | | hash (lock chain code) | the name of the unlock chain code.
9. The system of claim 8, wherein each of the unlockcodeandpara is a conditional settable payment system that supports the utxo modeliAccording to the corresponding input iniThe collection address type of (1) is constructed, and specifically comprises:
when iniIf the type of the collection address is publickeyhash type, then the collection address is unlockcodeandparaiContaining only iniA signature corresponding to a private key pair (inputs, outputs, nonce), wherein nonce is a random number;
when iniIf the collection address type is script hash type collection address, then unlockcodeandparaiContains iniAnd the name of the unlocking chain code specified by the address and the corresponding input parameter.
10. The system of claim 9, wherein the fabric chain code parses and validates a transaction request to form fabric standard output reads and writes, and the method comprises:
the fabric chain code executes the GetState (in) function to obtain each input in of inputs in the transaction requestiJudging whether the state is over-flowering or not, if so, ending; if not, the program is put into readsets and is continuously executed,
judgment input iniIf the type of the gathering address is public key hash type gathering address, verifying whether sigs is correct or not; if the script hash type collection address is the script hash type collection address, the invokechainkcode function is operated to call the input iniThe method comprises the steps of specifying an unlocking script unlockcode and parameters, and judging whether the operation result of the unlocking script unlockcode is true or not; when sigs is verified to be correct and/or all inputs iniWhen the operation result of the unlocking script unlockcode is true, the execution is continued,
detecting whether the input value sum is equal to the output value sum, and the label of the input and output are matched, if and only if the input value sum is equal to the output value sum, and the label of the input and output are matched, continuing the execution,
running DelState (in) function to input iniAdding to writes, adding to input in writesiChanges the input state of the transaction request into spent state, and deletes the original input in the transaction requestiAnd the execution is continued,
for each output utxo of outputs in the transaction application request, the fabric chain code executes a PutState (txid j; out) function that writes (txid j, out) into the state book of the block chain, where out is (amount; owner; label).
CN201910262508.1A 2019-04-02 2019-04-02 Settable payment method and system supporting utxo model Active CN110322346B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910262508.1A CN110322346B (en) 2019-04-02 2019-04-02 Settable payment method and system supporting utxo model

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910262508.1A CN110322346B (en) 2019-04-02 2019-04-02 Settable payment method and system supporting utxo model

Publications (2)

Publication Number Publication Date
CN110322346A CN110322346A (en) 2019-10-11
CN110322346B true CN110322346B (en) 2022-02-15

Family

ID=68112942

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910262508.1A Active CN110322346B (en) 2019-04-02 2019-04-02 Settable payment method and system supporting utxo model

Country Status (1)

Country Link
CN (1) CN110322346B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111080291A (en) * 2019-11-21 2020-04-28 武汉天喻信息产业股份有限公司 Goods delivery payment application method and system based on Fabric
WO2021134424A1 (en) * 2019-12-31 2021-07-08 深圳市网心科技有限公司 Blockchain-based digital currency transaction method, apparatus and system

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109274752A (en) * 2018-10-10 2019-01-25 腾讯科技(深圳)有限公司 The access method and device, electronic equipment, storage medium of block chain data
CN109447636A (en) * 2018-10-15 2019-03-08 联动优势科技有限公司 A kind of assets transfer method and device
CN109493014A (en) * 2018-10-18 2019-03-19 北京瑞卓喜投科技发展有限公司 A kind of token operational approach and operation system based on block chain
CN109542888A (en) * 2018-12-03 2019-03-29 百度在线网络技术(北京)有限公司 The data modification and synchronous method of block chain, device, equipment and storage medium

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11354658B2 (en) * 2016-02-11 2022-06-07 Mastercard International Incorporated Method and system for offline blockchain exchanges
US10333705B2 (en) * 2016-04-30 2019-06-25 Civic Technologies, Inc. Methods and apparatus for providing attestation of information using a centralized or distributed ledger

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109274752A (en) * 2018-10-10 2019-01-25 腾讯科技(深圳)有限公司 The access method and device, electronic equipment, storage medium of block chain data
CN109447636A (en) * 2018-10-15 2019-03-08 联动优势科技有限公司 A kind of assets transfer method and device
CN109493014A (en) * 2018-10-18 2019-03-19 北京瑞卓喜投科技发展有限公司 A kind of token operational approach and operation system based on block chain
CN109542888A (en) * 2018-12-03 2019-03-29 百度在线网络技术(北京)有限公司 The data modification and synchronous method of block chain, device, equipment and storage medium

Also Published As

Publication number Publication date
CN110322346A (en) 2019-10-11

Similar Documents

Publication Publication Date Title
CN110363665B (en) Credit right data processing method, device, equipment and medium
CN109102269B (en) Transfer method and device based on block chain, block chain node and storage medium
CN111629039A (en) Block chain consensus method, client, endorsement node and sequencing node
EP3779760B1 (en) Blockchain-based data processing method and apparatus, and electronic device
CN103714625B (en) A kind of charging intelligent card method and system
US20080215357A1 (en) Detection of unknown scenarios
CN110322346B (en) Settable payment method and system supporting utxo model
CN111383114A (en) Asset information management method and device based on block chain
LU102556B1 (en) Blockchain-enhanced open internet of things access architecture
CN111402033A (en) Asset information management method and device based on block chain
CN113179282A (en) Method and device for merging account numbers and server
CN115456603A (en) Double-chain structure-based approval process processing method and device
CN101090414A (en) Mobile payment service implementing method based on quick response matrix code
CN108492071A (en) A kind of express delivery information processing method and device based on block chain
CN111340530A (en) Block chain-based digital rights and interests system
CN113269565B (en) Anti-counterfeiting identification method and device for preventing identification code from being reused and electronic equipment
CN114219342A (en) Carbon asset management method and device based on non-homogeneous evidence
WO2021120760A1 (en) Method and device for issuing electronic invoice employing blockchain
US20210056542A1 (en) System and method for optimizing cryptocurrency transactions
CN110336872B (en) Method, device and system for acquiring third-party data
CN112435127A (en) Contract signing method, device, equipment and storage medium based on block chain
CN110363513A (en) Payment unions method and apparatus based on block chain
CN113657997A (en) Bank business processing method and device based on account group
Ilgi et al. Formal verification for security technologies in the blockchain with artificial intelligence: a survey
CN109102381B (en) Accounting processing method and device

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
GR01 Patent grant
GR01 Patent grant