@keep-network/tbtc-v2 0.1.1-dev.2 → 0.1.1-dev.20
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.
- package/artifacts/TBTC.json +18 -18
- package/artifacts/TBTCToken.json +18 -18
- package/artifacts/VendingMachine.json +19 -19
- package/artifacts/solcInputs/5c08a447a71edda5755711e12ca577ad.json +140 -0
- package/build/contracts/GovernanceUtils.sol/GovernanceUtils.dbg.json +1 -1
- package/build/contracts/GovernanceUtils.sol/GovernanceUtils.json +2 -2
- package/build/contracts/bank/Bank.sol/Bank.dbg.json +4 -0
- package/build/contracts/bank/Bank.sol/Bank.json +537 -0
- package/build/contracts/bridge/BitcoinTx.sol/BitcoinTx.dbg.json +4 -0
- package/build/contracts/bridge/BitcoinTx.sol/BitcoinTx.json +10 -0
- package/build/contracts/bridge/Bridge.sol/Bridge.dbg.json +1 -1
- package/build/contracts/bridge/Bridge.sol/Bridge.json +739 -48
- package/build/contracts/bridge/Bridge.sol/IRelay.dbg.json +4 -0
- package/build/contracts/bridge/Bridge.sol/IRelay.json +37 -0
- package/build/contracts/bridge/VendingMachine.sol/VendingMachine.dbg.json +1 -1
- package/build/contracts/bridge/VendingMachine.sol/VendingMachine.json +2 -2
- package/build/contracts/token/TBTC.sol/TBTC.dbg.json +1 -1
- package/build/contracts/token/TBTC.sol/TBTC.json +2 -2
- package/build/contracts/vault/IVault.sol/IVault.dbg.json +4 -0
- package/build/contracts/vault/IVault.sol/IVault.json +47 -0
- package/build/contracts/vault/TBTCVault.sol/TBTCVault.dbg.json +4 -0
- package/build/contracts/vault/TBTCVault.sol/TBTCVault.json +181 -0
- package/contracts/GovernanceUtils.sol +1 -1
- package/contracts/bank/Bank.sol +390 -0
- package/contracts/bridge/BitcoinTx.sol +126 -0
- package/contracts/bridge/Bridge.sol +1593 -104
- package/contracts/bridge/VendingMachine.sol +1 -1
- package/contracts/token/TBTC.sol +1 -1
- package/contracts/vault/IVault.sol +60 -0
- package/contracts/vault/TBTCVault.sol +146 -0
- package/package.json +9 -9
- package/artifacts/solcInputs/02b9e185d8beb23545e98201d474fc6b.json +0 -107
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
|
|
3
|
+
// ██████████████ ▐████▌ ██████████████
|
|
4
|
+
// ██████████████ ▐████▌ ██████████████
|
|
5
|
+
// ▐████▌ ▐████▌
|
|
6
|
+
// ▐████▌ ▐████▌
|
|
7
|
+
// ██████████████ ▐████▌ ██████████████
|
|
8
|
+
// ██████████████ ▐████▌ ██████████████
|
|
9
|
+
// ▐████▌ ▐████▌
|
|
10
|
+
// ▐████▌ ▐████▌
|
|
11
|
+
// ▐████▌ ▐████▌
|
|
12
|
+
// ▐████▌ ▐████▌
|
|
13
|
+
// ▐████▌ ▐████▌
|
|
14
|
+
// ▐████▌ ▐████▌
|
|
15
|
+
|
|
16
|
+
pragma solidity ^0.8.9;
|
|
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
|
+
/// @dev Byte order corresponds to the Bitcoin internal byte order.
|
|
120
|
+
bytes32 txHash;
|
|
121
|
+
/// @notice Index of the transaction output (0-indexed).
|
|
122
|
+
uint32 txOutputIndex;
|
|
123
|
+
/// @notice Value of the transaction output.
|
|
124
|
+
uint64 txOutputValue;
|
|
125
|
+
}
|
|
126
|
+
}
|