@keep-network/tbtc-v2 0.1.1-dev.72 → 0.1.1-dev.75

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 (89) hide show
  1. package/artifacts/Bank.json +15 -15
  2. package/artifacts/Bridge.json +14 -1
  3. package/artifacts/DefaultProxyAdmin.json +5 -5
  4. package/artifacts/Deposit.json +10 -10
  5. package/artifacts/DepositSweep.json +11 -11
  6. package/artifacts/EcdsaDkgValidator.json +9 -9
  7. package/artifacts/EcdsaInactivity.json +8 -8
  8. package/artifacts/Fraud.json +21 -21
  9. package/artifacts/KeepRegistry.json +1 -1
  10. package/artifacts/KeepStake.json +2 -2
  11. package/artifacts/KeepToken.json +2 -2
  12. package/artifacts/KeepTokenStaking.json +1 -1
  13. package/artifacts/MovingFunds.json +33 -33
  14. package/artifacts/NuCypherStakingEscrow.json +1 -1
  15. package/artifacts/NuCypherToken.json +2 -2
  16. package/artifacts/RandomBeaconStub.json +5 -5
  17. package/artifacts/Redemption.json +22 -22
  18. package/artifacts/ReimbursementPool.json +5 -5
  19. package/artifacts/Relay.json +9 -9
  20. package/artifacts/SortitionPool.json +9 -9
  21. package/artifacts/T.json +2 -2
  22. package/artifacts/TBTC.json +17 -17
  23. package/artifacts/TBTCToken.json +15 -15
  24. package/artifacts/TokenStaking.json +1 -1
  25. package/artifacts/TokenholderGovernor.json +9 -9
  26. package/artifacts/TokenholderTimelock.json +8 -8
  27. package/artifacts/VendingMachine.json +18 -18
  28. package/artifacts/VendingMachineKeep.json +1 -1
  29. package/artifacts/VendingMachineNuCypher.json +1 -1
  30. package/artifacts/WalletRegistry.json +17 -17
  31. package/artifacts/WalletRegistry_Implementation.json +73 -73
  32. package/artifacts/WalletRegistry_Proxy.json +17 -17
  33. package/artifacts/Wallets.json +12 -12
  34. package/artifacts/solcInputs/49c80d59bf0ae61f27a8bb5db19af68a.json +272 -0
  35. package/build/contracts/GovernanceUtils.sol/GovernanceUtils.dbg.json +1 -1
  36. package/build/contracts/GovernanceUtils.sol/GovernanceUtils.json +2 -2
  37. package/build/contracts/bank/Bank.sol/Bank.dbg.json +1 -1
  38. package/build/contracts/bank/Bank.sol/Bank.json +2 -2
  39. package/build/contracts/bridge/BitcoinTx.sol/BitcoinTx.dbg.json +1 -1
  40. package/build/contracts/bridge/BitcoinTx.sol/BitcoinTx.json +2 -2
  41. package/build/contracts/bridge/Bridge.sol/Bridge.dbg.json +1 -1
  42. package/build/contracts/bridge/Bridge.sol/Bridge.json +58 -42
  43. package/build/contracts/bridge/BridgeState.sol/BridgeState.dbg.json +1 -1
  44. package/build/contracts/bridge/BridgeState.sol/BridgeState.json +8 -2
  45. package/build/contracts/bridge/Deposit.sol/Deposit.dbg.json +1 -1
  46. package/build/contracts/bridge/Deposit.sol/Deposit.json +2 -2
  47. package/build/contracts/bridge/DepositSweep.sol/DepositSweep.dbg.json +1 -1
  48. package/build/contracts/bridge/DepositSweep.sol/DepositSweep.json +2 -2
  49. package/build/contracts/bridge/EcdsaLib.sol/EcdsaLib.dbg.json +1 -1
  50. package/build/contracts/bridge/Fraud.sol/Fraud.dbg.json +1 -1
  51. package/build/contracts/bridge/Fraud.sol/Fraud.json +2 -2
  52. package/build/contracts/bridge/Heartbeat.sol/Heartbeat.dbg.json +1 -1
  53. package/build/contracts/bridge/Heartbeat.sol/Heartbeat.json +2 -2
  54. package/build/contracts/bridge/IRelay.sol/IRelay.dbg.json +1 -1
  55. package/build/contracts/bridge/MovingFunds.sol/MovingFunds.dbg.json +1 -1
  56. package/build/contracts/bridge/MovingFunds.sol/MovingFunds.json +2 -2
  57. package/build/contracts/bridge/Redemption.sol/OutboundTx.dbg.json +1 -1
  58. package/build/contracts/bridge/Redemption.sol/OutboundTx.json +2 -2
  59. package/build/contracts/bridge/Redemption.sol/Redemption.dbg.json +1 -1
  60. package/build/contracts/bridge/Redemption.sol/Redemption.json +2 -2
  61. package/build/contracts/bridge/VendingMachine.sol/VendingMachine.dbg.json +1 -1
  62. package/build/contracts/bridge/VendingMachine.sol/VendingMachine.json +2 -2
  63. package/build/contracts/bridge/Wallets.sol/Wallets.dbg.json +1 -1
  64. package/build/contracts/bridge/Wallets.sol/Wallets.json +2 -2
  65. package/build/contracts/token/TBTC.sol/TBTC.dbg.json +1 -1
  66. package/build/contracts/token/TBTC.sol/TBTC.json +2 -2
  67. package/build/contracts/vault/DonationVault.sol/DonationVault.dbg.json +1 -1
  68. package/build/contracts/vault/DonationVault.sol/DonationVault.json +2 -2
  69. package/build/contracts/vault/IVault.sol/IVault.dbg.json +1 -1
  70. package/build/contracts/vault/TBTCVault.sol/TBTCVault.dbg.json +1 -1
  71. package/build/contracts/vault/TBTCVault.sol/TBTCVault.json +2 -2
  72. package/contracts/GovernanceUtils.sol +3 -3
  73. package/contracts/bank/Bank.sol +2 -2
  74. package/contracts/bridge/BitcoinTx.sol +7 -7
  75. package/contracts/bridge/Bridge.sol +221 -203
  76. package/contracts/bridge/BridgeState.sol +75 -49
  77. package/contracts/bridge/Deposit.sol +5 -5
  78. package/contracts/bridge/DepositSweep.sol +12 -12
  79. package/contracts/bridge/Fraud.sol +25 -25
  80. package/contracts/bridge/Heartbeat.sol +1 -1
  81. package/contracts/bridge/MovingFunds.sol +81 -72
  82. package/contracts/bridge/Redemption.sol +32 -31
  83. package/contracts/bridge/Wallets.sol +29 -29
  84. package/contracts/vault/DonationVault.sol +9 -9
  85. package/contracts/vault/IVault.sol +4 -4
  86. package/contracts/vault/TBTCVault.sol +14 -14
  87. package/export.json +13 -0
  88. package/package.json +3 -3
  89. package/artifacts/solcInputs/55df7785455cbf6ded1b912686e91d3f.json +0 -269
@@ -16,12 +16,8 @@
16
16
  pragma solidity ^0.8.9;
17
17
 
18
18
  import "@keep-network/random-beacon/contracts/Governable.sol";
19
-
20
19
  import {IWalletOwner as EcdsaWalletOwner} from "@keep-network/ecdsa/contracts/api/IWalletOwner.sol";
21
20
 
22
- // TODO: We used RC version of @openzeppelin/contracts-upgradeable to use `reinitializer`
23
- // in upgrades. We should revisit this part before mainnet deployment and use
24
- // a final release package if it's ready.
25
21
  import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
26
22
 
27
23
  import "./IRelay.sol";
@@ -58,9 +54,6 @@ import "../bank/Bank.sol";
58
54
  /// @dev Bridge is an upgradeable component of the Bank. The order of
59
55
  /// functionalities in this contract is: deposit, sweep, redemption,
60
56
  /// moving funds, wallet lifecycle, frauds, parameters.
61
- ///
62
- /// TODO: Align the convention around `param` and `dev` endings. They should
63
- /// not have a punctuation mark.
64
57
  contract Bridge is Governable, EcdsaWalletOwner, Initializable {
65
58
  using BridgeState for BridgeState.Storage;
66
59
  using Deposit for BridgeState.Storage;
@@ -198,6 +191,7 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
198
191
  event MovingFundsParametersUpdated(
199
192
  uint64 movingFundsTxMaxTotalFee,
200
193
  uint64 movingFundsDustThreshold,
194
+ uint32 movingFundsTimeoutResetDelay,
201
195
  uint32 movingFundsTimeout,
202
196
  uint96 movingFundsTimeoutSlashingAmount,
203
197
  uint256 movingFundsTimeoutNotifierRewardMultiplier,
@@ -225,14 +219,14 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
225
219
  );
226
220
 
227
221
  /// @dev Initializes upgradable contract on deployment.
228
- /// @param _bank Address of the Bank the Bridge belongs to
222
+ /// @param _bank Address of the Bank the Bridge belongs to.
229
223
  /// @param _relay Address of the Bitcoin relay providing the current Bitcoin
230
- /// network difficulty
224
+ /// network difficulty.
231
225
  /// @param _treasury Address where the deposit and redemption treasury fees
232
- /// will be sent to
233
- /// @param _ecdsaWalletRegistry Address of the ECDSA Wallet Registry contract
226
+ /// will be sent to.
227
+ /// @param _ecdsaWalletRegistry Address of the ECDSA Wallet Registry contract.
234
228
  /// @param _txProofDifficultyFactor The number of confirmations on the Bitcoin
235
- /// chain required to successfully evaluate an SPV proof
229
+ /// chain required to successfully evaluate an SPV proof.
236
230
  function initialize(
237
231
  address _bank,
238
232
  address _relay,
@@ -258,6 +252,7 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
258
252
  self.txProofDifficultyFactor = _txProofDifficultyFactor;
259
253
 
260
254
  // TODO: Revisit initial values.
255
+ // https://github.com/keep-network/tbtc-v2/issues/258
261
256
  self.depositDustThreshold = 1000000; // 1000000 satoshi = 0.01 BTC
262
257
  self.depositTxMaxFee = 10000; // 10000 satoshi
263
258
  self.depositTreasuryFeeDivisor = 2000; // 1/2000 == 5bps == 0.05% == 0.0005
@@ -269,6 +264,7 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
269
264
  self.redemptionTimeoutNotifierRewardMultiplier = 100; // 100%
270
265
  self.movingFundsTxMaxTotalFee = 10000; // 10000 satoshi
271
266
  self.movingFundsDustThreshold = 20000; // 20000 satoshi
267
+ self.movingFundsTimeoutResetDelay = 6 days;
272
268
  self.movingFundsTimeout = 7 days;
273
269
  self.movingFundsTimeoutSlashingAmount = 10000 * 1e18; // 10000 T
274
270
  self.movingFundsTimeoutNotifierRewardMultiplier = 100; //100%
@@ -302,13 +298,13 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
302
298
  /// outputs. The deposit may be routed to one of the trusted vaults.
303
299
  /// When a deposit is routed to a vault, vault gets notified when
304
300
  /// the deposit gets swept and it may execute the appropriate action.
305
- /// @param fundingTx Bitcoin funding transaction data, see `BitcoinTx.Info`
306
- /// @param reveal Deposit reveal data, see `RevealInfo struct
301
+ /// @param fundingTx Bitcoin funding transaction data, see `BitcoinTx.Info`.
302
+ /// @param reveal Deposit reveal data, see `RevealInfo struct.
307
303
  /// @dev Requirements:
308
- /// - `reveal.walletPubKeyHash` must identify a `Live` wallet
309
- /// - `reveal.vault` must be 0x0 or point to a trusted vault
304
+ /// - `reveal.walletPubKeyHash` must identify a `Live` wallet,
305
+ /// - `reveal.vault` must be 0x0 or point to a trusted vault,
310
306
  /// - `reveal.fundingOutputIndex` must point to the actual P2(W)SH
311
- /// output of the BTC deposit transaction
307
+ /// output of the BTC deposit transaction,
312
308
  /// - `reveal.depositor` must be the Ethereum address used in the
313
309
  /// P2(W)SH BTC deposit transaction,
314
310
  /// - `reveal.blindingFactor` must be the blinding factor used in the
@@ -343,11 +339,11 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
343
339
  /// during the reveal transaction, minus their fee share.
344
340
  ///
345
341
  /// It is possible to prove the given sweep only one time.
346
- /// @param sweepTx Bitcoin sweep transaction data
347
- /// @param sweepProof Bitcoin sweep proof data
342
+ /// @param sweepTx Bitcoin sweep transaction data.
343
+ /// @param sweepProof Bitcoin sweep proof data.
348
344
  /// @param mainUtxo Data of the wallet's main UTXO, as currently known on
349
345
  /// the Ethereum chain. If no main UTXO exists for the given wallet,
350
- /// this parameter is ignored
346
+ /// this parameter is ignored.
351
347
  /// @param vault Optional address of the vault where all swept deposits
352
348
  /// should be routed to. All deposits swept as part of the transaction
353
349
  /// must have their `vault` parameters set to the same address.
@@ -361,7 +357,7 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
361
357
  /// - `sweepTx` components must match the expected structure. See
362
358
  /// `BitcoinTx.Info` docs for reference. Their values must exactly
363
359
  /// correspond to appropriate Bitcoin transaction fields to produce
364
- /// a provable transaction hash.
360
+ /// a provable transaction hash,
365
361
  /// - The `sweepTx` should represent a Bitcoin transaction with 1..n
366
362
  /// inputs. If the wallet has no main UTXO, all n inputs should
367
363
  /// correspond to P2(W)SH revealed deposits UTXOs. If the wallet has
@@ -369,14 +365,14 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
369
365
  /// main UTXO and remaining n-1 inputs should correspond to P2(W)SH
370
366
  /// revealed deposits UTXOs. That transaction must have only
371
367
  /// one P2(W)PKH output locking funds on the 20-byte wallet public
372
- /// key hash.
368
+ /// key hash,
373
369
  /// - All revealed deposits that are swept by `sweepTx` must have
374
370
  /// their `vault` parameters set to the same address as the address
375
- /// passed in the `vault` function parameter.
371
+ /// passed in the `vault` function parameter,
376
372
  /// - `sweepProof` components must match the expected structure. See
377
373
  /// `BitcoinTx.Proof` docs for reference. The `bitcoinHeaders`
378
374
  /// field must contain a valid number of block headers, not less
379
- /// than the `txProofDifficultyFactor` contract constant.
375
+ /// than the `txProofDifficultyFactor` contract constant,
380
376
  /// - `mainUtxo` components must point to the recent main UTXO
381
377
  /// of the given wallet, as currently known on the Ethereum chain.
382
378
  /// If there is no main UTXO, this parameter is ignored.
@@ -392,12 +388,12 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
392
388
  /// @notice Requests redemption of the given amount from the specified
393
389
  /// wallet to the redeemer Bitcoin output script.
394
390
  /// @param walletPubKeyHash The 20-byte wallet public key hash (computed
395
- /// using Bitcoin HASH160 over the compressed ECDSA public key)
391
+ /// using Bitcoin HASH160 over the compressed ECDSA public key).
396
392
  /// @param mainUtxo Data of the wallet's main UTXO, as currently known on
397
- /// the Ethereum chain
393
+ /// the Ethereum chain.
398
394
  /// @param redeemerOutputScript The redeemer's length-prefixed output
399
395
  /// script (P2PKH, P2WPKH, P2SH or P2WSH) that will be used to lock
400
- /// redeemed BTC
396
+ /// redeemed BTC.
401
397
  /// @param amount Requested amount in satoshi. This is also the TBTC amount
402
398
  /// that is taken from redeemer's balance in the Bank upon request.
403
399
  /// Once the request is handled, the actual amount of BTC locked
@@ -407,15 +403,15 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
407
403
  /// `amount - (amount / redemptionTreasuryFeeDivisor) - redemptionTxMaxFee`.
408
404
  /// Fees values are taken at the moment of request creation.
409
405
  /// @dev Requirements:
410
- /// - Wallet behind `walletPubKeyHash` must be live
406
+ /// - Wallet behind `walletPubKeyHash` must be live,
411
407
  /// - `mainUtxo` components must point to the recent main UTXO
412
- /// of the given wallet, as currently known on the Ethereum chain.
413
- /// - `redeemerOutputScript` must be a proper Bitcoin script
414
- /// - `redeemerOutputScript` cannot have wallet PKH as payload
415
- /// - `amount` must be above or equal the `redemptionDustThreshold`
408
+ /// of the given wallet, as currently known on the Ethereum chain,
409
+ /// - `redeemerOutputScript` must be a proper Bitcoin script,
410
+ /// - `redeemerOutputScript` cannot have wallet PKH as payload,
411
+ /// - `amount` must be above or equal the `redemptionDustThreshold`,
416
412
  /// - Given `walletPubKeyHash` and `redeemerOutputScript` pair can be
417
- /// used for only one pending request at the same time
418
- /// - Wallet must have enough Bitcoin balance to proceed the request
413
+ /// used for only one pending request at the same time,
414
+ /// - Wallet must have enough Bitcoin balance to proceed the request,
419
415
  /// - Redeemer must make an allowance in the Bank that the Bridge
420
416
  /// contract can spend the given `amount`.
421
417
  function requestRedemption(
@@ -441,18 +437,18 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
441
437
  /// transferring the treasury fee sum to the treasury address.
442
438
  ///
443
439
  /// It is possible to prove the given redemption only one time.
444
- /// @param redemptionTx Bitcoin redemption transaction data
445
- /// @param redemptionProof Bitcoin redemption proof data
440
+ /// @param redemptionTx Bitcoin redemption transaction data.
441
+ /// @param redemptionProof Bitcoin redemption proof data.
446
442
  /// @param mainUtxo Data of the wallet's main UTXO, as currently known on
447
- /// the Ethereum chain
443
+ /// the Ethereum chain.
448
444
  /// @param walletPubKeyHash 20-byte public key hash (computed using Bitcoin
449
445
  /// HASH160 over the compressed ECDSA public key) of the wallet which
450
- /// performed the redemption transaction
446
+ /// performed the redemption transaction.
451
447
  /// @dev Requirements:
452
448
  /// - `redemptionTx` components must match the expected structure. See
453
449
  /// `BitcoinTx.Info` docs for reference. Their values must exactly
454
450
  /// correspond to appropriate Bitcoin transaction fields to produce
455
- /// a provable transaction hash.
451
+ /// a provable transaction hash,
456
452
  /// - The `redemptionTx` should represent a Bitcoin transaction with
457
453
  /// exactly 1 input that refers to the wallet's main UTXO. That
458
454
  /// transaction should have 1..n outputs handling existing pending
@@ -460,14 +456,14 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
460
456
  /// There can be also 1 optional output representing the
461
457
  /// change and pointing back to the 20-byte wallet public key hash.
462
458
  /// The change should be always present if the redeemed value sum
463
- /// is lower than the total wallet's BTC balance.
459
+ /// is lower than the total wallet's BTC balance,
464
460
  /// - `redemptionProof` components must match the expected structure.
465
461
  /// See `BitcoinTx.Proof` docs for reference. The `bitcoinHeaders`
466
462
  /// field must contain a valid number of block headers, not less
467
- /// than the `txProofDifficultyFactor` contract constant.
463
+ /// than the `txProofDifficultyFactor` contract constant,
468
464
  /// - `mainUtxo` components must point to the recent main UTXO
469
465
  /// of the given wallet, as currently known on the Ethereum chain.
470
- /// Additionally, the recent main UTXO on Ethereum must be set.
466
+ /// Additionally, the recent main UTXO on Ethereum must be set,
471
467
  /// - `walletPubKeyHash` must be connected with the main UTXO used
472
468
  /// as transaction single input.
473
469
  /// Other remarks:
@@ -495,36 +491,36 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
495
491
  /// request is identified by the key built as
496
492
  /// `keccak256(walletPubKeyHash | redeemerOutputScript)`.
497
493
  /// The results of calling this function:
498
- /// - the pending redemptions value for the wallet will be decreased
494
+ /// - The pending redemptions value for the wallet will be decreased
499
495
  /// by the requested amount (minus treasury fee),
500
- /// - the tokens taken from the redeemer on redemption request will
496
+ /// - The tokens taken from the redeemer on redemption request will
501
497
  /// be returned to the redeemer,
502
- /// - the request will be moved from pending redemptions to
498
+ /// - The request will be moved from pending redemptions to
503
499
  /// timed-out redemptions,
504
- /// - if the state of the wallet is `Live` or `MovingFunds`, the
500
+ /// - If the state of the wallet is `Live` or `MovingFunds`, the
505
501
  /// wallet operators will be slashed and the notifier will be
506
502
  /// rewarded,
507
- /// - if the state of wallet is `Live`, the wallet will be closed or
503
+ /// - If the state of wallet is `Live`, the wallet will be closed or
508
504
  /// marked as `MovingFunds` (depending on the presence or absence
509
505
  /// of the wallet's main UTXO) and the wallet will no longer be
510
506
  /// marked as the active wallet (if it was marked as such).
511
- /// @param walletPubKeyHash 20-byte public key hash of the wallet
512
- /// @param walletMembersIDs Identifiers of the wallet signing group members
507
+ /// @param walletPubKeyHash 20-byte public key hash of the wallet.
508
+ /// @param walletMembersIDs Identifiers of the wallet signing group members.
513
509
  /// @param redeemerOutputScript The redeemer's length-prefixed output
514
- /// script (P2PKH, P2WPKH, P2SH or P2WSH)
510
+ /// script (P2PKH, P2WPKH, P2SH or P2WSH).
515
511
  /// @dev Requirements:
516
- /// - The wallet must be in the Live or MovingFunds or Terminated state
512
+ /// - The wallet must be in the Live or MovingFunds or Terminated state,
517
513
  /// - The redemption request identified by `walletPubKeyHash` and
518
- /// `redeemerOutputScript` must exist
514
+ /// `redeemerOutputScript` must exist,
519
515
  /// - The expression `keccak256(abi.encode(walletMembersIDs))` must
520
516
  /// be exactly the same as the hash stored under `membersIdsHash`
521
517
  /// for the given `walletID`. Those IDs are not directly stored
522
518
  /// in the contract for gas efficiency purposes but they can be
523
519
  /// read from appropriate `DkgResultSubmitted` and `DkgResultApproved`
524
- /// events of the `WalletRegistry` contract
520
+ /// events of the `WalletRegistry` contract,
525
521
  /// - The amount of time defined by `redemptionTimeout` must have
526
522
  /// passed since the redemption was requested (the request must be
527
- /// timed-out)
523
+ /// timed-out).
528
524
  function notifyRedemptionTimeout(
529
525
  bytes20 walletPubKeyHash,
530
526
  uint32[] calldata walletMembersIDs,
@@ -541,42 +537,42 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
541
537
  /// Once all requirements are met, that function registers the
542
538
  /// target wallets commitment and opens the way for moving funds
543
539
  /// proof submission.
544
- /// @param walletPubKeyHash 20-byte public key hash of the source wallet
540
+ /// @param walletPubKeyHash 20-byte public key hash of the source wallet.
545
541
  /// @param walletMainUtxo Data of the source wallet's main UTXO, as
546
- /// currently known on the Ethereum chain
542
+ /// currently known on the Ethereum chain.
547
543
  /// @param walletMembersIDs Identifiers of the source wallet signing group
548
- /// members
544
+ /// members.
549
545
  /// @param walletMemberIndex Position of the caller in the source wallet
550
- /// signing group members list
546
+ /// signing group members list.
551
547
  /// @param targetWallets List of 20-byte public key hashes of the target
552
- /// wallets that the source wallet commits to move the funds to
548
+ /// wallets that the source wallet commits to move the funds to.
553
549
  /// @dev Requirements:
554
- /// - The source wallet must be in the MovingFunds state
555
- /// - The source wallet must not have pending redemption requests
556
- /// - The source wallet must not have pending moved funds sweep requests
557
- /// - The source wallet must not have submitted its commitment already
550
+ /// - The source wallet must be in the MovingFunds state,
551
+ /// - The source wallet must not have pending redemption requests,
552
+ /// - The source wallet must not have pending moved funds sweep requests,
553
+ /// - The source wallet must not have submitted its commitment already,
558
554
  /// - The expression `keccak256(abi.encode(walletMembersIDs))` must
559
555
  /// be exactly the same as the hash stored under `membersIdsHash`
560
556
  /// for the given source wallet in the ECDSA registry. Those IDs are
561
557
  /// not directly stored in the contract for gas efficiency purposes
562
558
  /// but they can be read from appropriate `DkgResultSubmitted`
563
- /// and `DkgResultApproved` events.
564
- /// - The `walletMemberIndex` must be in range [1, walletMembersIDs.length]
559
+ /// and `DkgResultApproved` events,
560
+ /// - The `walletMemberIndex` must be in range [1, walletMembersIDs.length],
565
561
  /// - The caller must be the member of the source wallet signing group
566
- /// at the position indicated by `walletMemberIndex` parameter
562
+ /// at the position indicated by `walletMemberIndex` parameter,
567
563
  /// - The `walletMainUtxo` components must point to the recent main
568
564
  /// UTXO of the source wallet, as currently known on the Ethereum
569
- /// chain.
570
- /// - Source wallet BTC balance must be greater than zero
571
- /// - At least one Live wallet must exist in the system
565
+ /// chain,
566
+ /// - Source wallet BTC balance must be greater than zero,
567
+ /// - At least one Live wallet must exist in the system,
572
568
  /// - Submitted target wallets count must match the expected count
573
569
  /// `N = min(liveWalletsCount, ceil(walletBtcBalance / walletMaxBtcTransfer))`
574
- /// where `N > 0`
575
- /// - Each target wallet must be not equal to the source wallet
570
+ /// where `N > 0`,
571
+ /// - Each target wallet must be not equal to the source wallet,
576
572
  /// - Each target wallet must follow the expected order i.e. all
577
573
  /// target wallets 20-byte public key hashes represented as numbers
578
- /// must form a strictly increasing sequence without duplicates.
579
- /// - Each target wallet must be in Live state
574
+ /// must form a strictly increasing sequence without duplicates,
575
+ /// - Each target wallet must be in Live state.
580
576
  function submitMovingFundsCommitment(
581
577
  bytes20 walletPubKeyHash,
582
578
  BitcoinTx.UTXO calldata walletMainUtxo,
@@ -596,12 +592,13 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
596
592
  /// @notice Resets the moving funds timeout for the given wallet if the
597
593
  /// target wallet commitment cannot be submitted due to a lack
598
594
  /// of live wallets in the system.
599
- /// @param walletPubKeyHash 20-byte public key hash of the moving funds wallet
595
+ /// @param walletPubKeyHash 20-byte public key hash of the moving funds wallet.
600
596
  /// @dev Requirements:
601
- /// - The wallet must be in the MovingFunds state
597
+ /// - The wallet must be in the MovingFunds state,
602
598
  /// - The target wallets commitment must not be already submitted for
603
- /// the given moving funds wallet
604
- /// - Live wallets count must be zero
599
+ /// the given moving funds wallet,
600
+ /// - Live wallets count must be zero,
601
+ /// - The moving funds timeout reset delay must be elapsed.
605
602
  function resetMovingFundsTimeout(bytes20 walletPubKeyHash) external {
606
603
  self.resetMovingFundsTimeout(walletPubKeyHash);
607
604
  }
@@ -618,37 +615,37 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
618
615
  ///
619
616
  /// It is possible to prove the given moving funds transaction only
620
617
  /// one time.
621
- /// @param movingFundsTx Bitcoin moving funds transaction data
622
- /// @param movingFundsProof Bitcoin moving funds proof data
618
+ /// @param movingFundsTx Bitcoin moving funds transaction data.
619
+ /// @param movingFundsProof Bitcoin moving funds proof data.
623
620
  /// @param mainUtxo Data of the wallet's main UTXO, as currently known on
624
- /// the Ethereum chain
621
+ /// the Ethereum chain.
625
622
  /// @param walletPubKeyHash 20-byte public key hash (computed using Bitcoin
626
623
  /// HASH160 over the compressed ECDSA public key) of the wallet
627
- /// which performed the moving funds transaction
624
+ /// which performed the moving funds transaction.
628
625
  /// @dev Requirements:
629
626
  /// - `movingFundsTx` components must match the expected structure. See
630
627
  /// `BitcoinTx.Info` docs for reference. Their values must exactly
631
628
  /// correspond to appropriate Bitcoin transaction fields to produce
632
- /// a provable transaction hash.
629
+ /// a provable transaction hash,
633
630
  /// - The `movingFundsTx` should represent a Bitcoin transaction with
634
631
  /// exactly 1 input that refers to the wallet's main UTXO. That
635
632
  /// transaction should have 1..n outputs corresponding to the
636
633
  /// pre-committed target wallets. Outputs must be ordered in the
637
634
  /// same way as their corresponding target wallets are ordered
638
- /// within the target wallets commitment.
635
+ /// within the target wallets commitment,
639
636
  /// - `movingFundsProof` components must match the expected structure.
640
637
  /// See `BitcoinTx.Proof` docs for reference. The `bitcoinHeaders`
641
638
  /// field must contain a valid number of block headers, not less
642
- /// than the `txProofDifficultyFactor` contract constant.
639
+ /// than the `txProofDifficultyFactor` contract constant,
643
640
  /// - `mainUtxo` components must point to the recent main UTXO
644
641
  /// of the given wallet, as currently known on the Ethereum chain.
645
- /// Additionally, the recent main UTXO on Ethereum must be set.
642
+ /// Additionally, the recent main UTXO on Ethereum must be set,
646
643
  /// - `walletPubKeyHash` must be connected with the main UTXO used
647
- /// as transaction single input.
644
+ /// as transaction single input,
648
645
  /// - The wallet that `walletPubKeyHash` points to must be in the
649
- /// MovingFunds state.
646
+ /// MovingFunds state,
650
647
  /// - The target wallets commitment must be submitted by the wallet
651
- /// that `walletPubKeyHash` points to.
648
+ /// that `walletPubKeyHash` points to,
652
649
  /// - The total Bitcoin transaction fee must be lesser or equal
653
650
  /// to `movingFundsTxMaxTotalFee` governable parameter.
654
651
  function submitMovingFundsProof(
@@ -667,17 +664,17 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
667
664
 
668
665
  /// @notice Notifies about a timed out moving funds process. Terminates
669
666
  /// the wallet and slashes signing group members as a result.
670
- /// @param walletPubKeyHash 20-byte public key hash of the wallet
671
- /// @param walletMembersIDs Identifiers of the wallet signing group members
667
+ /// @param walletPubKeyHash 20-byte public key hash of the wallet.
668
+ /// @param walletMembersIDs Identifiers of the wallet signing group members.
672
669
  /// @dev Requirements:
673
- /// - The wallet must be in the MovingFunds state
674
- /// - The moving funds timeout must be actually exceeded
670
+ /// - The wallet must be in the MovingFunds state,
671
+ /// - The moving funds timeout must be actually exceeded,
675
672
  /// - The expression `keccak256(abi.encode(walletMembersIDs))` must
676
673
  /// be exactly the same as the hash stored under `membersIdsHash`
677
674
  /// for the given `walletID`. Those IDs are not directly stored
678
675
  /// in the contract for gas efficiency purposes but they can be
679
676
  /// read from appropriate `DkgResultSubmitted` and `DkgResultApproved`
680
- /// events of the `WalletRegistry` contract
677
+ /// events of the `WalletRegistry` contract.
681
678
  function notifyMovingFundsTimeout(
682
679
  bytes20 walletPubKeyHash,
683
680
  uint32[] calldata walletMembersIDs
@@ -692,12 +689,12 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
692
689
  /// @param mainUtxo Data of the wallet's main UTXO, as currently known
693
690
  /// on the Ethereum chain.
694
691
  /// @dev Requirements:
695
- /// - The wallet must be in the MovingFunds state
692
+ /// - The wallet must be in the MovingFunds state,
696
693
  /// - The `mainUtxo` components must point to the recent main UTXO
697
694
  /// of the given wallet, as currently known on the Ethereum chain.
698
695
  /// If the wallet has no main UTXO, this parameter can be empty as it
699
- /// is ignored.
700
- /// - The wallet BTC balance must be below the moving funds threshold
696
+ /// is ignored,
697
+ /// - The wallet BTC balance must be below the moving funds threshold.
701
698
  function notifyMovingFundsBelowDust(
702
699
  bytes20 walletPubKeyHash,
703
700
  BitcoinTx.UTXO calldata mainUtxo
@@ -719,29 +716,29 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
719
716
  ///
720
717
  /// It is possible to prove the given sweep transaction only
721
718
  /// one time.
722
- /// @param sweepTx Bitcoin sweep funds transaction data
723
- /// @param sweepProof Bitcoin sweep funds proof data
719
+ /// @param sweepTx Bitcoin sweep funds transaction data.
720
+ /// @param sweepProof Bitcoin sweep funds proof data.
724
721
  /// @param mainUtxo Data of the sweeping wallet's main UTXO, as currently
725
- /// known on the Ethereum chain
722
+ /// known on the Ethereum chain.
726
723
  /// @dev Requirements:
727
724
  /// - `sweepTx` components must match the expected structure. See
728
725
  /// `BitcoinTx.Info` docs for reference. Their values must exactly
729
726
  /// correspond to appropriate Bitcoin transaction fields to produce
730
- /// a provable transaction hash.
727
+ /// a provable transaction hash,
731
728
  /// - The `sweepTx` should represent a Bitcoin transaction with
732
729
  /// the first input pointing to a moved funds sweep request targeted
733
730
  /// to the wallet, and optionally, the second input pointing to the
734
731
  /// wallet's main UTXO, if the sweeping wallet has a main UTXO set.
735
732
  /// There should be only one output locking funds on the sweeping
736
- /// wallet 20-byte public key hash.
733
+ /// wallet 20-byte public key hash,
737
734
  /// - `sweepProof` components must match the expected structure.
738
735
  /// See `BitcoinTx.Proof` docs for reference. The `bitcoinHeaders`
739
736
  /// field must contain a valid number of block headers, not less
740
- /// than the `txProofDifficultyFactor` contract constant.
737
+ /// than the `txProofDifficultyFactor` contract constant,
741
738
  /// - `mainUtxo` components must point to the recent main UTXO
742
739
  /// of the sweeping wallet, as currently known on the Ethereum chain.
743
- /// If there is no main UTXO, this parameter is ignored.
744
- /// - The sweeping wallet must be in the Live or MovingFunds state.
740
+ /// If there is no main UTXO, this parameter is ignored,
741
+ /// - The sweeping wallet must be in the Live or MovingFunds state,
745
742
  /// - The total Bitcoin transaction fee must be lesser or equal
746
743
  /// to `movedFundsSweepTxMaxTotalFee` governable parameter.
747
744
  function submitMovedFundsSweepProof(
@@ -757,21 +754,21 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
757
754
  /// the wallet and slashes signing group members as a result.
758
755
  /// Marks the given sweep request as TimedOut.
759
756
  /// @param movingFundsTxHash 32-byte hash of the moving funds transaction
760
- /// that caused the sweep request to be created
757
+ /// that caused the sweep request to be created.
761
758
  /// @param movingFundsTxOutputIndex Index of the moving funds transaction
762
759
  /// output that is subject of the sweep request.
763
- /// @param walletMembersIDs Identifiers of the wallet signing group members
760
+ /// @param walletMembersIDs Identifiers of the wallet signing group members.
764
761
  /// @dev Requirements:
765
- /// - The moved funds sweep request must be in the Pending state
766
- /// - The moved funds sweep timeout must be actually exceeded
762
+ /// - The moved funds sweep request must be in the Pending state,
763
+ /// - The moved funds sweep timeout must be actually exceeded,
767
764
  /// - The wallet must be either in the Live or MovingFunds or
768
- /// Terminated state
765
+ /// Terminated state,
769
766
  /// - The expression `keccak256(abi.encode(walletMembersIDs))` must
770
767
  /// be exactly the same as the hash stored under `membersIdsHash`
771
768
  /// for the given `walletID`. Those IDs are not directly stored
772
769
  /// in the contract for gas efficiency purposes but they can be
773
770
  /// read from appropriate `DkgResultSubmitted` and `DkgResultApproved`
774
- /// events of the `WalletRegistry` contract
771
+ /// events of the `WalletRegistry` contract.
775
772
  function notifyMovedFundsSweepTimeout(
776
773
  bytes32 movingFundsTxHash,
777
774
  uint32 movingFundsTxOutputIndex,
@@ -796,14 +793,14 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
796
793
  /// UTXO of the given active wallet, as currently known on the
797
794
  /// Ethereum chain. If there is no active wallet at the moment, or
798
795
  /// the active wallet has no main UTXO, this parameter can be
799
- /// empty as it is ignored.
800
- /// - Wallet creation must not be in progress
796
+ /// empty as it is ignored,
797
+ /// - Wallet creation must not be in progress,
801
798
  /// - If the active wallet is set, one of the following
802
799
  /// conditions must be true:
803
800
  /// - The active wallet BTC balance is above the minimum threshold
804
801
  /// and the active wallet is old enough, i.e. the creation period
805
- /// was elapsed since its creation time
806
- /// - The active wallet BTC balance is above the maximum threshold
802
+ /// was elapsed since its creation time,
803
+ /// - The active wallet BTC balance is above the maximum threshold.
807
804
  function requestNewWallet(BitcoinTx.UTXO calldata activeWalletMainUtxo)
808
805
  external
809
806
  {
@@ -816,8 +813,8 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
816
813
  /// @param publicKeyX Wallet's public key's X coordinate.
817
814
  /// @param publicKeyY Wallet's public key's Y coordinate.
818
815
  /// @dev Requirements:
819
- /// - The only caller authorized to call this function is `registry`
820
- /// - Given wallet data must not belong to an already registered wallet
816
+ /// - The only caller authorized to call this function is `registry`,
817
+ /// - Given wallet data must not belong to an already registered wallet.
821
818
  function __ecdsaWalletCreatedCallback(
822
819
  bytes32 ecdsaWalletID,
823
820
  bytes32 publicKeyX,
@@ -828,11 +825,11 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
828
825
 
829
826
  /// @notice A callback function that is called by the ECDSA Wallet Registry
830
827
  /// once a wallet heartbeat failure is detected.
831
- /// @param publicKeyX Wallet's public key's X coordinate
832
- /// @param publicKeyY Wallet's public key's Y coordinate
828
+ /// @param publicKeyX Wallet's public key's X coordinate.
829
+ /// @param publicKeyY Wallet's public key's Y coordinate.
833
830
  /// @dev Requirements:
834
- /// - The only caller authorized to call this function is `registry`
835
- /// - Wallet must be in Live state
831
+ /// - The only caller authorized to call this function is `registry`,
832
+ /// - Wallet must be in Live state.
836
833
  function __ecdsaWalletHeartbeatFailedCallback(
837
834
  bytes32,
838
835
  bytes32 publicKeyX,
@@ -843,19 +840,19 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
843
840
 
844
841
  /// @notice Notifies that the wallet is either old enough or has too few
845
842
  /// satoshi left and qualifies to be closed.
846
- /// @param walletPubKeyHash 20-byte public key hash of the wallet
843
+ /// @param walletPubKeyHash 20-byte public key hash of the wallet.
847
844
  /// @param walletMainUtxo Data of the wallet's main UTXO, as currently
848
845
  /// known on the Ethereum chain.
849
846
  /// @dev Requirements:
850
- /// - Wallet must not be set as the current active wallet
847
+ /// - Wallet must not be set as the current active wallet,
851
848
  /// - Wallet must exceed the wallet maximum age OR the wallet BTC
852
849
  /// balance must be lesser than the minimum threshold. If the latter
853
850
  /// case is true, the `walletMainUtxo` components must point to the
854
851
  /// recent main UTXO of the given wallet, as currently known on the
855
852
  /// Ethereum chain. If the wallet has no main UTXO, this parameter
856
853
  /// can be empty as it is ignored since the wallet balance is
857
- /// assumed to be zero.
858
- /// - Wallet must be in Live state
854
+ /// assumed to be zero,
855
+ /// - Wallet must be in Live state.
859
856
  function notifyCloseableWallet(
860
857
  bytes20 walletPubKeyHash,
861
858
  BitcoinTx.UTXO calldata walletMainUtxo
@@ -866,10 +863,10 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
866
863
  /// @notice Notifies about the end of the closing period for the given wallet.
867
864
  /// Closes the wallet ultimately and notifies the ECDSA registry
868
865
  /// about this fact.
869
- /// @param walletPubKeyHash 20-byte public key hash of the wallet
866
+ /// @param walletPubKeyHash 20-byte public key hash of the wallet.
870
867
  /// @dev Requirements:
871
- /// - The wallet must be in the Closing state
872
- /// - The wallet closing period must have elapsed
868
+ /// - The wallet must be in the Closing state,
869
+ /// - The wallet closing period must have elapsed.
873
870
  function notifyWalletClosingPeriodElapsed(bytes20 walletPubKeyHash)
874
871
  external
875
872
  {
@@ -892,7 +889,7 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
892
889
  /// must deposit ETH that is returned back upon justified fraud
893
890
  /// challenge or confiscated otherwise.
894
891
  /// @param walletPublicKey The public key of the wallet in the uncompressed
895
- /// and unprefixed format (64 bytes)
892
+ /// and unprefixed format (64 bytes).
896
893
  /// @param preimageSha256 The hash that was generated by applying SHA-256
897
894
  /// one time over the preimage used during input signing. The preimage
898
895
  /// is a serialized subset of the transaction and its structure
@@ -900,17 +897,17 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
900
897
  /// Notice that applying SHA-256 over the `preimageSha256` results
901
898
  /// in `sighash`. The path from `preimage` to `sighash` looks like
902
899
  /// this:
903
- /// preimage -> (SHA-256) -> preimageSha256 -> (SHA-256) -> sighash
904
- /// @param signature Bitcoin signature in the R/S/V format
900
+ /// preimage -> (SHA-256) -> preimageSha256 -> (SHA-256) -> sighash.
901
+ /// @param signature Bitcoin signature in the R/S/V format.
905
902
  /// @dev Requirements:
906
903
  /// - Wallet behind `walletPublicKey` must be in Live or MovingFunds
907
- /// or Closing state
904
+ /// or Closing state,
908
905
  /// - The challenger must send appropriate amount of ETH used as
909
- /// fraud challenge deposit
906
+ /// fraud challenge deposit,
910
907
  /// - The signature (represented by r, s and v) must be generated by
911
908
  /// the wallet behind `walletPubKey` during signing of `sighash`
912
- /// which was calculated from `preimageSha256`
913
- /// - Wallet can be challenged for the given signature only once
909
+ /// which was calculated from `preimageSha256`,
910
+ /// - Wallet can be challenged for the given signature only once.
914
911
  function submitFraudChallenge(
915
912
  bytes calldata walletPublicKey,
916
913
  bytes memory preimageSha256,
@@ -932,21 +929,21 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
932
929
  /// resolved and the amount of ether deposited by the challenger is
933
930
  /// sent to the treasury.
934
931
  /// @param walletPublicKey The public key of the wallet in the uncompressed
935
- /// and unprefixed format (64 bytes)
932
+ /// and unprefixed format (64 bytes).
936
933
  /// @param preimage The preimage which produces sighash used to generate the
937
934
  /// ECDSA signature that is the subject of the fraud claim. It is a
938
935
  /// serialized subset of the transaction. The exact subset used as
939
936
  /// the preimage depends on the transaction input the signature is
940
- /// produced for. See BIP-143 for reference
937
+ /// produced for. See BIP-143 for reference.
941
938
  /// @param witness Flag indicating whether the preimage was produced for a
942
- /// witness input. True for witness, false for non-witness input
939
+ /// witness input. True for witness, false for non-witness input.
943
940
  /// @dev Requirements:
944
941
  /// - `walletPublicKey` and `sighash` calculated as `hash256(preimage)`
945
- /// must identify an open fraud challenge
942
+ /// must identify an open fraud challenge,
946
943
  /// - the preimage must be a valid preimage of a transaction generated
947
- /// according to the protocol rules and already proved in the Bridge
944
+ /// according to the protocol rules and already proved in the Bridge,
948
945
  /// - before a defeat attempt is made the transaction that spends the
949
- /// given UTXO must be proven in the Bridge
946
+ /// given UTXO must be proven in the Bridge.
950
947
  function defeatFraudChallenge(
951
948
  bytes calldata walletPublicKey,
952
949
  bytes calldata preimage,
@@ -967,16 +964,16 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
967
964
  /// challenge is marked as resolved and the amount of ether
968
965
  /// deposited by the challenger is sent to the treasury.
969
966
  /// @param walletPublicKey The public key of the wallet in the uncompressed
970
- /// and unprefixed format (64 bytes)
967
+ /// and unprefixed format (64 bytes).
971
968
  /// @param heartbeatMessage Off-chain heartbeat message meeting the heartbeat
972
969
  /// message format requirements which produces sighash used to
973
970
  /// generate the ECDSA signature that is the subject of the fraud
974
- /// claim
971
+ /// claim.
975
972
  /// @dev Requirements:
976
973
  /// - `walletPublicKey` and `sighash` calculated as
977
- /// `hash256(heartbeatMessage)` must identify an open fraud challenge
974
+ /// `hash256(heartbeatMessage)` must identify an open fraud challenge,
978
975
  /// - `heartbeatMessage` must follow a strict format of heartbeat
979
- /// messages
976
+ /// messages.
980
977
  function defeatFraudChallengeWithHeartbeat(
981
978
  bytes calldata walletPublicKey,
982
979
  bytes calldata heartbeatMessage
@@ -998,8 +995,8 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
998
995
  /// deposited is returned to the challenger and the challenger is
999
996
  /// rewarded.
1000
997
  /// @param walletPublicKey The public key of the wallet in the uncompressed
1001
- /// and unprefixed format (64 bytes)
1002
- /// @param walletMembersIDs Identifiers of the wallet signing group members
998
+ /// and unprefixed format (64 bytes).
999
+ /// @param walletMembersIDs Identifiers of the wallet signing group members.
1003
1000
  /// @param preimageSha256 The hash that was generated by applying SHA-256
1004
1001
  /// one time over the preimage used during input signing. The preimage
1005
1002
  /// is a serialized subset of the transaction and its structure
@@ -1007,20 +1004,20 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
1007
1004
  /// Notice that applying SHA-256 over the `preimageSha256` results
1008
1005
  /// in `sighash`. The path from `preimage` to `sighash` looks like
1009
1006
  /// this:
1010
- /// preimage -> (SHA-256) -> preimageSha256 -> (SHA-256) -> sighash
1007
+ /// preimage -> (SHA-256) -> preimageSha256 -> (SHA-256) -> sighash.
1011
1008
  /// @dev Requirements:
1012
1009
  /// - The wallet must be in the Live or MovingFunds or Closing or
1013
- /// Terminated state
1010
+ /// Terminated state,
1014
1011
  /// - The `walletPublicKey` and `sighash` calculated from
1015
- /// `preimageSha256` must identify an open fraud challenge
1012
+ /// `preimageSha256` must identify an open fraud challenge,
1016
1013
  /// - The expression `keccak256(abi.encode(walletMembersIDs))` must
1017
1014
  /// be exactly the same as the hash stored under `membersIdsHash`
1018
1015
  /// for the given `walletID`. Those IDs are not directly stored
1019
1016
  /// in the contract for gas efficiency purposes but they can be
1020
1017
  /// read from appropriate `DkgResultSubmitted` and `DkgResultApproved`
1021
- /// events of the `WalletRegistry` contract
1018
+ /// events of the `WalletRegistry` contract,
1022
1019
  /// - The amount of time indicated by `challengeDefeatTimeout` must pass
1023
- /// after the challenge was reported
1020
+ /// after the challenge was reported.
1024
1021
  function notifyFraudChallengeDefeatTimeout(
1025
1022
  bytes calldata walletPublicKey,
1026
1023
  uint32[] calldata walletMembersIDs,
@@ -1037,14 +1034,14 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
1037
1034
  /// or no longer trusted. Vaults are not trusted by default.
1038
1035
  /// Trusted vault must meet the following criteria:
1039
1036
  /// - `IVault.receiveBalanceIncrease` must have a known, low gas
1040
- /// cost.
1037
+ /// cost,
1041
1038
  /// - `IVault.receiveBalanceIncrease` must never revert.
1042
1039
  /// @dev Without restricting reveal only to trusted vaults, malicious
1043
1040
  /// vaults not meeting the criteria would be able to nuke sweep proof
1044
1041
  /// transactions executed by ECDSA wallet with deposits routed to
1045
1042
  /// them.
1046
- /// @param vault The address of the vault
1047
- /// @param isTrusted flag indicating whether the vault is trusted or not
1043
+ /// @param vault The address of the vault.
1044
+ /// @param isTrusted flag indicating whether the vault is trusted or not.
1048
1045
  /// @dev Can only be called by the Governance.
1049
1046
  function setVaultStatus(address vault, bool isTrusted)
1050
1047
  external
@@ -1060,7 +1057,7 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
1060
1057
  //// deposit. Value of this parameter must take into account the value
1061
1058
  /// of `depositTreasuryFeeDivisor` and `depositTxMaxFee` parameters
1062
1059
  /// in order to make requests that can incur the treasury and
1063
- /// transaction fee and still satisfy the depositor
1060
+ /// transaction fee and still satisfy the depositor.
1064
1061
  /// @param depositTreasuryFeeDivisor New value of the treasury fee divisor.
1065
1062
  /// It is the divisor used to compute the treasury fee taken from
1066
1063
  /// each deposit and transferred to the treasury upon sweep proof
@@ -1068,16 +1065,16 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
1068
1065
  /// `treasuryFee = depositedAmount / depositTreasuryFeeDivisor`
1069
1066
  /// For example, if the treasury fee needs to be 2% of each deposit,
1070
1067
  /// the `depositTreasuryFeeDivisor` should be set to `50`
1071
- /// because `1/50 = 0.02 = 2%`
1068
+ /// because `1/50 = 0.02 = 2%`.
1072
1069
  /// @param depositTxMaxFee New value of the deposit tx max fee in satoshis.
1073
1070
  /// It is the maximum amount of BTC transaction fee that can
1074
1071
  /// be incurred by each swept deposit being part of the given sweep
1075
1072
  /// transaction. If the maximum BTC transaction fee is exceeded,
1076
- /// such transaction is considered a fraud
1073
+ /// such transaction is considered a fraud.
1077
1074
  /// @dev Requirements:
1078
- /// - Deposit dust threshold must be greater than zero
1079
- /// - Deposit treasury fee divisor must be greater than zero
1080
- /// - Deposit transaction max fee must be greater than zero
1075
+ /// - Deposit dust threshold must be greater than zero,
1076
+ /// - Deposit treasury fee divisor must be greater than zero,
1077
+ /// - Deposit transaction max fee must be greater than zero.
1081
1078
  function updateDepositParameters(
1082
1079
  uint64 depositDustThreshold,
1083
1080
  uint64 depositTreasuryFeeDivisor,
@@ -1122,20 +1119,20 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
1122
1119
  /// redeemer in full amount.
1123
1120
  /// @param redemptionTimeoutSlashingAmount New value of the redemption
1124
1121
  /// timeout slashing amount in T, it is the amount slashed from each
1125
- /// wallet member for redemption timeout
1122
+ /// wallet member for redemption timeout.
1126
1123
  /// @param redemptionTimeoutNotifierRewardMultiplier New value of the
1127
1124
  /// redemption timeout notifier reward multiplier as percentage,
1128
1125
  /// it determines the percentage of the notifier reward from the
1129
1126
  /// staking contact the notifier of a redemption timeout receives.
1130
- /// The value must be in the range [0, 100]
1127
+ /// The value must be in the range [0, 100].
1131
1128
  /// @dev Requirements:
1132
1129
  /// - Redemption dust threshold must be greater than moving funds dust
1133
- /// threshold
1134
- /// - Redemption treasury fee divisor must be greater than zero
1135
- /// - Redemption transaction max fee must be greater than zero
1136
- /// - Redemption timeout must be greater than zero
1130
+ /// threshold,
1131
+ /// - Redemption treasury fee divisor must be greater than zero,
1132
+ /// - Redemption transaction max fee must be greater than zero,
1133
+ /// - Redemption timeout must be greater than zero,
1137
1134
  /// - Redemption timeout notifier reward multiplier must be in the
1138
- /// range [0, 100]
1135
+ /// range [0, 100].
1139
1136
  function updateRedemptionParameters(
1140
1137
  uint64 redemptionDustThreshold,
1141
1138
  uint64 redemptionTreasuryFeeDivisor,
@@ -1162,10 +1159,17 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
1162
1159
  /// funds transaction.
1163
1160
  /// @param movingFundsDustThreshold New value of the moving funds dust
1164
1161
  /// threshold. It is the minimal satoshi amount that makes sense to
1165
- // be transferred during the moving funds process. Moving funds
1166
- // wallets having their BTC balance below that value can begin
1167
- // closing immediately as transferring such a low value may not be
1168
- // possible due to BTC network fees.
1162
+ /// be transferred during the moving funds process. Moving funds
1163
+ /// wallets having their BTC balance below that value can begin
1164
+ /// closing immediately as transferring such a low value may not be
1165
+ /// possible due to BTC network fees.
1166
+ /// @param movingFundsTimeoutResetDelay New value of the moving funds
1167
+ /// timeout reset delay in seconds. It is the time after which the
1168
+ /// moving funds timeout can be reset in case the target wallet
1169
+ /// commitment cannot be submitted due to a lack of live wallets
1170
+ /// in the system. It is counted from the moment when the wallet
1171
+ /// was requested to move their funds and switched to the MovingFunds
1172
+ /// state or from the moment the timeout was reset the last time.
1169
1173
  /// @param movingFundsTimeout New value of the moving funds timeout in
1170
1174
  /// seconds. It is the time after which the moving funds process can
1171
1175
  /// be reported as timed out. It is counted from the moment when the
@@ -1173,12 +1177,12 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
1173
1177
  /// MovingFunds state.
1174
1178
  /// @param movingFundsTimeoutSlashingAmount New value of the moving funds
1175
1179
  /// timeout slashing amount in T, it is the amount slashed from each
1176
- /// wallet member for moving funds timeout
1180
+ /// wallet member for moving funds timeout.
1177
1181
  /// @param movingFundsTimeoutNotifierRewardMultiplier New value of the
1178
1182
  /// moving funds timeout notifier reward multiplier as percentage,
1179
1183
  /// it determines the percentage of the notifier reward from the
1180
1184
  /// staking contact the notifier of a moving funds timeout receives.
1181
- /// The value must be in the range [0, 100]
1185
+ /// The value must be in the range [0, 100].
1182
1186
  /// @param movedFundsSweepTxMaxTotalFee New value of the moved funds sweep
1183
1187
  /// transaction max total fee in satoshis. It is the maximum amount
1184
1188
  /// of the total BTC transaction fee that is acceptable in a single
@@ -1191,26 +1195,29 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
1191
1195
  /// funds.
1192
1196
  /// @param movedFundsSweepTimeoutSlashingAmount New value of the moved
1193
1197
  /// funds sweep timeout slashing amount in T, it is the amount
1194
- /// slashed from each wallet member for moved funds sweep timeout
1198
+ /// slashed from each wallet member for moved funds sweep timeout.
1195
1199
  /// @param movedFundsSweepTimeoutNotifierRewardMultiplier New value of
1196
1200
  /// the moved funds sweep timeout notifier reward multiplier as
1197
1201
  /// percentage, it determines the percentage of the notifier reward
1198
1202
  /// from the staking contact the notifier of a moved funds sweep
1199
- /// timeout receives. The value must be in the range [0, 100]
1203
+ /// timeout receives. The value must be in the range [0, 100].
1200
1204
  /// @dev Requirements:
1201
- /// - Moving funds transaction max total fee must be greater than zero
1205
+ /// - Moving funds transaction max total fee must be greater than zero,
1202
1206
  /// - Moving funds dust threshold must be greater than zero and lower
1203
- /// than the redemption dust threshold
1204
- /// - Moving funds timeout must be greater than zero
1207
+ /// than the redemption dust threshold,
1208
+ /// - Moving funds timeout reset delay must be greater than zero,
1209
+ /// - Moving funds timeout must be greater than the moving funds
1210
+ /// timeout reset delay,
1205
1211
  /// - Moving funds timeout notifier reward multiplier must be in the
1206
- /// range [0, 100]
1207
- /// - Moved funds sweep transaction max total fee must be greater than zero
1208
- /// - Moved funds sweep timeout must be greater than zero
1212
+ /// range [0, 100],
1213
+ /// - Moved funds sweep transaction max total fee must be greater than zero,
1214
+ /// - Moved funds sweep timeout must be greater than zero,
1209
1215
  /// - Moved funds sweep timeout notifier reward multiplier must be in the
1210
- /// range [0, 100]
1216
+ /// range [0, 100].
1211
1217
  function updateMovingFundsParameters(
1212
1218
  uint64 movingFundsTxMaxTotalFee,
1213
1219
  uint64 movingFundsDustThreshold,
1220
+ uint32 movingFundsTimeoutResetDelay,
1214
1221
  uint32 movingFundsTimeout,
1215
1222
  uint96 movingFundsTimeoutSlashingAmount,
1216
1223
  uint256 movingFundsTimeoutNotifierRewardMultiplier,
@@ -1222,6 +1229,7 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
1222
1229
  self.updateMovingFundsParameters(
1223
1230
  movingFundsTxMaxTotalFee,
1224
1231
  movingFundsDustThreshold,
1232
+ movingFundsTimeoutResetDelay,
1225
1233
  movingFundsTimeout,
1226
1234
  movingFundsTimeoutSlashingAmount,
1227
1235
  movingFundsTimeoutNotifierRewardMultiplier,
@@ -1235,29 +1243,29 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
1235
1243
  /// @notice Updates parameters of wallets.
1236
1244
  /// @param walletCreationPeriod New value of the wallet creation period in
1237
1245
  /// seconds, determines how frequently a new wallet creation can be
1238
- /// requested
1246
+ /// requested.
1239
1247
  /// @param walletCreationMinBtcBalance New value of the wallet minimum BTC
1240
- /// balance in satoshi, used to decide about wallet creation
1248
+ /// balance in satoshi, used to decide about wallet creation.
1241
1249
  /// @param walletCreationMaxBtcBalance New value of the wallet maximum BTC
1242
- /// balance in satoshi, used to decide about wallet creation
1250
+ /// balance in satoshi, used to decide about wallet creation.
1243
1251
  /// @param walletClosureMinBtcBalance New value of the wallet minimum BTC
1244
- /// balance in satoshi, used to decide about wallet closure
1252
+ /// balance in satoshi, used to decide about wallet closure.
1245
1253
  /// @param walletMaxAge New value of the wallet maximum age in seconds,
1246
1254
  /// indicates the maximum age of a wallet in seconds, after which
1247
- /// the wallet moving funds process can be requested
1255
+ /// the wallet moving funds process can be requested.
1248
1256
  /// @param walletMaxBtcTransfer New value of the wallet maximum BTC transfer
1249
1257
  /// in satoshi, determines the maximum amount that can be transferred
1250
- // to a single target wallet during the moving funds process
1258
+ // to a single target wallet during the moving funds process.
1251
1259
  /// @param walletClosingPeriod New value of the wallet closing period in
1252
1260
  /// seconds, determines the length of the wallet closing period,
1253
1261
  // i.e. the period when the wallet remains in the Closing state
1254
- // and can be subject of deposit fraud challenges
1262
+ // and can be subject of deposit fraud challenges.
1255
1263
  /// @dev Requirements:
1256
- /// - Wallet minimum BTC balance must be greater than zero
1264
+ /// - Wallet minimum BTC balance must be greater than zero,
1257
1265
  /// - Wallet maximum BTC balance must be greater than the wallet
1258
- /// minimum BTC balance
1259
- /// - Wallet maximum BTC transfer must be greater than zero
1260
- /// - Wallet closing period must be greater than zero
1266
+ /// minimum BTC balance,
1267
+ /// - Wallet maximum BTC transfer must be greater than zero,
1268
+ /// - Wallet closing period must be greater than zero.
1261
1269
  function updateWalletParameters(
1262
1270
  uint32 walletCreationPeriod,
1263
1271
  uint64 walletCreationMinBtcBalance,
@@ -1281,20 +1289,20 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
1281
1289
  /// @notice Updates parameters related to frauds.
1282
1290
  /// @param fraudChallengeDepositAmount New value of the fraud challenge
1283
1291
  /// deposit amount in wei, it is the amount of ETH the party
1284
- /// challenging the wallet for fraud needs to deposit
1292
+ /// challenging the wallet for fraud needs to deposit.
1285
1293
  /// @param fraudChallengeDefeatTimeout New value of the challenge defeat
1286
1294
  /// timeout in seconds, it is the amount of time the wallet has to
1287
- /// defeat a fraud challenge. The value must be greater than zero
1295
+ /// defeat a fraud challenge. The value must be greater than zero.
1288
1296
  /// @param fraudSlashingAmount New value of the fraud slashing amount in T,
1289
1297
  /// it is the amount slashed from each wallet member for committing
1290
- /// a fraud
1298
+ /// a fraud.
1291
1299
  /// @param fraudNotifierRewardMultiplier New value of the fraud notifier
1292
1300
  /// reward multiplier as percentage, it determines the percentage of
1293
1301
  /// the notifier reward from the staking contact the notifier of
1294
- /// a fraud receives. The value must be in the range [0, 100]
1302
+ /// a fraud receives. The value must be in the range [0, 100].
1295
1303
  /// @dev Requirements:
1296
- /// - Fraud challenge defeat timeout must be greater than 0
1297
- /// - Fraud notifier reward multiplier must be in the range [0, 100]
1304
+ /// - Fraud challenge defeat timeout must be greater than 0,
1305
+ /// - Fraud notifier reward multiplier must be in the range [0, 100].
1298
1306
  function updateFraudParameters(
1299
1307
  uint256 fraudChallengeDepositAmount,
1300
1308
  uint256 fraudChallengeDefeatTimeout,
@@ -1334,9 +1342,9 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
1334
1342
  /// to this mapping by the `requestRedemption` method (duplicates
1335
1343
  /// not allowed) and are removed by one of the following methods:
1336
1344
  /// - `submitRedemptionProof` in case the request was handled
1337
- /// successfully
1345
+ /// successfully,
1338
1346
  /// - `notifyRedemptionTimeout` in case the request was reported
1339
- /// to be timed out
1347
+ /// to be timed out.
1340
1348
  function pendingRedemptions(uint256 redemptionKey)
1341
1349
  external
1342
1350
  view
@@ -1378,7 +1386,7 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
1378
1386
 
1379
1387
  /// @notice Gets details about a registered wallet.
1380
1388
  /// @param walletPubKeyHash The 20-byte wallet public key hash (computed
1381
- /// using Bitcoin HASH160 over the compressed ECDSA public key)
1389
+ /// using Bitcoin HASH160 over the compressed ECDSA public key).
1382
1390
  /// @return Wallet details.
1383
1391
  function wallets(bytes20 walletPubKeyHash)
1384
1392
  external
@@ -1419,7 +1427,7 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
1419
1427
  /// is actually an UTXO representing the moved funds and is supposed
1420
1428
  /// to be swept with the current main UTXO of the recipient wallet.
1421
1429
  /// @param requestKey Request key built as
1422
- /// `keccak256(movingFundsTxHash | movingFundsOutputIndex)`
1430
+ /// `keccak256(movingFundsTxHash | movingFundsOutputIndex)`.
1423
1431
  /// @return Details of the moved funds sweep request.
1424
1432
  function movedFundsSweepRequests(uint256 requestKey)
1425
1433
  external
@@ -1533,6 +1541,14 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
1533
1541
  /// funds wallets having their BTC balance below that value can
1534
1542
  /// begin closing immediately as transferring such a low value may
1535
1543
  /// not be possible due to BTC network fees.
1544
+ /// @return movingFundsTimeoutResetDelay Time after which the moving funds
1545
+ /// timeout can be reset in case the target wallet commitment
1546
+ /// cannot be submitted due to a lack of live wallets in the system.
1547
+ /// It is counted from the moment when the wallet was requested to
1548
+ /// move their funds and switched to the MovingFunds state or from
1549
+ /// the moment the timeout was reset the last time. Value in seconds
1550
+ /// This value should be lower than the value of the
1551
+ /// `movingFundsTimeout`.
1536
1552
  /// @return movingFundsTimeout Time after which the moving funds process
1537
1553
  /// can be reported as timed out. It is counted from the moment
1538
1554
  /// when the wallet was requested to move their funds and switched
@@ -1562,6 +1578,7 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
1562
1578
  returns (
1563
1579
  uint64 movingFundsTxMaxTotalFee,
1564
1580
  uint64 movingFundsDustThreshold,
1581
+ uint32 movingFundsTimeoutResetDelay,
1565
1582
  uint32 movingFundsTimeout,
1566
1583
  uint96 movingFundsTimeoutSlashingAmount,
1567
1584
  uint256 movingFundsTimeoutNotifierRewardMultiplier,
@@ -1573,6 +1590,7 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
1573
1590
  {
1574
1591
  movingFundsTxMaxTotalFee = self.movingFundsTxMaxTotalFee;
1575
1592
  movingFundsDustThreshold = self.movingFundsDustThreshold;
1593
+ movingFundsTimeoutResetDelay = self.movingFundsTimeoutResetDelay;
1576
1594
  movingFundsTimeout = self.movingFundsTimeout;
1577
1595
  movingFundsTimeoutSlashingAmount = self
1578
1596
  .movingFundsTimeoutSlashingAmount;