@keep-network/tbtc-v2 0.1.1-dev.71 → 0.1.1-dev.74
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/Bank.json +15 -15
- package/artifacts/Bridge.json +1 -1
- package/artifacts/DefaultProxyAdmin.json +5 -5
- package/artifacts/Deposit.json +10 -10
- package/artifacts/DepositSweep.json +13 -13
- package/artifacts/EcdsaDkgValidator.json +9 -9
- package/artifacts/EcdsaInactivity.json +8 -8
- package/artifacts/Fraud.json +23 -23
- package/artifacts/KeepRegistry.json +1 -1
- package/artifacts/KeepStake.json +2 -2
- package/artifacts/KeepToken.json +2 -2
- package/artifacts/KeepTokenStaking.json +1 -1
- package/artifacts/MovingFunds.json +31 -31
- package/artifacts/NuCypherStakingEscrow.json +1 -1
- package/artifacts/NuCypherToken.json +2 -2
- package/artifacts/RandomBeaconStub.json +5 -5
- package/artifacts/Redemption.json +22 -22
- package/artifacts/ReimbursementPool.json +5 -5
- package/artifacts/Relay.json +9 -9
- package/artifacts/SortitionPool.json +9 -9
- package/artifacts/T.json +2 -2
- package/artifacts/TBTC.json +17 -17
- package/artifacts/TBTCToken.json +15 -15
- package/artifacts/TokenStaking.json +1 -1
- package/artifacts/TokenholderGovernor.json +9 -9
- package/artifacts/TokenholderTimelock.json +8 -8
- package/artifacts/VendingMachine.json +18 -18
- package/artifacts/VendingMachineKeep.json +1 -1
- package/artifacts/VendingMachineNuCypher.json +1 -1
- package/artifacts/WalletRegistry.json +17 -17
- package/artifacts/WalletRegistry_Implementation.json +73 -73
- package/artifacts/WalletRegistry_Proxy.json +17 -17
- package/artifacts/Wallets.json +12 -12
- package/artifacts/solcInputs/3d39c8183330efd748c005f3c281bf2c.json +272 -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 +1 -1
- package/build/contracts/bank/Bank.sol/Bank.json +2 -2
- package/build/contracts/bridge/BitcoinTx.sol/BitcoinTx.dbg.json +1 -1
- package/build/contracts/bridge/BitcoinTx.sol/BitcoinTx.json +2 -2
- package/build/contracts/bridge/Bridge.sol/Bridge.dbg.json +1 -1
- package/build/contracts/bridge/Bridge.sol/Bridge.json +2 -2
- package/build/contracts/bridge/BridgeState.sol/BridgeState.dbg.json +1 -1
- package/build/contracts/bridge/BridgeState.sol/BridgeState.json +2 -2
- package/build/contracts/bridge/Deposit.sol/Deposit.dbg.json +1 -1
- package/build/contracts/bridge/Deposit.sol/Deposit.json +2 -2
- package/build/contracts/bridge/DepositSweep.sol/DepositSweep.dbg.json +1 -1
- package/build/contracts/bridge/DepositSweep.sol/DepositSweep.json +2 -2
- package/build/contracts/bridge/EcdsaLib.sol/EcdsaLib.dbg.json +1 -1
- package/build/contracts/bridge/Fraud.sol/Fraud.dbg.json +1 -1
- package/build/contracts/bridge/Fraud.sol/Fraud.json +2 -2
- package/build/contracts/bridge/Heartbeat.sol/Heartbeat.dbg.json +1 -1
- package/build/contracts/bridge/Heartbeat.sol/Heartbeat.json +2 -2
- package/build/contracts/bridge/IRelay.sol/IRelay.dbg.json +1 -1
- package/build/contracts/bridge/MovingFunds.sol/MovingFunds.dbg.json +1 -1
- package/build/contracts/bridge/MovingFunds.sol/MovingFunds.json +2 -2
- package/build/contracts/bridge/Redemption.sol/OutboundTx.dbg.json +1 -1
- package/build/contracts/bridge/Redemption.sol/OutboundTx.json +2 -2
- package/build/contracts/bridge/Redemption.sol/Redemption.dbg.json +1 -1
- package/build/contracts/bridge/Redemption.sol/Redemption.json +2 -2
- package/build/contracts/bridge/VendingMachine.sol/VendingMachine.dbg.json +1 -1
- package/build/contracts/bridge/VendingMachine.sol/VendingMachine.json +2 -2
- package/build/contracts/bridge/Wallets.sol/Wallets.dbg.json +1 -1
- package/build/contracts/bridge/Wallets.sol/Wallets.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/DonationVault.sol/DonationVault.dbg.json +1 -1
- package/build/contracts/vault/DonationVault.sol/DonationVault.json +2 -2
- package/build/contracts/vault/IVault.sol/IVault.dbg.json +1 -1
- package/build/contracts/vault/TBTCVault.sol/TBTCVault.dbg.json +1 -1
- package/build/contracts/vault/TBTCVault.sol/TBTCVault.json +2 -2
- package/contracts/GovernanceUtils.sol +3 -3
- package/contracts/bank/Bank.sol +2 -2
- package/contracts/bridge/BitcoinTx.sol +7 -7
- package/contracts/bridge/Bridge.sol +193 -199
- package/contracts/bridge/BridgeState.sol +43 -44
- package/contracts/bridge/Deposit.sol +5 -7
- package/contracts/bridge/DepositSweep.sol +12 -12
- package/contracts/bridge/Fraud.sol +25 -25
- package/contracts/bridge/Heartbeat.sol +1 -1
- package/contracts/bridge/MovingFunds.sol +72 -72
- package/contracts/bridge/Redemption.sol +32 -39
- package/contracts/bridge/Wallets.sol +29 -29
- package/contracts/vault/DonationVault.sol +9 -9
- package/contracts/vault/IVault.sol +4 -4
- package/contracts/vault/TBTCVault.sol +14 -14
- package/package.json +3 -3
- package/artifacts/solcInputs/55619e5b15411ce6622d6da869c273a1.json +0 -269
|
@@ -27,7 +27,6 @@ import "./MovingFunds.sol";
|
|
|
27
27
|
import "../bank/Bank.sol";
|
|
28
28
|
|
|
29
29
|
library BridgeState {
|
|
30
|
-
// TODO: Make parameters governable
|
|
31
30
|
struct Storage {
|
|
32
31
|
// Address of the Bank the Bridge belongs to.
|
|
33
32
|
Bank bank;
|
|
@@ -179,9 +178,9 @@ library BridgeState {
|
|
|
179
178
|
// to this mapping by the `requestRedemption` method (duplicates
|
|
180
179
|
// not allowed) and are removed by one of the following methods:
|
|
181
180
|
// - `submitRedemptionProof` in case the request was handled
|
|
182
|
-
// successfully
|
|
181
|
+
// successfully,
|
|
183
182
|
// - `notifyRedemptionTimeout` in case the request was reported
|
|
184
|
-
// to be timed out
|
|
183
|
+
// to be timed out.
|
|
185
184
|
mapping(uint256 => Redemption.RedemptionRequest) pendingRedemptions;
|
|
186
185
|
// Collection of all timed out redemptions requests indexed by
|
|
187
186
|
// redemption key built as
|
|
@@ -316,7 +315,7 @@ library BridgeState {
|
|
|
316
315
|
//// deposit. Value of this parameter must take into account the value
|
|
317
316
|
/// of `depositTreasuryFeeDivisor` and `depositTxMaxFee` parameters
|
|
318
317
|
/// in order to make requests that can incur the treasury and
|
|
319
|
-
/// transaction fee and still satisfy the depositor
|
|
318
|
+
/// transaction fee and still satisfy the depositor.
|
|
320
319
|
/// @param _depositTreasuryFeeDivisor New value of the treasury fee divisor.
|
|
321
320
|
/// It is the divisor used to compute the treasury fee taken from
|
|
322
321
|
/// each deposit and transferred to the treasury upon sweep proof
|
|
@@ -324,16 +323,16 @@ library BridgeState {
|
|
|
324
323
|
/// `treasuryFee = depositedAmount / depositTreasuryFeeDivisor`
|
|
325
324
|
/// For example, if the treasury fee needs to be 2% of each deposit,
|
|
326
325
|
/// the `depositTreasuryFeeDivisor` should be set to `50`
|
|
327
|
-
/// because `1/50 = 0.02 = 2
|
|
326
|
+
/// because `1/50 = 0.02 = 2%`.
|
|
328
327
|
/// @param _depositTxMaxFee New value of the deposit tx max fee in satoshis.
|
|
329
328
|
/// It is the maximum amount of BTC transaction fee that can
|
|
330
329
|
/// be incurred by each swept deposit being part of the given sweep
|
|
331
330
|
/// transaction. If the maximum BTC transaction fee is exceeded,
|
|
332
|
-
/// such transaction is considered a fraud
|
|
331
|
+
/// such transaction is considered a fraud.
|
|
333
332
|
/// @dev Requirements:
|
|
334
|
-
/// - Deposit dust threshold must be greater than zero
|
|
335
|
-
/// - Deposit treasury fee divisor must be greater than zero
|
|
336
|
-
/// - Deposit transaction max fee must be greater than zero
|
|
333
|
+
/// - Deposit dust threshold must be greater than zero,
|
|
334
|
+
/// - Deposit treasury fee divisor must be greater than zero,
|
|
335
|
+
/// - Deposit transaction max fee must be greater than zero.
|
|
337
336
|
function updateDepositParameters(
|
|
338
337
|
Storage storage self,
|
|
339
338
|
uint64 _depositDustThreshold,
|
|
@@ -398,20 +397,20 @@ library BridgeState {
|
|
|
398
397
|
/// redeemer in full amount.
|
|
399
398
|
/// @param _redemptionTimeoutSlashingAmount New value of the redemption
|
|
400
399
|
/// timeout slashing amount in T, it is the amount slashed from each
|
|
401
|
-
/// wallet member for redemption timeout
|
|
400
|
+
/// wallet member for redemption timeout.
|
|
402
401
|
/// @param _redemptionTimeoutNotifierRewardMultiplier New value of the
|
|
403
402
|
/// redemption timeout notifier reward multiplier as percentage,
|
|
404
403
|
/// it determines the percentage of the notifier reward from the
|
|
405
404
|
/// staking contact the notifier of a redemption timeout receives.
|
|
406
|
-
/// The value must be in the range [0, 100]
|
|
405
|
+
/// The value must be in the range [0, 100].
|
|
407
406
|
/// @dev Requirements:
|
|
408
407
|
/// - Redemption dust threshold must be greater than moving funds dust
|
|
409
|
-
/// threshold
|
|
410
|
-
/// - Redemption treasury fee divisor must be greater than zero
|
|
411
|
-
/// - Redemption transaction max fee must be greater than zero
|
|
412
|
-
/// - Redemption timeout must be greater than zero
|
|
408
|
+
/// threshold,
|
|
409
|
+
/// - Redemption treasury fee divisor must be greater than zero,
|
|
410
|
+
/// - Redemption transaction max fee must be greater than zero,
|
|
411
|
+
/// - Redemption timeout must be greater than zero,
|
|
413
412
|
/// - Redemption timeout notifier reward multiplier must be in the
|
|
414
|
-
/// range [0, 100]
|
|
413
|
+
/// range [0, 100].
|
|
415
414
|
function updateRedemptionParameters(
|
|
416
415
|
Storage storage self,
|
|
417
416
|
uint64 _redemptionDustThreshold,
|
|
@@ -483,12 +482,12 @@ library BridgeState {
|
|
|
483
482
|
/// MovingFunds state.
|
|
484
483
|
/// @param _movingFundsTimeoutSlashingAmount New value of the moving funds
|
|
485
484
|
/// timeout slashing amount in T, it is the amount slashed from each
|
|
486
|
-
/// wallet member for moving funds timeout
|
|
485
|
+
/// wallet member for moving funds timeout.
|
|
487
486
|
/// @param _movingFundsTimeoutNotifierRewardMultiplier New value of the
|
|
488
487
|
/// moving funds timeout notifier reward multiplier as percentage,
|
|
489
488
|
/// it determines the percentage of the notifier reward from the
|
|
490
489
|
/// staking contact the notifier of a moving funds timeout receives.
|
|
491
|
-
/// The value must be in the range [0, 100]
|
|
490
|
+
/// The value must be in the range [0, 100].
|
|
492
491
|
/// @param _movedFundsSweepTxMaxTotalFee New value of the moved funds sweep
|
|
493
492
|
/// transaction max total fee in satoshis. It is the maximum amount
|
|
494
493
|
/// of the total BTC transaction fee that is acceptable in a single
|
|
@@ -501,23 +500,23 @@ library BridgeState {
|
|
|
501
500
|
/// funds.
|
|
502
501
|
/// @param _movedFundsSweepTimeoutSlashingAmount New value of the moved
|
|
503
502
|
/// funds sweep timeout slashing amount in T, it is the amount
|
|
504
|
-
/// slashed from each wallet member for moved funds sweep timeout
|
|
503
|
+
/// slashed from each wallet member for moved funds sweep timeout.
|
|
505
504
|
/// @param _movedFundsSweepTimeoutNotifierRewardMultiplier New value of
|
|
506
505
|
/// the moved funds sweep timeout notifier reward multiplier as
|
|
507
506
|
/// percentage, it determines the percentage of the notifier reward
|
|
508
507
|
/// from the staking contact the notifier of a moved funds sweep
|
|
509
|
-
/// timeout receives. The value must be in the range [0, 100]
|
|
508
|
+
/// timeout receives. The value must be in the range [0, 100].
|
|
510
509
|
/// @dev Requirements:
|
|
511
|
-
/// - Moving funds transaction max total fee must be greater than zero
|
|
510
|
+
/// - Moving funds transaction max total fee must be greater than zero,
|
|
512
511
|
/// - Moving funds dust threshold must be greater than zero and lower
|
|
513
|
-
/// than the redemption dust threshold
|
|
514
|
-
/// - Moving funds timeout must be greater than zero
|
|
512
|
+
/// than the redemption dust threshold,
|
|
513
|
+
/// - Moving funds timeout must be greater than zero,
|
|
515
514
|
/// - Moving funds timeout notifier reward multiplier must be in the
|
|
516
|
-
/// range [0, 100]
|
|
517
|
-
/// - Moved funds sweep transaction max total fee must be greater than zero
|
|
518
|
-
/// - Moved funds sweep timeout must be greater than zero
|
|
515
|
+
/// range [0, 100],
|
|
516
|
+
/// - Moved funds sweep transaction max total fee must be greater than zero,
|
|
517
|
+
/// - Moved funds sweep timeout must be greater than zero,
|
|
519
518
|
/// - Moved funds sweep timeout notifier reward multiplier must be in the
|
|
520
|
-
/// range [0, 100]
|
|
519
|
+
/// range [0, 100].
|
|
521
520
|
function updateMovingFundsParameters(
|
|
522
521
|
Storage storage self,
|
|
523
522
|
uint64 _movingFundsTxMaxTotalFee,
|
|
@@ -596,29 +595,29 @@ library BridgeState {
|
|
|
596
595
|
/// @notice Updates parameters of wallets.
|
|
597
596
|
/// @param _walletCreationPeriod New value of the wallet creation period in
|
|
598
597
|
/// seconds, determines how frequently a new wallet creation can be
|
|
599
|
-
/// requested
|
|
598
|
+
/// requested.
|
|
600
599
|
/// @param _walletCreationMinBtcBalance New value of the wallet minimum BTC
|
|
601
|
-
/// balance in satoshi, used to decide about wallet creation
|
|
600
|
+
/// balance in satoshi, used to decide about wallet creation.
|
|
602
601
|
/// @param _walletCreationMaxBtcBalance New value of the wallet maximum BTC
|
|
603
|
-
/// balance in satoshi, used to decide about wallet creation
|
|
602
|
+
/// balance in satoshi, used to decide about wallet creation.
|
|
604
603
|
/// @param _walletClosureMinBtcBalance New value of the wallet minimum BTC
|
|
605
|
-
/// balance in satoshi, used to decide about wallet closure
|
|
604
|
+
/// balance in satoshi, used to decide about wallet closure.
|
|
606
605
|
/// @param _walletMaxAge New value of the wallet maximum age in seconds,
|
|
607
606
|
/// indicates the maximum age of a wallet in seconds, after which
|
|
608
|
-
/// the wallet moving funds process can be requested
|
|
607
|
+
/// the wallet moving funds process can be requested.
|
|
609
608
|
/// @param _walletMaxBtcTransfer New value of the wallet maximum BTC transfer
|
|
610
609
|
/// in satoshi, determines the maximum amount that can be transferred
|
|
611
|
-
/// to a single target wallet during the moving funds process
|
|
610
|
+
/// to a single target wallet during the moving funds process.
|
|
612
611
|
/// @param _walletClosingPeriod New value of the wallet closing period in
|
|
613
612
|
/// seconds, determines the length of the wallet closing period,
|
|
614
613
|
// i.e. the period when the wallet remains in the Closing state
|
|
615
|
-
// and can be subject of deposit fraud challenges
|
|
614
|
+
// and can be subject of deposit fraud challenges.
|
|
616
615
|
/// @dev Requirements:
|
|
617
|
-
/// - Wallet minimum BTC balance must be greater than zero
|
|
616
|
+
/// - Wallet minimum BTC balance must be greater than zero,
|
|
618
617
|
/// - Wallet maximum BTC balance must be greater than the wallet
|
|
619
|
-
/// minimum BTC balance
|
|
620
|
-
/// - Wallet maximum BTC transfer must be greater than zero
|
|
621
|
-
/// - Wallet closing period must be greater than zero
|
|
618
|
+
/// minimum BTC balance,
|
|
619
|
+
/// - Wallet maximum BTC transfer must be greater than zero,
|
|
620
|
+
/// - Wallet closing period must be greater than zero.
|
|
622
621
|
function updateWalletParameters(
|
|
623
622
|
Storage storage self,
|
|
624
623
|
uint32 _walletCreationPeriod,
|
|
@@ -668,20 +667,20 @@ library BridgeState {
|
|
|
668
667
|
/// @notice Updates parameters related to frauds.
|
|
669
668
|
/// @param _fraudChallengeDepositAmount New value of the fraud challenge
|
|
670
669
|
/// deposit amount in wei, it is the amount of ETH the party
|
|
671
|
-
/// challenging the wallet for fraud needs to deposit
|
|
670
|
+
/// challenging the wallet for fraud needs to deposit.
|
|
672
671
|
/// @param _fraudChallengeDefeatTimeout New value of the challenge defeat
|
|
673
672
|
/// timeout in seconds, it is the amount of time the wallet has to
|
|
674
|
-
/// defeat a fraud challenge. The value must be greater than zero
|
|
673
|
+
/// defeat a fraud challenge. The value must be greater than zero.
|
|
675
674
|
/// @param _fraudSlashingAmount New value of the fraud slashing amount in T,
|
|
676
675
|
/// it is the amount slashed from each wallet member for committing
|
|
677
|
-
/// a fraud
|
|
676
|
+
/// a fraud.
|
|
678
677
|
/// @param _fraudNotifierRewardMultiplier New value of the fraud notifier
|
|
679
678
|
/// reward multiplier as percentage, it determines the percentage of
|
|
680
679
|
/// the notifier reward from the staking contact the notifier of
|
|
681
|
-
/// a fraud receives. The value must be in the range [0, 100]
|
|
680
|
+
/// a fraud receives. The value must be in the range [0, 100].
|
|
682
681
|
/// @dev Requirements:
|
|
683
|
-
/// - Fraud challenge defeat timeout must be greater than 0
|
|
684
|
-
/// - Fraud notifier reward multiplier must be in the range [0, 100]
|
|
682
|
+
/// - Fraud challenge defeat timeout must be greater than 0,
|
|
683
|
+
/// - Fraud notifier reward multiplier must be in the range [0, 100].
|
|
685
684
|
function updateFraudParameters(
|
|
686
685
|
Storage storage self,
|
|
687
686
|
uint256 _fraudChallengeDepositAmount,
|
|
@@ -123,13 +123,13 @@ library Deposit {
|
|
|
123
123
|
/// outputs. The deposit may be routed to one of the trusted vaults.
|
|
124
124
|
/// When a deposit is routed to a vault, vault gets notified when
|
|
125
125
|
/// the deposit gets swept and it may execute the appropriate action.
|
|
126
|
-
/// @param fundingTx Bitcoin funding transaction data, see `BitcoinTx.Info
|
|
127
|
-
/// @param reveal Deposit reveal data, see `RevealInfo struct
|
|
126
|
+
/// @param fundingTx Bitcoin funding transaction data, see `BitcoinTx.Info`.
|
|
127
|
+
/// @param reveal Deposit reveal data, see `RevealInfo struct.
|
|
128
128
|
/// @dev Requirements:
|
|
129
|
-
/// - `reveal.walletPubKeyHash` must identify a `Live` wallet
|
|
130
|
-
/// - `reveal.vault` must be 0x0 or point to a trusted vault
|
|
129
|
+
/// - `reveal.walletPubKeyHash` must identify a `Live` wallet,
|
|
130
|
+
/// - `reveal.vault` must be 0x0 or point to a trusted vault,
|
|
131
131
|
/// - `reveal.fundingOutputIndex` must point to the actual P2(W)SH
|
|
132
|
-
/// output of the BTC deposit transaction
|
|
132
|
+
/// output of the BTC deposit transaction,
|
|
133
133
|
/// - `reveal.depositor` must be the Ethereum address used in the
|
|
134
134
|
/// P2(W)SH BTC deposit transaction,
|
|
135
135
|
/// - `reveal.blindingFactor` must be the blinding factor used in the
|
|
@@ -162,8 +162,6 @@ library Deposit {
|
|
|
162
162
|
"Vault is not trusted"
|
|
163
163
|
);
|
|
164
164
|
|
|
165
|
-
// TODO: Should we enforce a specific locktime at contract level?
|
|
166
|
-
|
|
167
165
|
bytes memory expectedScript = abi.encodePacked(
|
|
168
166
|
hex"14", // Byte length of depositor Ethereum address.
|
|
169
167
|
reveal.depositor,
|
|
@@ -105,11 +105,11 @@ library DepositSweep {
|
|
|
105
105
|
/// during the reveal transaction, minus their fee share.
|
|
106
106
|
///
|
|
107
107
|
/// It is possible to prove the given sweep only one time.
|
|
108
|
-
/// @param sweepTx Bitcoin sweep transaction data
|
|
109
|
-
/// @param sweepProof Bitcoin sweep proof data
|
|
108
|
+
/// @param sweepTx Bitcoin sweep transaction data.
|
|
109
|
+
/// @param sweepProof Bitcoin sweep proof data.
|
|
110
110
|
/// @param mainUtxo Data of the wallet's main UTXO, as currently known on
|
|
111
111
|
/// the Ethereum chain. If no main UTXO exists for the given wallet,
|
|
112
|
-
/// this parameter is ignored
|
|
112
|
+
/// this parameter is ignored.
|
|
113
113
|
/// @param vault Optional address of the vault where all swept deposits
|
|
114
114
|
/// should be routed to. All deposits swept as part of the transaction
|
|
115
115
|
/// must have their `vault` parameters set to the same address.
|
|
@@ -123,7 +123,7 @@ library DepositSweep {
|
|
|
123
123
|
/// - `sweepTx` components must match the expected structure. See
|
|
124
124
|
/// `BitcoinTx.Info` docs for reference. Their values must exactly
|
|
125
125
|
/// correspond to appropriate Bitcoin transaction fields to produce
|
|
126
|
-
/// a provable transaction hash
|
|
126
|
+
/// a provable transaction hash,
|
|
127
127
|
/// - The `sweepTx` should represent a Bitcoin transaction with 1..n
|
|
128
128
|
/// inputs. If the wallet has no main UTXO, all n inputs should
|
|
129
129
|
/// correspond to P2(W)SH revealed deposits UTXOs. If the wallet has
|
|
@@ -131,14 +131,14 @@ library DepositSweep {
|
|
|
131
131
|
/// main UTXO and remaining n-1 inputs should correspond to P2(W)SH
|
|
132
132
|
/// revealed deposits UTXOs. That transaction must have only
|
|
133
133
|
/// one P2(W)PKH output locking funds on the 20-byte wallet public
|
|
134
|
-
/// key hash
|
|
134
|
+
/// key hash,
|
|
135
135
|
/// - All revealed deposits that are swept by `sweepTx` must have
|
|
136
136
|
/// their `vault` parameters set to the same address as the address
|
|
137
|
-
/// passed in the `vault` function parameter
|
|
137
|
+
/// passed in the `vault` function parameter,
|
|
138
138
|
/// - `sweepProof` components must match the expected structure. See
|
|
139
139
|
/// `BitcoinTx.Proof` docs for reference. The `bitcoinHeaders`
|
|
140
140
|
/// field must contain a valid number of block headers, not less
|
|
141
|
-
/// than the `txProofDifficultyFactor` contract constant
|
|
141
|
+
/// than the `txProofDifficultyFactor` contract constant,
|
|
142
142
|
/// - `mainUtxo` components must point to the recent main UTXO
|
|
143
143
|
/// of the given wallet, as currently known on the Ethereum chain.
|
|
144
144
|
/// If there is no main UTXO, this parameter is ignored.
|
|
@@ -261,14 +261,14 @@ library DepositSweep {
|
|
|
261
261
|
/// Bitcoin transaction.
|
|
262
262
|
/// @param mainUtxo Data of the wallet's main UTXO, as currently known on
|
|
263
263
|
/// the Ethereum chain. If no main UTXO exists for the given wallet,
|
|
264
|
-
/// this parameter is ignored
|
|
264
|
+
/// this parameter is ignored.
|
|
265
265
|
/// @return wallet Data of the sweeping wallet.
|
|
266
266
|
/// @return resolvedMainUtxo The actual main UTXO of the sweeping wallet
|
|
267
267
|
/// resolved by cross-checking the `mainUtxo` parameter with
|
|
268
268
|
/// the chain state. If the validation went well, this is the
|
|
269
269
|
/// plain-text main UTXO corresponding to the `wallet.mainUtxoHash`.
|
|
270
270
|
/// @dev Requirements:
|
|
271
|
-
/// - Sweeping wallet must be either in Live or MovingFunds state
|
|
271
|
+
/// - Sweeping wallet must be either in Live or MovingFunds state,
|
|
272
272
|
/// - If the main UTXO of the sweeping wallet exists in the storage,
|
|
273
273
|
/// the passed `mainUTXO` parameter must be equal to the stored one.
|
|
274
274
|
function resolveDepositSweepingWallet(
|
|
@@ -319,7 +319,7 @@ library DepositSweep {
|
|
|
319
319
|
/// @param sweepTxOutputVector Bitcoin sweep transaction output vector.
|
|
320
320
|
/// This function assumes vector's structure is valid so it must be
|
|
321
321
|
/// validated using e.g. `BTCUtils.validateVout` function before
|
|
322
|
-
/// it is passed here
|
|
322
|
+
/// it is passed here.
|
|
323
323
|
/// @return walletPubKeyHash 20-byte wallet public key hash.
|
|
324
324
|
/// @return value 8-byte sweep transaction output value.
|
|
325
325
|
function processDepositSweepTxOutput(
|
|
@@ -502,8 +502,8 @@ library DepositSweep {
|
|
|
502
502
|
}
|
|
503
503
|
|
|
504
504
|
/// @notice Parses a Bitcoin transaction input starting at the given index.
|
|
505
|
-
/// @param inputVector Bitcoin transaction input vector
|
|
506
|
-
/// @param inputStartingIndex Index the given input starts at
|
|
505
|
+
/// @param inputVector Bitcoin transaction input vector.
|
|
506
|
+
/// @param inputStartingIndex Index the given input starts at.
|
|
507
507
|
/// @return outpointTxHash 32-byte hash of the Bitcoin transaction which is
|
|
508
508
|
/// pointed in the given input's outpoint.
|
|
509
509
|
/// @return outpointIndex 4-byte index of the Bitcoin transaction output
|
|
@@ -109,9 +109,9 @@ library Fraud {
|
|
|
109
109
|
/// proof of a transaction that consumes the given input according
|
|
110
110
|
/// to protocol rules. To prevent spurious allegations, the caller
|
|
111
111
|
/// must deposit ETH that is returned back upon justified fraud
|
|
112
|
-
/// challenge or confiscated otherwise
|
|
112
|
+
/// challenge or confiscated otherwise.
|
|
113
113
|
/// @param walletPublicKey The public key of the wallet in the uncompressed
|
|
114
|
-
/// and unprefixed format (64 bytes)
|
|
114
|
+
/// and unprefixed format (64 bytes).
|
|
115
115
|
/// @param preimageSha256 The hash that was generated by applying SHA-256
|
|
116
116
|
/// one time over the preimage used during input signing. The preimage
|
|
117
117
|
/// is a serialized subset of the transaction and its structure
|
|
@@ -119,17 +119,17 @@ library Fraud {
|
|
|
119
119
|
/// Notice that applying SHA-256 over the `preimageSha256` results
|
|
120
120
|
/// in `sighash`. The path from `preimage` to `sighash` looks like
|
|
121
121
|
/// this:
|
|
122
|
-
/// preimage -> (SHA-256) -> preimageSha256 -> (SHA-256) -> sighash
|
|
122
|
+
/// preimage -> (SHA-256) -> preimageSha256 -> (SHA-256) -> sighash.
|
|
123
123
|
/// @param signature Bitcoin signature in the R/S/V format
|
|
124
124
|
/// @dev Requirements:
|
|
125
125
|
/// - Wallet behind `walletPublicKey` must be in Live or MovingFunds
|
|
126
|
-
/// or Closing state
|
|
126
|
+
/// or Closing state,
|
|
127
127
|
/// - The challenger must send appropriate amount of ETH used as
|
|
128
|
-
/// fraud challenge deposit
|
|
128
|
+
/// fraud challenge deposit,
|
|
129
129
|
/// - The signature (represented by r, s and v) must be generated by
|
|
130
130
|
/// the wallet behind `walletPubKey` during signing of `sighash`
|
|
131
|
-
/// which was calculated from `preimageSha256
|
|
132
|
-
/// - Wallet can be challenged for the given signature only once
|
|
131
|
+
/// which was calculated from `preimageSha256`,
|
|
132
|
+
/// - Wallet can be challenged for the given signature only once.
|
|
133
133
|
function submitFraudChallenge(
|
|
134
134
|
BridgeState.Storage storage self,
|
|
135
135
|
bytes calldata walletPublicKey,
|
|
@@ -210,21 +210,21 @@ library Fraud {
|
|
|
210
210
|
/// resolved and the amount of ether deposited by the challenger is
|
|
211
211
|
/// sent to the treasury.
|
|
212
212
|
/// @param walletPublicKey The public key of the wallet in the uncompressed
|
|
213
|
-
/// and unprefixed format (64 bytes)
|
|
213
|
+
/// and unprefixed format (64 bytes).
|
|
214
214
|
/// @param preimage The preimage which produces sighash used to generate the
|
|
215
215
|
/// ECDSA signature that is the subject of the fraud claim. It is a
|
|
216
216
|
/// serialized subset of the transaction. The exact subset used as
|
|
217
217
|
/// the preimage depends on the transaction input the signature is
|
|
218
|
-
/// produced for. See BIP-143 for reference
|
|
218
|
+
/// produced for. See BIP-143 for reference.
|
|
219
219
|
/// @param witness Flag indicating whether the preimage was produced for a
|
|
220
220
|
/// witness input. True for witness, false for non-witness input.
|
|
221
221
|
/// @dev Requirements:
|
|
222
222
|
/// - `walletPublicKey` and `sighash` calculated as `hash256(preimage)`
|
|
223
|
-
/// must identify an open fraud challenge
|
|
223
|
+
/// must identify an open fraud challenge,
|
|
224
224
|
/// - the preimage must be a valid preimage of a transaction generated
|
|
225
|
-
/// according to the protocol rules and already proved in the Bridge
|
|
225
|
+
/// according to the protocol rules and already proved in the Bridge,
|
|
226
226
|
/// - before a defeat attempt is made the transaction that spends the
|
|
227
|
-
/// given UTXO must be proven in the Bridge
|
|
227
|
+
/// given UTXO must be proven in the Bridge.
|
|
228
228
|
function defeatFraudChallenge(
|
|
229
229
|
BridgeState.Storage storage self,
|
|
230
230
|
bytes calldata walletPublicKey,
|
|
@@ -277,16 +277,16 @@ library Fraud {
|
|
|
277
277
|
/// challenge is marked as resolved and the amount of ether
|
|
278
278
|
/// deposited by the challenger is sent to the treasury.
|
|
279
279
|
/// @param walletPublicKey The public key of the wallet in the uncompressed
|
|
280
|
-
/// and unprefixed format (64 bytes)
|
|
280
|
+
/// and unprefixed format (64 bytes),
|
|
281
281
|
/// @param heartbeatMessage Off-chain heartbeat message meeting the heartbeat
|
|
282
282
|
/// message format requirements which produces sighash used to
|
|
283
283
|
/// generate the ECDSA signature that is the subject of the fraud
|
|
284
|
-
/// claim
|
|
284
|
+
/// claim.
|
|
285
285
|
/// @dev Requirements:
|
|
286
286
|
/// - `walletPublicKey` and `sighash` calculated as
|
|
287
|
-
/// `hash256(heartbeatMessage)` must identify an open fraud challenge
|
|
287
|
+
/// `hash256(heartbeatMessage)` must identify an open fraud challenge,
|
|
288
288
|
/// - `heartbeatMessage` must follow a strict format of heartbeat
|
|
289
|
-
/// messages
|
|
289
|
+
/// messages.
|
|
290
290
|
function defeatFraudChallengeWithHeartbeat(
|
|
291
291
|
BridgeState.Storage storage self,
|
|
292
292
|
bytes calldata walletPublicKey,
|
|
@@ -355,8 +355,8 @@ library Fraud {
|
|
|
355
355
|
/// deposited is returned to the challenger and the challenger is
|
|
356
356
|
/// rewarded.
|
|
357
357
|
/// @param walletPublicKey The public key of the wallet in the uncompressed
|
|
358
|
-
/// and unprefixed format (64 bytes)
|
|
359
|
-
/// @param walletMembersIDs Identifiers of the wallet signing group members
|
|
358
|
+
/// and unprefixed format (64 bytes).
|
|
359
|
+
/// @param walletMembersIDs Identifiers of the wallet signing group members.
|
|
360
360
|
/// @param preimageSha256 The hash that was generated by applying SHA-256
|
|
361
361
|
/// one time over the preimage used during input signing. The preimage
|
|
362
362
|
/// is a serialized subset of the transaction and its structure
|
|
@@ -364,20 +364,20 @@ library Fraud {
|
|
|
364
364
|
/// Notice that applying SHA-256 over the `preimageSha256` results
|
|
365
365
|
/// in `sighash`. The path from `preimage` to `sighash` looks like
|
|
366
366
|
/// this:
|
|
367
|
-
/// preimage -> (SHA-256) -> preimageSha256 -> (SHA-256) -> sighash
|
|
367
|
+
/// preimage -> (SHA-256) -> preimageSha256 -> (SHA-256) -> sighash.
|
|
368
368
|
/// @dev Requirements:
|
|
369
369
|
/// - The wallet must be in the Live or MovingFunds or Closing or
|
|
370
|
-
/// Terminated state
|
|
370
|
+
/// Terminated state,
|
|
371
371
|
/// - The `walletPublicKey` and `sighash` calculated from
|
|
372
|
-
/// `preimageSha256` must identify an open fraud challenge
|
|
372
|
+
/// `preimageSha256` must identify an open fraud challenge,
|
|
373
373
|
/// - The expression `keccak256(abi.encode(walletMembersIDs))` must
|
|
374
374
|
/// be exactly the same as the hash stored under `membersIdsHash`
|
|
375
375
|
/// for the given `walletID`. Those IDs are not directly stored
|
|
376
376
|
/// in the contract for gas efficiency purposes but they can be
|
|
377
377
|
/// read from appropriate `DkgResultSubmitted` and `DkgResultApproved`
|
|
378
|
-
/// events of the `WalletRegistry` contract
|
|
378
|
+
/// events of the `WalletRegistry` contract,
|
|
379
379
|
/// - The amount of time indicated by `challengeDefeatTimeout` must pass
|
|
380
|
-
/// after the challenge was reported
|
|
380
|
+
/// after the challenge was reported.
|
|
381
381
|
function notifyFraudChallengeDefeatTimeout(
|
|
382
382
|
BridgeState.Storage storage self,
|
|
383
383
|
bytes calldata walletPublicKey,
|
|
@@ -504,7 +504,7 @@ library Fraud {
|
|
|
504
504
|
/// ECDSA signature that is the subject of the fraud claim. It is a
|
|
505
505
|
/// serialized subset of the transaction. The exact subset used as
|
|
506
506
|
/// the preimage depends on the transaction input the signature is
|
|
507
|
-
/// produced for. See BIP-143 for reference
|
|
507
|
+
/// produced for. See BIP-143 for reference.
|
|
508
508
|
/// @return utxoKey UTXO key that identifies spent input.
|
|
509
509
|
function extractUtxoKeyFromNonWitnessPreimage(bytes calldata preimage)
|
|
510
510
|
internal
|
|
@@ -588,7 +588,7 @@ library Fraud {
|
|
|
588
588
|
|
|
589
589
|
/// @notice Extracts the sighash type from the given preimage.
|
|
590
590
|
/// @param preimage Serialized subset of the transaction. See BIP-143 for
|
|
591
|
-
/// reference
|
|
591
|
+
/// reference.
|
|
592
592
|
/// @dev Sighash type is stored as the last 4 bytes in the preimage (little
|
|
593
593
|
/// endian).
|
|
594
594
|
/// @return sighashType Sighash type as a 32-bit integer.
|
|
@@ -90,7 +90,7 @@ library Heartbeat {
|
|
|
90
90
|
/// heartbeat message.
|
|
91
91
|
/// @param message Message signed by the wallet. It is a potential heartbeat
|
|
92
92
|
/// message, Bitcoin transaction preimage, or an arbitrary signed
|
|
93
|
-
/// bytes
|
|
93
|
+
/// bytes.
|
|
94
94
|
/// @dev Wallet heartbeat message must be exactly 16 bytes long with the first
|
|
95
95
|
/// 8 bytes set to 0xffffffffffffffff.
|
|
96
96
|
/// @return True if valid heartbeat message, false otherwise.
|