@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
@@ -124,42 +124,42 @@ library MovingFunds {
124
124
  /// Once all requirements are met, that function registers the
125
125
  /// target wallets commitment and opens the way for moving funds
126
126
  /// proof submission.
127
- /// @param walletPubKeyHash 20-byte public key hash of the source wallet
127
+ /// @param walletPubKeyHash 20-byte public key hash of the source wallet.
128
128
  /// @param walletMainUtxo Data of the source wallet's main UTXO, as
129
- /// currently known on the Ethereum chain
129
+ /// currently known on the Ethereum chain.
130
130
  /// @param walletMembersIDs Identifiers of the source wallet signing group
131
- /// members
131
+ /// members.
132
132
  /// @param walletMemberIndex Position of the caller in the source wallet
133
- /// signing group members list
133
+ /// signing group members list.
134
134
  /// @param targetWallets List of 20-byte public key hashes of the target
135
- /// wallets that the source wallet commits to move the funds to
135
+ /// wallets that the source wallet commits to move the funds to.
136
136
  /// @dev Requirements:
137
- /// - The source wallet must be in the MovingFunds state
138
- /// - The source wallet must not have pending redemption requests
139
- /// - The source wallet must not have pending moved funds sweep requests
140
- /// - The source wallet must not have submitted its commitment already
137
+ /// - The source wallet must be in the MovingFunds state,
138
+ /// - The source wallet must not have pending redemption requests,
139
+ /// - The source wallet must not have pending moved funds sweep requests,
140
+ /// - The source wallet must not have submitted its commitment already,
141
141
  /// - The expression `keccak256(abi.encode(walletMembersIDs))` must
142
142
  /// be exactly the same as the hash stored under `membersIdsHash`
143
143
  /// for the given source wallet in the ECDSA registry. Those IDs are
144
144
  /// not directly stored in the contract for gas efficiency purposes
145
145
  /// but they can be read from appropriate `DkgResultSubmitted`
146
- /// and `DkgResultApproved` events.
147
- /// - The `walletMemberIndex` must be in range [1, walletMembersIDs.length]
146
+ /// and `DkgResultApproved` events,
147
+ /// - The `walletMemberIndex` must be in range [1, walletMembersIDs.length],
148
148
  /// - The caller must be the member of the source wallet signing group
149
- /// at the position indicated by `walletMemberIndex` parameter
149
+ /// at the position indicated by `walletMemberIndex` parameter,
150
150
  /// - The `walletMainUtxo` components must point to the recent main
151
151
  /// UTXO of the source wallet, as currently known on the Ethereum
152
- /// chain.
153
- /// - Source wallet BTC balance must be greater than zero
154
- /// - At least one Live wallet must exist in the system
152
+ /// chain,
153
+ /// - Source wallet BTC balance must be greater than zero,
154
+ /// - At least one Live wallet must exist in the system,
155
155
  /// - Submitted target wallets count must match the expected count
156
156
  /// `N = min(liveWalletsCount, ceil(walletBtcBalance / walletMaxBtcTransfer))`
157
- /// where `N > 0`
158
- /// - Each target wallet must be not equal to the source wallet
157
+ /// where `N > 0`,
158
+ /// - Each target wallet must be not equal to the source wallet,
159
159
  /// - Each target wallet must follow the expected order i.e. all
160
160
  /// target wallets 20-byte public key hashes represented as numbers
161
- /// must form a strictly increasing sequence without duplicates.
162
- /// - Each target wallet must be in Live state
161
+ /// must form a strictly increasing sequence without duplicates,
162
+ /// - Each target wallet must be in Live state.
163
163
  function submitMovingFundsCommitment(
164
164
  BridgeState.Storage storage self,
165
165
  bytes20 walletPubKeyHash,
@@ -265,10 +265,11 @@ library MovingFunds {
265
265
  /// of live wallets in the system.
266
266
  /// @param walletPubKeyHash 20-byte public key hash of the moving funds wallet
267
267
  /// @dev Requirements:
268
- /// - The wallet must be in the MovingFunds state
268
+ /// - The wallet must be in the MovingFunds state,
269
269
  /// - The target wallets commitment must not be already submitted for
270
- /// the given moving funds wallet
271
- /// - Live wallets count must be zero
270
+ /// the given moving funds wallet,
271
+ /// - Live wallets count must be zero,
272
+ /// - The moving funds timeout reset delay must be elapsed.
272
273
  function resetMovingFundsTimeout(
273
274
  BridgeState.Storage storage self,
274
275
  bytes20 walletPubKeyHash
@@ -292,6 +293,14 @@ library MovingFunds {
292
293
 
293
294
  require(self.liveWalletsCount == 0, "Live wallets count must be zero");
294
295
 
296
+ require(
297
+ /* solhint-disable-next-line not-rely-on-time */
298
+ block.timestamp >
299
+ wallet.movingFundsRequestedAt +
300
+ self.movingFundsTimeoutResetDelay,
301
+ "Moving funds timeout cannot be reset yet"
302
+ );
303
+
295
304
  /* solhint-disable-next-line not-rely-on-time */
296
305
  wallet.movingFundsRequestedAt = uint32(block.timestamp);
297
306
 
@@ -310,37 +319,37 @@ library MovingFunds {
310
319
  ///
311
320
  /// It is possible to prove the given moving funds transaction only
312
321
  /// one time.
313
- /// @param movingFundsTx Bitcoin moving funds transaction data
314
- /// @param movingFundsProof Bitcoin moving funds proof data
322
+ /// @param movingFundsTx Bitcoin moving funds transaction data.
323
+ /// @param movingFundsProof Bitcoin moving funds proof data.
315
324
  /// @param mainUtxo Data of the wallet's main UTXO, as currently known on
316
- /// the Ethereum chain
325
+ /// the Ethereum chain.
317
326
  /// @param walletPubKeyHash 20-byte public key hash (computed using Bitcoin
318
327
  /// HASH160 over the compressed ECDSA public key) of the wallet
319
- /// which performed the moving funds transaction
328
+ /// which performed the moving funds transaction.
320
329
  /// @dev Requirements:
321
330
  /// - `movingFundsTx` components must match the expected structure. See
322
331
  /// `BitcoinTx.Info` docs for reference. Their values must exactly
323
332
  /// correspond to appropriate Bitcoin transaction fields to produce
324
- /// a provable transaction hash.
333
+ /// a provable transaction hash,
325
334
  /// - The `movingFundsTx` should represent a Bitcoin transaction with
326
335
  /// exactly 1 input that refers to the wallet's main UTXO. That
327
336
  /// transaction should have 1..n outputs corresponding to the
328
337
  /// pre-committed target wallets. Outputs must be ordered in the
329
338
  /// same way as their corresponding target wallets are ordered
330
- /// within the target wallets commitment.
339
+ /// within the target wallets commitment,
331
340
  /// - `movingFundsProof` components must match the expected structure.
332
341
  /// See `BitcoinTx.Proof` docs for reference. The `bitcoinHeaders`
333
342
  /// field must contain a valid number of block headers, not less
334
- /// than the `txProofDifficultyFactor` contract constant.
343
+ /// than the `txProofDifficultyFactor` contract constant,
335
344
  /// - `mainUtxo` components must point to the recent main UTXO
336
345
  /// of the given wallet, as currently known on the Ethereum chain.
337
- /// Additionally, the recent main UTXO on Ethereum must be set.
346
+ /// Additionally, the recent main UTXO on Ethereum must be set,
338
347
  /// - `walletPubKeyHash` must be connected with the main UTXO used
339
- /// as transaction single input.
348
+ /// as transaction single input,
340
349
  /// - The wallet that `walletPubKeyHash` points to must be in the
341
- /// MovingFunds state.
350
+ /// MovingFunds state,
342
351
  /// - The target wallets commitment must be submitted by the wallet
343
- /// that `walletPubKeyHash` points to.
352
+ /// that `walletPubKeyHash` points to,
344
353
  /// - The total Bitcoin transaction fee must be lesser or equal
345
354
  /// to `movingFundsTxMaxTotalFee` governable parameter.
346
355
  function submitMovingFundsProof(
@@ -399,8 +408,8 @@ library MovingFunds {
399
408
  /// @return outputsTotalValue Sum of all outputs values.
400
409
  /// @dev Requirements:
401
410
  /// - The `movingFundsTxOutputVector` must be parseable, i.e. must
402
- /// be validated by the caller as stated in their parameter doc.
403
- /// - Each output must refer to a 20-byte public key hash.
411
+ /// be validated by the caller as stated in their parameter doc,
412
+ /// - Each output must refer to a 20-byte public key hash,
404
413
  /// - The total outputs value must be evenly divided over all outputs.
405
414
  function processMovingFundsTxOutputs(
406
415
  BridgeState.Storage storage self,
@@ -523,17 +532,17 @@ library MovingFunds {
523
532
 
524
533
  /// @notice Notifies about a timed out moving funds process. Terminates
525
534
  /// the wallet and slashes signing group members as a result.
526
- /// @param walletPubKeyHash 20-byte public key hash of the wallet
527
- /// @param walletMembersIDs Identifiers of the wallet signing group members
535
+ /// @param walletPubKeyHash 20-byte public key hash of the wallet.
536
+ /// @param walletMembersIDs Identifiers of the wallet signing group members.
528
537
  /// @dev Requirements:
529
- /// - The wallet must be in the MovingFunds state
530
- /// - The moving funds timeout must be actually exceeded
538
+ /// - The wallet must be in the MovingFunds state,
539
+ /// - The moving funds timeout must be actually exceeded,
531
540
  /// - The expression `keccak256(abi.encode(walletMembersIDs))` must
532
541
  /// be exactly the same as the hash stored under `membersIdsHash`
533
542
  /// for the given `walletID`. Those IDs are not directly stored
534
543
  /// in the contract for gas efficiency purposes but they can be
535
544
  /// read from appropriate `DkgResultSubmitted` and `DkgResultApproved`
536
- /// events of the `WalletRegistry` contract
545
+ /// events of the `WalletRegistry` contract.
537
546
  function notifyMovingFundsTimeout(
538
547
  BridgeState.Storage storage self,
539
548
  bytes20 walletPubKeyHash,
@@ -572,16 +581,16 @@ library MovingFunds {
572
581
  /// @notice Notifies about a moving funds wallet whose BTC balance is
573
582
  /// below the moving funds dust threshold. Ends the moving funds
574
583
  /// process and begins wallet closing immediately.
575
- /// @param walletPubKeyHash 20-byte public key hash of the wallet
584
+ /// @param walletPubKeyHash 20-byte public key hash of the wallet.
576
585
  /// @param mainUtxo Data of the wallet's main UTXO, as currently known
577
586
  /// on the Ethereum chain.
578
587
  /// @dev Requirements:
579
- /// - The wallet must be in the MovingFunds state
588
+ /// - The wallet must be in the MovingFunds state,
580
589
  /// - The `mainUtxo` components must point to the recent main UTXO
581
590
  /// of the given wallet, as currently known on the Ethereum chain.
582
591
  /// If the wallet has no main UTXO, this parameter can be empty as it
583
- /// is ignored.
584
- /// - The wallet BTC balance must be below the moving funds threshold
592
+ /// is ignored,
593
+ /// - The wallet BTC balance must be below the moving funds threshold.
585
594
  function notifyMovingFundsBelowDust(
586
595
  BridgeState.Storage storage self,
587
596
  bytes20 walletPubKeyHash,
@@ -626,29 +635,29 @@ library MovingFunds {
626
635
  ///
627
636
  /// It is possible to prove the given sweep transaction only
628
637
  /// one time.
629
- /// @param sweepTx Bitcoin sweep funds transaction data
630
- /// @param sweepProof Bitcoin sweep funds proof data
638
+ /// @param sweepTx Bitcoin sweep funds transaction data.
639
+ /// @param sweepProof Bitcoin sweep funds proof data.
631
640
  /// @param mainUtxo Data of the sweeping wallet's main UTXO, as currently
632
- /// known on the Ethereum chain
641
+ /// known on the Ethereum chain.
633
642
  /// @dev Requirements:
634
643
  /// - `sweepTx` components must match the expected structure. See
635
644
  /// `BitcoinTx.Info` docs for reference. Their values must exactly
636
645
  /// correspond to appropriate Bitcoin transaction fields to produce
637
- /// a provable transaction hash.
646
+ /// a provable transaction hash,
638
647
  /// - The `sweepTx` should represent a Bitcoin transaction with
639
648
  /// the first input pointing to a wallet's sweep Pending request and,
640
649
  /// optionally, the second input pointing to the wallet's main UTXO,
641
650
  /// if the sweeping wallet has a main UTXO set. There should be only
642
651
  /// one output locking funds on the sweeping wallet 20-byte public
643
- /// key hash.
652
+ /// key hash,
644
653
  /// - `sweepProof` components must match the expected structure.
645
654
  /// See `BitcoinTx.Proof` docs for reference. The `bitcoinHeaders`
646
655
  /// field must contain a valid number of block headers, not less
647
- /// than the `txProofDifficultyFactor` contract constant.
656
+ /// than the `txProofDifficultyFactor` contract constant,
648
657
  /// - `mainUtxo` components must point to the recent main UTXO
649
658
  /// of the sweeping wallet, as currently known on the Ethereum chain.
650
- /// If there is no main UTXO, this parameter is ignored.
651
- /// - The sweeping wallet must be in the Live or MovingFunds state.
659
+ /// If there is no main UTXO, this parameter is ignored,
660
+ /// - The sweeping wallet must be in the Live or MovingFunds state,
652
661
  /// - The total Bitcoin transaction fee must be lesser or equal
653
662
  /// to `movedFundsSweepTxMaxTotalFee` governable parameter.
654
663
  function submitMovedFundsSweepProof(
@@ -705,13 +714,13 @@ library MovingFunds {
705
714
  /// vector.
706
715
  /// This function assumes vector's structure is valid so it must be
707
716
  /// validated using e.g. `BTCUtils.validateVout` function before
708
- /// it is passed here
717
+ /// it is passed here.
709
718
  /// @return walletPubKeyHash 20-byte wallet public key hash.
710
719
  /// @return value 8-byte moved funds sweep transaction output value.
711
720
  /// @dev Requirements:
712
- /// - Output vector must contain only one output
721
+ /// - Output vector must contain only one output,
713
722
  /// - The single output must be of P2PKH or P2WPKH type and lock the
714
- /// funds on a 20-byte public key hash
723
+ /// funds on a 20-byte public key hash.
715
724
  function processMovedFundsSweepTxOutput(
716
725
  BridgeState.Storage storage self,
717
726
  bytes memory sweepTxOutputVector
@@ -745,14 +754,14 @@ library MovingFunds {
745
754
  /// Bitcoin transaction.
746
755
  /// @param mainUtxo Data of the wallet's main UTXO, as currently known on
747
756
  /// the Ethereum chain. If no main UTXO exists for the given wallet,
748
- /// this parameter is ignored
757
+ /// this parameter is ignored.
749
758
  /// @return wallet Data of the sweeping wallet.
750
759
  /// @return resolvedMainUtxo The actual main UTXO of the sweeping wallet
751
760
  /// resolved by cross-checking the `mainUtxo` parameter with
752
761
  /// the chain state. If the validation went well, this is the
753
762
  /// plain-text main UTXO corresponding to the `wallet.mainUtxoHash`.
754
763
  /// @dev Requirements:
755
- /// - Sweeping wallet must be either in Live or MovingFunds state.
764
+ /// - Sweeping wallet must be either in Live or MovingFunds state,
756
765
  /// - If the main UTXO of the sweeping wallet exists in the storage,
757
766
  /// the passed `mainUTXO` parameter must be equal to the stored one.
758
767
  function resolveMovedFundsSweepingWallet(
@@ -807,19 +816,19 @@ library MovingFunds {
807
816
  /// @param sweepTxInputVector Bitcoin moved funds sweep transaction input vector.
808
817
  /// This function assumes vector's structure is valid so it must be
809
818
  /// validated using e.g. `BTCUtils.validateVin` function before
810
- /// it is passed here
819
+ /// it is passed here.
811
820
  /// @param mainUtxo Data of the sweeping wallet's main UTXO. If no main UTXO
812
821
  /// exists for the given the wallet, this parameter's fields should
813
- /// be zeroed to bypass the main UTXO validation
814
- /// @param walletPubKeyHash 20-byte public key hash of the sweeping wallet
822
+ /// be zeroed to bypass the main UTXO validation.
823
+ /// @param walletPubKeyHash 20-byte public key hash of the sweeping wallet.
815
824
  /// @return inputsTotalValue Total inputs value sum.
816
825
  /// @dev Requirements:
817
826
  /// - The input vector must consist of one mandatory and one optional
818
- /// input.
819
- /// - The mandatory input must be the first input in the vector
827
+ /// input,
828
+ /// - The mandatory input must be the first input in the vector,
820
829
  /// - The mandatory input must point to a Pending moved funds sweep
821
- /// request that is targeted to the sweeping wallet
822
- /// - The optional output must be the second input in the vector
830
+ /// request that is targeted to the sweeping wallet,
831
+ /// - The optional output must be the second input in the vector,
823
832
  /// - The optional input is required if the sweeping wallet has a
824
833
  /// main UTXO (i.e. the `mainUtxo` is not zeroed). In that case,
825
834
  /// that input must point the the sweeping wallet main UTXO.
@@ -956,8 +965,8 @@ library MovingFunds {
956
965
  }
957
966
 
958
967
  /// @notice Parses a Bitcoin transaction input starting at the given index.
959
- /// @param inputVector Bitcoin transaction input vector
960
- /// @param inputStartingIndex Index the given input starts at
968
+ /// @param inputVector Bitcoin transaction input vector.
969
+ /// @param inputStartingIndex Index the given input starts at.
961
970
  /// @return outpointTxHash 32-byte hash of the Bitcoin transaction which is
962
971
  /// pointed in the given input's outpoint.
963
972
  /// @return outpointIndex 4-byte index of the Bitcoin transaction output
@@ -994,21 +1003,21 @@ library MovingFunds {
994
1003
  /// the wallet and slashes signing group members as a result.
995
1004
  /// Marks the given sweep request as TimedOut.
996
1005
  /// @param movingFundsTxHash 32-byte hash of the moving funds transaction
997
- /// that caused the sweep request to be created
1006
+ /// that caused the sweep request to be created.
998
1007
  /// @param movingFundsTxOutputIndex Index of the moving funds transaction
999
1008
  /// output that is subject of the sweep request.
1000
- /// @param walletMembersIDs Identifiers of the wallet signing group members
1009
+ /// @param walletMembersIDs Identifiers of the wallet signing group members.
1001
1010
  /// @dev Requirements:
1002
- /// - The moved funds sweep request must be in the Pending state
1003
- /// - The moved funds sweep timeout must be actually exceeded
1011
+ /// - The moved funds sweep request must be in the Pending state,
1012
+ /// - The moved funds sweep timeout must be actually exceeded,
1004
1013
  /// - The wallet must be either in the Live or MovingFunds or
1005
- /// Terminated state
1014
+ /// Terminated state,,
1006
1015
  /// - The expression `keccak256(abi.encode(walletMembersIDs))` must
1007
1016
  /// be exactly the same as the hash stored under `membersIdsHash`
1008
1017
  /// for the given `walletID`. Those IDs are not directly stored
1009
1018
  /// in the contract for gas efficiency purposes but they can be
1010
1019
  /// read from appropriate `DkgResultSubmitted` and `DkgResultApproved`
1011
- /// events of the `WalletRegistry` contract
1020
+ /// events of the `WalletRegistry` contract.
1012
1021
  function notifyMovedFundsSweepTimeout(
1013
1022
  BridgeState.Storage storage self,
1014
1023
  bytes32 movingFundsTxHash,
@@ -39,7 +39,7 @@ library OutboundTx {
39
39
  /// @param walletOutboundTxInputVector Bitcoin outbound transaction's input
40
40
  /// vector. This function assumes vector's structure is valid so it
41
41
  /// must be validated using e.g. `BTCUtils.validateVin` function
42
- /// before it is passed here
42
+ /// before it is passed here.
43
43
  /// @param mainUtxo Data of the wallet's main UTXO, as currently known on
44
44
  /// the Ethereum chain.
45
45
  /// @param walletPubKeyHash 20-byte public key hash (computed using Bitcoin
@@ -101,7 +101,7 @@ library OutboundTx {
101
101
  /// @param walletOutboundTxInputVector Bitcoin outbound transaction input
102
102
  /// vector. This function assumes vector's structure is valid so it
103
103
  /// must be validated using e.g. `BTCUtils.validateVin` function
104
- /// before it is passed here
104
+ /// before it is passed here.
105
105
  /// @return outpointTxHash 32-byte hash of the Bitcoin transaction which is
106
106
  /// pointed in the input's outpoint.
107
107
  /// @return outpointIndex 4-byte index of the Bitcoin transaction output
@@ -234,12 +234,12 @@ library Redemption {
234
234
  /// @notice Requests redemption of the given amount from the specified
235
235
  /// wallet to the redeemer Bitcoin output script.
236
236
  /// @param walletPubKeyHash The 20-byte wallet public key hash (computed
237
- /// using Bitcoin HASH160 over the compressed ECDSA public key)
237
+ /// using Bitcoin HASH160 over the compressed ECDSA public key).
238
238
  /// @param mainUtxo Data of the wallet's main UTXO, as currently known on
239
- /// the Ethereum chain
239
+ /// the Ethereum chain.
240
240
  /// @param redeemerOutputScript The redeemer's length-prefixed output
241
241
  /// script (P2PKH, P2WPKH, P2SH or P2WSH) that will be used to lock
242
- /// redeemed BTC
242
+ /// redeemed BTC.
243
243
  /// @param amount Requested amount in satoshi. This is also the TBTC amount
244
244
  /// that is taken from redeemer's balance in the Bank upon request.
245
245
  /// Once the request is handled, the actual amount of BTC locked
@@ -249,15 +249,15 @@ library Redemption {
249
249
  /// `amount - (amount / redemptionTreasuryFeeDivisor) - redemptionTxMaxFee`.
250
250
  /// Fees values are taken at the moment of request creation.
251
251
  /// @dev Requirements:
252
- /// - Wallet behind `walletPubKeyHash` must be live
252
+ /// - Wallet behind `walletPubKeyHash` must be live,
253
253
  /// - `mainUtxo` components must point to the recent main UTXO
254
- /// of the given wallet, as currently known on the Ethereum chain.
255
- /// - `redeemerOutputScript` must be a proper Bitcoin script
256
- /// - `redeemerOutputScript` cannot have wallet PKH as payload
257
- /// - `amount` must be above or equal the `redemptionDustThreshold`
254
+ /// of the given wallet, as currently known on the Ethereum chain,
255
+ /// - `redeemerOutputScript` must be a proper Bitcoin script,
256
+ /// - `redeemerOutputScript` cannot have wallet PKH as payload,
257
+ /// - `amount` must be above or equal the `redemptionDustThreshold`,
258
258
  /// - Given `walletPubKeyHash` and `redeemerOutputScript` pair can be
259
- /// used for only one pending request at the same time
260
- /// - Wallet must have enough Bitcoin balance to proceed the request
259
+ /// used for only one pending request at the same time,
260
+ /// - Wallet must have enough Bitcoin balance to proceed the request,
261
261
  /// - Redeemer must make an allowance in the Bank that the Bridge
262
262
  /// contract can spend the given `amount`.
263
263
  function requestRedemption(
@@ -387,18 +387,18 @@ library Redemption {
387
387
  /// transferring the treasury fee sum to the treasury address.
388
388
  ///
389
389
  /// It is possible to prove the given redemption only one time.
390
- /// @param redemptionTx Bitcoin redemption transaction data
391
- /// @param redemptionProof Bitcoin redemption proof data
390
+ /// @param redemptionTx Bitcoin redemption transaction data.
391
+ /// @param redemptionProof Bitcoin redemption proof data.
392
392
  /// @param mainUtxo Data of the wallet's main UTXO, as currently known on
393
- /// the Ethereum chain
393
+ /// the Ethereum chain.
394
394
  /// @param walletPubKeyHash 20-byte public key hash (computed using Bitcoin
395
395
  /// HASH160 over the compressed ECDSA public key) of the wallet which
396
- /// performed the redemption transaction
396
+ /// performed the redemption transaction.
397
397
  /// @dev Requirements:
398
398
  /// - `redemptionTx` components must match the expected structure. See
399
399
  /// `BitcoinTx.Info` docs for reference. Their values must exactly
400
400
  /// correspond to appropriate Bitcoin transaction fields to produce
401
- /// a provable transaction hash.
401
+ /// a provable transaction hash,
402
402
  /// - The `redemptionTx` should represent a Bitcoin transaction with
403
403
  /// exactly 1 input that refers to the wallet's main UTXO. That
404
404
  /// transaction should have 1..n outputs handling existing pending
@@ -406,14 +406,14 @@ library Redemption {
406
406
  /// There can be also 1 optional output representing the
407
407
  /// change and pointing back to the 20-byte wallet public key hash.
408
408
  /// The change should be always present if the redeemed value sum
409
- /// is lower than the total wallet's BTC balance.
409
+ /// is lower than the total wallet's BTC balance,
410
410
  /// - `redemptionProof` components must match the expected structure.
411
411
  /// See `BitcoinTx.Proof` docs for reference. The `bitcoinHeaders`
412
412
  /// field must contain a valid number of block headers, not less
413
- /// than the `txProofDifficultyFactor` contract constant.
413
+ /// than the `txProofDifficultyFactor` contract constant,
414
414
  /// - `mainUtxo` components must point to the recent main UTXO
415
415
  /// of the given wallet, as currently known on the Ethereum chain.
416
- /// Additionally, the recent main UTXO on Ethereum must be set.
416
+ /// Additionally, the recent main UTXO on Ethereum must be set,
417
417
  /// - `walletPubKeyHash` must be connected with the main UTXO used
418
418
  /// as transaction single input.
419
419
  /// Other remarks:
@@ -500,7 +500,7 @@ library Redemption {
500
500
  /// @param redemptionTxOutputVector Bitcoin redemption transaction output
501
501
  /// vector. This function assumes vector's structure is valid so it
502
502
  /// must be validated using e.g. `BTCUtils.validateVout` function
503
- /// before it is passed here
503
+ /// before it is passed here.
504
504
  /// @param walletPubKeyHash 20-byte public key hash (computed using Bitcoin
505
505
  // HASH160 over the compressed ECDSA public key) of the wallet which
506
506
  /// performed the redemption transaction.
@@ -585,7 +585,7 @@ library Redemption {
585
585
  /// @param redemptionTxOutputVector Bitcoin redemption transaction output
586
586
  /// vector. This function assumes vector's structure is valid so it
587
587
  /// must be validated using e.g. `BTCUtils.validateVout` function
588
- /// before it is passed here
588
+ /// before it is passed here.
589
589
  /// @param walletPubKeyHash 20-byte public key hash (computed using Bitcoin
590
590
  // HASH160 over the compressed ECDSA public key) of the wallet which
591
591
  /// performed the redemption transaction.
@@ -608,6 +608,7 @@ library Redemption {
608
608
  // TODO: Check if we can optimize gas costs by adding
609
609
  // `extractValueAt` and `extractHashAt` in `bitcoin-spv-sol`
610
610
  // in order to avoid allocating bytes in memory.
611
+ // https://github.com/keep-network/tbtc-v2/issues/257
611
612
  uint256 outputLength = redemptionTxOutputVector
612
613
  .determineOutputLengthAt(processInfo.outputStartingIndex);
613
614
  bytes memory output = redemptionTxOutputVector.slice(
@@ -677,8 +678,8 @@ library Redemption {
677
678
  /// @param walletPubKeyHash 20-byte public key hash (computed using Bitcoin
678
679
  // HASH160 over the compressed ECDSA public key) of the wallet which
679
680
  /// performed the redemption transaction.
680
- /// @param outputScript Non-change output script to be processed
681
- /// @param outputValue Value of the output being processed
681
+ /// @param outputScript Non-change output script to be processed.
682
+ /// @param outputValue Value of the output being processed.
682
683
  /// @return burnableValue The value burnable as a result of processing this
683
684
  /// single redemption output. This value needs to be summed up with
684
685
  /// burnable values of all other outputs to evaluate total burnable
@@ -778,23 +779,23 @@ library Redemption {
778
779
  /// marked as `MovingFunds` (depending on the presence or absence
779
780
  /// of the wallet's main UTXO) and the wallet will no longer be
780
781
  /// marked as the active wallet (if it was marked as such).
781
- /// @param walletPubKeyHash 20-byte public key hash of the wallet
782
- /// @param walletMembersIDs Identifiers of the wallet signing group members
782
+ /// @param walletPubKeyHash 20-byte public key hash of the wallet.
783
+ /// @param walletMembersIDs Identifiers of the wallet signing group members.
783
784
  /// @param redeemerOutputScript The redeemer's length-prefixed output
784
- /// script (P2PKH, P2WPKH, P2SH or P2WSH)
785
+ /// script (P2PKH, P2WPKH, P2SH or P2WSH).
785
786
  /// @dev Requirements:
786
- /// - The wallet must be in the Live or MovingFunds or Terminated state
787
+ /// - The wallet must be in the Live or MovingFunds or Terminated state,
787
788
  /// - The redemption request identified by `walletPubKeyHash` and
788
- /// `redeemerOutputScript` must exist
789
+ /// `redeemerOutputScript` must exist,
789
790
  /// - The expression `keccak256(abi.encode(walletMembersIDs))` must
790
791
  /// be exactly the same as the hash stored under `membersIdsHash`
791
792
  /// for the given `walletID`. Those IDs are not directly stored
792
793
  /// in the contract for gas efficiency purposes but they can be
793
794
  /// read from appropriate `DkgResultSubmitted` and `DkgResultApproved`
794
- /// events of the `WalletRegistry` contract
795
+ /// events of the `WalletRegistry` contract,
795
796
  /// - The amount of time defined by `redemptionTimeout` must have
796
797
  /// passed since the redemption was requested (the request must be
797
- /// timed-out)
798
+ /// timed-out).
798
799
  function notifyRedemptionTimeout(
799
800
  BridgeState.Storage storage self,
800
801
  bytes20 walletPubKeyHash,