Login| Sign Up| Help| Contact|

Patent Searching and Data


Title:
OPTIMIZING BLOCKCHAIN TRANSACTION SIZE
Document Type and Number:
WIPO Patent Application WO/2023/208546
Kind Code:
A1
Abstract:
A computer-implemented method of determining an optimal set of input values for use as funding a set of respective blockchain transactions, wherein the method comprises: for a plurality of different respective sets of input values, determining the respective set of input values that minimises a function when evaluated based on the set of respective blockchain transactions, wherein the function is based on i) the total amount of fees of the respective transaction, ii) a maximum of the respective associated data fees, iii) is a total value of all input values used for respective inputs to the set of transactions, iv) a total number of spendable outputs across the set of transactions, v) an initial number of instances of each input value available to the optimizer, and vi) a total number of transactions in the set of transactions.

Inventors:
PAGANI ALESSIO (GB)
PAUNOIU ALEXANDRU (GB)
Application Number:
PCT/EP2023/058859
Publication Date:
November 02, 2023
Filing Date:
April 04, 2023
Export Citation:
Click for automatic bibliography generation   Help
Assignee:
NCHAIN LICENSING AG (CH)
International Classes:
H04L9/32; H04L9/00
Other References:
KARAKOSTAS DIMITRIS ET AL: "Efficient State Management in Distributed Ledgers", 23 October 2021, 16TH EUROPEAN CONFERENCE - COMPUTER VISION - ECCV 2020, CORNELL UNIVERSITY LIBRARY, 201 OLIN LIBRARY CORNELL UNIVERSITY ITHACA, NY 14853, PAGE(S) 319 - 338, XP047614807
DANIEL J DIROFF: "Bitcoin Coin Selection with Leverage", ARXIV.ORG, CORNELL UNIVERSITY LIBRARY, 201 OLIN LIBRARY CORNELL UNIVERSITY ITHACA, NY 14853, 4 November 2019 (2019-11-04), XP081525185
Attorney, Agent or Firm:
MAHON, Thomas James (GB)
Download PDF:
Claims:
CLAIMS

1. A computer-implemented method of determining an optimal set of input values for use as funding a set of respective blockchain transactions, wherein each transaction requires at least one input and at least one output, each respective input being a respective unspent transaction output, UTXO, having a respective input value, wherein each transaction comprises respective target data having an respective associated data fee, each input to a transaction has an associated input fee and each output of a transaction has an associated output fee, and wherein a total amount of respective input values of the respective UTXOs input to a respective transaction is required to be at least equal to a total amount of fees of the respective transaction, and wherein the method comprises: for a plurality of different respective sets of input values, determining the respective set of input values that minimises a function when evaluated based on the set of respective blockchain transactions, wherein the function is based on i) the total amount of fees of the respective transaction, ii) a maximum of the respective associated data fees, iii) is a total value of all input values used for respective inputs to the set of transactions, iv) a total number of spendable outputs across the set of transactions, v) an initial number of instances of each input value available to the optimizer, and vi) a total number of transactions in the set of transactions.

2. The method of claim 1, wherein the optimizer is configured to obtain each UTXO from a pool of UTXOs, and wherein the function is also based on vii) a number of communications between the optimizer and the pool of UTXOs required to obtain a total number of instances of each input value needed to fund the set of transactions.

3. The method of claim 1 or claim 2, wherein said determining comprises: a) evaluating the function based on the set of respective blockchain transactions, given an initial set of input values; b) determining a respective next set of input values by changing one or more of the input values in the initial set of input values; c) evaluating the function based on the set of respective blockchain transactions, given the respective next set of input values; and repeating steps b and c until the function is minimised for the set of respective blockchain transactions, wherein the respective next set of inputs values used in step c is used as the initial set of input values in step b.

4. The method of any preceding claim, wherein the function is minimised using a heuristic function.

5. The method of claim 4, wherein the heuristic function is a simulated annealing algorithm.

6. The method of claim 2 or any claim dependent thereon, wherein the function is of the following form: where F is the total amount of fees of the respective transaction, M is the maximum of the respective associated data fees, S is the total value of all input values used for respective inputs to the set of transactions, 0 is the total number of spendable outputs of across the set of transactions, Q is the total number of instances of each input value needed to fund the set of transactions, N is the total number of transactions in the set of transactions, C is the number of communications between the optimizer and the pool of UTXOs required to obtain the total number of instances of each input value needed to fund the set of transactions, and et is a respective input value associated with index i.

7. The method of any preceding claim, comprising, given the optimal set of input values, minimising a number of inputs and/or outputs of a target transaction by: determining a respective number of each respective UTXO having a respective value to be used as a respective input to the target transaction and a respective number of each output of the transaction having a respective value, by minimising, for each different respective value of the respective UTXOs and for each different respective value of each output, a sum of a) a number of each respective UTXO having a respective value multiplied by the associated input fee, and b) a sum of bi) a number of each respective output having a respective value multiplied by the associated output fee, and bii) a leftover fee, wherein said minimising is subject to the following constraints: i) a total amount of the respective values of the respective UTXOs must be at least equal to the data fees and a leftover amount, wherein the leftover amount is based on based on a total amount of respective values of one or more respective UTXOs input to the transaction, a total amount of respective values of one or more respective outputs of the transaction, and a total amount of fees of the transaction, ii) the determined respective number of each UTXO must be non-negative, iii) the determined respective number of each output must be non-negative, and iv) the leftover amount must be between zero and a maximum of a predetermined upper bound and a sum of the associated input fee and the associated output fee.

8. The method of claim 7, wherein said determining comprises minimizing the following equation: wherein each respective value is associated with a respective index i based on the respective value, and where wt is the respective number of each respective UTXO having a respective value corresponding to the index i, feein is the associated input fee, w- is the respective number of each output of the transaction having a respective value corresponding to index i, feeout is the associated output fee, and feeE is the leftover fee.

9. The method of claim 8, wherein: constraint i) is defined by w^ Ce^ — feein) + — I- wk(ek — feein) — w^e^ + feeout) — - wk(ek + feeout) = feeD + s, where et is the respective value corresponding to index i, feeD is the associated data fee, and s is the leftover amount; constraint ii) and constraint iii) are defined by Wj,w/ G Ns0; constraint iv) is defined by 0 < s < max{E, feeout + feein], where E is the predetermined upper bound.

10. The method of claim 7 or any claim dependent thereon, comprising calculating the leftover fee based on the leftover amount, wherein:

If the leftover amount is less than a sum of the associated input fee and the associated output fee, the leftover fee is the leftover amount; otherwise, if the leftover amount is less than a sum of the associated output fee and a predetermined minimum value, the leftover fee is the sum of the associated input fee and the associated output fee; otherwise, the leftover fee is equal to infinity.

11. The method of claim 7 or any claim dependent thereon, wherein said determining is performed using a dynamic programming approach.

12. The method of claim 11, wherein a change-making problem algorithm, cmp[<5,2], is defined as follows: where 6 is an index representing a respective position of a respective UTXO in a sequence ordered based on the respective value of the respective UTXO, 2 is the total amount of fees of the transaction, and es is the respective value at position 6 in the sequence, and wherein said determining comprises determining a minimum total transaction fee to cover the data fee by: calculating a first matrix, cmpin[6, 2], for a set of first input values

{ex — feein, ... , ek — feein], where k is the respective index corresponding to a highest respective value of the respective UTXOs; calculating a second matrix, cmpout[6, 2], for a set of second input feeout\ where Yin = cmpin[k,£], (C + Z)in = cmpin[k, C + 2] and Cout = cmp0Ut[k, C], and where

k(ek - feein), and calculating the array c feeE, where cmpfinai [feeD] is the minimum transaction fee to cover the data fee.

13. The method of claim 12, wherein a change-making problem algorithm, cmp[6, 2], is defined as follows: , , cmp [<5 mod 2, 2 — e5]) , otherwise where 6 is an index representing a respective position of a respective UTXO in a sequence ordered based on the respective value of the respective UTXO, 2 is the total amount of fees of the transaction, and es is the respective value at position 6 in the sequence, and wherein said determining comprises determining a minimum total transaction fee to cover the data fee by: calculating a first matrix, cmpin[6, 2], for a set of first input values

{ex — feein, ... , ek — feein], where k is the respective index corresponding to a highest respective value of the respective UTXOs; calculating a second matrix, cmpout[6, 2], for a set of second input feeout\ where Yin = cmpin[k,£], (C + Z)in = cmpin[k, C + 2] and Cout = cmp0Ut[k, C], and where

k(ek ~ feein), and calculating the array c feeE, where cmpfinai [feeD] is the minimum transaction fee to cover the data fee.

14. The method of any of claims 1 to 6, comprising, given the optimal set of input values, minimising a number of inputs and/or outputs of a target transaction by executing a fee decision algorithm, wherein the fee decision algorithm determines whether an additional output of the target transaction is required, and wherein said executing comprises: determining a leftover amount based on the total amount of respective values of one or more respective UTXOs input to the target transaction, the total amount of respective values of one or more respective outputs of the target transaction, and the total amount of fees of the target transaction, if the leftover amount if less than a total of the associated input fee and the associated output fee, causing the target transaction to be sent to a blockchain network without the additional output, if the leftover amount is greater than the associated output fee, causing the target transaction to be sent to the blockchain network with the additional output; and if the leftover amount is greater than the total of the associated input fee and the associated output fee and less than the associated output fee and a predetermined minimum value, causing the target transaction to be sent to the blockchain network with the additional output and an additional input.

15. The method of claim 14, comprising executing a variable-value input selection algorithm, wherein the variable input selection algorithm determines a first one of the at least one inputs of the target transaction, and wherein said executing comprises: if available, selecting a respective UTXO having a respective value which results in the leftover amount being less than the associated output fee; if not, then, if available, selecting a respective UTXO having a respective value which results in the leftover amount being greater than the associated output fee and the predetermined minimum value; if not, then, if available, selecting a respective UTXO having a respective value which results in the leftover amount being greater than the associated output fee and less the total of the associated input fee and the associated output fee; if not, selecting a respective UTXO having a respective value which results in the leftover amount being greater than the total of the associated input fee and the associated output fee and less than the associated output fee and the predetermined minimum value; adding the selected respective UTXO as the first input to the blockchain transaction; and causing the fee decision algorithm to be executed.

16. The method of claim 15, comprising: if the plurality of UTXOs does not include a respective UTXO having a respective value large enough to cover the total amount of fees of the target transaction, adding one or more additional UTXOs as one or more additional inputs to the transaction.

17. The method of claim 14, wherein the respective value of each of the plurality of UTXOs is a respective one of one or more predetermined values, each predetermined value being associated with a respective index based on the predetermined value and wherein the method comprises executing a multiple-value input selection algorithm, wherein said executing comprises: starting with a highest one of the predetermined values, performing a process of steps: a) determining a minimum number, wherein the minimum number corresponds to a smallest number of the respective UTXOs having that predetermined value that results in i) a total value of that predetermined value multiplied by the minimum number, being greater than ii) the data fee summed with a total amount of the associated input fees multiplied by the minimum number; b) if the plurality of UTXOs comprises at least the first minimum number of respective UTXOs having that predetermined value, adding the first minimum number of UTXOs having that predetermined value as respective inputs of the transaction, and causing the fee decision algorithm to be executed; c) if the plurality of UTXOs comprises a second number of respective UTXOs having that predetermined value which is less than the first minimum number of respective UTXOs having that predetermined value, adding the second number of respective UTXOs having that predetermined value as respective inputs of the transaction, and repeating the process of steps a), b) and c) for a next highest one of the predetermined values, wherein the data fee is replaced with a total of the data fee, summed with the second number multiplied by the associated input fee, minus the second number multiplied by that predetermined value, wherein the process is repeated for each next highest one of the predetermined values until the fee decision algorithm is executed.

18. The method of any of claims 7 to 17, wherein the predetermined minimum value is set by the blockchain protocol.

19. The method of any of claims 7 to 17, wherein the plurality of UTXOs are ordered monotonically by respective value.

20. The method of any of claims 7 to 17, comprising using the method to optimize a respective size of a plurality of respective blockchain transactions, each respective blockchain transaction having respective target data having the same associated data fee.

21. Computer equipment comprising: memory comprising one or more memory units; and processing apparatus comprising one or more processing units, wherein the memory stores code arranged to run on the processing apparatus, the code being configured so as when on the processing apparatus to perform the method of any of claims 1 to 20.

22. A computer program embodied on computer-readable storage and configured so as, when run on one or more processors, to perform the method of any of claims 1 to 20.

Description:
OPTIMIZING BLOCKCHAIN TRANSACTION SIZE

TECHNICAL FIELD

The present disclosure relates to a method of optimizing a size of a blockchain transaction by minimising a number of inputs and/or outputs of the transaction.

BACKGROUND

A blockchain refers to a form of distributed data structure, wherein a duplicate copy of the blockchain is maintained at each of a plurality of nodes in a distributed peer-to-peer (P2P) network (referred to below as a "blockchain network") and widely publicised. The blockchain comprises a chain of blocks of data, wherein each block comprises one or more transactions. Each transaction, other than so-called "coinbase transactions", points back to a preceding transaction in a sequence which may span one or more blocks going back to one or more coinbase transactions. Coinbase transactions are discussed further below.

Transactions that are submitted to the blockchain network are included in new blocks. New blocks are created by a process often referred to as "mining", which involves each of a plurality of the nodes competing to perform "proof-of-work", i.e. solving a cryptographic puzzle based on a representation of a defined set of ordered and validated pending transactions waiting to be included in a new block of the blockchain. It should be noted that the blockchain may be pruned at some nodes, and the publication of blocks can be achieved through the publication of mere block headers.

The transactions in the blockchain may be used for one or more of the following purposes: to convey a digital asset (i.e. a number of digital tokens), to order a set of entries in a virtualised ledger or registry, to receive and process timestamp entries, and/or to time- order index pointers. A blockchain can also be exploited in order to layer additional functionality on top of the blockchain. For example blockchain protocols may allow for storage of additional user data or indexes to data in a transaction. There is no pre-specified limit to the maximum data capacity that can be stored within a single transaction, and therefore increasingly more complex data can be incorporated. For instance this may be used to store an electronic document in the blockchain, or audio or video data.

Nodes of the blockchain network (which are often referred to as "miners") perform a distributed transaction registration and verification process, which will be described in more detail later. In summary, during this process a node validates transactions and inserts them into a block template for which they attempt to identify a valid proof-of-work solution. Once a valid solution is found, a new block is propagated to other nodes of the network, thus enabling each node to record the new block on the blockchain. In order to have a transaction recorded in the blockchain, a user (e.g. a blockchain client application) sends the transaction to one of the nodes of the network to be propagated. Nodes which receive the transaction may race to find a proof-of-work solution incorporating the validated transaction into a new block. Each node is configured to enforce the same node protocol, which will include one or more conditions for a transaction to be valid. Invalid transactions will not be propagated nor incorporated into blocks. Assuming the transaction is validated and thereby accepted onto the blockchain, then the transaction (including any user data) will thus remain registered and indexed at each of the nodes in the blockchain network as an immutable public record.

The node who successfully solved the proof-of-work puzzle to create the latest block is typically rewarded with a new transaction called the "coinbase transaction" which distributes an amount of the digital asset, i.e. a number of tokens. The detection and rejection of invalid transactions is enforced by the actions of competing nodes who act as agents of the network and are incentivised to report and block malfeasance. The widespread publication of information allows users to continuously audit the performance of nodes. The publication of the mere block headers allows participants to ensure the ongoing integrity of the blockchain.

In an "output-based" model (sometimes referred to as a UTXO-based model), the data structure of a given transaction comprises one or more inputs and one or more outputs. Any spendable output comprises an element specifying an amount of the digital asset that is derivable from the proceeding sequence of transactions. The spendable output is sometimes referred to as a UTXO ("unspent transaction output"). The output may further comprise a locking script specifying a condition for the future redemption of the output. A locking script is a predicate defining the conditions necessary to validate and transfer digital tokens or assets. Each input of a transaction (other than a coinbase transaction) comprises a pointer (i.e. a reference) to such an output in a preceding transaction, and may further comprise an unlocking script for unlocking the locking script of the pointed-to output. So consider a pair of transactions, call them a first and a second transaction (or "target" transaction). The first transaction comprises at least one output specifying an amount of the digital asset, and comprising a locking script defining one or more conditions of unlocking the output. The second, target transaction comprises at least one input, comprising a pointer to the output of the first transaction, and an unlocking script for unlocking the output of the first transaction.

In such a model, when the second, target transaction is sent to the blockchain network to be propagated and recorded in the blockchain, one of the criteria for validity applied at each node will be that the unlocking script meets all of the one or more conditions defined in the locking script of the first transaction. Another will be that the output of the first transaction has not already been redeemed by another, earlier valid transaction. Any node that finds the target transaction invalid according to any of these conditions will not propagate it (as a valid transaction, but possibly to register an invalid transaction) nor include it in a new block to be recorded in the blockchain.

An alternative type of transaction model is an account-based model. In this case each transaction does not define the amount to be transferred by referring back to the UTXO of a preceding transaction in a sequence of past transactions, but rather by reference to an absolute account balance. The current state of all accounts is stored by the nodes separate to the blockchain and is updated constantly.

SUMMARY

It is a feature of most blockchains that a transaction has an associated transaction fee based on the size of the transaction. Each input to a transaction is an unspent transaction output (UTXO) from a previous transaction and has an associated value. Similarly, each spendable output of a transaction itself is a UTXO with an associated value. The sum of the value(s) associated with the one or more inputs must be at least equal to the sum of the value(s) associated with the one or more outputs and the transaction fee. One option for meeting this condition is to add more inputs until the condition is met. However, adding more inputs increases the transaction size, and hence the transaction fee. Moreover, adding more inputs may necessitate the need for more outputs, which also increase the transaction size, and hence the transaction fee.

The present disclosure provides techniques for optimising the transaction size by minimising the number of inputs and/or or outputs of a transaction whilst still satisfying the fee-based condition, given a particular set of UTXOs available for serving as inputs to the transaction. Minimising the transaction size provides storage savings (e.g. for the blockchain nodes) and bandwidth benefits (e.g. when initially sending the transaction to the blockchain nodes, and when those blockchain nodes distribute to the transaction to other nodes). Minimizing the transaction size also has the additional benefit in reducing the transaction fee for the sending party.

The present disclosure also provides techniques for identifying the optimal value (i.e. the denomination) of the inputs for a given funding scenario. This allows the creation of predefined UTXOs, spendable when needed for a particular scenario. This pre-processing allows faster transaction creation (therefore faster transaction throughput) when needed.

There are two extremes for funding a transaction in terms of input values. At one extreme, a single UTXO is used as an input to the transaction. This is beneficial in terms of input size (or number of inputs), but in most scenarios would require the creation of a change output to reclaim at least some of the value locked by the UTXO. This is unsuitable for funding many transactions at a high rate. At the other extreme, one could maintain a pool of UTXOs each with the lowest possible value (e.g. one Satoshi). This allows the exact transaction fee to be covered. However, this is inefficient in terms of the size of the transaction as the transaction would typically require a large number of these lowest value UTXOs. The techniques described herein provide a trade-off between the two extremes. According to one aspect disclosed herein, there is provided a computer-implemented method of determining an optimal set of input values for use as funding a set of respective blockchain transactions, wherein each transaction requires at least one input and at least one output, each respective input being a respective unspent transaction output, UTXO, having a respective input value, wherein each transaction comprises respective target data having an respective associated data fee, each input to a transaction has an associated input fee and each output of a transaction has an associated output fee, and wherein a total amount of respective input values of the respective UTXOs input to a respective transaction is required to be at least equal to a total amount of fees of the respective transaction, and wherein the method comprises: for a plurality of different respective sets of input values, determining the respective set of input values that minimises a function when evaluated based on the set of respective blockchain transactions, wherein the function is based on i) the total amount of fees of the respective transaction, ii) a maximum of the respective associated data fees, iii) is a total value of all input values used for respective inputs to the set of transactions, iv) a total number of spendable outputs across the set of transactions, v) an initial number of instances of each input value available to the optimizer, and vi) a total number of transactions in the set of transactions.

The optimizer (e.g. a user, service provider, etc.) determines the optimal split of UTXO values (i.e. denominations) that can be used to fund many data payloads of varying sizes, up to a maximum size associated with the maximum data fee. Determining the optimal split enables UTXOs to be quickly accessed (for fast and parallelisable transaction processing) while keeping the transaction size (and therefore fees) low. In other words, by determining in advance the right denominations for funding transactions up to a certain size, the optimizer is then able to complete transaction templates (by adding one or more inputs) faster than if choosing from a random set of denominations, reaching a balance between the amount of fees spent and transaction throughput (i.e. number of completed transaction templates per second).

In some embodiments, the optimizer has access to (e.g. control of) a plurality of UTXOs split into the denominations determined by optimizing the function described above. For instance, the optimizer may control the private keys necessary for spending the UTXOs, or at least have awareness of which UTXOs are available for funding the transaction. As mentioned, each input has an associated input fee and each output has an associated output fee. Each spendable output (i.e. an output having a respective value) may be required to have a predetermined minimum value. This is sometimes referred to as a dust limit. The transaction contains target data having an associated data fee. The target data is generally any data of the transaction other than the data associated with the input(s) and output(s), which have their own associated fees. The target data may therefore include components of the transaction which are inherent to the transaction (e.g. a version number). The target data may also include user-defined data, e.g. an image, text, etc.

Some techniques for funding a transaction may rely on simply adding enough UTXOs to the transaction until the data fees are covered. However this would not necessarily result in an optimal transaction size. In contrast, according to some embodiments, the optimizer is configured to determine, from the available UTXOs, the minimum number of inputs and outputs of the transaction, and the associated values of those inputs and outputs, that satisfy the fee requirements of the transaction. That is, given a set of UTXOs of certain values, and target data having an associated fee, the optimizer determines how to optimally fund the transaction (by adding one or more input UTXOs) whilst minimising the size of the transaction (in terms of number of inputs and outputs).

BRIEF DESCRIPTION OF THE DRAWINGS

To assist understanding of embodiments of the present disclosure and to show how such embodiments may be put into effect, reference is made, by way of example only, to the accompanying drawings in which:

Figure 1 is a schematic block diagram of a system for implementing a blockchain,

Figure 2 schematically illustrates some examples of transactions which may be recorded in a blockchain, Figure 3 schematically illustrates an example service for building and submitting transactions to the blockchain,

Figure 4 is a visualisation of a simulated annealing algorithm,

Figure 5 is a schematic block diagram of a system for implementing the described embodiments and

Figure 6 shows a transaction fees graph with respect to the leftover fee.

DETAILED DESCRIPTION OF EMBODIMENTS

1. EXAMPLE SYSTEM OVERVIEW

Figure 1 shows an example system 100 for implementing a blockchain 150. The system 100 may comprise a packet-switched network 101, typically a wide-area internetwork such as the Internet. The packet-switched network 101 comprises a plurality of blockchain nodes 104 that may be arranged to form a peer-to-peer (P2P) network 106 within the packet- switched network 101. Whilst not illustrated, the blockchain nodes 104 may be arranged as a near-complete graph. Each blockchain node 104 is therefore highly connected to other blockchain nodes 104.

Each blockchain node 104 comprises computer equipment of a peer, with different ones of the nodes 104 belonging to different peers. Each blockchain node 104 comprises processing apparatus comprising one or more processors, e.g. one or more central processing units (CPUs), accelerator processors, application specific processors and/or field programmable gate arrays (FPGAs), and other equipment such as application specific integrated circuits (ASICs). Each node also comprises memory, i.e. computer-readable storage in the form of a non-transitory computer-readable medium or media. The memory may comprise one or more memory units employing one or more memory media, e.g. a magnetic medium such as a hard disk; an electronic medium such as a solid-state drive (SSD), flash memory or EEPROM; and/or an optical medium such as an optical disk drive. The blockchain 150 comprises a chain of blocks of data 151, wherein a respective copy of the blockchain 150 is maintained at each of a plurality of blockchain nodes 104 in the distributed or blockchain network 106. As mentioned above, maintaining a copy of the blockchain 150 does not necessarily mean storing the blockchain 150 in full. Instead, the blockchain 150 may be pruned of data so long as each blockchain node 150 stores the block header (discussed below) of each block 151. Each block 151 in the chain comprises one or more transactions 152, wherein a transaction in this context refers to a kind of data structure. The nature of the data structure will depend on the type of transaction protocol used as part of a transaction model or scheme. A given blockchain will use one particular transaction protocol throughout. In one common type of transaction protocol, the data structure of each transaction 152 comprises at least one input and at least one output. Each output specifies an amount representing a quantity of a digital asset as property, an example of which is a user 103 to whom the output is cryptographically locked (requiring a signature or other solution of that user in order to be unlocked and thereby redeemed or spent). Each input points back to the output of a preceding transaction 152, thereby linking the transactions.

Each block 151 also comprises a block pointer 155 pointing back to the previously created block 151 in the chain so as to define a sequential order to the blocks 151. Each transaction

152 (other than a coinbase transaction) comprises a pointer back to a previous transaction so as to define an order to sequences of transactions (N.B. sequences of transactions 152 are allowed to branch). The chain of blocks 151 goes all the way back to a genesis block (Gb)

153 which was the first block in the chain. One or more original transactions 152 early on in the chain 150 pointed to the genesis block 153 rather than a preceding transaction.

Each of the blockchain nodes 104 is configured to forward transactions 152 to other blockchain nodes 104, and thereby cause transactions 152 to be propagated throughout the network 106. Each blockchain node 104 is configured to create blocks 151 and to store a respective copy of the same blockchain 150 in their respective memory. Each blockchain node 104 also maintains an ordered set (or "pool") 154 of transactions 152 waiting to be incorporated into blocks 151. The ordered pool 154 is often referred to as a "mempool". This term herein is not intended to limit to any particular blockchain, protocol or model. It refers to the ordered set of transactions which a node 104 has accepted as valid and for which the node 104 is obliged not to accept any other transactions attempting to spend the same output.

In a given present transaction 152j, the (or each) input comprises a pointer referencing the output of a preceding transaction 152i in the sequence of transactions, specifying that this output is to be redeemed or "spent" in the present transaction 152j. Spending or redeeming does not necessarily imply transfer of a financial asset, though that is certainly one common application. More generally spending could be described as consuming the output, or assigning it to one or more outputs in another, onward transaction. In general, the preceding transaction could be any transaction in the ordered set 154 or any block 151. The preceding transaction 152i need not necessarily exist at the time the present transaction 152j is created or even sent to the network 106, though the preceding transaction 152i will need to exist and be validated in order for the present transaction to be valid. Hence "preceding" herein refers to a predecessor in a logical sequence linked by pointers, not necessarily the time of creation or sending in a temporal sequence, and hence it does not necessarily exclude that the transactions 152i, 152j be created or sent out-of-order (see discussion below on orphan transactions). The preceding transaction 152i could equally be called the antecedent or predecessor transaction.

The input of the present transaction 152j also comprises the input authorisation, for example the signature of the user 103a to whom the output of the preceding transaction 152i is locked. In turn, the output of the present transaction 152j can be cryptographically locked to a new user or entity 103b. The present transaction 152j can thus transfer the amount defined in the input of the preceding transaction 152i to the new user or entity 103b as defined in the output of the present transaction 152j . In some cases a transaction 152 may have multiple outputs to split the input amount between multiple users or entities (one of whom could be the original user or entity 103a in order to give change). In some cases a transaction can also have multiple inputs to gather together the amounts from multiple outputs of one or more preceding transactions, and redistribute to one or more outputs of the current transaction. According to an output-based transaction protocol such as bitcoin, when a party 103, such as an individual user or an organization, wishes to enact a new transaction 152j (either manually or by an automated process employed by the party), then the enacting party sends the new transaction from its computer terminal 102 to a recipient. The enacting party or the recipient will eventually send this transaction to one or more of the blockchain nodes 104 of the network 106 (which nowadays are typically servers or data centres, but could in principle be other user terminals). It is also not excluded that the party 103 enacting the new transaction 152j could send the transaction directly to one or more of the blockchain nodes 104 and, in some examples, not to the recipient. A blockchain node 104 that receives a transaction checks whether the transaction is valid according to a blockchain node protocol which is applied at each of the blockchain nodes 104. The blockchain node protocol typically requires the blockchain node 104 to check that a cryptographic signature in the new transaction 152j matches the expected signature, which depends on the previous transaction 152i in an ordered sequence of transactions 152. In such an output-based transaction protocol, this may comprise checking that the cryptographic signature or other authorisation of the party 103 included in the input of the new transaction 152j matches a condition defined in the output of the preceding transaction 152i which the new transaction spends (or "assigns"), wherein this condition typically comprises at least checking that the cryptographic signature or other authorisation in the input of the new transaction 152j unlocks the output of the previous transaction 152i to which the input of the new transaction is linked to. The condition may be at least partially defined by a script included in the output of the preceding transaction 152i . Alternatively it could simply be fixed by the blockchain node protocol alone, or it could be due to a combination of these. Either way, if the new transaction 152j is valid, the blockchain node 104 forwards it to one or more other blockchain nodes 104 in the blockchain network 106. These other blockchain nodes 104 apply the same test according to the same blockchain node protocol, and so forward the new transaction 152j on to one or more further nodes 104, and so forth. In this way the new transaction is propagated throughout the network of blockchain nodes 104.

In an output-based model, the definition of whether a given output (e.g. UTXO) is assigned (or "spent") is whether it has yet been validly redeemed by the input of another, onward transaction 152j according to the blockchain node protocol. Another condition for a transaction to be valid is that the output of the preceding transaction 152i which it attempts to redeem has not already been redeemed by another transaction. Again if not valid, the transaction 152j will not be propagated (unless flagged as invalid and propagated for alerting) or recorded in the blockchain 150. This guards against double-spending whereby the transactor tries to assign the output of the same transaction more than once. An account-based model on the other hand guards against double-spending by maintaining an account balance. Because again there is a defined order of transactions, the account balance has a single defined state at any one time.

In addition to validating transactions, blockchain nodes 104 also race to be the first to create blocks of transactions in a process commonly referred to as mining, which is supported by "proof-of-work". At a blockchain node 104, new transactions are added to an ordered pool 154 of valid transactions that have not yet appeared in a block 151 recorded on the blockchain 150. The blockchain nodes then race to assemble a new valid block 151 of transactions 152 from the ordered set of transactions 154 by attempting to solve a cryptographic puzzle. Typically this comprises searching for a "nonce" value such that when the nonce is concatenated with a representation of the ordered pool of pending transactions 154 and hashed, then the output of the hash meets a predetermined condition. E.g. the predetermined condition may be that the output of the hash has a certain predefined number of leading zeros. Note that this is just one particular type of proof-of- work puzzle, and other types are not excluded. A property of a hash function is that it has an unpredictable output with respect to its input. Therefore this search can only be performed by brute force, thus consuming a substantive amount of processing resource at each blockchain node 104 that is trying to solve the puzzle.

The first blockchain node 104 to solve the puzzle announces this to the network 106, providing the solution as proof which can then be easily checked by the other blockchain nodes 104 in the network (once given the solution to a hash it is straightforward to check that it causes the output of the hash to meet the condition). The first blockchain node 104 propagates a block to a threshold consensus of other nodes that accept the block and thus enforce the protocol rules. The ordered set of transactions 154 then becomes recorded as a new block 151 in the blockchain 150 by each of the blockchain nodes 104. A block pointer 155 is also assigned to the new block 151n pointing back to the previously created block 151n-l in the chain. The significant amount of effort, for example in the form of hash, required to create a proof-of-work solution signals the intent of the first node 104 to follow the rules of the blockchain protocol. Such rules include not accepting a transaction as valid if it spends or assigns the same output as a previously validated transaction, otherwise known as double-spending. Once created, the block 151 cannot be modified since it is recognized and maintained at each of the blockchain nodes 104 in the blockchain network 106. The block pointer 155 also imposes a sequential order to the blocks 151. Since the transactions 152 are recorded in the ordered blocks at each blockchain node 104 in a network 106, this therefore provides an immutable public ledger of the transactions.

Note that different blockchain nodes 104 racing to solve the puzzle at any given time may be doing so based on different snapshots of the pool of yet-to-be published transactions 154 at any given time, depending on when they started searching for a solution or the order in which the transactions were received. Whoever solves their respective puzzle first defines which transactions 152 are included in the next new block 151n and in which order, and the current pool 154 of unpublished transactions is updated. The blockchain nodes 104 then continue to race to create a block from the newly-defined ordered pool of unpublished transactions 154, and so forth. A protocol also exists for resolving any "fork" that may arise, which is where two blockchain nodesl04 solve their puzzle within a very short time of one another such that a conflicting view of the blockchain gets propagated between nodes 104. In short, whichever prong of the fork grows the longest becomes the definitive blockchain 150. Note this should not affect the users or agents of the network as the same transactions will appear in both forks.

According to the bitcoin blockchain (and most other blockchains) a node that successfully constructs a new block 104 is granted the ability to newly assign an additional, accepted amount of the digital asset in a new special kind of transaction which distributes an additional defined quantity of the digital asset (as opposed to an inter-agent, or inter-user transaction which transfers an amount of the digital asset from one agent or user to another). This special type of transaction is usually referred to as a "coinbase transaction", but may also be termed an "initiation transaction" or "generation transaction". It typically forms the first transaction of the new block 151n. The proof-of-work signals the intent of the node that constructs the new block to follow the protocol rules allowing this special transaction to be redeemed later. The blockchain protocol rules may require a maturity period, for example 100 blocks, before this special transaction may be redeemed. Often a regular (non-generation) transaction 152 will also specify an additional transaction fee in one of its outputs, to further reward the blockchain node 104 that created the block 151n in which that transaction was published. This fee is normally referred to as the "transaction fee", and is discussed blow.

Due to the resources involved in transaction validation and publication, typically at least each of the blockchain nodes 104 takes the form of a server comprising one or more physical server units, or even whole a data centre. However in principle any given blockchain node 104 could take the form of a user terminal or a group of user terminals networked together.

The memory of each blockchain node 104 stores software configured to run on the processing apparatus of the blockchain node 104 in order to perform its respective role or roles and handle transactions 152 in accordance with the blockchain node protocol. It will be understood that any action attributed herein to a blockchain node 104 may be performed by the software run on the processing apparatus of the respective computer equipment. The node software may be implemented in one or more applications at the application layer, or a lower layer such as the operating system layer or a protocol layer, or any combination of these.

Also connected to the network 101 is the computer equipment 102 of each of a plurality of parties 103 in the role of consuming users. These users may interact with the blockchain network 106 but do not participate in validating transactions or constructing blocks. Some of these users or agents 103 may act as senders and recipients in transactions. Other users may interact with the blockchain 150 without necessarily acting as senders or recipients. For instance, some parties may act as storage entities that store a copy of the blockchain 150 (e.g. having obtained a copy of the blockchain from a blockchain node 104). Some or all of the parties 103 may be connected as part of a different network, e.g. a network overlaid on top of the blockchain network 106. Users of the blockchain network (often referred to as "clients") may be said to be part of a system that includes the blockchain network 106; however, these users are not blockchain nodes 104 as they do not perform the roles required of the blockchain nodes. Instead, each party 103 may interact with the blockchain network 106 and thereby utilize the blockchain 150 by connecting to (i.e. communicating with) a blockchain node 106. Two parties 103 and their respective equipment 102 are shown for illustrative purposes: a first party 103a and his/her respective computer equipment 102a, and a second party 103b and his/her respective computer equipment 102b. It will be understood that many more such parties 103 and their respective computer equipment 102 may be present and participating in the system 100, but for convenience they are not illustrated. Each party 103 may be an individual or an organization. Purely by way of illustration the first party 103a is referred to herein as Alice and the second party 103b is referred to as Bob, but it will be appreciated that this is not limiting and any reference herein to Alice or Bob may be replaced with "first party" and "second "party" respectively.

The computer equipment 102 of each party 103 comprises respective processing apparatus comprising one or more processors, e.g. one or more CPUs, GPUs, other accelerator processors, application specific processors, and/or FPGAs. The computer equipment 102 of each party 103 further comprises memory, i.e. computer-readable storage in the form of a non-transitory computer-readable medium or media. This memory may comprise one or more memory units employing one or more memory media, e.g. a magnetic medium such as hard disk; an electronic medium such as an SSD, flash memory or EEPROM; and/or an optical medium such as an optical disc drive. The memory on the computer equipment 102 of each party 103 stores software comprising a respective instance of at least one client application 105 arranged to run on the processing apparatus. It will be understood that any action attributed herein to a given party 103 may be performed using the software run on the processing apparatus of the respective computer equipment 102. The computer equipment 102 of each party 103 comprises at least one user terminal, e.g. a desktop or laptop computer, a tablet, a smartphone, or a wearable device such as a smartwatch. The computer equipment 102 of a given party 103 may also comprise one or more other networked resources, such as cloud computing resources accessed via the user terminal.

The client application 105 may be initially provided to the computer equipment 102 of any given party 103 on suitable computer-readable storage medium or media, e.g. downloaded from a server, or provided on a removable storage device such as a removable SSD, flash memory key, removable EEPROM, removable magnetic disk drive, magnetic floppy disk or tape, optical disk such as a CD or DVD ROM, or a removable optical drive, etc.

The client application 105 comprises at least a "wallet" function. This has two main functionalities. One of these is to enable the respective party 103 to create, authorise (for example sign) and send transactions 152 to one or more bitcoin nodes 104 to then be propagated throughout the network of blockchain nodes 104 and thereby included in the blockchain 150. The other is to report back to the respective party the amount of the digital asset that he or she currently owns. In an output-based system, this second functionality comprises collating the amounts defined in the outputs of the various 152 transactions scattered throughout the blockchain 150 that belong to the party in question.

Note: whilst the various client functionality may be described as being integrated into a given client application 105, this is not necessarily limiting and instead any client functionality described herein may instead be implemented in a suite of two or more distinct applications, e.g. interfacing via an API, or one being a plug-in to the other. More generally the client functionality could be implemented at the application layer or a lower layer such as the operating system, or any combination of these. The following will be described in terms of a client application 105 but it will be appreciated that this is not limiting.

The instance of the client application or software 105 on each computer equipment 102 is operatively coupled to at least one of the blockchain nodes 104 of the network 106. This enables the wallet function of the client 105 to send transactions 152 to the network 106. The client 105 is also able to contact blockchain nodes 104 in order to query the blockchain 150 for any transactions of which the respective party 103 is the recipient (or indeed inspect other parties' transactions in the blockchain 150, since in embodiments the blockchain 150 is a public facility which provides trust in transactions in part through its public visibility). The wallet function on each computer equipment 102 is configured to formulate and send transactions 152 according to a transaction protocol. As set out above, each blockchain node 104 runs software configured to validate transactions 152 according to the blockchain node protocol, and to forward transactions 152 in order to propagate them throughout the blockchain network 106. The transaction protocol and the node protocol correspond to one another, and a given transaction protocol goes with a given node protocol, together implementing a given transaction model. The same transaction protocol is used for all transactions 152 in the blockchain 150. The same node protocol is used by all the nodes 104 in the network 106.

When a given party 103, say Alice, wishes to send a new transaction 152j to be included in the blockchain 150, then she formulates the new transaction in accordance with the relevant transaction protocol (using the wallet function in her client application 105). She then sends the transaction 152 from the client application 105 to one or more blockchain nodes 104 to which she is connected. E.g. this could be the blockchain node 104 that is best connected to Alice's computer 102. When any given blockchain node 104 receives a new transaction 152j, it handles it in accordance with the blockchain node protocol and its respective role. This comprises first checking whether the newly received transaction 152j meets a certain condition for being "valid", examples of which will be discussed in more detail shortly. In some transaction protocols, the condition for validation may be configurable on a per-transaction basis by scripts included in the transactions 152. Alternatively the condition could simply be a built-in feature of the node protocol, or be defined by a combination of the script and the node protocol.

On condition that the newly received transaction 152j passes the test for being deemed valid (i.e. on condition that it is "validated"), any blockchain node 104 that receives the transaction 152j will add the new validated transaction 152 to the ordered set of transactions 154 maintained at that blockchain node 104. Further, any blockchain node 104 that receives the transaction 152j will propagate the validated transaction 152 onward to one or more other blockchain nodes 104 in the network 106. Since each blockchain node 104 applies the same protocol, then assuming the transaction 152j is valid, this means it will soon be propagated throughout the whole network 106.

Once admitted to the ordered pool of pending transactions 154 maintained at a given blockchain node 104, that blockchain node 104 will start competing to solve the proof-of- work puzzle on the latest version of their respective pool of 154 including the new transaction 152 (recall that other blockchain nodes 104 may be trying to solve the puzzle based on a different pool of transactionsl54, but whoever gets there first will define the set of transactions that are included in the latest block 151. Eventually a blockchain node 104 will solve the puzzle for a part of the ordered pool 154 which includes Alice's transaction 152j). Once the proof-of-work has been done for the pool 154 including the new transaction 152j, it immutably becomes part of one of the blocks 151 in the blockchain 150. Each transaction 152 comprises a pointer back to an earlier transaction, so the order of the transactions is also immutably recorded.

Different blockchain nodes 104 may receive different instances of a given transaction first and therefore have conflicting views of which instance is 'valid' before one instance is published in a new block 151, at which point all blockchain nodes 104 agree that the published instance is the only valid instance. If a blockchain node 104 accepts one instance as valid, and then discovers that a second instance has been recorded in the blockchain 150 then that blockchain node 104 must accept this and will discard (i.e. treat as invalid) the instance which it had initially accepted (i.e. the one that has not been published in a block 151).

An alternative type of transaction protocol operated by some blockchain networks may be referred to as an "account-based" protocol, as part of an account-based transaction model. In the account-based case, each transaction does not define the amount to be transferred by referring back to the UTXO of a preceding transaction in a sequence of past transactions, but rather by reference to an absolute account balance. The current state of all accounts is stored, by the nodes of that network, separate to the blockchain and is updated constantly. In such a system, transactions are ordered using a running transaction tally of the account (also called the "position"). This value is signed by the sender as part of their cryptographic signature and is hashed as part of the transaction reference calculation. In addition, an optional data field may also be signed the transaction. This data field may point back to a previous transaction, for example if the previous transaction ID is included in the data field.

2. UTXO-BASED MODEL

Figure 2 illustrates an example transaction protocol. This is an example of a UTXO-based protocol. A transaction 152 (abbreviated "Tx") is the fundamental data structure of the blockchain 150 (each block 151 comprising one or more transactions 152). The following will be described by reference to an output-based or "UTXO" based protocol. However, this is not limiting to all possible embodiments. Note that while the example UTXO-based protocol is described with reference to bitcoin, it may equally be implemented on other example blockchain networks.

In a UTXO-based model, each transaction ("Tx") 152 comprises a data structure comprising one or more inputs 202, and one or more outputs 203. Each output 203 may comprise an unspent transaction output (UTXO), which can be used as the source for the input 202 of another new transaction (if the UTXO has not already been redeemed). The UTXO includes a value specifying an amount of a digital asset. This represents a set number of tokens on the distributed ledger. The UTXO may also contain the transaction ID of the transaction from which it came, amongst other information. The transaction data structure may also comprise a header 201, which may comprise an indicator of the size of the input field(s) 202 and output field(s) 203. The header 201 may also include an ID of the transaction. In embodiments the transaction ID is the hash of the transaction data (excluding the transaction ID itself) and stored in the header 201 of the raw transaction 152 submitted to the nodes 104.

Say Alice 103a wishes to create a transaction 152j transferring an amount of the digital asset in question to Bob 103b. In Figure 2 Alice's new transaction 152j is labelled " Txi". It takes an amount of the digital asset that is locked to Alice in the output 203 of a preceding transaction 152i in the sequence, and transfers at least some of this to Bob. The preceding transaction 152i is labelled “ Txo" in Figure 2. TAT? and Txi are just arbitrary labels. They do not necessarily mean that Txo is the first transaction in the blockchain 151, nor that Txi is the immediate next transaction in the pool 154. Txi could point back to any preceding (i.e. antecedent) transaction that still has an unspent output 203 locked to Alice.

The preceding transaction Txo may already have been validated and included in a block 151 of the blockchain 150 at the time when Alice creates her new transaction Txi, or at least by the time she sends it to the network 106. It may already have been included in one of the blocks 151 at that time, or it may be still waiting in the ordered set 154 in which case it will soon be included in a new block 151. Alternatively Txo and Txi could be created and sent to the network 106 together, or Txo could even be sent after Txi if the node protocol allows for buffering "orphan" transactions. The terms "preceding" and "subsequent" as used herein in the context of the sequence of transactions refer to the order of the transactions in the sequence as defined by the transaction pointers specified in the transactions (which transaction points back to which other transaction, and so forth). They could equally be replaced with "predecessor" and "successor", or "antecedent" and "descendant", "parent" and "child", or such like. It does not necessarily imply an order in which they are created, sent to the network 106, or arrive at any given blockchain node 104. Nevertheless, a subsequent transaction (the descendent transaction or "child") which points to a preceding transaction (the antecedent transaction or "parent") will not be validated until and unless the parent transaction is validated. A child that arrives at a blockchain node 104 before its parent is considered an orphan. It may be discarded or buffered for a certain time to wait for the parent, depending on the node protocol and/or node behaviour.

One of the one or more outputs 203 of the preceding transaction Txo comprises a particular UTXO, labelled here UTXOo. Each UTXO comprises a value specifying an amount of the digital asset represented by the UTXO, and a locking script which defines a condition which must be met by an unlocking script in the input 202 of a subsequent transaction in order for the subsequent transaction to be validated, and therefore for the UTXO to be successfully redeemed. Typically the locking script locks the amount to a particular party (the beneficiary of the transaction in which it is included). I.e. the locking script defines an unlocking condition, typically comprising a condition that the unlocking script in the input of the subsequent transaction comprises the cryptographic signature of the party to whom the preceding transaction is locked.

The locking script (aka scriptPubKey) is a piece of code written in the domain specific language recognized by the node protocol. A particular example of such a language is called "Script" (capital S) which is used by the blockchain network. The locking script specifies what information is required to spend a transaction output 203, for example the requirement of Alice's signature. Unlocking scripts appear in the outputs of transactions. The unlocking script (aka scriptSig) is a piece of code written the domain specific language that provides the information required to satisfy the locking script criteria. For example, it may contain Bob's signature. Unlocking scripts appear in the input 202 of transactions.

So in the example illustrated, UTXOo in the output 203 of TAT? comprises a locking script [Checksig PA] which requires a signature Sig PA of Alice in order for UTXOo to be redeemed (strictly, in order for a subsequent transaction attempting to redeem UTXOo to be valid). [Checksig PA] contains a representation (i.e. a hash) of the public key PA from a public- private key pair of Alice. The input 202 of Txi comprises a pointer pointing back to Txi (e.g. by means of its transaction ID, TxIDo, which in embodiments is the hash of the whole transaction Txo). The input 202 of Txi comprises an index identifying UTXOo within Txo, to identify it amongst any other possible outputs of Txo. The input 202 of Txi further comprises an unlocking script <Sig PA> which comprises a cryptographic signature of Alice, created by Alice applying her private key from the key pair to a predefined portion of data (sometimes called the "message" in cryptography). The data (or "message") that needs to be signed by Alice to provide a valid signature may be defined by the locking script, or by the node protocol, or by a combination of these.

When the new transaction Txi arrives at a blockchain node 104, the node applies the node protocol. This comprises running the locking script and unlocking script together to check whether the unlocking script meets the condition defined in the locking script (where this condition may comprise one or more criteria). In embodiments this involves concatenating the two scripts: <Sig PA> <PA> | | [Checksig PA\ where "| |" represents a concatenation and "<...>" means place the data on the stack, and "[...]" is a function comprised by the locking script (in this example a stack-based language). Equivalently the scripts may be run one after the other, with a common stack, rather than concatenating the scripts. Either way, when run together, the scripts use the public key PA of Alice, as included in the locking script in the output of Txo, to authenticate that the unlocking script in the input of Txi contains the signature of Alice signing the expected portion of data. The expected portion of data itself (the "message") also needs to be included in order to perform this authentication. In embodiments the signed data comprises the whole of Txi (so a separate element does not need to be included specifying the signed portion of data in the clear, as it is already inherently present).

The details of authentication by public-private cryptography will be familiar to a person skilled in the art. Basically, if Alice has signed a message using her private key, then given Alice's public key and the message in the clear, another entity such as a node 104 is able to authenticate that the message must have been signed by Alice. Signing typically comprises hashing the message, signing the hash, and tagging this onto the message as a signature, thus enabling any holder of the public key to authenticate the signature. Note therefore that any reference herein to signing a particular piece of data or part of a transaction, or such like, can in embodiments mean signing a hash of that piece of data or part of the transaction.

If the unlocking script in Txi meets the one or more conditions specified in the locking script of Txo (so in the example shown, if Alice's signature is provided in Txi and authenticated), then the blockchain node 104 deems Txi valid. This means that the blockchain node 104 will add Txi to the ordered pool of pending transactions 154. The blockchain node 104 will also forward the transaction 7k; to one or more other blockchain nodes 104 in the network 106, so that it will be propagated throughout the network 106. Once Txi has been validated and included in the blockchain 150, this defines <77T(%from 7k?as spent. Note that Txi can only be valid if it spends an unspent transaction output 203. If it attempts to spend an output that has already been spent by another transaction 152, then Txi will be invalid even if all the other conditions are met. Hence the blockchain node 104 also needs to check whether the referenced UTXO in the preceding transaction Txo is already spent (i.e. whether it has already formed a valid input to another valid transaction). This is one reason why it is important for the blockchain 150 to impose a defined order on the transactions 152. In practice a given blockchain node 104 may maintain a separate database marking which UTXOs 203 in which transactions 152 have been spent, but ultimately what defines whether a UTXO has been spent is whether it has already formed a valid input to another valid transaction in the blockchain 150.

If the total amount specified in all the outputs 203 of a given transaction 152 is greater than the total amount pointed to by all its inputs 202, this is another basis for invalidity in most transaction models. Therefore such transactions will not be propagated nor included in a block 151.

Note that in UTXO-based transaction models, a given UTXO needs to be spent as a whole. It cannot "leave behind" a fraction of the amount defined in the UTXO as spent while another fraction is spent. However the amount from the UTXO can be split between multiple outputs of the next transaction. E.g. the amount defined in UTXOo in TAT? can be split between multiple UTXOs in Txi. Hence if Alice does not want to give Bob all of the amount defined in UTXOo, she can use the remainder to give herself change in a second output of Txi, or pay another party.

In practice Alice will also usually need to include a fee for the bitcoin node 104 that successfully includes her transaction 104 in a block 151. If Alice does not include such a fee, TAT? may be rejected by the blockchain nodes 104, and hence although technically valid, may not be propagated and included in the blockchain 150 (the node protocol does not force blockchain nodes 104 to accept transactions 152 if they don't want). In some protocols, the transaction fee does not require its own separate output 203 (i.e. does not need a separate UTXO). Instead any difference between the total amount pointed to by the input(s) 202 and the total amount of specified in the output(s) 203 of a given transaction 152 is automatically given to the blockchain node 104 publishing the transaction. E.g. say a pointer to UTXOo is the only input to Txi, and Txi has only one output UTXOi. If the amount of the digital asset specified in UTXOo is greater than the amount specified in UTXOi, then the difference may be assigned (or spent) by the node 104 that wins the proof-of-work race to create the block containing UTXOi. Alternatively or additionally however, it is not necessarily excluded that a transaction fee could be specified explicitly in its own one of the UTXOs 203 of the transaction 152.

Alice and Bob's digital assets consist of the UTXOs locked to them in any transactions 152 anywhere in the blockchain 150. Hence typically, the assets of a given party 103 are scattered throughout the UTXOs of various transactions 152 throughout the blockchain 150. There is no one number stored anywhere in the blockchain 150 that defines the total balance of a given party 103. It is the role of the wallet function in the client application 105 to collate together the values of all the various UTXOs which are locked to the respective party and have not yet been spent in another onward transaction. It can do this by querying the copy of the blockchain 150 as stored at any of the bitcoin nodes 104.

Note that the script code is often represented schematically (i.e. not using the exact language). For example, one may use operation codes (opcodes) to represent a particular function. "OP_..." refers to a particular opcode of the Script language. As an example, OP_RETURN is an opcode of the Script language that when preceded by OP_FALSE at the beginning of a locking script creates an unspendable output of a transaction that can store data within the transaction, and thereby record the data immutably in the blockchain 150. E.g. the data could comprise a document which it is desired to store in the blockchain.

Typically an input of a transaction contains a digital signature corresponding to a public key PA. In embodiments this is based on the ECDSA using the elliptic curve secp256kl. A digital signature signs a particular piece of data. In some embodiments, for a given transaction the signature will sign part of the transaction input, and some or all of the transaction outputs. The particular parts of the outputs it signs depends on the SIGHASH flag. The SIGHASH flag is usually a 4-byte code included at the end of a signature to select which outputs are signed (and thus fixed at the time of signing). The locking script is sometimes called "scriptPubKey" referring to the fact that it typically comprises the public key of the party to whom the respective transaction is locked. The unlocking script is sometimes called "scriptSig" referring to the fact that it typically supplies the corresponding signature. However, more generally it is not essential in all applications of a blockchain 150 that the condition for a UTXO to be redeemed comprises authenticating a signature. More generally the scripting language could be used to define any one or more conditions. Hence the more general terms "locking script" and "unlocking script" may be preferred.

3. SIDE CHANNEL

As shown in Figure 1, the client application on each of Alice and Bob's computer equipment 102a, 120b, respectively, may comprise additional communication functionality. This additional functionality enables Alice 103a to establish a separate side channel 107 with Bob 103b (at the instigation of either party or a third party). The side channel 107 enables exchange of data separately from the blockchain network. Such communication is sometimes referred to as "off-chain" communication. For instance this may be used to exchange a transaction 152 between Alice and Bob without the transaction (yet) being registered onto the blockchain network 106 or making its way onto the chain 150, until one of the parties chooses to broadcast it to the network 106. Sharing a transaction in this way is sometimes referred to as sharing a "transaction template". A transaction template may lack one or more inputs and/or outputs that are required in order to form a complete transaction. Alternatively or additionally, the side channel 107 may be used to exchange any other transaction related data, such as keys, negotiated amounts or terms, data content, etc.

The side channel 107 may be established via the same packet-switched network 101 as the blockchain network 106. Alternatively or additionally, the side channel 301 may be established via a different network such as a mobile cellular network, or a local area network such as a local wireless network, or even a direct wired or wireless link between Alice and Bob's devices 102a, 102b. Generally, the side channel 107 as referred to anywhere herein may comprise any one or more links via one or more networking technologies or communication media for exchanging data "off-chain", i.e. separately from the blockchain network 106. Where more than one link is used, then the bundle or collection of off-chain links as a whole may be referred to as the side channel 107. Note therefore that if it is said that Alice and Bob exchange certain pieces of information or data, or such like, over the side channel 107, then this does not necessarily imply all these pieces of data have to be send over exactly the same link or even the same type of network.

4. TRANSACTION FUNDING

4.1 Data funding

Generally speaking, UTXO-based blockchains can be seen as a cash system, where each unspent transaction outputs (UTXO) is a coin that can be spent only once. Each payment transaction consumes one or more UTXOs and creates one or more new UTXOs.

Figure 3 illustrates an example system 300 which may be used to increase scalability. The system comprises a funding service 301 that manages UTXOs using a service called a transaction builder (TxBuilder) 302 which holds a cache of several unspent transaction outputs (UTXOs). Given some data, the purpose of the TxBuilder 302 is to embed the data in a transaction that can be then published on the blockchain 150.

The TxBuilder 302 receives funds (i.e., UTXOs) from the funding service 301 split into fixed values e 1( ... , e k . These UTXOs are cached by the TxBuilder 302 into k buckets according to their values e 1( ... , e k , each bucket having a maximum capacity of Q UTXOs. Herein, e 1( ... , e k are referred to as denominations. Assume a client 303 (e.g. user application 105) requires storage of data D, the executed protocol steps are shown in Figure 3 and are detailed below:

1. The client 303 calls the TxBuilder 302, requesting storage of data D.

2. The TxBuilder 302 creates a transaction that embeds the data D: a. The TxBuilder 302 funds the transaction using the cached UTXOs from the Funding Service 301 and adds the required change outputs. b. If it does not have enough UTXOs of a certain denomination type in the cache, the TxBuilder 302 requests more denominations from the Funding Service 301. 3. The TxBuilder 302 sends the transaction to the funding service 301.

4. The funding service 301 sends the transaction to the broadcaster service 304.

5. The transaction is broadcast to the Bitcoin SV blockchain using the mAPI service.

6. The client 303 is notified that the data has been stored together with an inclusion proof (e.g. transaction ID containing the data together with a Merkle inclusion proof).

Each of the funding service 301, transaction builder 302, client 303 and broadcaster service 304 are components that may be implemented in hardware or software.

4.2 Dust limit

Some blockchains have a dust limit. The dust limit prevents transactions with very low value from being published. The reason for having a dust limit is that under the standard fee policies, a very low value output would require a higher fee to spend than the value of the output itself, making these transactions uneconomical to spend (the cost of the unlocking script would be higher than the UTXO value).

Another reason for setting a dust limit is to prevent dusting attacks. Dusting attacks are used by scammers to deanonymize transactions, revealing individuals or organizations behind a wallet. Scammers can "dust" a large number of addresses, wait for wallets to spend these dust outputs and then perform analysis to reveal which of these addresses belong to the same wallet.

4.3 Consolidation transactions

A consolidation transaction is a transaction that reduces the number of UTXOs by a margin that is more valuable for the network than the corresponding transaction fee. From a node's point of view the size of the UTXO database matters because the larger it is the higher the cost of maintaining it, for this reason it is in a node's economic interest to trim the UTXO where possible. Consolidation transactions, which have many inputs and few outputs, result in a shrinking of the UTXO database. T1

In general, a transaction is considered a consolidation transaction if:

• The input/output ratio is at least 1 to 100 (at least 100 inputs for each output).

• It only uses standard P2PKH inputs or bare multi-sig outputs with no more than two signatures.

• It only uses inputs confirmed for at least 6 blocks.

5. OPTIMISATION ALGORITHMS

5.1 Change-Making Problem (CMP)

The change-making problem (CMP) addresses the question of minimising the number of coins of certain denominations that sum up to an amount S. The question can be formulated as a minimisation problem. Given a set of denominations e 1( ... , e k and an amount S, solve: subject W t G N >0 where w t is the number of denominations of value This problem can be solved with dynamic programming in a similar manner as the 0-1 Knapsack problem. Let cmp[6, 2] be the minimum number of coins used to fund the amount 2 using the first 6 denominations.

We define cmp [<5, 2] as follows: oo, 6 = 0 cmp[6 — 1, 2J, e s > L min(cmp [<5 — 1, 2], 1 + cmp [<5, 2 — e 5 ]) , otherwise

We discuss each case:

• The first case is trivial, and says that we cannot solve the minimisation problem without any denominations. We use infinity oo to denote this. • In the second case, if the <5th denomination e s equals the amount 2, then 2 is paid for using e s . Thus, the minimum number of coins we use is 1.

• In the third case the <5th denomination is too large to pay for 2. Then the minimum number of coins is attained using the first 8 objects is equal to the maximum value attained using the first <5 — 1 objects.

• Finally, in the fourth case either the minimum value is attained using the first <5 — 1 denominations or by including the <5th denomination e s .

5.2 Simulated Annealing

Many problems are computationally intractable (NP-hard) through a deterministic algorithm. To approximate the solution of such difficult problems we can use heuristic algorithms such as Simulated Annealing, Tabu Search or Genetic algorithms that have proven to give reliable results to optimisation problems.

Simulated Annealing (SA) results in a fast convergence to an answer. This is a heuristic algorithm designed to approximate the global minimum of a function /(%) that has a large domain D of values x. In order to heuristically search for values /(%) close to the global minimum we start with an initial approximator x Q G D and parameters T o , T min and 0 < p < 1. T o and T min are called temperatures and p is the percentage at which the temperature decreases from T o to T min . The search for the global minimum also depends on a function neighbour that outputs a value the function f is evaluated on.

The pseudocode of the algorithm is the following:

1. Define x best x 0 , T T o .

2. While T > T min execute: a. Find an approximator in the neighbourhood of x best \ x new <- neighbour (x best ). b. Compute /(x new ). c. Compute A/ = f(.x new ) - f(x best ). i. If A/ < 0, then the value x new improves on the output of the function f and it becomes the current best approximator

■X-best ^new - _A£ ii. If A/ > 0, then we define the exponential value p = e r . If p is larger or equal than a value c randomly sampled from the uniform distribution (7(0,1), then we assign the new approximator to x best : x best <- %new d. T <- T - (l — p).

3. Output f(x best )' .

We expand on the steps above to give the intuition of this algorithm. If we want to improve on the value f(x best ), we derive a new approximator x new from the current best approximator x best in Step 3. a. If the neighbouring approximator x new improves on the value f(x best ), we update the approximator x best in Step 3.c.i.

The idea of this algorithm is that if x new does not improve on the value f(x best ), then we may still accept it as long as p > c in Step 3.c.ii. This condition allows for the algorithm to escape local minima of / at the cost of temporarily increasing the value of f in order to approximate the global minimum. This is shown in Figure 4.

The value T starts at a positive value T o and is decreased by multiplication with the drop rate p in Step 3.d, until it reaches a value T min close to 0. This ensures that at the start of the algorithm we escape local minima more frequently in Step 3.c.ii . As T decreases and approaches 0, the value of p approaches 0 and accepting non-optimal approximators x new becomes less likely. In this case the algorithm focuses on improving the global minimum approximator using Step 3.c.i. When implementing the algorithm, we may define the function neighbour. This is problem dependent.

6. OPTIMISING TRANSACTION SIZE

Embodiments of the present disclosure relate to optimizing a size of a transaction, and determining a set of precomputed denominations that provides the best trade-off between transaction size and time to identify and retrieve UTXOs. This is useful for high-throughput applications or applications that need parallelisable transaction creation. Figure 5 illustrates an example system 500 for implementing the described embodiments. As shown, the system 500 includes an optimizer 502 that has access to a store of UTXOS 501. The optimizer 502 is configured to connect directly or indirectly to the blockchain network 106. In an example implementation, the optimizer 502 may take the form of, or comprise, the transaction builder 302 of Figure 3. In this implementation, the optimizer 502 may additionally comprise one or both of the funding service 301 and the broadcaster service 304. The optimizer may be operated by a user such as Alice 103a or Bob 103b. In general, the optimizer may be implemented in hardware or software, or a combination.

The optimizer 502 obtains a transaction template. The optimizer 502 may generate the transaction template or receive the transaction template from a different entity, e.g. a client application 303, a user 103, etc. The transaction template may have a structure similar to that shown in Figure 2. The transaction template includes at least one input and at least one output. Each input to the transaction has an associated value. Each output of the transaction may be a spendable output or an unspendable output. An unspendable output has no associated value, whereas a spendable output does. The transaction template includes target data. Each input has an associated input fee that contributes to a total transaction fee. Each output also has an associated output fee that contributes to the total transaction fee. Similarly, the target data has an associated data fee that contributes to the total transaction fee. The fees are typically based on the size of the relevant field, e.g. a fee per byte. The total amount of the value(s) of the input(s) must be at least equal to a sum of the total amount of the value(s) of the output(s) and the transaction fee. If not, the transaction may (or will) be rejected when submitted to the network 106.

The UTXO store 501 contains a plurality of UTXOs which are available for being input to the transaction. The UTXO store 501 may be operated by the optimizer 502. The optimizer 502 is configured to communicate with the UTXO store to determine which UTXOs are available. In some examples, the UTXO store contains UTXOs of only certain values, e.g. of only a single value. That is, the UTXO store contains UTXOs of predetermined values and only UTXO of those predetermined values are added to the UTXO store. In other examples, the UTXO store contains UTXOs of varying values. In other words, the UTXO store contains UTXO of any value and there is no processing involved in adding or removing UTXOs of certain values. In some examples, the UTXOs are ordered from smallest value to highest value (or vice versa) in order to make searching of the UTXO store 501 more efficient.

The optimizer 502 determines the number of inputs of each particular value that are required to fund the transaction. The optimizer 502 also determines the number of additional outputs of each particular value (i.e. other than the output containing the target data) that are required. One or more additional outputs may be required so as to prevent excess fee leakage and/or create UTXOs of certain values for future use. In other words, the optimizer 502 determines a number of inputs and outputs having a first value, a number of inputs and outputs having a second value, and so on, for each value of UTXO available to the optimizer 502. Note that the number of inputs and outputs of a certain value may be zero. Similarly, the number of inputs having a certain value may be different to the number of outputs having the same value.

Moreover, rather than just determining any number of inputs and outputs of particular values, the optimizer 502 determines the minimum number of inputs of each value and the minimum number of outputs of each value that satisfies a set of funding criteria. This is done by minimising, for each different UTXO value, a sum of a) the number of each different input UTXO value multiplied by the associated input fee, and b) a sum of bi) the number of each different output UTXO value multiplied by the associated output fee, and bii) a leftover fee. The minimization is subject to several constraints, discussed below.

Once the optimizer 502 has determined the optimal number of inputs and outputs of different values, the optimizer 502 causes the completed transaction to be sent to the blockchain network 106. For example, the optimizer may submit the transaction to the network 106. Or, the optimizer may send the transaction to a different entity or component (e.g. broadcaster service 304) to be sent to the network 106.

In some embodiments, described in mathematical terms, the optimizer 502 may determine which UTXOs to use to fund the transaction by minimizing the following equation: where w t is the number of UTXOs input to the transaction having a respective value corresponding to the index i, fee in is the input fee, w- is the number of UTXOs of the transaction (i.e. the outputs) having a respective value corresponding to index i, fee out is the output fee, and fee E is the leftover fee. The leftover fee is discussed below.

The equation is minimised subject to the following conditions: i) a total value of the UTXOs input to the transaction must be at least equal to the data fees and the leftover amount, the number of each input UTXO must be zero or more, the number of each output UTXO must be zero or more, and the leftover amount must be between zero and a maximum of a predetermined upper bound and a sum of the input fee and the output fee.

Minimizing the equation thus outputs a respective number of input UTXOs at each value and a respective number of output UTXOs at each value (where the number of a UTXO at a given value may be zero). It is particular advantageous to use a set of predetermined UTXO values to fund the transaction.

The leftover fee is calculated based on a leftover amount. For each possible solution to the equation, the respective values of the transaction's input(s) are summed to give a total input value. The respective values of the transaction's output(s) are summed to give a total output value. The total transaction fee is determined based on the input fees, the output fees and the data fees. The leftover amount is then determined as the difference between the total input value and the sum of the total output value and the total transaction fee. The optimizer 502 may then determine the leftover fee by inputting the leftover amount into a fee decision algorithm.

The fee decision algorithm outputs one of three leftover amounts. If the leftover amount is less that the total of a single input fee and a single output fee, then the fee decision algorithm outputs the leftover amount as the leftover fee. If the leftover amount is instead more than the total of a single output fee and the dust limit, then the fee decision algorithm outputs the sum of a single output fee and a single input fee as the leftover fee. If the leftover amount takes any other value, the fee decision algorithm outputs infinity as the leftover fee. This signals that there are not enough inputs, and that the equation can minimised further. In other words, the minimisation of the equation requires a different number of inputs and outputs.

The above equation may be solved using a dynamic programming approach, as described in section 7.4 below. For instance, a modified change-making problem algorithm may be used to solve the equation. The change-making problem algorithm per se is well-known. However in its original form it is not suitable for solving the equation above. This is because it does not take into account the specific features of the blockchain, including fees for adding inputs and outputs to a transaction, and the dust limit. The present disclosure thus recognises how the change-making problem algorithm is to be adapted in order to solve the equation and optimise transaction funding.

In other embodiments, the optimizer 502 may be configured to execute a fee decision algorithm. The fee decision algorithm determines, based on the state of the transaction template, a leftover amount (or leftover value). The respective values of the transaction's input(s) are summed to give a total input value. The respective values of the transaction's output(s) are summed to give a total output value. The total transaction fee is determined based on the input fees, the output fees and the data fees. The leftover amount is then determined as the difference between the total input value and the sum of the total output value and the total transaction fee. The fee decision algorithm may itself calculate the leftover amount, or it may receive the leftover amount as an input to the algorithm.

Based on the leftover amount, the fee decision algorithm determines whether one or more additional inputs and/or one or more additional outputs are required. The fee decision algorithm minimises the transaction size by only adding the additional input(s) and output(s) if required to satisfy the fee condition associated with the transaction. In some examples, at the time of executing the fee decision algorithm, the transaction template has a single input and a single output. In some examples, the single output is an unspendable output with no value.

The fee decision algorithm then takes one of three options, the first option being more favourable than the second, and the second option being more favourable than the third. As a first option, if the leftover amount is less that the total of a single input fee and a single output fee, no additional input or output is added to the transaction. The optimizer 502 thus causes the transaction template to be sent to the network 106. In some examples, this means that the leftover amount is left to the blockchain node 104 that incorporates the transaction into a new block 151.

As a second option, if the leftover amount is greater than a single output fee and the dust limit, then an additional output is added to the transaction by the optimizer 502 and the transaction is sent to the network 106. The additional output may be assigned a value equal to or less than the leftover amount (but at least equal to the dust limit).

As a third option, if the leftover amount is less than a single output fee and the dust limit, but more than the total of a single input fee and a single output fee, then an additional input and an additional output is added to the transaction by the optimizer 502. The transaction is then sent to the network 106. The additional output may be assigned a value equal to or less than the leftover amount (but at least equal to the dust limit).

In some embodiments, the fee decision algorithm may be ran after a transaction builder algorithm has been run, where the transaction builder algorithm first attempts to optimise the transaction size, with the fee decision algorithm then optimizing transaction size by determining what action to take with the leftover amount.

In some examples, the UTXO store comprises UTXOs of varying values, and the first input of the transaction template is determined by (i.e. selected by) a variable input section algorithm (an example of a transaction builder algorithm). The optimizer 502 is configured to execute the variable input section algorithm. When executed, the algorithm determines whether a UTXO is available that has a value which results in the leftover amount being less than a single output fee. If such a UTXO is available, the UTXO is selected as an input to the transaction and the fee decision algorithm is executed. If such a UTXO is not available, the selection algorithm determines whether a UTXO is available which results in the leftover amount being more than a single output fee and the dust limit. If a UTXO is available which meets this criteria, the UTXO is selected and the fee decision algorithm is executed. If such a UTXO is not available, the selection algorithm determines whether a UTXO is available that has a value which results in the leftover amount more than a single output fee but less than a combined total of a single input fee and a single output fee. If such a UTXO is available which meets this criteria, it is selected and the fee decision algorithm is executed. If such a UTXO is not available, the selection algorithm determines whether a UTXO is available which has a value that results in the leftover amount being more than the combined input and output fee, and less than a single output fee and the dust limit. If available, this UTXO is selected and the fee decision algorithm is executed.

In these examples, if the UTXO store does not include a UTXO large enough to cover the transaction fees, one or more additional UTXOs are selected as inputs to the transaction.

In some examples, the UTXO store consists of UTXOs of a single value, and the first input of the transaction template is determined by (i.e. selected by) a single-value input selection algorithm (another example of a transaction builder algorithm). This section algorithm determines how many of these single value UTXOs are required as inputs to the transaction. When executed by the optimizer 502, the selection algorithm determines the smallest quantity of UTXOs such that the total value of that quantity of UTXOs having the single value is greater than a sum of i) the data fee and ii) the total value of input fees associated with that quantity of UTXOs. The optimizer 502 adds the UTXOs to the transaction and executes the fee decision algorithm.

In some examples, the UTXO store comprises UTXOs of set values. That is, each UTXO has a value equal to one of a predefined set of values. For example, the UTXO store may comprise UTXOs that have one of two predefined values, or three predefined values, etc. In other words, the UTXO values are not random. Each value is associated with a respective index, with the lowest value associated with the lowest index and the highest value associated with the highest index. In these examples, the input(s) of the transaction template may be determined by (i.e. selected by) a multiple-value input selection algorithm (another example of a transaction builder algorithm).

Starting with the highest index (corresponding to the highest value of UTXOs), the selection algorithm determines the smallest quantity of UTXOs at that highest value such that the total value of that quantity of UTXOs is greater than a sum of i) the data fee and ii) the total value of input fees associated with that quantity of UTXOs. If the UTXO store includes that smallest quantity of UTXOs, the selection algorithm adds the UTXOs to the transaction and executes the fee decision algorithm. If the UTXO store does not include the smallest equation of UTXOs at the highest value, the selection algorithm adds to the transaction all of the UTXOs at the highest value that are stored in the UTXO store. For instance, if three UTXOs are required but the UTXO store only contains two, then the two UTXOs are added to the transaction.

Then, the process is repeated for the next highest index (i.e. the penultimate index) corresponding to the next highest value of UTXOs. The data fee is reassigned a fee equal to the data fee, plus the fees associated with the number of inputs added to the transaction, minus the total value of the inputs added to the transaction. Thus the selection algorithm determines the smallest quantity of UTXOs at the next highest value such that the total value of that quantity of UTXOs is greater than a sum of i) the re-assigned data fee and ii) the total value of input fees associated with that quantity of UTXOs. If the UTXO store includes that smallest quantity of UTXOs, the selection algorithm adds the UTXOs to the transaction and executes the fee decision algorithm. If the UTXO store does not include the smallest equation of UTXOs at the highest value, the selection algorithm adds to the transaction all of the UTXOs at the highest value that are stored in the UTXO store. The process of updating the data fee, determining the smallest quantity of UTXOs at the next highest value, and adding UTXOs to the transaction continues until the fee decision algorithm is executed. In some examples, the UTXO store comprises UTXOs of varying values. In other examples, the UTXO store comprises UTXOs of set values. That is, each UTXO has a value equal to one of a predefined set of values. For example, the UTXO store may comprise UTXOs that have one of two predefined values, or three predefined values, etc. In other words, the UTXO values are not random.

The optimizer 502 may use the embodiments above to optimize a plurality of transactions. In some examples, each transaction has the same type and size of target data and therefore has the same associated data fee. Therefore the same number and value of the input UTXOs and output UTXOs may be used for each of the plurality of transactions.

As stated above, embodiments relate to determining the optimal set of denominations (UTXO values) for a given funding scenario, i.e. for a transaction with target data up to a maximum data size / maximum data fee. The funding scenario may be defined by a predefined set of expected transactions (or transaction sizes). This optimal set of denominations may then be used as the UTXO pool accessible by the optimizer 502, as described above. That is, given the optimal set of denominations, the optimizer may determine the number of, and the value of, the inputs and outputs of a given transaction so as to minimise the size of that transaction.

The optimizer 502 determines the optimal set of denominations (also referred to as UTXO values or input values) by minimizing a function. The function may be referred to as a "denomination function". The denomination function is evaluated based on a plurality (likely many) different sets of denominations. Each pair of sets of denominations differs in at least one denomination. For illustrative purposes, one set may contain denominations 1, 2 and 3, another set may contain denominations, 1, 3 and 5, another set may contain denominations 9, 17, and 100, and so on. That is, two or more sets may contain one or more denominations of the same value. Similarly, two or more sets may contain no denominations of the same value. In some examples, the smallest denomination is at least equal to the dust limit.

The denomination function is based on the following variables: i) the total amount of fees of the respective transaction (taking into account all input fees, output fees, and data fees); ii) the maximum data fee that any given transaction fee will have due to the target data included in that transaction; iii) the total value of all denominations required to fund a set of transactions; iv) a total number of spendable (i.e. change outputs) of across the set of transactions; v) an initial number of instances of each denomination available to the optimizer; and vi) a total number of transactions that are to be funded using the set of denominations.

In some examples, the optimizer 502 obtains the UTXOs used to fund a transaction from a separate pool of UTXOs (e.g. maintained by the funding service 301). In these examples, the denomination function may also be dependent upon the number of communications between the optimizer and the UTXO pool (or host of the UTXO pool), where each communication is a request for the initial number of instances of each denomination.

The denomination function is evaluated using a plurality of different sets of denominations. The set of denominations that results in the minimum value of the function is the optimal set of denominations. The optimal set of denominations may be used by the optimizer 502 when funding one or more transactions, e.g. using one of the algorithms described above or below in section 7.4 and 7.5.

The denomination function is first evaluated with an initial set of denominations, then a second set of denominations (which differs from the initial set), then a third set (which differs from the first and second sets), and so on. In some examples, a "neighbour function" may be used to determine each next set of denominations to be evaluated. Each denomination is assigned an index, e.g. from 1 to k (where k is the total number of denominations). The neighbour function works by sampling an index from 1 to k, then selecting the corresponding denomination to form part of the next set.

The number of denominations per set (k) may be predefined at the start of the computation, e.g. fixed at three, five, ten, etc. In other examples, the number of denominations in each set may vary. For example, the heuristic algorithm (e.g. the neighbour function) may determine the best value for k.

In general any suitable heuristic technique may be used to minimise the denomination function. For instance, a genetic algorithm may be used. Alternatively, a simulated annealing algorithm may be used, as described in section 7.5 below.

7. EXAMPLE IMPLEMENTATIONS

The section shows how some example transactions can be optimally funded using the described embodiments. We assume throughout that we want to create a transaction that contains the data payload D. The length of the data can be variable in size, encrypted or not. We define the optimal funding of such a transaction as finding the set of UTXOs that minimises transaction fees. This task is two layered:

1. Given a set of UTXOs, which UTXOs should be spent to minimise the transaction fees?

2. Which is the best set of UTXOs that on average minimises transaction fees (as given in Question 1) for many funding requests of data payloads with varying sizes?

7.1 Setup

We define an example scenario with reference to Figure 3. Assume a client service 303 calls the TxBuilder 302 requiring funding for data D. The TxBuilder 302 then constructs a transaction with the necessary inputs and change outputs. For example, the transaction may take the following form: where in lf ...,in n are amounts controlled by the Funding service 301, and the first output is the change returning ou^ Satoshis to the service 301. Each unlocking script (i.e., each input) has an associated transaction fee fee in and similarly the P2PKH locking script (i.e., output 0) has an associated fee fee out . Furthermore, the UTXOs unlocked by the inputs need to cover the data fees fee D associated with data D (i.e., output 1). More concretely, we have:

LZI-L + in 2 + — I- in n = out } + fee out + n ■ fee in + fee D + E

The column "Value" shown as being part of the Input is not part of the transaction, but is shown to illustrate the amount of Satoshis to unlock. The row "Fee"s is not part of the transaction, but is shown to illustrate the amount of transaction fees.

As it is very unlikely that the sum of the available input values in t equals the required fees (fee out + n ■ fee in + fee D ), we usually provide a higher amount of 40atoshis than required. We use the notation E to denote any remaining amount of 40atoshis that can be used to cover fees for a change output), or it can be left to the miner as additional fees. We call E an excess term or leftover amount.

We consider the following example:

• in ± = 300 SAT, in 2 = 448 SAT;

• fee in = 74 SAT, fee out = 17 SAT; data D has size 800 bytes, the fee rate is 0.5 SAT/byte, and consequently fee D = 400

SAT.

We can pay for fee D using in x and in 2 . We derive the value of the change output out^ from the formula: ini + in 2 = ou^ + fee out + 2 • fee in + fee D + s

Then s = 183 SAT. £ can be left as additional fee to the miner or returned to the payer as change. Paying an additional fee out to create the new output, we can create an additional change output worth 164 SAT (e — fee out ).

Hereinafter, the following assumptions are made:

• fee D also includes the fees necessary to pay for the transaction header and auxiliary information (nVersion, locktime, number of inputs, number of outputs).

• We consider the specific case of data funding, but the techniques are generalisable to fund transactions that have several spendable outputs.

• fee out < fee in < l d , where l d is the dust limit. The inequalities hold when using P2PKH unlocking scripts and locking scripts where at a rate of 0.5 SAT/byte we have: o fee out = 17 SAT, corresponding to a standard P2PKH output:

■ 25 bytes for P2PKH locking script (20 bytes for public key hash + opcodes)

■ 8 bytes to encode the value (in satoshis)

■ 1 byte for variable-length script size o fee in = 74 SAT, corresponding to a P2PKH unlocking script which is at most 148 bytes:

■ 40 bytes for spending UTXO reference (32 bytes TxID + sequence number)

■ up to 108 bytes for P2PKH unlocking script (up to 73 bytes ECDSA signature + 33 bytes public key + opcodes)

■ 1 byte for variable-length script size o The dust limit in Bitcoin is currently set at l d = 135 SAT for P2PKH scripts.

• fee out , fee in and l d are fixed constants because we fix the script type, whereas fee D can vary. 7.2 Variable UTXO values

One option to create a transaction that funds storing data D on-chain is to spend the required outputs from a UTXO pool containing UTXOs of variable amounts. We show four example funding scenarios. For the purpose of simplifying computations, we assume the data transaction fees fee D = 226 SAT.

7.2.1 Example 1

The UTXO pool contains 3 UTXOs with values 200 SAT, 310 SAT and 430 SAT.

The funding of data D that minimises transaction fees is to select in ± = 310 SAT, which covers fee in , fee D and an additional E = 10 SAT fee is left to the miner. The transaction is:

In this example we cannot add a change because fee out > E. It is worth noting that using the higher UTXO, worth 430 SAT, would allow to create a change output and collect the change. However, the cost of the new output (fee out = 17 SAT) would be higher than leaving the current E to the miner.

7.2.2 Example 2

The UTXO pool contains 3 UTXOs with values 200 SAT, 500 SAT and 800 SAT.

The funding of data D that minimises transaction fees is in ± = 500 SAT, which covers fee in , fee D and the output fee fee out for a change output. The transaction is:

An alternative (more expensive) solution would be to only have the data output and omit the change. This would lead to an additional 200 SAT fee left to the miner (change +

7.2.3 Example 3

The UTXO pool contains 3 UTXOs with values 200 SAT, 250 SAT and 350 SAT.

The funding of data D that minimises transaction fees is to select in ± = 350 SAT which covers fee in , fee D and an additional s = 50 SAT fee is left to the miner. The transaction is: In this example fee out < E, SO we can add a change output, but doing so would result in an output that is less than the dust limit l d which is not allowed by policy.

7.2.4 Example 4 The UTXO pool contains 3 UTXOs with values 250 SAT, 280 SAT and 290 SAT.

The funding of data D that minimises transaction fees is to select in x = 250 SAT and in 2 = 280 SAT which cover 2fee in , fee D and the output fee fee out for a change output. The transaction is:

In this example we needed to combine two inputs to cover all required transaction fees.

This scenario is more expensive in comparison to the above examples as we have to pay a fee fee in for each input. 7.3 Implementation

The examples discussed can be generalised according the following formula: in! = fee in + fee D + E, where the value of the input in x is used to cover the fees for the input fee in and the fees for the data fee D . As already mentioned, any remaining amount of satoshis is called excess term E.

The excess term E can be left to the miner as additional reward or it can be returned to the transaction funder in the form of change output. As the choice of the funding a UTXO (in^ determines the value of E, choosing the optimal in } is important in this process. The reason is that this determines what can be done with E: leave it to the miner or return it to the funding service 301 as change output.

Assuming a dust limit l d > fee in we identify four scenarios (see Figure 5), depending on the value of E:

1. E < fee out (solid line)

In this case we cannot add a change output since E is not enough to cover the additional transaction fee fee out to create the output locking script for the change transaction, E is left to the miner as additional reward.

2. fee out < E < fee in + fee out (small dashed line)

Also in this case we cannot add a change output, E would be enough to cover the additional transaction fee fee out but the resulting output is below the dust limit l d . E is left to the miner as additional reward.

3. fee in + fee out < E < fee out + l d (double line)

In this case is favourable to create a change output and collect E. AS the resulting change would still be below the dust limit l d , an additional input in 2 is required to increase E above the threshold l d . With the addition of another input, the total transaction fee becomes 2 • fee in + fee out + fee D , and the remaining E is returned as output change.

4. E > fee out + l d (large dashed line)

Also in this case is favourable to create a change output and collect E. Differently from the previous case, here the change is already above the dust limit and there is no need to add an additional input. The total transaction fees therefore are fee in + fee out + fee D and the remaining E is output change.

The 4 scenarios determine if the excess term can be collected in a change output or has to be left to the miner as additional fee. They can be summarised in a function as follows: fee_decision

Input: £

Output: additional transaction fees

1. If e < fee in + fee out then output E.

2. Otherwise if fee in + fee out < E < fee out + l d then output fee out + f ee in .

3. Otherwise, output fee out . fee_decision is a specific example of the fee decision algorithm described in section 6.

Based on the four scenarios described in Figure 5, the funding protocol chooses the funding UTXO in lt among the ones available in the pool, that reduces the fees to be paid to the miner. Given fee in + fee D (the minimum amount to be paid to publish a transaction embedding data D) we build the transaction with minimum fees. This is done by ordering the strategies from the best (lowest additional transaction fee) to the worst (highest additional transaction fee) that should be used when selecting from the available UTXOs for funding the transaction:

7.4 Dynamic programming approach

The approach presented in this section is based on the CMP algorithm presented in Section 5.1 above. CMP has two limitations. Firstly, it assumes that there are no transaction fees and secondly it does not take advantage of change. These limitations may lead to non- optimal transaction funding by not minimising fees. This is particularly relevant in blockchain transactions, as inputs and outputs have an associated fee. Define the weights w t to be the number of inputs spending UTXOs of denomination e b and the weights w[ to be the number of outputs of the denomination e t . The spent UTXOs pay for fee D , input fees, output values, output fees and the excess term. This is captured by the following relation:

We subtract the term + — I- w k e k + Yi w t fee in + Yi w- fee out from both sides of the equation:

Furthermore, we rewrite the equation as follows:

= fee D + E

This is the equation that the inputs, outputs and the excess term have to satisfy. Then the minimisation problem we solve is the following: subject to w 1 (e 1 - fee in ) + ••• + w k (e k - fee in ) - w[(e 1 + fee out ) -

~ Wk(e k + fee out ) = fee D + E,

Wi,w[ e N s0 ,

0 < E < max{E, fee out + fee in } where fee E = fee_decision(e) for E < fee in + fee out and E > l d + fee out , otherwise fee E = oo. The value E is an upper bound for the excess term which has to be chosen as input to the problem. We detail this later.

We discuss the minimisation problem:

• The first line of the problem says that we want to minimise transaction fees by reducing the values of w it w- or fee E . • The second line introduces the first constraint of the minimisation: we can minimise fees subject to covering the data fees fee D and any excess term e.

• The second and third constraints bound the values of w it w- and e.

When the upper bound E is very high (e.g. E = 2 • e k + fee out ), then wj = ••• = = 0 and consequently if a change output is created, it values e. This choice can be made if in practice splitting the output into denominations is too expensive in terms of transaction fees. This can be the case if too many UTXOs of small denomination values have to be created. Then it is better to create an additional transaction that spends multiple UTXOs of value £ and turns them into denominations.

On the other hand, if E < fee out + fee in then e < fee out + fee in and the minimisation will create outputs using the value of the denominations. The value e is left to the miner as additional transaction fees.

The minimisation introduces two problems that require us to change the CMP algorithm:

• the terms w- (e k + fee out ) are deducted (so increasing w[ decreases the total value) and

• the excess term e is variable.

One option is to use the minimisation algorithm described below.

Step 1: Deducting values

The function below shows how to minimise transaction fees for each transaction that covers data fees 2 < fee D . We assume £ = 0 and discuss the excess term in Step 2. com p ute_cm p_negati ve

Inputs: e 1( ..., e k , fee D

1. Execute the CMP algorithm defined in Section 5.1 on the denominations with $ C^k ’ f^^D-

This outputs a matrix cmp in [<5, 2], 6 < k, 2 < S. Each element of the matrix at position (<5, 2) represents the minimum number UTXOs we have to spend to cover a fee 2 < S using the first 6 denominations. We discuss the value S below.

2. Execute the CMP algorithm in Section 5.1 on the denominations with

S (e k -i "h f^^out) ’ fe^D-

This outputs a matrix cmp out [<5, C], 6 < k, C < S. Each element of the matrix at position (<5, C) represents the minimum number UTXOs we have to spend to cover a fee C < S using the first 6 denominations. We discuss the value S below.

We use the following notation: 2 in = cmp in [k,l], (C + 2) in = cmp in [k, C + 2] and C out = cmp out [fc, C],

3. Define the one-dimensional array cmp neg computing the minimum transaction fees as follows:

4. where

C = wl( ei + fee out ) + ••• + w k (e k + fee out ) and

C + 2 = w 1 (e 1 - fee in ) + ••• + w k (e k - fee in ).

Then either the fee 2 is covered with no change and then 2 in • fee in is the minimum transaction fee, or the fee 2 is covered by deducting C from the amount C + 2. In the latter case, the minimum transaction fee required to cover 2 is given by (C + 2) fn - fee in + Cout ■ fe ^out-

5. Output the array cmp neg . Then the transaction that covers the data fees fee D has the minimum transaction fee cm P neg [fee D ],

The amounts (e k — fee in ) ■ fee D and (e,^ + fee out ) ■ fee D represent the worst case scenario where to cover fee D we need to spend w k ••= fee D UTXOs of value e k and create w k-± := fee D outputs of value e k-r such that e k fe^in C^k-1 "h feeout) !■

This means we only cover 1 SAT unit with each input, output pair. By creating the transaction with fee D inputs, subtracting the outputs and associated input and output fees, we then cover fee D . We have

The transaction below illustrates the values C and C + 2:

The inputs spend C + 2 input fees. The total change outputs cover C - output fees.

Step 2: Excess term

Finally, we solve the minimisation problem for variable excess terms 0 < E < max{E, fee out + fee in } using the following function: com p ute_cm p_fi na I

Inputs: e 1( e 2 , ..., e k ,fee D , E

1. Execute compute_neg_final with inputs e 1( e k and fee D + max{E, fee out + fee in }. This outputs the array cmp neg .

2. Define the one-dimensional array cmpf inai computing the minimum transaction fees as follows:

3. Output the array cmpf ina i. Then the minimum transaction fee to cover the data fees fee D for variable excess E is

Once cmpf inai has been computed, for each data fee 2 < fee D we can create a transaction in worst case time O(fee D /e } ). Furthermore, each transaction has minimum fees and its construction is faster than the Greedy approach describe above if fee D le r is lower than k.

The CMP algorithm requires O(kS) space. We can further optimise this by rewriting the recurrence as: , , cmp [8 mod 2, 2 — e 5 ]) , otherwise

This gives a space complexity of only 0(5) requiring the allocation of a matrix of size 2 x S. We discuss the optimisation and refer to Section 5.1 for the CMP algorithm. In Section 2.2.1 the computation of cmp[8, 2] depends only on the value cmp[<5 — 1,2] and cmp[3, Z — e 5 ]. Thus, to compute the 6 row of the matrix cmp we only need the current row 6 and the previous row <5 — 1. Using this observation, we only need two rows in the matrix, the (8 mod 2)t/i row acting like the <5 row and the (8 — 1 mod 2)th row acting like the 8 — 1 row.

If we do not want the change output to be split into denominations, it is sufficient to set E = 2 • e k + fee out . In this case the solution is to fund fee D only with denominations of value

The advantage of splitting the output into denominations is that the UTXOs can then be directly stored in the funding service UTXO pool. If we choose not to split the change output into denominations, then an additional transaction has to be created in order to split the funds into denominations. Whereas both options require additional transaction fees (either because we have more outputs, or because we create another transaction), it requires less fees to split the output into denominations and avoid creating another transaction. 7.5 Finding denominations

This section describes a technique for finding the set of denominations that minimise the size of transactions and consequently minimise the transaction fees fee D .

7.5.1 Methodology

We define a function f that measures the fitness of a set of denominations e 1( ... , e k when used to fund a large number of transactions N of different sizes. In genetic algorithms, the fitness measures how close a given solution is to the optimum solution of the desired problem. The output of the function f aggregates several measurements of the set to fund each of the N transactions. We want to find the set of denominations that gives the minimum value of the function f. Because there are infinitely many sets of denominations e 1( ... , e k that can be used, finding the set that minimises the function f is intractable to solve using a deterministic algorithm. Thus, to find the set we use the heuristic Simulated Annealing (SA) algorithm introduced in Section 5.2.

7.5.2 Setup

To run SA, we need to define the function f we wish to minimise and the function neighbour that selects at each iteration the next evaluation point for/.

We assume that the TxBuilder 302 is initially loaded with Q instances of each denomination e 1( ..., e k . Depending on which denominations are used in transactions, our experimental results show how many instances Q t should the TxBuilder 302 load for each denomination e t . We fund a collection of N transactions each with different data fees fee D and define:

• M the maximum value fee D can take,

• F the total transaction fees paid,

• S the total value of all unlocked UTXOs used to fund all N transactions, and

• 0 the total number of change outputs. The change outputs will have to be split into denominations. Every time the TxBuilder 302 terminates to supply of UTXOs of denomination e b it communicates with the funding service 301 asking for Q UTXOs of denomination e t . We define C as the number of communications between the funding service 301 and the TxBuilder 302 needed to fund all N transactions.

The function f is evaluated on the set e 1( ..., e k and returns a positive number:

We discuss the definition of the function:

• The first term of this equation computes the expected transaction fees normalised by the maximum size of a transaction fee M.

• The second term measures how many funds need to be allocated to fund a transaction normalised by the maximum size of a transaction fee M.

• The third term adds a penalisation term for the change outputs, since they will have to be split into denominations. This adds computational overhead.

• The last term measures the impact of the number of communications C, each requiring Q instances of a denomination to be transferred to the Tx Builder from the Funding Service.

• We divide the sum of all four terms by the number of transactions N to obtain to obtain a value that indicates the fitness of the set e 1( ... , e k per transaction.

Finally, the function neighbour takes as input a set of denominations e 1( ... , e k and derives a new set. It executes the following three steps:

1. Sample with equal probability an integer i G {1, ..., k}

2. Sample with equal probability an integer e G {l d , l d + 1,

3. Return the set of denominations {e 1( ... , e^, e, e i+1 , ... , e k )

7.5.3 Parameters To run the SA algorithm using the optimal decomposition in Section 7.4.3, we choose the following parameters. These can be changed depending on specifications, without requiring any change of the algorithms.

• Set the maximum excess value to E = 2 • e k + fee out . Since f increases in value with the number of communications, it will not be optimal to use only one denomination e k as we will see in the results below.

• Set the number of transactions to N = 3000 and the quantity Q = N /k for each denomination. This number is chosen based on the number of UTXOs we expect to load in the TxBuilder N = Q ■ k.

• Assume the fee per byte is set to 0.5 SAT/byte, the dust limit l d is set to 135 SAT, and the transaction fees for the unlocking and locking scripts are - fee in = 74 SAT and fee out = 17 SAT respectively, corresponding to P2PKH scripts.

• The data fees are normally distributed with mean fee D = 191 SAT.

We analyse two examples: when the standard deviation of the set of fees fee D is 1 and when it is 30.

7.5.4 Experimental Results

7.5.4.1 Standard deviation 1

In this case 99.7% of data have fees fee D between 189 and 193 SAT. This applies when the data fees are expected to mostly stay constant for all data transactions. The table below shows the results we have obtained by running the SA algorithm depending on the number of denominations k = 1, 3, 5 and 7.

We make some observations:

• Since the standard deviation is only 1 the data fees fee D do not vary significantly and hence the simulation algorithm correctly identified that even if we choose 3, 5 or 7 denominations, the optimal strategy is to use a single denomination based on the usage column.

• The best denomination to choose is 267 SAT (as used in the set of 7 denominations). This is because it minimises S and F and moreover is used 2993 times. Furthermore, if we rerun the simulation using the single denomination 267, we obtain S = 802335 and F = 801460 and a usage of 3005. The values of S and F are lower than for the denomination of value 272 SAT.

• The 267 SAT denomination is exactly covering the data fee fee D in the case it reaches 193 SAT and one locking script fee fee in = 74 SAT.

Based on the observations, we can USE a single denomination e r = 267 SAT in all N = 3000 transactions. Then = 3000 = N/l.

7.5.4.2 Standard deviation 30

In this case 99.7% of data have fees fee D between 101 and 281 SAT. This setting applies when the data fees can vary considerably, and a better diversification of denominations is appropriate. The table below shows the results we have obtained by running the SA algorithm depending on the number of denominations k = 1, 3, 5 and 7.

We make the following observations:

• In our testing, out of 3000 transactions, only a maximum of 5 change outputs were created using the 3, 5 and 7 denominations. • Furthermore the sets of 3, 5, and 7 denominations yield a significant improvement of the value of the function f in comparison to using only one denomination.

• The sets of 3, 5, and 7 denominations, reduce the total required funding S and the total transaction fees F . In particular, the sets of 5 and 7 denominations perform best.

The set of 7 denominations gives an overall lower value of the function f , optimising the total required funds and transactions fees. This is due to a good diversification of denominations.

8. EXAMPLE USE CASES

This section shows how the algorithms of the previous sections can be used in two funding examples using single denominations. We assume a data payload of constant size, hence why single denominations are appropriate. Furthermore, because the data payload has constant size, we can compute the value of the single denomination with precision.

8.1 Use case 1

As reference we use the transaction published here: https://test.whatsonchain.com/tx/817a3b51d7923e0a25978737473 f80970c3268fl337750c 6d3c8c0edf7a6960f

The total number of bytes of the hex codes relating to the transaction's data is 382 bytes requiring a fee of 191 SAT using a 0.5 SAT/byte fee rate. Using the notation introduced above, the data fee fee D is 191 SAT.

Any P2PKH input using a compressed public key contains: the previous hash Txld (32 bytes), the outpoint value (4 bytes), the script length (1 byte), the locking script (at most 107 bytes [10]) and the nSequence value (4 bytes). Thus, a P2PKH input requires at most 148 bytes. The input fee is fee in is 74 SAT computed at a 0.5 SAT/byte fee rate.

Furthermore, any P2PKH output contains: the nValue field (8 bytes), the script length (1 byte), and the unlocking script (25 bytes). Thus, a P2PKH output requires 34 bytes. The output fee fee out is 17 SAT.

To cover the data fee fee D it is then enough to fix a single denomination e r of value 191+74 SAT, i.e. 265 SAT. Thus, using e r of value 265 SAT we cover all necessary fees (fee D and fee in ) and we do not require any change outputs.

8.2 Example 2

This example builds upon Example 1, and additional to funding data, we also require the funding of a P2PKH input and output. The P2PKH input and output are used to deterministically chain the transactions. The input unlocks a fixed dust amount d of 135 SAT and similarly the output has a value d. Thus, the single denomination e ± needs to account for fee D of 191 SAT, one P2PKH input fee fee in of 74 SAT and one P2PKH output fee fee out of 17 SAT. Furthermore, the single denomination needs to also cover its own input fee fee in of 74 SAT. Thus, e r = 191 + 2 • 74 + 17 SAT, i.e. e r = 356 SAT. An example transaction is given below:

By using e r as the single denomination, we cover all necessary fees and do not require any change outputs.

9. FURTHER REMARKS

Other variants or use cases of the disclosed techniques may become apparent to the person skilled in the art once given the disclosure herein. The scope of the disclosure is not limited by the described embodiments but only by the accompanying claims.

For instance, some embodiments above have been described in terms of a bitcoin network 106, bitcoin blockchain 150 and bitcoin nodes 104. However it will be appreciated that the bitcoin blockchain is one particular example of a blockchain 150 and the above description may apply generally to any blockchain. That is, the present invention is in by no way limited to the bitcoin blockchain. More generally, any reference above to bitcoin network 106, bitcoin blockchain 150 and bitcoin nodes 104 may be replaced with reference to a blockchain network 106, blockchain 150 and blockchain node 104 respectively. The blockchain, blockchain network and/or blockchain nodes may share some or all of the described properties of the bitcoin blockchain 150, bitcoin network 106 and bitcoin nodes 104 as described above. In preferred embodiments of the invention, the blockchain network 106 is the bitcoin network and bitcoin nodes 104 perform at least all of the described functions of creating, publishing, propagating and storing blocks 151 of the blockchain 150. It is not excluded that there may be other network entities (or network elements) that only perform one or some but not all of these functions. That is, a network entity may perform the function of propagating and/or storing blocks without creating and publishing blocks (recall that these entities are not considered nodes of the preferred bitcoin network 106).

In other embodiments of the invention, the blockchain network 106 may not be the bitcoin network. In these embodiments, it is not excluded that a node may perform at least one or some but not all of the functions of creating, publishing, propagating and storing blocks 151 of the blockchain 150. For instance, on those other blockchain networks a "node" may be used to refer to a network entity that is configured to create and publish blocks 151 but not store and/or propagate those blocks 151 to other nodes.

Even more generally, any reference to the term "bitcoin node" 104 above may be replaced with the term "network entity" or "network element", wherein such an entity/element is configured to perform some or all of the roles of creating, publishing, propagating and storing blocks. The functions of such a network entity/element may be implemented in hardware in the same way described above with reference to a blockchain node 104.

It will be appreciated that the above embodiments have been described by way of example only. More generally there may be provided a method, apparatus or program in accordance with any one or more of the following Statements.

Statement 1. A computer-implemented method of determining an optimal set of input values for use as funding a set of respective blockchain transactions, wherein each transaction requires at least one input and at least one output, each respective input being a respective unspent transaction output, UTXO, having a respective input value, wherein each transaction comprises respective target data having an respective associated data fee, each input to a transaction has an associated input fee and each output of a transaction has an associated output fee, and wherein a total amount of respective input values of the respective UTXOs input to a respective transaction is required to be at least equal to a total amount of fees of the respective transaction, and wherein the method comprises: for a plurality of different respective sets of input values, determining the respective set of input values that minimises a function when evaluated based on the set of respective blockchain transactions, wherein the function is based on i) the total amount of fees of the respective transaction, ii) a maximum of the respective associated data fees, iii) is a total value of all input values used for respective inputs to the set of transactions, iv) a total number of spendable outputs across the set of transactions, v) an initial number of instances of each input value available to the optimizer, and vi) a total number of transactions in the set of transactions.

Evaluating the function based on the set of respective blockchain transactions means evaluating the function based on the predefined transaction fees associated with the set of respective blockchain transactions.

Statement 2. The method of statement 1, wherein the optimizer is configured to obtain each UTXO form a pool of UTXOs, and wherein the function is also based on vii) a number of communications between the optimizer and the pool of UTXOs required to obtain a total number of instances of each input value needed to fund the set of transactions.

Statement 3. The method of statement 1 or statement 2, wherein said determining comprises: a) evaluating the function based on the set of respective blockchain transactions, given an initial set of input values; b) determining a respective next set of input values by changing one or more of the input values in the initial set of input values; c) evaluating the function based on the set of respective blockchain transactions, given the respective next set of input values; and repeating steps b and c until the function is minimised for the set of respective blockchain transactions, wherein the respective next set of inputs values used in step c is used as the initial set of input values in step b.

Statement 4. The method of any preceding statement, wherein the function is minimised using a heuristic function.

Statement 5. The method of statement 4, wherein the heuristic function is a simulated annealing algorithm.

Statement 6. The method of statement 2 or any statement dependent thereon, wherein the function is of the following form: where F is the total amount of fees of the respective transaction, M is the maximum of the respective associated data fees, S is the total value of all input values used for respective inputs to the set of transactions, 0 is the total number of spendable outputs of across the set of transactions, Q is the total number of instances of each input value needed to fund the set of transactions, N is the total number of transactions in the set of transactions, C is the number of communications between the optimizer and the pool of UTXOs required to obtain the total number of instances of each input value needed to fund the set of transactions, and e t is a respective input value associated with index i.

Statement 7. The method of any preceding statement, comprising, given the optimal set of input values, minimising a number of inputs and/or outputs of a target transaction by: determining a respective number of each respective UTXO having a respective value to be used as a respective input to the target transaction and a respective number of each output of the transaction having a respective value, by minimising, for each different respective value of the respective UTXOs and for each different respective value of each output, a sum of a) a number of each respective UTXO having a respective value multiplied by the associated input fee, and b) a sum of bi) a number of each respective output having a respective value multiplied by the associated output fee, and bii) a leftover fee, wherein said minimising is subject to the following constraints: i) a total amount of the respective values of the respective UTXOs must be at least equal to the data fees and a leftover amount, wherein the leftover amount is based on based on a total amount of respective values of one or more respective UTXOs input to the transaction, a total amount of respective values of one or more respective outputs of the transaction, and a total amount of fees of the transaction, ii) the determined respective number of each UTXO must be non-negative, iii) the determined respective number of each output must be non-negative, and iv) the leftover amount must be between zero and a maximum of a predetermined upper bound and a sum of the associated input fee and the associated output fee.

Statement 8. The method of statement 7, wherein said determining comprises minimizing the following equation: wherein each respective value is associated with a respective index i based on the respective value, and where w t is the respective number of each respective UTXO having a respective value corresponding to the index i, fee in is the associated input fee, w- is the respective number of each output of the transaction having a respective value corresponding to index i, fee out is the associated output fee, and fee E is the leftover fee.

Statement 9. The method of statement 8, wherein: constraint i) is defined fee out ) — - w k( e k + f ee out) = fee D + s, where e t is the respective value corresponding to index i, fee D is the associated data fee, and s is the leftover amount; constraint ii) and constraint iii) are defined by Wj,w/ G N s0 ; constraint iv) is defined by 0 < e < max{E, fee out + fee in }, where E is the predetermined upper bound.

Statement 10. The method of statement 7 or any statement dependent thereon, comprising calculating the leftover fee based on the leftover amount, wherein:

If the leftover amount is less than a sum of the associated input fee and the associated output fee, the leftover fee is the leftover amount; otherwise, if the leftover amount is less than a sum of the associated output fee and a predetermined minimum value, the leftover fee is the sum of the associated input fee and the associated output fee; otherwise, the leftover fee is equal to infinity.

Statement 11. The method of statement 7 or any statement dependent thereon, wherein said determining is performed using a dynamic programming approach.

Statement 12. The method of statement 11, wherein a change-making problem algorithm, cmp[<5, 2], is defined as follows: where 6 is an index representing a respective position of a respective UTXO in a sequence ordered based on the respective value of the respective UTXO, 2 is the total amount of fees of the transaction, and e s is the respective value at position 6 in the sequence, and wherein said determining comprises determining a minimum total transaction fee to cover the data fee by: calculating a first matrix, cmp in [6, 2], for a set of first input values

{e x — fee in , ... , e k — fee in ], where k is the respective index corresponding to a highest respective value of the respective UTXOs; calculating a second matrix, cmp out [6, 2], for a set of second input {t?l + ••• > + f & calculating an array, fee out \ where Y in = cmp in [k,£], (C + Z) in = cmp in [k, C + 2] and C out = cmp 0Ut [k, C], and where

k (e k - fee in ), and calculating the array c fee E , where cmpf inai [fee D ] is the minimum transaction fee to cover the data fee.

Statement 13. The method of statement 12, wherein a change-making problem algorithm, cmp[6, 2], is defined as follows: , , cmp [<5 mod 2, 2 — e 5 ]) , otherwise where 6 is an index representing a respective position of a respective UTXO in a sequence ordered based on the respective value of the respective UTXO, 2 is the total amount of fees of the transaction, and e s is the respective value at position 6 in the sequence, and wherein said determining comprises determining a minimum total transaction fee to cover the data fee by: calculating a first matrix, cmp in [6, 2], for a set of first input values

{e x — fee in , ... , e k — fee in ], where k is the respective index corresponding to a highest respective value of the respective UTXOs; calculating a second matrix, cmp out [6, 2], for a set of second input fee out \ where Y in = cmp in [k,£], (C + Z) in = cmp in [k, C + 2] and C out = cmp 0Ut [k, C], and where

k (e k - fee in ), and calculating the array c fee E , where cmpf inai [fee D ] is the minimum transaction fee to cover the data fee.

Statement 14. The method of any of statements 1 to 6, comprising, given the optimal set of input values, minimising a number of inputs and/or outputs of a target transaction by executing a fee decision algorithm, wherein the fee decision algorithm determines whether an additional output of the target transaction is required, and wherein said executing comprises: determining a leftover amount based on the total amount of respective values of one or more respective UTXOs input to the target transaction, the total amount of respective values of one or more respective outputs of the target transaction, and the total amount of fees of the target transaction, if the leftover amount if less than a total of the associated input fee and the associated output fee, causing the target transaction to be sent to a blockchain network without the additional output, if the leftover amount is greater than the associated output fee, causing the target transaction to be sent to the blockchain network with the additional output; and if the leftover amount is greater than the total of the associated input fee and the associated output fee and less than the associated output fee and a predetermined minimum value, causing the target transaction to be sent to the blockchain network with the additional output and an additional input.

Statement 15. The method of statement 14, comprising executing a variable-value input selection algorithm, wherein the variable input selection algorithm determines a first one of the at least one inputs of the target transaction, and wherein said executing comprises: if available, selecting a respective UTXO having a respective value which results in the leftover amount being less than the associated output fee; if not, then, if available, selecting a respective UTXO having a respective value which results in the leftover amount being greater than the associated output fee and the predetermined minimum value; if not, then, if available, selecting a respective UTXO having a respective value which results in the leftover amount being greater than the associated output fee and less the total of the associated input fee and the associated output fee; if not, selecting a respective UTXO having a respective value which results in the leftover amount being greater than the total of the associated input fee and the associated output fee and less than the associated output fee and the predetermined minimum value; adding the selected respective UTXO as the first input to the blockchain transaction; and causing the fee decision algorithm to be executed.

Statement 16. The method of statement 15, comprising: if the plurality of UTXOs does not include a respective UTXO having a respective value large enough to cover the total amount of fees of the target transaction, adding one or more additional UTXOs as one or more additional inputs to the transaction.

Statement 17. The method of statement 14, wherein the respective value of each of the plurality of UTXOs is a respective one of one or more predetermined values, each predetermined value being associated with a respective index based on the predetermined value and wherein the method comprises executing a multiple-value input selection algorithm, wherein said executing comprises: starting with a highest one of the predetermined values, performing a process of steps: a) determining a minimum number, wherein the minimum number corresponds to a smallest number of the respective UTXOs having that predetermined value that results in i) a total value of that predetermined value multiplied by the minimum number, being greater than ii) the data fee summed with a total amount of the associated input fees multiplied by the minimum number; b) if the plurality of UTXOs comprises at least the first minimum number of respective UTXOs having that predetermined value, adding the first minimum number of UTXOs having that predetermined value as respective inputs of the transaction, and causing the fee decision algorithm to be executed; c) if the plurality of UTXOs comprises a second number of respective UTXOs having that predetermined value which is less than the first minimum number of respective UTXOs having that predetermined value, adding the second number of respective UTXOs having that predetermined value as respective inputs of the transaction, and repeating the process of steps a), b) and c) for a next highest one of the predetermined values, wherein the data fee is replaced with a total of the data fee, summed with the second number multiplied by the associated input fee, minus the second number multiplied by that predetermined value, wherein the process is repeated for each next highest one of the predetermined values until the fee decision algorithm is executed.

Statement 18. The method of any of statements 7 to 17, wherein the predetermined minimum value is set by the blockchain protocol.

Statement 19. The method of any of statements 7 to 17, wherein the plurality of UTXOs are ordered monotonically by respective value.

Statement 20. The method of any of statements 7 to 17, comprising using the method to optimize a respective size of a plurality of respective blockchain transactions, each respective blockchain transaction having respective target data having the same associated data fee.

Statement 21. Computer equipment comprising: memory comprising one or more memory units; and processing apparatus comprising one or more processing units, wherein the memory stores code arranged to run on the processing apparatus, the code being configured so as when on the processing apparatus to perform the method of any of statements 1 to 20.

Statement 22. A computer program embodied on computer-readable storage and configured so as, when run on one or more processors, to perform the method of any of statements 1 to 20.