@keep-network/tbtc-v2 0.1.1-dev.0 → 0.1.1-dev.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/artifacts/TBTC.json +24 -24
  2. package/artifacts/TBTCToken.json +24 -24
  3. package/artifacts/VendingMachine.json +17 -17
  4. package/artifacts/solcInputs/258c81d1106a1d8dae0e3424749db907.json +134 -0
  5. package/build/contracts/GovernanceUtils.sol/GovernanceUtils.dbg.json +1 -1
  6. package/build/contracts/bank/Bank.sol/Bank.dbg.json +4 -0
  7. package/build/contracts/bank/Bank.sol/Bank.json +537 -0
  8. package/build/contracts/bridge/BitcoinTx.sol/BitcoinTx.dbg.json +4 -0
  9. package/build/contracts/bridge/BitcoinTx.sol/BitcoinTx.json +10 -0
  10. package/build/contracts/bridge/Bridge.sol/Bridge.dbg.json +4 -0
  11. package/build/contracts/bridge/Bridge.sol/Bridge.json +473 -0
  12. package/build/contracts/bridge/Bridge.sol/IRelay.dbg.json +4 -0
  13. package/build/contracts/bridge/Bridge.sol/IRelay.json +37 -0
  14. package/build/contracts/bridge/VendingMachine.sol/VendingMachine.dbg.json +1 -1
  15. package/build/contracts/bridge/VendingMachine.sol/VendingMachine.json +2 -2
  16. package/build/contracts/token/TBTC.sol/TBTC.dbg.json +1 -1
  17. package/build/contracts/token/TBTC.sol/TBTC.json +4 -4
  18. package/build/contracts/vault/IVault.sol/IVault.dbg.json +4 -0
  19. package/build/contracts/vault/IVault.sol/IVault.json +47 -0
  20. package/build/contracts/vault/TBTCVault.sol/TBTCVault.dbg.json +4 -0
  21. package/build/contracts/vault/TBTCVault.sol/TBTCVault.json +181 -0
  22. package/contracts/bank/Bank.sol +389 -0
  23. package/contracts/bridge/BitcoinTx.sol +125 -0
  24. package/contracts/bridge/Bridge.sol +804 -0
  25. package/contracts/vault/IVault.sol +60 -0
  26. package/contracts/vault/TBTCVault.sol +146 -0
  27. package/deploy/00_resolve_tbtc_v1_token.ts +1 -1
  28. package/export.json +4 -4
  29. package/package.json +25 -15
  30. package/artifacts/solcInputs/7cc3eda3cb3ff2522d18b5e7b31ea228.json +0 -104
@@ -0,0 +1,125 @@
1
+ // SPDX-License-Identifier: MIT
2
+
3
+ // ██████████████ ▐████▌ ██████████████
4
+ // ██████████████ ▐████▌ ██████████████
5
+ // ▐████▌ ▐████▌
6
+ // ▐████▌ ▐████▌
7
+ // ██████████████ ▐████▌ ██████████████
8
+ // ██████████████ ▐████▌ ██████████████
9
+ // ▐████▌ ▐████▌
10
+ // ▐████▌ ▐████▌
11
+ // ▐████▌ ▐████▌
12
+ // ▐████▌ ▐████▌
13
+ // ▐████▌ ▐████▌
14
+ // ▐████▌ ▐████▌
15
+
16
+ pragma solidity 0.8.4;
17
+
18
+ /// @title Bitcoin transaction
19
+ /// @notice Allows to reference Bitcoin raw transaction in Solidity.
20
+ /// @dev See https://developer.bitcoin.org/reference/transactions.html#raw-transaction-format
21
+ ///
22
+ /// Raw Bitcon transaction data:
23
+ ///
24
+ /// | Bytes | Name | BTC type | Description |
25
+ /// |--------|--------------|------------------------|---------------------------|
26
+ /// | 4 | version | int32_t (LE) | TX version number |
27
+ /// | varies | tx_in_count | compactSize uint (LE) | Number of TX inputs |
28
+ /// | varies | tx_in | txIn[] | TX inputs |
29
+ /// | varies | tx_out count | compactSize uint (LE) | Number of TX outputs |
30
+ /// | varies | tx_out | txOut[] | TX outputs |
31
+ /// | 4 | lock_time | uint32_t (LE) | Unix time or block number |
32
+ ///
33
+ //
34
+ /// Non-coinbase transaction input (txIn):
35
+ ///
36
+ /// | Bytes | Name | BTC type | Description |
37
+ /// |--------|------------------|------------------------|---------------------------------------------|
38
+ /// | 36 | previous_output | outpoint | The previous outpoint being spent |
39
+ /// | varies | script bytes | compactSize uint (LE) | The number of bytes in the signature script |
40
+ /// | varies | signature script | char[] | The signature script, empty for P2WSH |
41
+ /// | 4 | sequence | uint32_t (LE) | Sequence number |
42
+ ///
43
+ ///
44
+ /// The reference to transaction being spent (outpoint):
45
+ ///
46
+ /// | Bytes | Name | BTC type | Description |
47
+ /// |-------|-------|---------------|------------------------------------------|
48
+ /// | 32 | hash | char[32] | Hash of the transaction to spend |
49
+ /// | 4 | index | uint32_t (LE) | Index of the specific output from the TX |
50
+ ///
51
+ ///
52
+ /// Transaction output (txOut):
53
+ ///
54
+ /// | Bytes | Name | BTC type | Description |
55
+ /// |--------|-----------------|-----------------------|--------------------------------------|
56
+ /// | 8 | value | int64_t (LE) | Number of satoshis to spend |
57
+ /// | 1+ | pk_script_bytes | compactSize uint (LE) | Number of bytes in the pubkey script |
58
+ /// | varies | pk_script | char[] | Pubkey script |
59
+ ///
60
+ /// compactSize uint format:
61
+ ///
62
+ /// | Value | Bytes | Format |
63
+ /// |-----------------------------------------|-------|----------------------------------------------|
64
+ /// | >= 0 && <= 252 | 1 | uint8_t |
65
+ /// | >= 253 && <= 0xffff | 3 | 0xfd followed by the number as uint16_t (LE) |
66
+ /// | >= 0x10000 && <= 0xffffffff | 5 | 0xfe followed by the number as uint32_t (LE) |
67
+ /// | >= 0x100000000 && <= 0xffffffffffffffff | 9 | 0xff followed by the number as uint64_t (LE) |
68
+ ///
69
+ /// (*) compactSize uint is often references as VarInt)
70
+ ///
71
+ library BitcoinTx {
72
+ /// @notice Represents Bitcoin transaction data for funding BTC deposit
73
+ /// P2(W)SH transaction.
74
+ struct Info {
75
+ /// @notice Bitcoin transaction version
76
+ /// @dev `version` from raw Bitcon transaction data.
77
+ /// Encoded as 4-bytes signed integer, little endian.
78
+ bytes4 version;
79
+ /// @notice All Bitcoin transaction inputs, prepended by the number of
80
+ /// transaction inputs.
81
+ /// @dev `tx_in_count | tx_in` from raw Bitcon transaction data.
82
+ ///
83
+ /// The number of transaction inputs encoded as compactSize
84
+ /// unsigned integer, little-endian.
85
+ ///
86
+ /// Note that some popular block explorers reverse the order of
87
+ /// bytes from `outpoint`'s `hash` and display it as big-endian.
88
+ /// Solidity code of Bridge expects hashes in little-endian, just
89
+ /// like they are represented in a raw Bitcoin transaction.
90
+ bytes inputVector;
91
+ /// @notice All Bitcoin transaction outputs prepended by the number of
92
+ /// transaction outputs.
93
+ /// @dev `tx_out_count | tx_out` from raw Bitcoin transaction data.
94
+ ///
95
+ /// The number of transaction outputs encoded as a compactSize
96
+ /// unsigned integer, little-endian.
97
+ bytes outputVector;
98
+ /// @notice Bitcoin transaction locktime.
99
+ ///
100
+ /// @dev `lock_time` from raw Bitcoin transaction data.
101
+ /// Encoded as 4-bytes unsigned integer, little endian.
102
+ bytes4 locktime;
103
+ }
104
+
105
+ /// @notice Represents data needed to perform a Bitcoin SPV proof.
106
+ struct Proof {
107
+ /// @notice The merkle proof of transaction inclusion in a block.
108
+ bytes merkleProof;
109
+ /// @notice Transaction index in the block (0-indexed).
110
+ uint256 txIndexInBlock;
111
+ /// @notice Single byte-string of 80-byte bitcoin headers,
112
+ /// lowest height first.
113
+ bytes bitcoinHeaders;
114
+ }
115
+
116
+ /// @notice Represents info about an unspent transaction output.
117
+ struct UTXO {
118
+ /// @notice Hash of the transaction the output belongs to.
119
+ bytes32 txHash;
120
+ /// @notice Index of the transaction output.
121
+ uint32 txOutputIndex;
122
+ /// @notice Value of the transaction output.
123
+ uint64 txOutputValue;
124
+ }
125
+ }