@keep-network/tbtc-v2 0.1.1-dev.3 → 0.1.1-dev.7
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 +10 -10
- package/artifacts/TBTCToken.json +10 -10
- package/artifacts/VendingMachine.json +11 -11
- package/artifacts/solcInputs/25bea07ad744b8c97e466495ad2abf97.json +128 -0
- package/build/contracts/GovernanceUtils.sol/GovernanceUtils.dbg.json +1 -1
- package/build/contracts/bank/Bank.sol/Bank.dbg.json +1 -1
- package/build/contracts/bank/Bank.sol/Bank.json +25 -2
- 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 +116 -71
- package/build/contracts/bridge/VendingMachine.sol/VendingMachine.dbg.json +1 -1
- package/build/contracts/token/TBTC.sol/TBTC.dbg.json +1 -1
- package/build/contracts/vault/IVault.sol/IVault.dbg.json +4 -0
- package/build/contracts/vault/IVault.sol/IVault.json +29 -0
- package/build/contracts/vault/TBTCVault.sol/TBTCVault.dbg.json +1 -1
- package/build/contracts/vault/TBTCVault.sol/TBTCVault.json +20 -2
- package/contracts/bank/Bank.sol +36 -1
- package/contracts/bridge/BitcoinTx.sol +104 -0
- package/contracts/bridge/Bridge.sol +225 -83
- package/contracts/vault/IVault.sol +38 -0
- package/contracts/vault/TBTCVault.sol +31 -7
- package/package.json +3 -2
- package/artifacts/solcInputs/cebfa5efa019cb9c8c5e23e38703b883.json +0 -113
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_format": "hh-sol-artifact-1",
|
|
3
|
+
"contractName": "IVault",
|
|
4
|
+
"sourceName": "contracts/vault/IVault.sol",
|
|
5
|
+
"abi": [
|
|
6
|
+
{
|
|
7
|
+
"inputs": [
|
|
8
|
+
{
|
|
9
|
+
"internalType": "address[]",
|
|
10
|
+
"name": "depositors",
|
|
11
|
+
"type": "address[]"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"internalType": "uint256[]",
|
|
15
|
+
"name": "depositedAmounts",
|
|
16
|
+
"type": "uint256[]"
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
"name": "onBalanceIncreased",
|
|
20
|
+
"outputs": [],
|
|
21
|
+
"stateMutability": "nonpayable",
|
|
22
|
+
"type": "function"
|
|
23
|
+
}
|
|
24
|
+
],
|
|
25
|
+
"bytecode": "0x",
|
|
26
|
+
"deployedBytecode": "0x",
|
|
27
|
+
"linkReferences": {},
|
|
28
|
+
"deployedLinkReferences": {}
|
|
29
|
+
}
|
|
@@ -83,6 +83,24 @@
|
|
|
83
83
|
"stateMutability": "nonpayable",
|
|
84
84
|
"type": "function"
|
|
85
85
|
},
|
|
86
|
+
{
|
|
87
|
+
"inputs": [
|
|
88
|
+
{
|
|
89
|
+
"internalType": "address[]",
|
|
90
|
+
"name": "depositors",
|
|
91
|
+
"type": "address[]"
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"internalType": "uint256[]",
|
|
95
|
+
"name": "depositedAmounts",
|
|
96
|
+
"type": "uint256[]"
|
|
97
|
+
}
|
|
98
|
+
],
|
|
99
|
+
"name": "onBalanceIncreased",
|
|
100
|
+
"outputs": [],
|
|
101
|
+
"stateMutability": "nonpayable",
|
|
102
|
+
"type": "function"
|
|
103
|
+
},
|
|
86
104
|
{
|
|
87
105
|
"inputs": [
|
|
88
106
|
{
|
|
@@ -138,8 +156,8 @@
|
|
|
138
156
|
"type": "function"
|
|
139
157
|
}
|
|
140
158
|
],
|
|
141
|
-
"bytecode": "
|
|
142
|
-
"deployedBytecode": "
|
|
159
|
+
"bytecode": "0x60806040523480156200001157600080fd5b5060405162001300380380620013008339818101604052810190620000379190620001d4565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415620000aa576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620000a19062000285565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156200011d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620001149062000263565b60405180910390fd5b816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050620003c0565b600081519050620001b7816200038c565b92915050565b600081519050620001ce81620003a6565b92915050565b60008060408385031215620001e857600080fd5b6000620001f885828601620001a6565b92505060206200020b85828601620001bd565b9150509250929050565b600062000224602683620002a7565b9150620002318262000314565b604082019050919050565b60006200024b602083620002a7565b9150620002588262000363565b602082019050919050565b600060208201905081810360008301526200027e8162000215565b9050919050565b60006020820190508181036000830152620002a0816200023c565b9050919050565b600082825260208201905092915050565b6000620002c582620002f4565b9050919050565b6000620002d982620002b8565b9050919050565b6000620002ed82620002b8565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b7f5442544320746f6b656e2063616e206e6f7420626520746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f42616e6b2063616e206e6f7420626520746865207a65726f2061646472657373600082015250565b6200039781620002cc565b8114620003a357600080fd5b50565b620003b181620002e0565b8114620003bd57600080fd5b50565b610f3080620003d06000396000f3fe608060405234801561001057600080fd5b50600436106100625760003560e01c806376cdb03b146100675780638f4ffcb114610085578063a0712d68146100a1578063ad7581e1146100bd578063db006a75146100d9578063e5d3d714146100f5575b600080fd5b61006f610113565b60405161007c9190610bdb565b60405180910390f35b61009f600480360381019061009a919061092e565b610137565b005b6100bb60048036038101906100b69190610a23565b610246565b005b6100d760048036038101906100d291906109ae565b6103d3565b005b6100f360048036038101906100ee9190610a23565b610566565b005b6100fd610573565b60405161010a9190610bf6565b60405180910390f35b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16146101c7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101be90610c31565b60405180910390fd5b8273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610235576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161022c90610c11565b60405180910390fd5b61023f8585610599565b5050505050565b60003390508160008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231836040518263ffffffff1660e01b81526004016102a59190610b60565b60206040518083038186803b1580156102bd57600080fd5b505afa1580156102d1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102f59190610a4c565b1015610336576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161032d90610c91565b60405180910390fd5b6103408183610707565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16637c6db49c8230856040518463ffffffff1660e01b815260040161039d93929190610b7b565b600060405180830381600087803b1580156103b757600080fd5b505af11580156103cb573d6000803e3d6000fd5b505050505050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610461576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161045890610c51565b60405180910390fd5b60008484905014156104a8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161049f90610c71565b60405180910390fd5b60005b8484905081101561055f5761054c8585838181106104f2577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90506020020160208101906105079190610905565b848484818110610540577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90506020020135610707565b808061055790610d61565b9150506104ab565b5050505050565b6105703382610599565b50565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b8173ffffffffffffffffffffffffffffffffffffffff167f4896181ff8f4543cc00db9fe9b6fb7e6f032b7eb772c72ab1ec1b4d2e03b9369826040516105df9190610cb1565b60405180910390a2600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166379cc679083836040518363ffffffff1660e01b8152600401610644929190610bb2565b600060405180830381600087803b15801561065e57600080fd5b505af1158015610672573d6000803e3d6000fd5b5050505060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166356a6d9ef83836040518363ffffffff1660e01b81526004016106d1929190610bb2565b600060405180830381600087803b1580156106eb57600080fd5b505af11580156106ff573d6000803e3d6000fd5b505050505050565b8173ffffffffffffffffffffffffffffffffffffffff167f30385c845b448a36257a6a1716e6ad2e1bc2cbe333cde1e69fe849ad6511adfe8260405161074d9190610cb1565b60405180910390a2600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166340c10f1983836040518363ffffffff1660e01b81526004016107b2929190610bb2565b600060405180830381600087803b1580156107cc57600080fd5b505af11580156107e0573d6000803e3d6000fd5b505050505050565b6000813590506107f781610ecc565b92915050565b60008083601f84011261080f57600080fd5b8235905067ffffffffffffffff81111561082857600080fd5b60208301915083602082028301111561084057600080fd5b9250929050565b60008083601f84011261085957600080fd5b8235905067ffffffffffffffff81111561087257600080fd5b60208301915083602082028301111561088a57600080fd5b9250929050565b60008083601f8401126108a357600080fd5b8235905067ffffffffffffffff8111156108bc57600080fd5b6020830191508360018202830111156108d457600080fd5b9250929050565b6000813590506108ea81610ee3565b92915050565b6000815190506108ff81610ee3565b92915050565b60006020828403121561091757600080fd5b6000610925848285016107e8565b91505092915050565b60008060008060006080868803121561094657600080fd5b6000610954888289016107e8565b9550506020610965888289016108db565b9450506040610976888289016107e8565b935050606086013567ffffffffffffffff81111561099357600080fd5b61099f88828901610891565b92509250509295509295909350565b600080600080604085870312156109c457600080fd5b600085013567ffffffffffffffff8111156109de57600080fd5b6109ea878288016107fd565b9450945050602085013567ffffffffffffffff811115610a0957600080fd5b610a1587828801610847565b925092505092959194509250565b600060208284031215610a3557600080fd5b6000610a43848285016108db565b91505092915050565b600060208284031215610a5e57600080fd5b6000610a6c848285016108f0565b91505092915050565b610a7e81610cdd565b82525050565b610a8d81610d19565b82525050565b610a9c81610d3d565b82525050565b6000610aaf601883610ccc565b9150610aba82610dd9565b602082019050919050565b6000610ad2601183610ccc565b9150610add82610e02565b602082019050919050565b6000610af5601683610ccc565b9150610b0082610e2b565b602082019050919050565b6000610b18601783610ccc565b9150610b2382610e54565b602082019050919050565b6000610b3b602283610ccc565b9150610b4682610e7d565b604082019050919050565b610b5a81610d0f565b82525050565b6000602082019050610b756000830184610a75565b92915050565b6000606082019050610b906000830186610a75565b610b9d6020830185610a75565b610baa6040830184610b51565b949350505050565b6000604082019050610bc76000830185610a75565b610bd46020830184610b51565b9392505050565b6000602082019050610bf06000830184610a84565b92915050565b6000602082019050610c0b6000830184610a93565b92915050565b60006020820190508181036000830152610c2a81610aa2565b9050919050565b60006020820190508181036000830152610c4a81610ac5565b9050919050565b60006020820190508181036000830152610c6a81610ae8565b9050919050565b60006020820190508181036000830152610c8a81610b0b565b9050919050565b60006020820190508181036000830152610caa81610b2e565b9050919050565b6000602082019050610cc66000830184610b51565b92915050565b600082825260208201905092915050565b6000610ce882610cef565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b6000610d2482610d2b565b9050919050565b6000610d3682610cef565b9050919050565b6000610d4882610d4f565b9050919050565b6000610d5a82610cef565b9050919050565b6000610d6c82610d0f565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415610d9f57610d9e610daa565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4f6e6c7920544254432063616c6c657220616c6c6f7765640000000000000000600082015250565b7f546f6b656e206973206e6f742054425443000000000000000000000000000000600082015250565b7f43616c6c6572206973206e6f74207468652042616e6b00000000000000000000600082015250565b7f4e6f206465706f7369746f727320737065636966696564000000000000000000600082015250565b7f416d6f756e7420657863656564732062616c616e636520696e2074686520626160008201527f6e6b000000000000000000000000000000000000000000000000000000000000602082015250565b610ed581610cdd565b8114610ee057600080fd5b50565b610eec81610d0f565b8114610ef757600080fd5b5056fea26469706673582212202f0a068f7e8f74337505a425a28fbdc0bb82990dea78c1d1172b110d2c5e937464736f6c63430008040033",
|
|
160
|
+
"deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100625760003560e01c806376cdb03b146100675780638f4ffcb114610085578063a0712d68146100a1578063ad7581e1146100bd578063db006a75146100d9578063e5d3d714146100f5575b600080fd5b61006f610113565b60405161007c9190610bdb565b60405180910390f35b61009f600480360381019061009a919061092e565b610137565b005b6100bb60048036038101906100b69190610a23565b610246565b005b6100d760048036038101906100d291906109ae565b6103d3565b005b6100f360048036038101906100ee9190610a23565b610566565b005b6100fd610573565b60405161010a9190610bf6565b60405180910390f35b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16146101c7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101be90610c31565b60405180910390fd5b8273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610235576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161022c90610c11565b60405180910390fd5b61023f8585610599565b5050505050565b60003390508160008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231836040518263ffffffff1660e01b81526004016102a59190610b60565b60206040518083038186803b1580156102bd57600080fd5b505afa1580156102d1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102f59190610a4c565b1015610336576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161032d90610c91565b60405180910390fd5b6103408183610707565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16637c6db49c8230856040518463ffffffff1660e01b815260040161039d93929190610b7b565b600060405180830381600087803b1580156103b757600080fd5b505af11580156103cb573d6000803e3d6000fd5b505050505050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610461576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161045890610c51565b60405180910390fd5b60008484905014156104a8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161049f90610c71565b60405180910390fd5b60005b8484905081101561055f5761054c8585838181106104f2577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90506020020160208101906105079190610905565b848484818110610540577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90506020020135610707565b808061055790610d61565b9150506104ab565b5050505050565b6105703382610599565b50565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b8173ffffffffffffffffffffffffffffffffffffffff167f4896181ff8f4543cc00db9fe9b6fb7e6f032b7eb772c72ab1ec1b4d2e03b9369826040516105df9190610cb1565b60405180910390a2600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166379cc679083836040518363ffffffff1660e01b8152600401610644929190610bb2565b600060405180830381600087803b15801561065e57600080fd5b505af1158015610672573d6000803e3d6000fd5b5050505060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166356a6d9ef83836040518363ffffffff1660e01b81526004016106d1929190610bb2565b600060405180830381600087803b1580156106eb57600080fd5b505af11580156106ff573d6000803e3d6000fd5b505050505050565b8173ffffffffffffffffffffffffffffffffffffffff167f30385c845b448a36257a6a1716e6ad2e1bc2cbe333cde1e69fe849ad6511adfe8260405161074d9190610cb1565b60405180910390a2600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166340c10f1983836040518363ffffffff1660e01b81526004016107b2929190610bb2565b600060405180830381600087803b1580156107cc57600080fd5b505af11580156107e0573d6000803e3d6000fd5b505050505050565b6000813590506107f781610ecc565b92915050565b60008083601f84011261080f57600080fd5b8235905067ffffffffffffffff81111561082857600080fd5b60208301915083602082028301111561084057600080fd5b9250929050565b60008083601f84011261085957600080fd5b8235905067ffffffffffffffff81111561087257600080fd5b60208301915083602082028301111561088a57600080fd5b9250929050565b60008083601f8401126108a357600080fd5b8235905067ffffffffffffffff8111156108bc57600080fd5b6020830191508360018202830111156108d457600080fd5b9250929050565b6000813590506108ea81610ee3565b92915050565b6000815190506108ff81610ee3565b92915050565b60006020828403121561091757600080fd5b6000610925848285016107e8565b91505092915050565b60008060008060006080868803121561094657600080fd5b6000610954888289016107e8565b9550506020610965888289016108db565b9450506040610976888289016107e8565b935050606086013567ffffffffffffffff81111561099357600080fd5b61099f88828901610891565b92509250509295509295909350565b600080600080604085870312156109c457600080fd5b600085013567ffffffffffffffff8111156109de57600080fd5b6109ea878288016107fd565b9450945050602085013567ffffffffffffffff811115610a0957600080fd5b610a1587828801610847565b925092505092959194509250565b600060208284031215610a3557600080fd5b6000610a43848285016108db565b91505092915050565b600060208284031215610a5e57600080fd5b6000610a6c848285016108f0565b91505092915050565b610a7e81610cdd565b82525050565b610a8d81610d19565b82525050565b610a9c81610d3d565b82525050565b6000610aaf601883610ccc565b9150610aba82610dd9565b602082019050919050565b6000610ad2601183610ccc565b9150610add82610e02565b602082019050919050565b6000610af5601683610ccc565b9150610b0082610e2b565b602082019050919050565b6000610b18601783610ccc565b9150610b2382610e54565b602082019050919050565b6000610b3b602283610ccc565b9150610b4682610e7d565b604082019050919050565b610b5a81610d0f565b82525050565b6000602082019050610b756000830184610a75565b92915050565b6000606082019050610b906000830186610a75565b610b9d6020830185610a75565b610baa6040830184610b51565b949350505050565b6000604082019050610bc76000830185610a75565b610bd46020830184610b51565b9392505050565b6000602082019050610bf06000830184610a84565b92915050565b6000602082019050610c0b6000830184610a93565b92915050565b60006020820190508181036000830152610c2a81610aa2565b9050919050565b60006020820190508181036000830152610c4a81610ac5565b9050919050565b60006020820190508181036000830152610c6a81610ae8565b9050919050565b60006020820190508181036000830152610c8a81610b0b565b9050919050565b60006020820190508181036000830152610caa81610b2e565b9050919050565b6000602082019050610cc66000830184610b51565b92915050565b600082825260208201905092915050565b6000610ce882610cef565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b6000610d2482610d2b565b9050919050565b6000610d3682610cef565b9050919050565b6000610d4882610d4f565b9050919050565b6000610d5a82610cef565b9050919050565b6000610d6c82610d0f565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415610d9f57610d9e610daa565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4f6e6c7920544254432063616c6c657220616c6c6f7765640000000000000000600082015250565b7f546f6b656e206973206e6f742054425443000000000000000000000000000000600082015250565b7f43616c6c6572206973206e6f74207468652042616e6b00000000000000000000600082015250565b7f4e6f206465706f7369746f727320737065636966696564000000000000000000600082015250565b7f416d6f756e7420657863656564732062616c616e636520696e2074686520626160008201527f6e6b000000000000000000000000000000000000000000000000000000000000602082015250565b610ed581610cdd565b8114610ee057600080fd5b50565b610eec81610d0f565b8114610ef757600080fd5b5056fea26469706673582212202f0a068f7e8f74337505a425a28fbdc0bb82990dea78c1d1172b110d2c5e937464736f6c63430008040033",
|
|
143
161
|
"linkReferences": {},
|
|
144
162
|
"deployedLinkReferences": {}
|
|
145
163
|
}
|
package/contracts/bank/Bank.sol
CHANGED
|
@@ -12,10 +12,13 @@
|
|
|
12
12
|
// ▐████▌ ▐████▌
|
|
13
13
|
// ▐████▌ ▐████▌
|
|
14
14
|
// ▐████▌ ▐████▌
|
|
15
|
+
|
|
15
16
|
pragma solidity 0.8.4;
|
|
16
17
|
|
|
17
18
|
import "@openzeppelin/contracts/access/Ownable.sol";
|
|
18
19
|
|
|
20
|
+
import "../vault/IVault.sol";
|
|
21
|
+
|
|
19
22
|
/// @title Bitcoin Bank
|
|
20
23
|
/// @notice Bank is a central component tracking Bitcoin balances. Balances can
|
|
21
24
|
/// be transferred between holders and holders can approve their
|
|
@@ -231,7 +234,8 @@ contract Bank is Ownable {
|
|
|
231
234
|
|
|
232
235
|
/// @notice Increases balances of the provided `recipients` by the provided
|
|
233
236
|
/// `amounts`. Can only be called by the Bridge.
|
|
234
|
-
/// @dev
|
|
237
|
+
/// @dev Requirements:
|
|
238
|
+
/// - length of `recipients` and `amounts` must be the same.
|
|
235
239
|
function increaseBalances(
|
|
236
240
|
address[] calldata recipients,
|
|
237
241
|
uint256[] calldata amounts
|
|
@@ -254,6 +258,37 @@ contract Bank is Ownable {
|
|
|
254
258
|
_increaseBalance(recipient, amount);
|
|
255
259
|
}
|
|
256
260
|
|
|
261
|
+
/// @notice Increases the given smart contract `vault`'s balance and
|
|
262
|
+
/// notifies the `vault` contract. Called by the Bridge after
|
|
263
|
+
/// the deposits routed by depositors to that `vault` have been
|
|
264
|
+
/// swept by the Bridge. This way, the depositor does not have to
|
|
265
|
+
/// issue a separate transaction to the `vault` contract.
|
|
266
|
+
/// Can be called only by the Bridge.
|
|
267
|
+
/// @dev Requirements:
|
|
268
|
+
/// - `vault` must implement `IVault` interface,
|
|
269
|
+
/// - length of `depositors` and `depositedAmounts` must be the same.
|
|
270
|
+
/// @param vault Address of `IVault` recipient contract
|
|
271
|
+
/// @param depositors Addresses of depositors whose deposits have been swept
|
|
272
|
+
/// @param depositedAmounts Amounts deposited by individual depositors and
|
|
273
|
+
/// swept. The `vault`'s balance in the Bank will be increased by the
|
|
274
|
+
/// sum of all elements in this array.
|
|
275
|
+
function increaseBalanceAndCall(
|
|
276
|
+
address vault,
|
|
277
|
+
address[] calldata depositors,
|
|
278
|
+
uint256[] calldata depositedAmounts
|
|
279
|
+
) external onlyBridge {
|
|
280
|
+
require(
|
|
281
|
+
depositors.length == depositedAmounts.length,
|
|
282
|
+
"Arrays must have the same length"
|
|
283
|
+
);
|
|
284
|
+
uint256 totalAmount = 0;
|
|
285
|
+
for (uint256 i = 0; i < depositedAmounts.length; i++) {
|
|
286
|
+
totalAmount += depositedAmounts[i];
|
|
287
|
+
}
|
|
288
|
+
_increaseBalance(vault, totalAmount);
|
|
289
|
+
IVault(vault).onBalanceIncreased(depositors, depositedAmounts);
|
|
290
|
+
}
|
|
291
|
+
|
|
257
292
|
/// @notice Decreases caller's balance by the provided `amount`. There is no
|
|
258
293
|
/// way to restore the balance so do not call this function unless
|
|
259
294
|
/// you really know what you are doing!
|
|
@@ -0,0 +1,104 @@
|
|
|
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
|
+
}
|