Threshold Network 백서

Threshold Network

원문

bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 36쪽 중 11쪽

source wallet signing group members. | | walletMemberIndex | uint256 | Position of the caller in the source wallet signing group members list. | | targetWallets | bytes20\[] | List of 20-byte public key hashes of the target wallets that the source wallet commits to move the funds to. | ### resetMovingFundsTimeout ```solidity function resetMovingFundsTimeout(bytes20 walletPubKeyHash) external ``` Resets the moving funds timeout for the given wallet if the target wallet commitment cannot be submitted due to a lack of live wallets in the system. Requirements: * The wallet must be in the MovingFunds state, * The target wallets commitment must not be already submitted for the given moving funds wallet, * Live wallets count must be zero, * The moving funds timeout reset delay must be elapsed. #### Parameters | Name | Type | Description | | ---------------- | ------- | --------------------------------------------------- | | walletPubKeyHash | bytes20 | 20-byte public key hash of the moving funds wallet. | ### submitMovingFundsProof ```solidity function submitMovingFundsProof(struct BitcoinTx.Info movingFundsTx, struct BitcoinTx.Proof movingFundsProof, struct BitcoinTx.UTXO mainUtxo, bytes20 walletPubKeyHash) external ``` Used by the wallet to prove the BTC moving funds transaction and to make the necessary state changes. Moving funds is only accepted if it satisfies SPV proof. The function validates the moving funds transaction structure by checking if it actually spends the main UTXO of the declared wallet and locks the value on the pre-committed target wallets using a reasonable transaction fee. If all preconditions are met, this functions closes the source wallet. It is possible to prove the given moving funds transaction only one time. Requirements: * `movingFundsTx` components must match the expected structure. See `BitcoinTx.Info` docs for reference. Their values must exactly correspond to appropriate Bitcoin transaction fields to produce a provable transaction hash, * The `movingFundsTx` should represent a Bitcoin transaction with exactly 1 input that refers to the wallet's main UTXO. That transaction should have 1..n outputs corresponding to the pre-committed target wallets. Outputs must be ordered in the same way as their corresponding target wallets are ordered within the target wallets commitment, * `movingFundsProof` components must match the expected structure. See `BitcoinTx.Proof` docs for reference. The `bitcoinHeaders` field must contain a valid number of block headers, not less than the `txProofDifficultyFactor` contract constant, * `mainUtxo` components must point to the recent main UTXO of the given wallet, as currently known on the Ethereum chain. Additionally, the recent main UTXO on Ethereum must be set, * `walletPubKeyHash` must be connected with the main UTXO used as transaction single input, * The wallet that `walletPubKeyHash` points to must be in the MovingFunds state, * The target wallets commitment must be submitted by the wallet that `walletPubKeyHash` points to, * The total Bitcoin transaction fee must be lesser or equal to `movingFundsTxMaxTotalFee` governable parameter. #### Parameters | Name | Type | Description | | ---------------- | ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | | movingFundsTx | struct BitcoinTx.Info | Bitcoin moving funds transaction data. | | movingFundsProof | struct BitcoinTx.Proof | Bitcoin moving funds proof data. | | mainUtxo | struct BitcoinTx.UTXO | Data of the wallet's main UTXO, as currently known on the Ethereum chain. | | walletPubKeyHash | bytes20 | 20-byte public key hash (computed using Bitcoin HASH160 over the compressed ECDSA public key) of the wallet which performed the moving funds transaction. | ### notifyMovingFundsTimeout ```solidity function notifyMovingFundsTimeout(bytes20 walletPubKeyHash, uint32[] walletMembersIDs) external ``` Notifies about a timed out moving funds process. Terminates the wallet and slashes signing group members as a result. Requirements: * The wallet must be in the MovingFunds state, * The moving funds timeout must be actually exceeded, * The expression `keccak256(abi.encode(walletMembersIDs))` must be exactly the same as the hash stored under `membersIdsHash` for the given `walletID`. Those IDs are not directly stored in the contract for gas efficiency purposes but they can be read from appropriate `DkgResultSubmitted` and `DkgResultApproved` events of the `WalletRegistry` contract. #### Parameters | Name | Type | Description | | ---------------- | --------- | ------------------------------------------------ | | walletPubKeyHash | bytes20 | 20-byte public key hash of the wallet. | | walletMembersIDs | uint32\[] | Identifiers of the wallet signing group members. | ### notifyMovingFundsBelowDust ```solidity function notifyMovingFundsBelowDust(bytes20 walletPubKeyHash, struct BitcoinTx.UTXO mainUtxo) external ``` Notifies about a moving funds wallet whose BTC balance is below the moving funds dust threshold. Ends the moving funds process and begins wallet closing immediately. Requirements: * The wallet must be in the MovingFunds state, * The `mainUtxo` components must point to the recent main UTXO of the given wallet, as currently known on the Ethereum chain. If the wallet has no main UTXO, this parameter can be empty as it is ignored, * The wallet BTC balance must be below the moving funds threshold. #### Parameters | Name | Type | Description | | ---------------- | --------------------- | ------------------------------------------------------------------------- | | walletPubKeyHash | bytes20 | 20-byte public key hash of the wallet | | mainUtxo | struct BitcoinTx.UTXO | Data of the wallet's main UTXO, as currently known on the Ethereum chain. | ### submitMovedFundsSweepProof ```solidity function submitMovedFundsSweepProof(struct BitcoinTx.Info sweepTx, struct BitcoinTx.Proof sweepProof, struct BitcoinTx.UTXO mainUtxo) external ``` Used by the wallet to prove the BTC moved funds sweep transaction and to make the necessary state changes. Moved funds sweep is only accepted if it satisfies SPV proof. The function validates the sweep transaction structure by checking if it actually spends the moved funds UTXO and the sweeping wallet's main UTXO (optionally), and if it locks the value on the sweeping wallet's 20-byte public key hash using a reasonable transaction fee. If all preconditions are met, this function updates the sweeping wallet main UTXO, thus their BTC balance. It is possible to prove the given sweep transaction only one time. Requirements: * `sweepTx` components must match the expected structure. See `BitcoinTx.Info` docs for reference. Their values must exactly correspond to appropriate Bitcoin transaction fields to produce a provable transaction hash, * The `sweepTx` should represent a Bitcoin transaction with the first input pointing to a moved funds sweep request targeted to the wallet, and optionally, the second input pointing to the wallet's main UTXO, if the sweeping wallet has a main UTXO set. There should be only one output locking funds on the sweeping wallet 20-byte public key hash, * `sweepProof` components must match the expected structure. See `BitcoinTx.Proof` docs for reference. The `bitcoinHeaders` field must contain a valid number of block headers, not less than the `txProofDifficultyFactor` contract constant, * `mainUtxo` components must point to the recent main UTXO of the sweeping wallet, as currently known on the Ethereum chain. If there is no main UTXO, this parameter is ignored, * The sweeping wallet must be in the Live or MovingFunds state, * The total Bitcoin transaction fee must be lesser or equal to `movedFundsSweepTxMaxTotalFee` governable parameter. #### Parameters | Name | Type | Description | | ---------- | ---------------------- | ---------------------------------------------------------------------------------- | | sweepTx | struct BitcoinTx.Info | Bitcoin sweep funds transaction data. | | sweepProof | struct BitcoinTx.Proof | Bitcoin sweep funds proof data. | | mainUtxo | struct BitcoinTx.UTXO | Data of the sweeping wallet's main UTXO, as currently known on the Ethereum chain. | ### notifyMovedFundsSweepTimeout ```solidity function notifyMovedFundsSweepTimeout(bytes32 movingFundsTxHash, uint32 movingFundsTxOutputIndex, uint32[] walletMembersIDs) external ``` Notifies about a timed out moved funds sweep process. If the wallet is not terminated yet, that function terminates the wallet and slashes signing group members as a result. Marks the given sweep request as TimedOut. Requirements: * The moved funds sweep request must be in the Pending state, * The moved funds sweep timeout must be actually exceeded, * The wallet must be either in the Live or MovingFunds or Terminated state, * The expression `keccak256(abi.encode(walletMembersIDs))` must be exactly the same as the hash stored under `membersIdsHash` for the given `walletID`. Those IDs are not directly stored in the contract for gas efficiency purposes but they can be read from appropriate `DkgResultSubmitted` and `DkgResultApproved` events of the `WalletRegistry` contract. #### Parameters | Name | Type | Description | | ------------------------ | --------- | ----------------------------------------------------------------------------------------- | | movingFundsTxHash | bytes32 | 32-byte hash of the moving funds transaction that caused the sweep request to be created. | | movingFundsTxOutputIndex | uint32 | Index of the moving funds transaction output that is subject of the sweep request. | | walletMembersIDs | uint32\[] | Identifiers of the wallet signing group members. | ### requestNewWallet ```solidity function requestNewWallet(struct BitcoinTx.UTXO activeWalletMainUtxo) external ``` Requests creation of a new wallet. This function just forms a request and the creation process is performed asynchronously. Once a wallet is created, the ECDSA Wallet Registry will notify this contract by calling the `__ecdsaWalletCreatedCallback` function. Requirements: * `activeWalletMainUtxo` components must point to the recent main UTXO of the given active wallet, as currently known on the Ethereum chain. If there is no active wallet at the moment, or the active wallet has no main UTXO, this parameter can be empty as it is ignored, * Wallet creation must not be in progress, * If the active wallet is set, one of the following conditions must be true: * The active wallet BTC balance is above the minimum threshold and the active wallet is old enough, i.e. the creation period was elapsed since its creation time, * The active wallet BTC balance is above the maximum threshold. #### Parameters | Name | Type | Description | | -------------------- | --------------------- | -------------------------------------------------------------------------------- | | activeWalletMainUtxo | struct BitcoinTx.UTXO | Data of the active wallet's main UTXO, as currently known on the Ethereum chain. | ### \_\_ecdsaWalletCreatedCallback ```solidity function __ecdsaWalletCreatedCallback(bytes32 ecdsaWalletID, bytes32 publicKeyX, bytes32 publicKeyY) external ``` A callback function that is called by the ECDSA Wallet Registry once a new ECDSA wallet is created. Requirements: * The only caller authorized to call this function is `registry`, * Given wallet data must not belong to an already registered wallet. #### Parameters | Name | Type | Description | | ------------- | ------- | ----------------------------------- | | ecdsaWalletID | bytes32 | Wallet's unique identifier. | | publicKeyX | bytes32 | Wallet's public key's X coordinate. | | publicKeyY | bytes32 | Wallet's public key's Y coordinate. | ### \_\_ecdsaWalletHeartbeatFailedCallback ```solidity function __ecdsaWalletHeartbeatFailedCallback(bytes32, bytes32 publicKeyX, bytes32 publicKeyY) external ``` A callback function that is called by the ECDSA Wallet Registry once a wallet heartbeat failure is detected. Requirements: * The only caller authorized to call this function is `registry`, * Wallet must be in Live state. #### Parameters | Name | Type | Description | | ---------- | ------- | ----------------------------------- | | | bytes32 | | | publicKeyX | bytes32 | Wallet's public key's X coordinate. | | publicKeyY | bytes32 | Wallet's public key's Y coordinate. | ### notifyWalletCloseable ```solidity function notifyWalletCloseable(bytes20 walletPubKeyHash, struct BitcoinTx.UTXO walletMainUtxo) external ``` Notifies that the wallet is either old enough or has too few satoshi left and qualifies to be closed. Requirements: * Wallet must not be set as the current active wallet, * Wallet must exceed the wallet maximum age OR the wallet BTC balance must be lesser than the minimum threshold. If the latter case is true, the `walletMainUtxo` components must point to the recent main UTXO of the given wallet, as currently known on the Ethereum chain. If the wallet has no main UTXO, this parameter can be empty as it is ignored since the wallet balance is assumed to be zero, * Wallet must be in Live state. #### Parameters | Name | Type | Description | | ---------------- | --------------------- | ------------------------------------------------------------------------- | | walletPubKeyHash | bytes20 | 20-byte public key hash of the wallet. | | walletMainUtxo | struct BitcoinTx.UTXO | Data of the wallet's main UTXO, as currently known on the Ethereum chain. | ### notifyWalletClosingPeriodElapsed ```solidity function notifyWalletClosingPeriodElapsed(bytes20 walletPubKeyHash) external ``` Notifies about the end of the closing period for the given wallet. Closes the wallet ultimately and notifies the ECDSA registry about this fact. Requirements: * The wallet must be in the Closing state, * The wallet closing period must have elapsed. #### Parameters | Name | Type | Description | | ---------------- | ------- | -------------------------------------- | | walletPubKeyHash | bytes20 | 20-byte public key hash of the wallet. | ### submitFraudChallenge ```solidity function submitFraudChallenge(bytes walletPublicKey, bytes preimageSha256, struct BitcoinTx.RSVSignature signature) external payable ``` Submits a fraud challenge indicating that a UTXO being under wallet control was unlocked by the wallet but was not used according to the protocol rules. That means the wallet signed a transaction input pointing to that UTXO and there is a unique sighash and signature pair associated with that input. This function uses those parameters to create a fraud accusation that proves a given transaction input unlocking the given UTXO was actually signed by the wallet. This function cannot determine whether the transaction was actually broadcast and the input was consumed in a fraudulent way so it just opens a challenge period during which the wallet can defeat the challenge by submitting proof of a transaction that consumes the given input according to protocol rules. To prevent spurious allegations, the caller must deposit ETH that is returned back upon justified fraud challenge or confiscated otherwise. Requirements: * Wallet behind `walletPublicKey` must be in Live or MovingFunds or Closing state, * The challenger must send appropriate amount of ETH used as fraud challenge deposit, * The signature (represented by r, s and v) must be generated by the wallet behind `walletPubKey` during signing of `sighash` which was calculated from `preimageSha256`, * Wallet can be challenged for the given signature only once. #### Parameters | Name | Type | Description | | --------------- | ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | walletPublicKey | bytes | The public key of the wallet in the uncompressed and unprefixed format (64 bytes). | | preimageSha256 | bytes | The hash that was generated by applying SHA-256 one time over the preimage used during input signing. The preimage is a serialized subset of the transaction and its structure depends on the transaction input (see BIP-143 for reference). Notice that applying SHA-256 over the `preimageSha256` results in `sighash`. The path from `preimage` to `sighash` looks like this: preimage -> (SHA-256) -> preimageSha256 -> (SHA-256) -> sighash. | | signature | struct BitcoinTx.RSVSignature | Bitcoin signature in the R/S/V format. | ### defeatFraudChallenge ```solidity function defeatFraudChallenge(bytes walletPublicKey, bytes preimage, bool witness) external ``` Allows to defeat a pending fraud challenge against a wallet if the transaction that spends the UTXO follows the protocol rules. In order to defeat the challenge the same `walletPublicKey` and signature (represented by `r`, `s` and `v`) must be provided as were used to calculate the sighash during input signing. The fraud challenge defeat attempt will only succeed if the inputs in the preimage are considered honestly spent by the wallet. Therefore the transaction spending the UTXO must be proven in the Bridge before a challenge defeat is called. If successfully defeated, the fraud challenge is marked as resolved and the amount of ether deposited by the challenger is sent to the treasury. Requirements: * `walletPublicKey` and `sighash` calculated as `hash256(preimage)` must identify an open fraud challenge, * the preimage must be a valid preimage of a transaction generated according to the protocol rules and already proved in the Bridge, * before a defeat attempt is made the transaction that spends the given UTXO must be proven in the Bridge. #### Parameters | Name | Type | Description | | --------------- | ----- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | walletPublicKey | bytes | The public key of the wallet in the uncompressed and unprefixed format (64 bytes). | | preimage | bytes | The preimage which produces sighash used to generate the ECDSA signature that is the subject of the fraud claim. It is a serialized subset of the transaction. The exact subset used as the preimage depends on the transaction input the signature is produced for. See BIP-143 for reference. | | witness | bool | Flag indicating whether the preimage was produced for a witness input. True for witness, false for non-witness input. | ### defeatFraudChallengeWithHeartbeat ```solidity function defeatFraudChallengeWithHeartbeat(bytes walletPublicKey, bytes heartbeatMessage) external ``` Allows to defeat a pending fraud challenge against a wallet by proving the sighash and signature were produced for an off-chain wallet heartbeat message following a strict format. In order to defeat the challenge the same `walletPublicKey` and signature (represented by `r`, `s` and `v`) must be provided as were used to calculate the sighash during heartbeat message signing. The fraud challenge defeat attempt will only succeed if the signed message follows a strict format required for heartbeat messages. If successfully defeated, the fraud challenge is marked as resolved and the amount of ether deposited by the challenger is sent to the treasury. Requirements: * `walletPublicKey` and `sighash` calculated as `hash256(heartbeatMessage)` must identify an open fraud challenge, * `heartbeatMessage` must follow a strict forma
프로젝트로 돌아가기