@keep-network/tbtc-v2 1.7.0 → 1.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/artifacts/.chainId +1 -1
- package/artifacts/BLS.json +223 -0
- package/artifacts/Bank.json +50 -40
- package/artifacts/BeaconAuthorization.json +273 -0
- package/artifacts/BeaconDkg.json +241 -0
- package/artifacts/BeaconDkgValidator.json +501 -0
- package/artifacts/BeaconInactivity.json +151 -0
- package/artifacts/BeaconSortitionPool.json +1187 -0
- package/artifacts/Bridge.json +449 -32
- package/artifacts/BridgeGovernance.json +22 -22
- package/artifacts/BridgeGovernanceParameters.json +10 -10
- package/artifacts/Deposit.json +12 -12
- package/artifacts/DepositSweep.json +12 -12
- package/artifacts/DonationVault.json +17 -17
- package/artifacts/EcdsaDkgValidator.json +517 -0
- package/artifacts/EcdsaInactivity.json +156 -0
- package/artifacts/EcdsaSortitionPool.json +1187 -0
- package/artifacts/Fraud.json +12 -12
- package/artifacts/LightRelay.json +38 -38
- package/artifacts/LightRelayMaintainerProxy.json +31 -31
- package/artifacts/MaintainerProxy.json +44 -44
- package/artifacts/MovingFunds.json +12 -12
- package/artifacts/NuCypherToken.json +711 -0
- package/artifacts/RandomBeacon.json +3271 -0
- package/artifacts/RandomBeaconChaosnet.json +252 -0
- package/artifacts/RandomBeaconGovernance.json +3499 -0
- package/artifacts/Redemption.json +12 -12
- package/artifacts/RedemptionWatchtower.json +39 -39
- package/artifacts/ReimbursementPool.json +509 -0
- package/artifacts/T.json +1148 -0
- package/artifacts/TBTC.json +37 -36
- package/artifacts/TBTCToken.json +738 -0
- package/artifacts/TBTCVault.json +47 -47
- package/artifacts/Timelock.json +148 -148
- package/artifacts/TokenStaking.json +2117 -0
- package/artifacts/TokenholderGovernor.json +1795 -0
- package/artifacts/TokenholderTimelock.json +1058 -0
- package/artifacts/VendingMachine.json +35 -34
- package/artifacts/VendingMachineNuCypher.json +400 -0
- package/artifacts/VendingMachineV2.json +21 -21
- package/artifacts/VendingMachineV3.json +21 -21
- package/artifacts/WalletProposalValidator.json +12 -12
- package/artifacts/WalletRegistry.json +1962 -0
- package/artifacts/WalletRegistryGovernance.json +2863 -0
- package/artifacts/Wallets.json +12 -12
- package/artifacts/solcInputs/{be146ce112252bdda3a03de3614fbbf1.json → 2cb3f9e60e45f0ca528d3d5260ff3139.json} +31 -7
- package/build/contracts/GovernanceUtils.sol/GovernanceUtils.dbg.json +1 -1
- package/build/contracts/Timelock.sol/Timelock.dbg.json +1 -1
- package/build/contracts/bank/Bank.sol/Bank.dbg.json +1 -1
- package/build/contracts/bank/IReceiveBalanceApproval.sol/IReceiveBalanceApproval.dbg.json +1 -1
- package/build/contracts/bridge/BitcoinTx.sol/BitcoinTx.dbg.json +1 -1
- package/build/contracts/bridge/Bridge.sol/Bridge.dbg.json +1 -1
- package/build/contracts/bridge/BridgeGovernanceParameters.sol/BridgeGovernanceParameters.dbg.json +1 -1
- package/build/contracts/bridge/BridgeState.sol/BridgeState.dbg.json +1 -1
- package/build/contracts/bridge/Deposit.sol/Deposit.dbg.json +1 -1
- package/build/contracts/bridge/DepositSweep.sol/DepositSweep.dbg.json +1 -1
- package/build/contracts/bridge/EcdsaLib.sol/EcdsaLib.dbg.json +1 -1
- package/build/contracts/bridge/Fraud.sol/Fraud.dbg.json +1 -1
- package/build/contracts/bridge/Heartbeat.sol/Heartbeat.dbg.json +1 -1
- package/build/contracts/bridge/IRelay.sol/IRelay.dbg.json +1 -1
- package/build/contracts/bridge/MovingFunds.sol/MovingFunds.dbg.json +1 -1
- package/build/contracts/bridge/Redemption.sol/IRedemptionWatchtower.dbg.json +1 -1
- package/build/contracts/bridge/Redemption.sol/OutboundTx.dbg.json +1 -1
- package/build/contracts/bridge/Redemption.sol/Redemption.dbg.json +1 -1
- package/build/contracts/bridge/RedemptionWatchtower.sol/RedemptionWatchtower.dbg.json +1 -1
- package/build/contracts/bridge/VendingMachine.sol/VendingMachine.dbg.json +1 -1
- package/build/contracts/bridge/VendingMachineV2.sol/VendingMachineV2.dbg.json +1 -1
- package/build/contracts/bridge/VendingMachineV3.sol/VendingMachineV3.dbg.json +1 -1
- package/build/contracts/bridge/WalletProposalValidator.sol/WalletProposalValidator.dbg.json +1 -1
- package/build/contracts/bridge/Wallets.sol/Wallets.dbg.json +1 -1
- package/build/contracts/integrator/AbstractTBTCDepositor.sol/AbstractTBTCDepositor.dbg.json +1 -1
- package/build/contracts/integrator/IBridge.sol/IBridge.dbg.json +1 -1
- package/build/contracts/integrator/IBridge.sol/IBridgeTypes.dbg.json +1 -1
- package/build/contracts/integrator/ITBTCVault.sol/ITBTCVault.dbg.json +1 -1
- package/build/contracts/l2/L1BitcoinDepositor.sol/L1BitcoinDepositor.dbg.json +1 -1
- package/build/contracts/l2/L1BitcoinDepositor.sol/L1BitcoinDepositor.json +41 -2
- package/build/contracts/l2/L2BitcoinDepositor.sol/IL2WormholeGateway.dbg.json +1 -1
- package/build/contracts/l2/L2BitcoinDepositor.sol/L2BitcoinDepositor.dbg.json +1 -1
- package/build/contracts/l2/L2TBTC.sol/L2TBTC.dbg.json +1 -1
- package/build/contracts/l2/L2WormholeGateway.sol/L2WormholeGateway.dbg.json +1 -1
- package/build/contracts/l2/Wormhole.sol/IWormhole.dbg.json +1 -1
- package/build/contracts/l2/Wormhole.sol/IWormholeReceiver.dbg.json +1 -1
- package/build/contracts/l2/Wormhole.sol/IWormholeRelayer.dbg.json +1 -1
- package/build/contracts/l2/Wormhole.sol/IWormholeTokenBridge.dbg.json +1 -1
- package/build/contracts/l2/Wormhole.sol/WormholeTypes.dbg.json +1 -1
- package/build/contracts/l2/Wormhole.sol/WormholeUtils.dbg.json +1 -1
- package/build/contracts/maintainer/MaintainerProxy.sol/MaintainerProxy.dbg.json +1 -1
- package/build/contracts/relay/LightRelay.sol/ILightRelay.dbg.json +1 -1
- package/build/contracts/relay/LightRelay.sol/LightRelay.dbg.json +1 -1
- package/build/contracts/relay/LightRelay.sol/RelayUtils.dbg.json +1 -1
- package/build/contracts/relay/LightRelayMaintainerProxy.sol/LightRelayMaintainerProxy.dbg.json +1 -1
- package/build/contracts/test/BankStub.sol/BankStub.dbg.json +1 -1
- package/build/contracts/test/BridgeStub.sol/BridgeStub.dbg.json +1 -1
- package/build/contracts/test/HeartbeatStub.sol/HeartbeatStub.dbg.json +1 -1
- package/build/contracts/test/LightRelayStub.sol/LightRelayStub.dbg.json +1 -1
- package/build/contracts/test/ReceiveApprovalStub.sol/ReceiveApprovalStub.dbg.json +1 -1
- package/build/contracts/test/SepoliaLightRelay.sol/SepoliaLightRelay.dbg.json +1 -1
- package/build/contracts/test/SystemTestRelay.sol/SystemTestRelay.dbg.json +1 -1
- package/build/contracts/test/TestBitcoinTx.sol/TestBitcoinTx.dbg.json +1 -1
- package/build/contracts/test/TestERC20.sol/TestERC20.dbg.json +1 -1
- package/build/contracts/test/TestERC721.sol/TestERC721.dbg.json +1 -1
- package/build/contracts/test/TestEcdsaLib.sol/TestEcdsaLib.dbg.json +1 -1
- package/build/contracts/test/TestTBTCDepositor.sol/MockBridge.dbg.json +1 -1
- package/build/contracts/test/TestTBTCDepositor.sol/MockTBTCVault.dbg.json +1 -1
- package/build/contracts/test/TestTBTCDepositor.sol/TestTBTCDepositor.dbg.json +1 -1
- package/build/contracts/test/WormholeBridgeStub.sol/WormholeBridgeStub.dbg.json +1 -1
- package/build/contracts/token/TBTC.sol/TBTC.dbg.json +1 -1
- package/build/contracts/vault/DonationVault.sol/DonationVault.dbg.json +1 -1
- package/build/contracts/vault/IVault.sol/IVault.dbg.json +1 -1
- package/build/contracts/vault/TBTCOptimisticMinting.sol/TBTCOptimisticMinting.dbg.json +1 -1
- package/build/contracts/vault/TBTCVault.sol/TBTCVault.dbg.json +1 -1
- package/contracts/l2/L1BitcoinDepositor.sol +31 -0
- package/export/artifacts/@keep-network/ecdsa/contracts/EcdsaDkgValidator.sol/EcdsaDkgValidator.json +24 -24
- package/export/artifacts/@keep-network/ecdsa/contracts/WalletRegistry.sol/WalletRegistry.json +4999 -4814
- package/export/artifacts/@keep-network/ecdsa/contracts/libraries/EcdsaDkg.sol/EcdsaDkg.json +2 -2
- package/export/artifacts/@keep-network/ecdsa/contracts/libraries/EcdsaInactivity.sol/EcdsaInactivity.json +23 -23
- package/export/artifacts/@keep-network/random-beacon/contracts/ReimbursementPool.sol/ReimbursementPool.json +53 -53
- package/export/artifacts/@keep-network/sortition-pools/contracts/Chaosnet.sol/Chaosnet.json +21 -21
- package/export/artifacts/@keep-network/sortition-pools/contracts/Rewards.sol/Rewards.json +16 -16
- package/export/artifacts/@keep-network/sortition-pools/contracts/SortitionPool.sol/SortitionPool.json +206 -206
- package/export/artifacts/@keep-network/sortition-pools/contracts/SortitionTree.sol/SortitionTree.json +26 -26
- package/export/artifacts/@openzeppelin/contracts/governance/TimelockController.sol/TimelockController.json +107 -107
- package/export/artifacts/@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol/ERC1967Proxy.json +46 -46
- package/export/artifacts/@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol/ProxyAdmin.json +36 -36
- package/export/artifacts/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/TransparentUpgradeableProxy.json +78 -78
- package/export/artifacts/@openzeppelin/contracts/token/ERC721/ERC721.sol/ERC721.json +68 -68
- package/export/artifacts/@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol/ERC20Upgradeable.json +43 -43
- package/export/artifacts/@thesis/solidity-contracts/contracts/token/ERC20WithPermit.sol/ERC20WithPermit.json +79 -79
- package/export/artifacts/@thesis/solidity-contracts/contracts/token/MisfundRecovery.sol/MisfundRecovery.json +42 -42
- package/export/artifacts/contracts/Timelock.sol/Timelock.json +109 -109
- package/export/artifacts/contracts/bank/Bank.sol/Bank.json +77 -77
- package/export/artifacts/contracts/bridge/Bridge.sol/Bridge.json +338 -338
- package/export/artifacts/contracts/bridge/RedemptionWatchtower.sol/RedemptionWatchtower.json +128 -128
- package/export/artifacts/contracts/bridge/VendingMachine.sol/VendingMachine.json +108 -108
- package/export/artifacts/contracts/bridge/VendingMachineV2.sol/VendingMachineV2.json +63 -63
- package/export/artifacts/contracts/bridge/VendingMachineV3.sol/VendingMachineV3.json +65 -65
- package/export/artifacts/contracts/bridge/WalletProposalValidator.sol/WalletProposalValidator.json +67 -67
- package/export/artifacts/contracts/l2/L1BitcoinDepositor.sol/L1BitcoinDepositor.json +4431 -4171
- package/export/artifacts/contracts/l2/L2BitcoinDepositor.sol/L2BitcoinDepositor.json +62 -62
- package/export/artifacts/contracts/l2/L2TBTC.sol/L2TBTC.json +194 -194
- package/export/artifacts/contracts/l2/L2WormholeGateway.sol/L2WormholeGateway.json +102 -102
- package/export/artifacts/contracts/maintainer/MaintainerProxy.sol/MaintainerProxy.json +149 -149
- package/export/artifacts/contracts/relay/LightRelay.sol/LightRelay.json +76 -76
- package/export/artifacts/contracts/relay/LightRelayMaintainerProxy.sol/LightRelayMaintainerProxy.json +62 -62
- package/export/artifacts/contracts/test/BankStub.sol/BankStub.json +79 -79
- package/export/artifacts/contracts/test/BridgeStub.sol/BridgeStub.json +376 -376
- package/export/artifacts/contracts/test/HeartbeatStub.sol/HeartbeatStub.json +4 -4
- package/export/artifacts/contracts/test/LightRelayStub.sol/LightRelayStub.json +78 -78
- package/export/artifacts/contracts/test/ReceiveApprovalStub.sol/ReceiveApprovalStub.json +7 -7
- package/export/artifacts/contracts/test/SepoliaLightRelay.sol/SepoliaLightRelay.json +78 -78
- package/export/artifacts/contracts/test/SystemTestRelay.sol/SystemTestRelay.json +14 -14
- package/export/artifacts/contracts/test/TestBitcoinTx.sol/TestBitcoinTx.json +132 -132
- package/export/artifacts/contracts/test/TestERC20.sol/TestERC20.json +85 -85
- package/export/artifacts/contracts/test/TestERC721.sol/TestERC721.json +78 -78
- package/export/artifacts/contracts/test/TestEcdsaLib.sol/TestEcdsaLib.json +4 -4
- package/export/artifacts/contracts/test/TestTBTCDepositor.sol/MockBridge.json +34 -34
- package/export/artifacts/contracts/test/TestTBTCDepositor.sol/MockTBTCVault.json +20 -20
- package/export/artifacts/contracts/test/TestTBTCDepositor.sol/TestTBTCDepositor.json +52 -52
- package/export/artifacts/contracts/test/WormholeBridgeStub.sol/WormholeBridgeStub.json +37 -37
- package/export/artifacts/contracts/token/TBTC.sol/TBTC.json +104 -104
- package/export/artifacts/contracts/vault/DonationVault.sol/DonationVault.json +19 -19
- package/export/artifacts/contracts/vault/TBTCVault.sol/TBTCVault.json +184 -184
- package/export/typechain/factories/EcdsaAuthorization__factory.js +1 -1
- package/export/typechain/factories/IStaking__factory.js +24 -103
- package/export/typechain/factories/L1BitcoinDepositor__factory.js +40 -1
- package/export/typechain/factories/WalletRegistry__factory.js +1 -1
- package/package.json +2 -2
- package/artifacts/solcInputs/7c1f8f1dbded4c787d87a982d1fc8349.json +0 -410
- package/artifacts/solcInputs/7cc3eda3cb3ff2522d18b5e7b31ea228.json +0 -102
- package/artifacts/solcInputs/802132f7da69a8a4226cb9424480847b.json +0 -218
- package/artifacts/solcInputs/887fad6b16575ba42183543c324eeb0e.json +0 -335
- package/artifacts/solcInputs/98e272e2fbf178ec895387b6c503f9de.json +0 -68
- package/artifacts/solcInputs/b0025f1f7efe4824592ac0c9793776c3.json +0 -392
- package/artifacts/solcInputs/b7c5f3550cc22e16e6b6ea9582ccbee3.json +0 -341
- package/artifacts/solcInputs/d71d4b4434e6669852eaf643ebd2a7bc.json +0 -209
- package/artifacts/solcInputs/fccb130292c8c7cc958ab4fa31a3e180.json +0 -187
- package/export/deploy/00_resolve_relay.js +0 -83
- package/export/deploy/01_deploy_tbtc_v2_token.js +0 -70
- package/export/deploy/02_deploy_vending_machine.js +0 -84
- package/export/deploy/03_transfer_vending_machine_roles.js +0 -69
- package/export/deploy/04_deploy_bank.js +0 -73
- package/export/deploy/05_deploy_bridge.js +0 -178
- package/export/deploy/06_deploy_tbtc_vault.js +0 -80
- package/export/deploy/07_deploy_bridge_governance.js +0 -87
- package/export/deploy/08_deploy_maintainer_proxy.js +0 -80
- package/export/deploy/09_bank_update_bridge.js +0 -63
- package/export/deploy/10_authorize_spv_maintainer_in_bridge.js +0 -61
- package/export/deploy/11_transfer_bank_ownership.js +0 -60
- package/export/deploy/12_transfer_bridge_governance.js +0 -63
- package/export/deploy/13_transfer_bridge_governance_ownership.js +0 -60
- package/export/deploy/14_transfer_tbtc_vault_ownership.js +0 -60
- package/export/deploy/15_transfer_maintainer_proxy_ownership.js +0 -60
- package/export/deploy/16_initialize_wallet_owner.js +0 -63
- package/export/deploy/16_transfer_proxy_admin_ownership.js +0 -73
- package/export/deploy/17_authorize_maintainer_proxy_in_bridge.js +0 -63
- package/export/deploy/17_transfer_proxy_admin_ownership.js +0 -73
- package/export/deploy/18_authorize_maintainer_proxy_in_bridge.js +0 -63
- package/export/deploy/18_authorize_maintainer_proxy_in_reimbursement_pool.js +0 -63
- package/export/deploy/19_authorize_bridge_in_reimbursement_pool.js +0 -63
- package/export/deploy/19_authorize_maintainer_proxy_in_reimbursement_pool.js +0 -63
- package/export/deploy/20_authorize_bridge_in_reimbursement_pool.js +0 -63
- package/export/deploy/20_deploy_proxy_admin_with_deputy.js +0 -80
- package/export/deploy/21_transfer_reimbursement_pool_ownership.js +0 -60
- package/export/deploy/22_deploy_proxy_admin_with_deputy.js +0 -80
- package/export/deploy/24_transfer_maintainer_proxy_ownership.js +0 -60
- package/export/deploy/25_transfer_proxy_admin_ownership.js +0 -73
- package/export/deploy/26_authorize_maintainer_proxy_in_reimbursement_pool.js +0 -70
- package/export/deploy/27_authorize_bridge_in_reimbursement_pool.js +0 -70
- package/export/deploy/28_deploy_proxy_admin_with_deputy.js +0 -80
- package/export/deploy/34_deploy_wallet_coordinator.js +0 -115
- package/export/deploy/35_add_coordinator_address.js +0 -60
- package/export/deploy/35_transfer_wallet_coordinator_ownership.js +0 -60
- package/export/deploy/36_deploy_light_relay_maintainer_proxy.js +0 -86
- package/export/deploy/36_transfer_wallet_coordinator_ownership.js +0 -60
- package/export/deploy/37_authorize_maintainer_in_light_relay_maintainer_proxy.js +0 -65
- package/export/deploy/37_deploy_light_relay_maintainer_proxy.js +0 -86
- package/export/deploy/37_transfer_light_relay_maintainer_proxy_ownership.js +0 -60
- package/export/deploy/38_authorize_light_relay_maintainer_proxy_in_reimbursement_pool.js +0 -70
- package/export/deploy/38_authorize_maintainer_in_light_relay_maintainer_proxy.js +0 -65
- package/export/deploy/38_transfer_light_relay_maintainer_proxy_ownership.js +0 -60
- package/export/deploy/39_authorize_light_relay_maintainer_proxy_in_light_relay.js +0 -63
- package/export/deploy/39_authorize_light_relay_maintainer_proxy_in_reimbursement_pool.js +0 -70
- package/export/deploy/39_transfer_light_relay_maintainer_proxy_ownership.js +0 -60
- package/export/deploy/40_authorize_light_relay_maintainer_proxy_in_light_relay.js +0 -66
- package/export/deploy/40_authorize_light_relay_maintainer_proxy_in_reimbursement_pool.js +0 -70
- package/export/deploy/41_authorize_light_relay_maintainer_proxy_in_light_relay.js +0 -66
- package/export/typechain/GoerliLightRelay.js +0 -2
- package/export/typechain/RelayStub.js +0 -2
- package/export/typechain/TestRelay.js +0 -2
- package/export/typechain/WalletCoordinator.js +0 -2
- package/export/typechain/factories/GoerliLightRelay__factory.js +0 -535
- package/export/typechain/factories/RelayStub__factory.js +0 -546
- package/export/typechain/factories/TestRelay__factory.js +0 -168
- package/export/typechain/factories/WalletCoordinator__factory.js +0 -1121
- package/export.json +0 -16130
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"address": "
|
|
2
|
+
"address": "0x1a6a3e7Bb246158dF31d8f924B84D961669Ba4e5",
|
|
3
3
|
"abi": [
|
|
4
4
|
{
|
|
5
5
|
"anonymous": false,
|
|
@@ -434,43 +434,43 @@
|
|
|
434
434
|
"type": "function"
|
|
435
435
|
}
|
|
436
436
|
],
|
|
437
|
-
"transactionHash": "
|
|
437
|
+
"transactionHash": "0x29c860a5fe9d6725444ca4f597971645f9160f6e98040385f38c0ac8ad80f04f",
|
|
438
438
|
"receipt": {
|
|
439
439
|
"to": null,
|
|
440
|
-
"from": "
|
|
441
|
-
"contractAddress": "
|
|
442
|
-
"transactionIndex":
|
|
443
|
-
"gasUsed": "
|
|
444
|
-
"logsBloom": "
|
|
445
|
-
"blockHash": "
|
|
446
|
-
"transactionHash": "
|
|
440
|
+
"from": "0x70997970C51812dc3A010C7d01b50e0d17dc79C8",
|
|
441
|
+
"contractAddress": "0x1a6a3e7Bb246158dF31d8f924B84D961669Ba4e5",
|
|
442
|
+
"transactionIndex": 0,
|
|
443
|
+
"gasUsed": "1872803",
|
|
444
|
+
"logsBloom": "0x00000000000000000002000080000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000800020000000000000000001800000000000000000000000000000000400000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000001000000000000000000000000000000",
|
|
445
|
+
"blockHash": "0xf2a6f08d3cdb1b4fe313c29d9e92697e1320655f4a45c433ef70655634552a51",
|
|
446
|
+
"transactionHash": "0x29c860a5fe9d6725444ca4f597971645f9160f6e98040385f38c0ac8ad80f04f",
|
|
447
447
|
"logs": [
|
|
448
448
|
{
|
|
449
|
-
"transactionIndex":
|
|
450
|
-
"blockNumber":
|
|
451
|
-
"transactionHash": "
|
|
452
|
-
"address": "
|
|
449
|
+
"transactionIndex": 0,
|
|
450
|
+
"blockNumber": 46,
|
|
451
|
+
"transactionHash": "0x29c860a5fe9d6725444ca4f597971645f9160f6e98040385f38c0ac8ad80f04f",
|
|
452
|
+
"address": "0x1a6a3e7Bb246158dF31d8f924B84D961669Ba4e5",
|
|
453
453
|
"topics": [
|
|
454
454
|
"0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0",
|
|
455
455
|
"0x0000000000000000000000000000000000000000000000000000000000000000",
|
|
456
|
-
"
|
|
456
|
+
"0x00000000000000000000000070997970c51812dc3a010c7d01b50e0d17dc79c8"
|
|
457
457
|
],
|
|
458
458
|
"data": "0x",
|
|
459
|
-
"logIndex":
|
|
460
|
-
"blockHash": "
|
|
459
|
+
"logIndex": 0,
|
|
460
|
+
"blockHash": "0xf2a6f08d3cdb1b4fe313c29d9e92697e1320655f4a45c433ef70655634552a51"
|
|
461
461
|
}
|
|
462
462
|
],
|
|
463
|
-
"blockNumber":
|
|
464
|
-
"cumulativeGasUsed": "
|
|
463
|
+
"blockNumber": 46,
|
|
464
|
+
"cumulativeGasUsed": "1872803",
|
|
465
465
|
"status": 1,
|
|
466
466
|
"byzantium": true
|
|
467
467
|
},
|
|
468
468
|
"args": [],
|
|
469
469
|
"numDeployments": 1,
|
|
470
|
-
"solcInputHash": "
|
|
471
|
-
"metadata": "{\"compiler\":{\"version\":\"0.8.17+commit.8df45f5f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"newStatus\",\"type\":\"bool\"}],\"name\":\"AuthorizationRequirementChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"blockHeight\",\"type\":\"uint256\"}],\"name\":\"Genesis\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newLength\",\"type\":\"uint256\"}],\"name\":\"ProofLengthChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldDifficulty\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newDifficulty\",\"type\":\"uint256\"}],\"name\":\"Retarget\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"submitter\",\"type\":\"address\"}],\"name\":\"SubmitterAuthorized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"submitter\",\"type\":\"address\"}],\"name\":\"SubmitterDeauthorized\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"authorizationRequired\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"submitter\",\"type\":\"address\"}],\"name\":\"authorize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"currentEpoch\",\"outputs\":[{\"internalType\":\"uint64\",\"name\":\"\",\"type\":\"uint64\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"submitter\",\"type\":\"address\"}],\"name\":\"deauthorize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"genesisHeader\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"genesisHeight\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"genesisProofLength\",\"type\":\"uint64\"}],\"name\":\"genesis\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"genesisEpoch\",\"outputs\":[{\"internalType\":\"uint64\",\"name\":\"\",\"type\":\"uint64\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"}],\"name\":\"getBlockDifficulty\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCurrentAndPrevEpochDifficulty\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"current\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"previous\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCurrentEpochDifficulty\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"epochNumber\",\"type\":\"uint256\"}],\"name\":\"getEpochDifficulty\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getPrevEpochDifficulty\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getRelayRange\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"relayGenesis\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"currentEpochEnd\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"isAuthorized\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"proofLength\",\"outputs\":[{\"internalType\":\"uint64\",\"name\":\"\",\"type\":\"uint64\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"ready\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"headers\",\"type\":\"bytes\"}],\"name\":\"retarget\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bool\",\"name\":\"status\",\"type\":\"bool\"}],\"name\":\"setAuthorizationStatus\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"newLength\",\"type\":\"uint64\"}],\"name\":\"setProofLength\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"headers\",\"type\":\"bytes\"}],\"name\":\"validateChain\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"startingHeaderTimestamp\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"headerCount\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"THE RELAY MUST NOT BE USED BEFORE GENESIS AND AT LEAST ONE RETARGET.\",\"kind\":\"dev\",\"methods\":{\"authorize(address)\":{\"params\":{\"submitter\":\"The address to be authorised.\"}},\"deauthorize(address)\":{\"params\":{\"submitter\":\"The address to be deauthorised.\"}},\"genesis(bytes,uint256,uint64)\":{\"details\":\"If the relay is used by querying the current and previous epoch difficulty, at least one retarget needs to be provided after genesis; otherwise the prevEpochDifficulty will be uninitialised and zero.\",\"params\":{\"genesisHeader\":\"The first block header of the genesis epoch.\",\"genesisHeight\":\"The block number of the first block of the epoch.\",\"genesisProofLength\":\"The number of blocks required to accept a proof.\"}},\"getBlockDifficulty(uint256)\":{\"params\":{\"blockNumber\":\"The number of the block. Must fall within the relay range (at or after the relay genesis, and at or before the end of the most recent epoch proven to the relay).\"},\"returns\":{\"_0\":\"The difficulty of the epoch.\"}},\"getCurrentEpochDifficulty()\":{\"details\":\"returns 0 if the relay is not ready.\",\"returns\":{\"_0\":\"The difficulty of the current epoch.\"}},\"getEpochDifficulty(uint256)\":{\"params\":{\"epochNumber\":\"The number of the epoch (the height of the first block of the epoch, divided by 2016). Must fall within the relay range.\"},\"returns\":{\"_0\":\"The difficulty of the epoch.\"}},\"getPrevEpochDifficulty()\":{\"details\":\"Returns 0 if the relay is not ready or has not had a retarget.\",\"returns\":{\"_0\":\"The difficulty of the previous epoch.\"}},\"getRelayRange()\":{\"details\":\"Assumes that the genesis has been set correctly. Additionally, if the next epoch after the current one has the exact same difficulty, headers for it can be validated as well. This function should be used for informative purposes, e.g. to determine whether a retarget must be provided before submitting a header chain for validation.\",\"returns\":{\"currentEpochEnd\":\"The height of the last block that can be included in header chains for the relay to validate.\",\"relayGenesis\":\"The height of the earliest block that can be included in header chains for the relay to validate.\"}},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.\"},\"retarget(bytes)\":{\"details\":\"Checks that the first X blocks are valid in the most recent epoch, that the difficulty of the new epoch is calculated correctly according to the block timestamps, and that the next X blocks would be valid in the new epoch. We have no information of block heights, so we cannot enforce that retargets only happen every 2016 blocks; instead, we assume that this is the case if a valid proof of work is provided. It is possible to cheat the relay by providing X blocks from earlier in the most recent epoch, and then mining X new blocks after them. However, each of these malicious blocks would have to be mined to a higher difficulty than the legitimate ones. Alternatively, if the retarget has not been performed yet, one could first mine X blocks in the old difficulty with timestamps set far in the future, and then another X blocks at a greatly reduced difficulty. In either case, cheating the realy requires more work than mining X legitimate blocks. Only the most recent epoch is vulnerable to these attacks; once a retarget has been proven to the relay, the epoch is immutable even if a contradictory proof were to be presented later.\",\"params\":{\"headers\":\"A chain of headers including the last X blocks before the retarget, followed by the first X blocks after the retarget, where X equals the current proof length.\"}},\"setAuthorizationStatus(bool)\":{\"params\":{\"status\":\"True if authorisation is to be required, false if not.\"}},\"setProofLength(uint64)\":{\"details\":\"For production, a high number (e.g. 20-50) is recommended. Small numbers are accepted but should only be used for testing.\",\"params\":{\"newLength\":\"The required number of blocks. Must be less than 2016.\"}},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"},\"validateChain(bytes)\":{\"details\":\"A chain of headers is accepted as valid if: - Its length is between 2 and 2015 headers. - Headers in the chain are sequential and refer to previous digests. - Each header is mined with the correct amount of work. - The difficulty in each header matches an epoch of the relay, as determined by the headers' timestamps. The headers must be between the genesis epoch and the latest proven epoch (inclusive). If the chain contains a retarget, it is accepted if the retarget has already been proven to the relay. If the chain contains blocks of an epoch that has not been proven to the relay (after a retarget within the header chain, or when the entire chain falls within an epoch that has not been proven yet), it will be rejected. One exception to this is when two subsequent epochs have exactly the same difficulty; headers from the latter epoch will be accepted if the previous epoch has been proven to the relay. This is because it is not possible to distinguish such headers from headers of the previous epoch. If the difficulty increases significantly between relay genesis and the present, creating fraudulent proofs for earlier epochs becomes easier. Users of the relay should check the timestamps of valid headers and only accept appropriately recent ones.\",\"params\":{\"headers\":\"A chain of 2 to 2015 bitcoin headers.\"},\"returns\":{\"headerCount\":\"The number of headers.\",\"startingHeaderTimestamp\":\"The timestamp of the first header.\"}}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"authorize(address)\":{\"notice\":\"Authorise the given address to submit retarget proofs.\"},\"deauthorize(address)\":{\"notice\":\"Rescind the authorisation of the submitter to retarget.\"},\"genesis(bytes,uint256,uint64)\":{\"notice\":\"Establish a starting point for the relay by providing the target, timestamp and blockheight of the first block of the relay genesis epoch.\"},\"getBlockDifficulty(uint256)\":{\"notice\":\"Get the difficulty of the specified block.\"},\"getCurrentEpochDifficulty()\":{\"notice\":\"Returns the difficulty of the current epoch.\"},\"getEpochDifficulty(uint256)\":{\"notice\":\"Get the difficulty of the specified epoch.\"},\"getPrevEpochDifficulty()\":{\"notice\":\"Returns the difficulty of the previous epoch.\"},\"getRelayRange()\":{\"notice\":\"Get the range of blocks the relay can accept proofs for.\"},\"retarget(bytes)\":{\"notice\":\"Add a new epoch to the relay by providing a proof of the difficulty before and after the retarget.\"},\"setAuthorizationStatus(bool)\":{\"notice\":\"Set whether the relay requires retarget submitters to be pre-authorised by governance.\"},\"setProofLength(uint64)\":{\"notice\":\"Set the number of blocks required to accept a header chain.\"},\"validateChain(bytes)\":{\"notice\":\"Check whether a given chain of headers should be accepted as valid within the rules of the relay. If the validation fails, this function throws an exception.\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/relay/LightRelay.sol\":\"LightRelay\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":1000},\"remappings\":[]},\"sources\":{\"@keep-network/bitcoin-spv-sol/contracts/BTCUtils.sol\":{\"content\":\"pragma solidity ^0.8.4;\\n\\n/** @title BitcoinSPV */\\n/** @author Summa (https://summa.one) */\\n\\nimport {BytesLib} from \\\"./BytesLib.sol\\\";\\nimport {SafeMath} from \\\"./SafeMath.sol\\\";\\n\\nlibrary BTCUtils {\\n using BytesLib for bytes;\\n using SafeMath for uint256;\\n\\n // The target at minimum Difficulty. Also the target of the genesis block\\n uint256 public constant DIFF1_TARGET = 0xffff0000000000000000000000000000000000000000000000000000;\\n\\n uint256 public constant RETARGET_PERIOD = 2 * 7 * 24 * 60 * 60; // 2 weeks in seconds\\n uint256 public constant RETARGET_PERIOD_BLOCKS = 2016; // 2 weeks in blocks\\n\\n uint256 public constant ERR_BAD_ARG = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff;\\n\\n /* ***** */\\n /* UTILS */\\n /* ***** */\\n\\n /// @notice Determines the length of a VarInt in bytes\\n /// @dev A VarInt of >1 byte is prefixed with a flag indicating its length\\n /// @param _flag The first byte of a VarInt\\n /// @return The number of non-flag bytes in the VarInt\\n function determineVarIntDataLength(bytes memory _flag) internal pure returns (uint8) {\\n return determineVarIntDataLengthAt(_flag, 0);\\n }\\n\\n /// @notice Determines the length of a VarInt in bytes\\n /// @dev A VarInt of >1 byte is prefixed with a flag indicating its length\\n /// @param _b The byte array containing a VarInt\\n /// @param _at The position of the VarInt in the array\\n /// @return The number of non-flag bytes in the VarInt\\n function determineVarIntDataLengthAt(bytes memory _b, uint256 _at) internal pure returns (uint8) {\\n if (uint8(_b[_at]) == 0xff) {\\n return 8; // one-byte flag, 8 bytes data\\n }\\n if (uint8(_b[_at]) == 0xfe) {\\n return 4; // one-byte flag, 4 bytes data\\n }\\n if (uint8(_b[_at]) == 0xfd) {\\n return 2; // one-byte flag, 2 bytes data\\n }\\n\\n return 0; // flag is data\\n }\\n\\n /// @notice Parse a VarInt into its data length and the number it represents\\n /// @dev Useful for Parsing Vins and Vouts. Returns ERR_BAD_ARG if insufficient bytes.\\n /// Caller SHOULD explicitly handle this case (or bubble it up)\\n /// @param _b A byte-string starting with a VarInt\\n /// @return number of bytes in the encoding (not counting the tag), the encoded int\\n function parseVarInt(bytes memory _b) internal pure returns (uint256, uint256) {\\n return parseVarIntAt(_b, 0);\\n }\\n\\n /// @notice Parse a VarInt into its data length and the number it represents\\n /// @dev Useful for Parsing Vins and Vouts. Returns ERR_BAD_ARG if insufficient bytes.\\n /// Caller SHOULD explicitly handle this case (or bubble it up)\\n /// @param _b A byte-string containing a VarInt\\n /// @param _at The position of the VarInt\\n /// @return number of bytes in the encoding (not counting the tag), the encoded int\\n function parseVarIntAt(bytes memory _b, uint256 _at) internal pure returns (uint256, uint256) {\\n uint8 _dataLen = determineVarIntDataLengthAt(_b, _at);\\n\\n if (_dataLen == 0) {\\n return (0, uint8(_b[_at]));\\n }\\n if (_b.length < 1 + _dataLen + _at) {\\n return (ERR_BAD_ARG, 0);\\n }\\n uint256 _number;\\n if (_dataLen == 2) {\\n _number = reverseUint16(uint16(_b.slice2(1 + _at)));\\n } else if (_dataLen == 4) {\\n _number = reverseUint32(uint32(_b.slice4(1 + _at)));\\n } else if (_dataLen == 8) {\\n _number = reverseUint64(uint64(_b.slice8(1 + _at)));\\n }\\n return (_dataLen, _number);\\n }\\n\\n /// @notice Changes the endianness of a byte array\\n /// @dev Returns a new, backwards, bytes\\n /// @param _b The bytes to reverse\\n /// @return The reversed bytes\\n function reverseEndianness(bytes memory _b) internal pure returns (bytes memory) {\\n bytes memory _newValue = new bytes(_b.length);\\n\\n for (uint i = 0; i < _b.length; i++) {\\n _newValue[_b.length - i - 1] = _b[i];\\n }\\n\\n return _newValue;\\n }\\n\\n /// @notice Changes the endianness of a uint256\\n /// @dev https://graphics.stanford.edu/~seander/bithacks.html#ReverseParallel\\n /// @param _b The unsigned integer to reverse\\n /// @return v The reversed value\\n function reverseUint256(uint256 _b) internal pure returns (uint256 v) {\\n v = _b;\\n\\n // swap bytes\\n v = ((v >> 8) & 0x00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF) |\\n ((v & 0x00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF) << 8);\\n // swap 2-byte long pairs\\n v = ((v >> 16) & 0x0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF) |\\n ((v & 0x0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF) << 16);\\n // swap 4-byte long pairs\\n v = ((v >> 32) & 0x00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF) |\\n ((v & 0x00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF) << 32);\\n // swap 8-byte long pairs\\n v = ((v >> 64) & 0x0000000000000000FFFFFFFFFFFFFFFF0000000000000000FFFFFFFFFFFFFFFF) |\\n ((v & 0x0000000000000000FFFFFFFFFFFFFFFF0000000000000000FFFFFFFFFFFFFFFF) << 64);\\n // swap 16-byte long pairs\\n v = (v >> 128) | (v << 128);\\n }\\n\\n /// @notice Changes the endianness of a uint64\\n /// @param _b The unsigned integer to reverse\\n /// @return v The reversed value\\n function reverseUint64(uint64 _b) internal pure returns (uint64 v) {\\n v = _b;\\n\\n // swap bytes\\n v = ((v >> 8) & 0x00FF00FF00FF00FF) |\\n ((v & 0x00FF00FF00FF00FF) << 8);\\n // swap 2-byte long pairs\\n v = ((v >> 16) & 0x0000FFFF0000FFFF) |\\n ((v & 0x0000FFFF0000FFFF) << 16);\\n // swap 4-byte long pairs\\n v = (v >> 32) | (v << 32);\\n }\\n\\n /// @notice Changes the endianness of a uint32\\n /// @param _b The unsigned integer to reverse\\n /// @return v The reversed value\\n function reverseUint32(uint32 _b) internal pure returns (uint32 v) {\\n v = _b;\\n\\n // swap bytes\\n v = ((v >> 8) & 0x00FF00FF) |\\n ((v & 0x00FF00FF) << 8);\\n // swap 2-byte long pairs\\n v = (v >> 16) | (v << 16);\\n }\\n\\n /// @notice Changes the endianness of a uint24\\n /// @param _b The unsigned integer to reverse\\n /// @return v The reversed value\\n function reverseUint24(uint24 _b) internal pure returns (uint24 v) {\\n v = (_b << 16) | (_b & 0x00FF00) | (_b >> 16);\\n }\\n\\n /// @notice Changes the endianness of a uint16\\n /// @param _b The unsigned integer to reverse\\n /// @return v The reversed value\\n function reverseUint16(uint16 _b) internal pure returns (uint16 v) {\\n v = (_b << 8) | (_b >> 8);\\n }\\n\\n\\n /// @notice Converts big-endian bytes to a uint\\n /// @dev Traverses the byte array and sums the bytes\\n /// @param _b The big-endian bytes-encoded integer\\n /// @return The integer representation\\n function bytesToUint(bytes memory _b) internal pure returns (uint256) {\\n uint256 _number;\\n\\n for (uint i = 0; i < _b.length; i++) {\\n _number = _number + uint8(_b[i]) * (2 ** (8 * (_b.length - (i + 1))));\\n }\\n\\n return _number;\\n }\\n\\n /// @notice Get the last _num bytes from a byte array\\n /// @param _b The byte array to slice\\n /// @param _num The number of bytes to extract from the end\\n /// @return The last _num bytes of _b\\n function lastBytes(bytes memory _b, uint256 _num) internal pure returns (bytes memory) {\\n uint256 _start = _b.length.sub(_num);\\n\\n return _b.slice(_start, _num);\\n }\\n\\n /// @notice Implements bitcoin's hash160 (rmd160(sha2()))\\n /// @dev abi.encodePacked changes the return to bytes instead of bytes32\\n /// @param _b The pre-image\\n /// @return The digest\\n function hash160(bytes memory _b) internal pure returns (bytes memory) {\\n return abi.encodePacked(ripemd160(abi.encodePacked(sha256(_b))));\\n }\\n\\n /// @notice Implements bitcoin's hash160 (sha2 + ripemd160)\\n /// @dev sha2 precompile at address(2), ripemd160 at address(3)\\n /// @param _b The pre-image\\n /// @return res The digest\\n function hash160View(bytes memory _b) internal view returns (bytes20 res) {\\n // solium-disable-next-line security/no-inline-assembly\\n assembly {\\n pop(staticcall(gas(), 2, add(_b, 32), mload(_b), 0x00, 32))\\n pop(staticcall(gas(), 3, 0x00, 32, 0x00, 32))\\n // read from position 12 = 0c\\n res := mload(0x0c)\\n }\\n }\\n\\n /// @notice Implements bitcoin's hash256 (double sha2)\\n /// @dev abi.encodePacked changes the return to bytes instead of bytes32\\n /// @param _b The pre-image\\n /// @return The digest\\n function hash256(bytes memory _b) internal pure returns (bytes32) {\\n return sha256(abi.encodePacked(sha256(_b)));\\n }\\n\\n /// @notice Implements bitcoin's hash256 (double sha2)\\n /// @dev sha2 is precompiled smart contract located at address(2)\\n /// @param _b The pre-image\\n /// @return res The digest\\n function hash256View(bytes memory _b) internal view returns (bytes32 res) {\\n // solium-disable-next-line security/no-inline-assembly\\n assembly {\\n pop(staticcall(gas(), 2, add(_b, 32), mload(_b), 0x00, 32))\\n pop(staticcall(gas(), 2, 0x00, 32, 0x00, 32))\\n res := mload(0x00)\\n }\\n }\\n\\n /// @notice Implements bitcoin's hash256 on a pair of bytes32\\n /// @dev sha2 is precompiled smart contract located at address(2)\\n /// @param _a The first bytes32 of the pre-image\\n /// @param _b The second bytes32 of the pre-image\\n /// @return res The digest\\n function hash256Pair(bytes32 _a, bytes32 _b) internal view returns (bytes32 res) {\\n // solium-disable-next-line security/no-inline-assembly\\n assembly {\\n mstore(0x00, _a)\\n mstore(0x20, _b)\\n pop(staticcall(gas(), 2, 0x00, 64, 0x00, 32))\\n pop(staticcall(gas(), 2, 0x00, 32, 0x00, 32))\\n res := mload(0x00)\\n }\\n }\\n\\n /// @notice Implements bitcoin's hash256 (double sha2)\\n /// @dev sha2 is precompiled smart contract located at address(2)\\n /// @param _b The array containing the pre-image\\n /// @param at The start of the pre-image\\n /// @param len The length of the pre-image\\n /// @return res The digest\\n function hash256Slice(\\n bytes memory _b,\\n uint256 at,\\n uint256 len\\n ) internal view returns (bytes32 res) {\\n // solium-disable-next-line security/no-inline-assembly\\n assembly {\\n pop(staticcall(gas(), 2, add(_b, add(32, at)), len, 0x00, 32))\\n pop(staticcall(gas(), 2, 0x00, 32, 0x00, 32))\\n res := mload(0x00)\\n }\\n }\\n\\n /* ************ */\\n /* Legacy Input */\\n /* ************ */\\n\\n /// @notice Extracts the nth input from the vin (0-indexed)\\n /// @dev Iterates over the vin. If you need to extract several, write a custom function\\n /// @param _vin The vin as a tightly-packed byte array\\n /// @param _index The 0-indexed location of the input to extract\\n /// @return The input as a byte array\\n function extractInputAtIndex(bytes memory _vin, uint256 _index) internal pure returns (bytes memory) {\\n uint256 _varIntDataLen;\\n uint256 _nIns;\\n\\n (_varIntDataLen, _nIns) = parseVarInt(_vin);\\n require(_varIntDataLen != ERR_BAD_ARG, \\\"Read overrun during VarInt parsing\\\");\\n require(_index < _nIns, \\\"Vin read overrun\\\");\\n\\n uint256 _len = 0;\\n uint256 _offset = 1 + _varIntDataLen;\\n\\n for (uint256 _i = 0; _i < _index; _i ++) {\\n _len = determineInputLengthAt(_vin, _offset);\\n require(_len != ERR_BAD_ARG, \\\"Bad VarInt in scriptSig\\\");\\n _offset = _offset + _len;\\n }\\n\\n _len = determineInputLengthAt(_vin, _offset);\\n require(_len != ERR_BAD_ARG, \\\"Bad VarInt in scriptSig\\\");\\n return _vin.slice(_offset, _len);\\n }\\n\\n /// @notice Determines whether an input is legacy\\n /// @dev False if no scriptSig, otherwise True\\n /// @param _input The input\\n /// @return True for legacy, False for witness\\n function isLegacyInput(bytes memory _input) internal pure returns (bool) {\\n return _input[36] != hex\\\"00\\\";\\n }\\n\\n /// @notice Determines the length of a scriptSig in an input\\n /// @dev Will return 0 if passed a witness input.\\n /// @param _input The LEGACY input\\n /// @return The length of the script sig\\n function extractScriptSigLen(bytes memory _input) internal pure returns (uint256, uint256) {\\n return extractScriptSigLenAt(_input, 0);\\n }\\n\\n /// @notice Determines the length of a scriptSig in an input\\n /// starting at the specified position\\n /// @dev Will return 0 if passed a witness input.\\n /// @param _input The byte array containing the LEGACY input\\n /// @param _at The position of the input in the array\\n /// @return The length of the script sig\\n function extractScriptSigLenAt(bytes memory _input, uint256 _at) internal pure returns (uint256, uint256) {\\n if (_input.length < 37 + _at) {\\n return (ERR_BAD_ARG, 0);\\n }\\n\\n uint256 _varIntDataLen;\\n uint256 _scriptSigLen;\\n (_varIntDataLen, _scriptSigLen) = parseVarIntAt(_input, _at + 36);\\n\\n return (_varIntDataLen, _scriptSigLen);\\n }\\n\\n /// @notice Determines the length of an input from its scriptSig\\n /// @dev 36 for outpoint, 1 for scriptSig length, 4 for sequence\\n /// @param _input The input\\n /// @return The length of the input in bytes\\n function determineInputLength(bytes memory _input) internal pure returns (uint256) {\\n return determineInputLengthAt(_input, 0);\\n }\\n\\n /// @notice Determines the length of an input from its scriptSig,\\n /// starting at the specified position\\n /// @dev 36 for outpoint, 1 for scriptSig length, 4 for sequence\\n /// @param _input The byte array containing the input\\n /// @param _at The position of the input in the array\\n /// @return The length of the input in bytes\\n function determineInputLengthAt(bytes memory _input, uint256 _at) internal pure returns (uint256) {\\n uint256 _varIntDataLen;\\n uint256 _scriptSigLen;\\n (_varIntDataLen, _scriptSigLen) = extractScriptSigLenAt(_input, _at);\\n if (_varIntDataLen == ERR_BAD_ARG) {\\n return ERR_BAD_ARG;\\n }\\n\\n return 36 + 1 + _varIntDataLen + _scriptSigLen + 4;\\n }\\n\\n /// @notice Extracts the LE sequence bytes from an input\\n /// @dev Sequence is used for relative time locks\\n /// @param _input The LEGACY input\\n /// @return The sequence bytes (LE uint)\\n function extractSequenceLELegacy(bytes memory _input) internal pure returns (bytes4) {\\n uint256 _varIntDataLen;\\n uint256 _scriptSigLen;\\n (_varIntDataLen, _scriptSigLen) = extractScriptSigLen(_input);\\n require(_varIntDataLen != ERR_BAD_ARG, \\\"Bad VarInt in scriptSig\\\");\\n return _input.slice4(36 + 1 + _varIntDataLen + _scriptSigLen);\\n }\\n\\n /// @notice Extracts the sequence from the input\\n /// @dev Sequence is a 4-byte little-endian number\\n /// @param _input The LEGACY input\\n /// @return The sequence number (big-endian uint)\\n function extractSequenceLegacy(bytes memory _input) internal pure returns (uint32) {\\n uint32 _leSeqence = uint32(extractSequenceLELegacy(_input));\\n uint32 _beSequence = reverseUint32(_leSeqence);\\n return _beSequence;\\n }\\n /// @notice Extracts the VarInt-prepended scriptSig from the input in a tx\\n /// @dev Will return hex\\\"00\\\" if passed a witness input\\n /// @param _input The LEGACY input\\n /// @return The length-prepended scriptSig\\n function extractScriptSig(bytes memory _input) internal pure returns (bytes memory) {\\n uint256 _varIntDataLen;\\n uint256 _scriptSigLen;\\n (_varIntDataLen, _scriptSigLen) = extractScriptSigLen(_input);\\n require(_varIntDataLen != ERR_BAD_ARG, \\\"Bad VarInt in scriptSig\\\");\\n return _input.slice(36, 1 + _varIntDataLen + _scriptSigLen);\\n }\\n\\n\\n /* ************* */\\n /* Witness Input */\\n /* ************* */\\n\\n /// @notice Extracts the LE sequence bytes from an input\\n /// @dev Sequence is used for relative time locks\\n /// @param _input The WITNESS input\\n /// @return The sequence bytes (LE uint)\\n function extractSequenceLEWitness(bytes memory _input) internal pure returns (bytes4) {\\n return _input.slice4(37);\\n }\\n\\n /// @notice Extracts the sequence from the input in a tx\\n /// @dev Sequence is a 4-byte little-endian number\\n /// @param _input The WITNESS input\\n /// @return The sequence number (big-endian uint)\\n function extractSequenceWitness(bytes memory _input) internal pure returns (uint32) {\\n uint32 _leSeqence = uint32(extractSequenceLEWitness(_input));\\n uint32 _inputeSequence = reverseUint32(_leSeqence);\\n return _inputeSequence;\\n }\\n\\n /// @notice Extracts the outpoint from the input in a tx\\n /// @dev 32-byte tx id with 4-byte index\\n /// @param _input The input\\n /// @return The outpoint (LE bytes of prev tx hash + LE bytes of prev tx index)\\n function extractOutpoint(bytes memory _input) internal pure returns (bytes memory) {\\n return _input.slice(0, 36);\\n }\\n\\n /// @notice Extracts the outpoint tx id from an input\\n /// @dev 32-byte tx id\\n /// @param _input The input\\n /// @return The tx id (little-endian bytes)\\n function extractInputTxIdLE(bytes memory _input) internal pure returns (bytes32) {\\n return _input.slice32(0);\\n }\\n\\n /// @notice Extracts the outpoint tx id from an input\\n /// starting at the specified position\\n /// @dev 32-byte tx id\\n /// @param _input The byte array containing the input\\n /// @param _at The position of the input\\n /// @return The tx id (little-endian bytes)\\n function extractInputTxIdLeAt(bytes memory _input, uint256 _at) internal pure returns (bytes32) {\\n return _input.slice32(_at);\\n }\\n\\n /// @notice Extracts the LE tx input index from the input in a tx\\n /// @dev 4-byte tx index\\n /// @param _input The input\\n /// @return The tx index (little-endian bytes)\\n function extractTxIndexLE(bytes memory _input) internal pure returns (bytes4) {\\n return _input.slice4(32);\\n }\\n\\n /// @notice Extracts the LE tx input index from the input in a tx\\n /// starting at the specified position\\n /// @dev 4-byte tx index\\n /// @param _input The byte array containing the input\\n /// @param _at The position of the input\\n /// @return The tx index (little-endian bytes)\\n function extractTxIndexLeAt(bytes memory _input, uint256 _at) internal pure returns (bytes4) {\\n return _input.slice4(32 + _at);\\n }\\n\\n /* ****** */\\n /* Output */\\n /* ****** */\\n\\n /// @notice Determines the length of an output\\n /// @dev Works with any properly formatted output\\n /// @param _output The output\\n /// @return The length indicated by the prefix, error if invalid length\\n function determineOutputLength(bytes memory _output) internal pure returns (uint256) {\\n return determineOutputLengthAt(_output, 0);\\n }\\n\\n /// @notice Determines the length of an output\\n /// starting at the specified position\\n /// @dev Works with any properly formatted output\\n /// @param _output The byte array containing the output\\n /// @param _at The position of the output\\n /// @return The length indicated by the prefix, error if invalid length\\n function determineOutputLengthAt(bytes memory _output, uint256 _at) internal pure returns (uint256) {\\n if (_output.length < 9 + _at) {\\n return ERR_BAD_ARG;\\n }\\n uint256 _varIntDataLen;\\n uint256 _scriptPubkeyLength;\\n (_varIntDataLen, _scriptPubkeyLength) = parseVarIntAt(_output, 8 + _at);\\n\\n if (_varIntDataLen == ERR_BAD_ARG) {\\n return ERR_BAD_ARG;\\n }\\n\\n // 8-byte value, 1-byte for tag itself\\n return 8 + 1 + _varIntDataLen + _scriptPubkeyLength;\\n }\\n\\n /// @notice Extracts the output at a given index in the TxOuts vector\\n /// @dev Iterates over the vout. If you need to extract multiple, write a custom function\\n /// @param _vout The _vout to extract from\\n /// @param _index The 0-indexed location of the output to extract\\n /// @return The specified output\\n function extractOutputAtIndex(bytes memory _vout, uint256 _index) internal pure returns (bytes memory) {\\n uint256 _varIntDataLen;\\n uint256 _nOuts;\\n\\n (_varIntDataLen, _nOuts) = parseVarInt(_vout);\\n require(_varIntDataLen != ERR_BAD_ARG, \\\"Read overrun during VarInt parsing\\\");\\n require(_index < _nOuts, \\\"Vout read overrun\\\");\\n\\n uint256 _len = 0;\\n uint256 _offset = 1 + _varIntDataLen;\\n\\n for (uint256 _i = 0; _i < _index; _i ++) {\\n _len = determineOutputLengthAt(_vout, _offset);\\n require(_len != ERR_BAD_ARG, \\\"Bad VarInt in scriptPubkey\\\");\\n _offset += _len;\\n }\\n\\n _len = determineOutputLengthAt(_vout, _offset);\\n require(_len != ERR_BAD_ARG, \\\"Bad VarInt in scriptPubkey\\\");\\n return _vout.slice(_offset, _len);\\n }\\n\\n /// @notice Extracts the value bytes from the output in a tx\\n /// @dev Value is an 8-byte little-endian number\\n /// @param _output The output\\n /// @return The output value as LE bytes\\n function extractValueLE(bytes memory _output) internal pure returns (bytes8) {\\n return _output.slice8(0);\\n }\\n\\n /// @notice Extracts the value from the output in a tx\\n /// @dev Value is an 8-byte little-endian number\\n /// @param _output The output\\n /// @return The output value\\n function extractValue(bytes memory _output) internal pure returns (uint64) {\\n uint64 _leValue = uint64(extractValueLE(_output));\\n uint64 _beValue = reverseUint64(_leValue);\\n return _beValue;\\n }\\n\\n /// @notice Extracts the value from the output in a tx\\n /// @dev Value is an 8-byte little-endian number\\n /// @param _output The byte array containing the output\\n /// @param _at The starting index of the output in the array\\n /// @return The output value\\n function extractValueAt(bytes memory _output, uint256 _at) internal pure returns (uint64) {\\n uint64 _leValue = uint64(_output.slice8(_at));\\n uint64 _beValue = reverseUint64(_leValue);\\n return _beValue;\\n }\\n\\n /// @notice Extracts the data from an op return output\\n /// @dev Returns hex\\\"\\\" if no data or not an op return\\n /// @param _output The output\\n /// @return Any data contained in the opreturn output, null if not an op return\\n function extractOpReturnData(bytes memory _output) internal pure returns (bytes memory) {\\n if (_output[9] != hex\\\"6a\\\") {\\n return hex\\\"\\\";\\n }\\n bytes1 _dataLen = _output[10];\\n return _output.slice(11, uint256(uint8(_dataLen)));\\n }\\n\\n /// @notice Extracts the hash from the output script\\n /// @dev Determines type by the length prefix and validates format\\n /// @param _output The output\\n /// @return The hash committed to by the pk_script, or null for errors\\n function extractHash(bytes memory _output) internal pure returns (bytes memory) {\\n return extractHashAt(_output, 8, _output.length - 8);\\n }\\n\\n /// @notice Extracts the hash from the output script\\n /// @dev Determines type by the length prefix and validates format\\n /// @param _output The byte array containing the output\\n /// @param _at The starting index of the output script in the array\\n /// (output start + 8)\\n /// @param _len The length of the output script\\n /// (output length - 8)\\n /// @return The hash committed to by the pk_script, or null for errors\\n function extractHashAt(\\n bytes memory _output,\\n uint256 _at,\\n uint256 _len\\n ) internal pure returns (bytes memory) {\\n uint8 _scriptLen = uint8(_output[_at]);\\n\\n // don't have to worry about overflow here.\\n // if _scriptLen + 1 overflows, then output length would have to be < 1\\n // for this check to pass. if it's < 1, then we errored when assigning\\n // _scriptLen\\n if (_scriptLen + 1 != _len) {\\n return hex\\\"\\\";\\n }\\n\\n if (uint8(_output[_at + 1]) == 0) {\\n if (_scriptLen < 2) {\\n return hex\\\"\\\";\\n }\\n uint256 _payloadLen = uint8(_output[_at + 2]);\\n // Check for maliciously formatted witness outputs.\\n // No need to worry about underflow as long b/c of the `< 2` check\\n if (_payloadLen != _scriptLen - 2 || (_payloadLen != 0x20 && _payloadLen != 0x14)) {\\n return hex\\\"\\\";\\n }\\n return _output.slice(_at + 3, _payloadLen);\\n } else {\\n bytes3 _tag = _output.slice3(_at);\\n // p2pkh\\n if (_tag == hex\\\"1976a9\\\") {\\n // Check for maliciously formatted p2pkh\\n // No need to worry about underflow, b/c of _scriptLen check\\n if (uint8(_output[_at + 3]) != 0x14 ||\\n _output.slice2(_at + _len - 2) != hex\\\"88ac\\\") {\\n return hex\\\"\\\";\\n }\\n return _output.slice(_at + 4, 20);\\n //p2sh\\n } else if (_tag == hex\\\"17a914\\\") {\\n // Check for maliciously formatted p2sh\\n // No need to worry about underflow, b/c of _scriptLen check\\n if (uint8(_output[_at + _len - 1]) != 0x87) {\\n return hex\\\"\\\";\\n }\\n return _output.slice(_at + 3, 20);\\n }\\n }\\n return hex\\\"\\\"; /* NB: will trigger on OPRETURN and any non-standard that doesn't overrun */\\n }\\n\\n /* ********** */\\n /* Witness TX */\\n /* ********** */\\n\\n\\n /// @notice Checks that the vin passed up is properly formatted\\n /// @dev Consider a vin with a valid vout in its scriptsig\\n /// @param _vin Raw bytes length-prefixed input vector\\n /// @return True if it represents a validly formatted vin\\n function validateVin(bytes memory _vin) internal pure returns (bool) {\\n uint256 _varIntDataLen;\\n uint256 _nIns;\\n\\n (_varIntDataLen, _nIns) = parseVarInt(_vin);\\n\\n // Not valid if it says there are too many or no inputs\\n if (_nIns == 0 || _varIntDataLen == ERR_BAD_ARG) {\\n return false;\\n }\\n\\n uint256 _offset = 1 + _varIntDataLen;\\n\\n for (uint256 i = 0; i < _nIns; i++) {\\n // If we're at the end, but still expect more\\n if (_offset >= _vin.length) {\\n return false;\\n }\\n\\n // Grab the next input and determine its length.\\n uint256 _nextLen = determineInputLengthAt(_vin, _offset);\\n if (_nextLen == ERR_BAD_ARG) {\\n return false;\\n }\\n\\n // Increase the offset by that much\\n _offset += _nextLen;\\n }\\n\\n // Returns false if we're not exactly at the end\\n return _offset == _vin.length;\\n }\\n\\n /// @notice Checks that the vout passed up is properly formatted\\n /// @dev Consider a vout with a valid scriptpubkey\\n /// @param _vout Raw bytes length-prefixed output vector\\n /// @return True if it represents a validly formatted vout\\n function validateVout(bytes memory _vout) internal pure returns (bool) {\\n uint256 _varIntDataLen;\\n uint256 _nOuts;\\n\\n (_varIntDataLen, _nOuts) = parseVarInt(_vout);\\n\\n // Not valid if it says there are too many or no outputs\\n if (_nOuts == 0 || _varIntDataLen == ERR_BAD_ARG) {\\n return false;\\n }\\n\\n uint256 _offset = 1 + _varIntDataLen;\\n\\n for (uint256 i = 0; i < _nOuts; i++) {\\n // If we're at the end, but still expect more\\n if (_offset >= _vout.length) {\\n return false;\\n }\\n\\n // Grab the next output and determine its length.\\n // Increase the offset by that much\\n uint256 _nextLen = determineOutputLengthAt(_vout, _offset);\\n if (_nextLen == ERR_BAD_ARG) {\\n return false;\\n }\\n\\n _offset += _nextLen;\\n }\\n\\n // Returns false if we're not exactly at the end\\n return _offset == _vout.length;\\n }\\n\\n\\n\\n /* ************ */\\n /* Block Header */\\n /* ************ */\\n\\n /// @notice Extracts the transaction merkle root from a block header\\n /// @dev Use verifyHash256Merkle to verify proofs with this root\\n /// @param _header The header\\n /// @return The merkle root (little-endian)\\n function extractMerkleRootLE(bytes memory _header) internal pure returns (bytes32) {\\n return _header.slice32(36);\\n }\\n\\n /// @notice Extracts the target from a block header\\n /// @dev Target is a 256-bit number encoded as a 3-byte mantissa and 1-byte exponent\\n /// @param _header The header\\n /// @return The target threshold\\n function extractTarget(bytes memory _header) internal pure returns (uint256) {\\n return extractTargetAt(_header, 0);\\n }\\n\\n /// @notice Extracts the target from a block header\\n /// @dev Target is a 256-bit number encoded as a 3-byte mantissa and 1-byte exponent\\n /// @param _header The array containing the header\\n /// @param at The start of the header\\n /// @return The target threshold\\n function extractTargetAt(bytes memory _header, uint256 at) internal pure returns (uint256) {\\n uint24 _m = uint24(_header.slice3(72 + at));\\n uint8 _e = uint8(_header[75 + at]);\\n uint256 _mantissa = uint256(reverseUint24(_m));\\n uint _exponent = _e - 3;\\n\\n return _mantissa * (256 ** _exponent);\\n }\\n\\n /// @notice Calculate difficulty from the difficulty 1 target and current target\\n /// @dev Difficulty 1 is 0x1d00ffff on mainnet and testnet\\n /// @dev Difficulty 1 is a 256-bit number encoded as a 3-byte mantissa and 1-byte exponent\\n /// @param _target The current target\\n /// @return The block difficulty (bdiff)\\n function calculateDifficulty(uint256 _target) internal pure returns (uint256) {\\n // Difficulty 1 calculated from 0x1d00ffff\\n return DIFF1_TARGET.div(_target);\\n }\\n\\n /// @notice Extracts the previous block's hash from a block header\\n /// @dev Block headers do NOT include block number :(\\n /// @param _header The header\\n /// @return The previous block's hash (little-endian)\\n function extractPrevBlockLE(bytes memory _header) internal pure returns (bytes32) {\\n return _header.slice32(4);\\n }\\n\\n /// @notice Extracts the previous block's hash from a block header\\n /// @dev Block headers do NOT include block number :(\\n /// @param _header The array containing the header\\n /// @param at The start of the header\\n /// @return The previous block's hash (little-endian)\\n function extractPrevBlockLEAt(\\n bytes memory _header,\\n uint256 at\\n ) internal pure returns (bytes32) {\\n return _header.slice32(4 + at);\\n }\\n\\n /// @notice Extracts the timestamp from a block header\\n /// @dev Time is not 100% reliable\\n /// @param _header The header\\n /// @return The timestamp (little-endian bytes)\\n function extractTimestampLE(bytes memory _header) internal pure returns (bytes4) {\\n return _header.slice4(68);\\n }\\n\\n /// @notice Extracts the timestamp from a block header\\n /// @dev Time is not 100% reliable\\n /// @param _header The header\\n /// @return The timestamp (uint)\\n function extractTimestamp(bytes memory _header) internal pure returns (uint32) {\\n return reverseUint32(uint32(extractTimestampLE(_header)));\\n }\\n\\n /// @notice Extracts the expected difficulty from a block header\\n /// @dev Does NOT verify the work\\n /// @param _header The header\\n /// @return The difficulty as an integer\\n function extractDifficulty(bytes memory _header) internal pure returns (uint256) {\\n return calculateDifficulty(extractTarget(_header));\\n }\\n\\n /// @notice Concatenates and hashes two inputs for merkle proving\\n /// @param _a The first hash\\n /// @param _b The second hash\\n /// @return The double-sha256 of the concatenated hashes\\n function _hash256MerkleStep(bytes memory _a, bytes memory _b) internal view returns (bytes32) {\\n return hash256View(abi.encodePacked(_a, _b));\\n }\\n\\n /// @notice Concatenates and hashes two inputs for merkle proving\\n /// @param _a The first hash\\n /// @param _b The second hash\\n /// @return The double-sha256 of the concatenated hashes\\n function _hash256MerkleStep(bytes32 _a, bytes32 _b) internal view returns (bytes32) {\\n return hash256Pair(_a, _b);\\n }\\n\\n\\n /// @notice Verifies a Bitcoin-style merkle tree\\n /// @dev Leaves are 0-indexed. Inefficient version.\\n /// @param _proof The proof. Tightly packed LE sha256 hashes. The last hash is the root\\n /// @param _index The index of the leaf\\n /// @return true if the proof is valid, else false\\n function verifyHash256Merkle(bytes memory _proof, uint _index) internal view returns (bool) {\\n // Not an even number of hashes\\n if (_proof.length % 32 != 0) {\\n return false;\\n }\\n\\n // Special case for coinbase-only blocks\\n if (_proof.length == 32) {\\n return true;\\n }\\n\\n // Should never occur\\n if (_proof.length == 64) {\\n return false;\\n }\\n\\n bytes32 _root = _proof.slice32(_proof.length - 32);\\n bytes32 _current = _proof.slice32(0);\\n bytes memory _tree = _proof.slice(32, _proof.length - 64);\\n\\n return verifyHash256Merkle(_current, _tree, _root, _index);\\n }\\n\\n /// @notice Verifies a Bitcoin-style merkle tree\\n /// @dev Leaves are 0-indexed. Efficient version.\\n /// @param _leaf The leaf of the proof. LE sha256 hash.\\n /// @param _tree The intermediate nodes in the proof.\\n /// Tightly packed LE sha256 hashes.\\n /// @param _root The root of the proof. LE sha256 hash.\\n /// @param _index The index of the leaf\\n /// @return true if the proof is valid, else false\\n function verifyHash256Merkle(\\n bytes32 _leaf,\\n bytes memory _tree,\\n bytes32 _root,\\n uint _index\\n ) internal view returns (bool) {\\n // Not an even number of hashes\\n if (_tree.length % 32 != 0) {\\n return false;\\n }\\n\\n // Should never occur\\n if (_tree.length == 0) {\\n return false;\\n }\\n\\n uint _idx = _index;\\n bytes32 _current = _leaf;\\n\\n // i moves in increments of 32\\n for (uint i = 0; i < _tree.length; i += 32) {\\n if (_idx % 2 == 1) {\\n _current = _hash256MerkleStep(_tree.slice32(i), _current);\\n } else {\\n _current = _hash256MerkleStep(_current, _tree.slice32(i));\\n }\\n _idx = _idx >> 1;\\n }\\n return _current == _root;\\n }\\n\\n /*\\n NB: https://github.com/bitcoin/bitcoin/blob/78dae8caccd82cfbfd76557f1fb7d7557c7b5edb/src/pow.cpp#L49-L72\\n NB: We get a full-bitlength target from this. For comparison with\\n header-encoded targets we need to mask it with the header target\\n e.g. (full & truncated) == truncated\\n */\\n /// @notice performs the bitcoin difficulty retarget\\n /// @dev implements the Bitcoin algorithm precisely\\n /// @param _previousTarget the target of the previous period\\n /// @param _firstTimestamp the timestamp of the first block in the difficulty period\\n /// @param _secondTimestamp the timestamp of the last block in the difficulty period\\n /// @return the new period's target threshold\\n function retargetAlgorithm(\\n uint256 _previousTarget,\\n uint256 _firstTimestamp,\\n uint256 _secondTimestamp\\n ) internal pure returns (uint256) {\\n uint256 _elapsedTime = _secondTimestamp.sub(_firstTimestamp);\\n\\n // Normalize ratio to factor of 4 if very long or very short\\n if (_elapsedTime < RETARGET_PERIOD.div(4)) {\\n _elapsedTime = RETARGET_PERIOD.div(4);\\n }\\n if (_elapsedTime > RETARGET_PERIOD.mul(4)) {\\n _elapsedTime = RETARGET_PERIOD.mul(4);\\n }\\n\\n /*\\n NB: high targets e.g. ffff0020 can cause overflows here\\n so we divide it by 256**2, then multiply by 256**2 later\\n we know the target is evenly divisible by 256**2, so this isn't an issue\\n */\\n\\n uint256 _adjusted = _previousTarget.div(65536).mul(_elapsedTime);\\n return _adjusted.div(RETARGET_PERIOD).mul(65536);\\n }\\n}\\n\",\"keccak256\":\"0x439eaa97e9239705f3d31e8d39dccbad32311f1f119e295d53c65e0ae3c5a5fc\"},\"@keep-network/bitcoin-spv-sol/contracts/BytesLib.sol\":{\"content\":\"pragma solidity ^0.8.4;\\n\\n/*\\n\\nhttps://github.com/GNSPS/solidity-bytes-utils/\\n\\nThis is free and unencumbered software released into the public domain.\\n\\nAnyone is free to copy, modify, publish, use, compile, sell, or\\ndistribute this software, either in source code form or as a compiled\\nbinary, for any purpose, commercial or non-commercial, and by any\\nmeans.\\n\\nIn jurisdictions that recognize copyright laws, the author or authors\\nof this software dedicate any and all copyright interest in the\\nsoftware to the public domain. We make this dedication for the benefit\\nof the public at large and to the detriment of our heirs and\\nsuccessors. We intend this dedication to be an overt act of\\nrelinquishment in perpetuity of all present and future rights to this\\nsoftware under copyright law.\\n\\nTHE SOFTWARE IS PROVIDED \\\"AS IS\\\", WITHOUT WARRANTY OF ANY KIND,\\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\\nIN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR\\nOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,\\nARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\\nOTHER DEALINGS IN THE SOFTWARE.\\n\\nFor more information, please refer to <https://unlicense.org>\\n*/\\n\\n\\n/** @title BytesLib **/\\n/** @author https://github.com/GNSPS **/\\n\\nlibrary BytesLib {\\n function concat(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bytes memory) {\\n bytes memory tempBytes;\\n\\n assembly {\\n // Get a location of some free memory and store it in tempBytes as\\n // Solidity does for memory variables.\\n tempBytes := mload(0x40)\\n\\n // Store the length of the first bytes array at the beginning of\\n // the memory for tempBytes.\\n let length := mload(_preBytes)\\n mstore(tempBytes, length)\\n\\n // Maintain a memory counter for the current write location in the\\n // temp bytes array by adding the 32 bytes for the array length to\\n // the starting location.\\n let mc := add(tempBytes, 0x20)\\n // Stop copying when the memory counter reaches the length of the\\n // first bytes array.\\n let end := add(mc, length)\\n\\n for {\\n // Initialize a copy counter to the start of the _preBytes data,\\n // 32 bytes into its memory.\\n let cc := add(_preBytes, 0x20)\\n } lt(mc, end) {\\n // Increase both counters by 32 bytes each iteration.\\n mc := add(mc, 0x20)\\n cc := add(cc, 0x20)\\n } {\\n // Write the _preBytes data into the tempBytes memory 32 bytes\\n // at a time.\\n mstore(mc, mload(cc))\\n }\\n\\n // Add the length of _postBytes to the current length of tempBytes\\n // and store it as the new length in the first 32 bytes of the\\n // tempBytes memory.\\n length := mload(_postBytes)\\n mstore(tempBytes, add(length, mload(tempBytes)))\\n\\n // Move the memory counter back from a multiple of 0x20 to the\\n // actual end of the _preBytes data.\\n mc := end\\n // Stop copying when the memory counter reaches the new combined\\n // length of the arrays.\\n end := add(mc, length)\\n\\n for {\\n let cc := add(_postBytes, 0x20)\\n } lt(mc, end) {\\n mc := add(mc, 0x20)\\n cc := add(cc, 0x20)\\n } {\\n mstore(mc, mload(cc))\\n }\\n\\n // Update the free-memory pointer by padding our last write location\\n // to 32 bytes: add 31 bytes to the end of tempBytes to move to the\\n // next 32 byte block, then round down to the nearest multiple of\\n // 32. If the sum of the length of the two arrays is zero then add\\n // one before rounding down to leave a blank 32 bytes (the length block with 0).\\n mstore(0x40, and(\\n add(add(end, iszero(add(length, mload(_preBytes)))), 31),\\n not(31) // Round down to the nearest 32 bytes.\\n ))\\n }\\n\\n return tempBytes;\\n }\\n\\n function concatStorage(bytes storage _preBytes, bytes memory _postBytes) internal {\\n assembly {\\n // Read the first 32 bytes of _preBytes storage, which is the length\\n // of the array. (We don't need to use the offset into the slot\\n // because arrays use the entire slot.)\\n let fslot := sload(_preBytes.slot)\\n // Arrays of 31 bytes or less have an even value in their slot,\\n // while longer arrays have an odd value. The actual length is\\n // the slot divided by two for odd values, and the lowest order\\n // byte divided by two for even values.\\n // If the slot is even, bitwise and the slot with 255 and divide by\\n // two to get the length. If the slot is odd, bitwise and the slot\\n // with -1 and divide by two.\\n let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2)\\n let mlength := mload(_postBytes)\\n let newlength := add(slength, mlength)\\n // slength can contain both the length and contents of the array\\n // if length < 32 bytes so let's prepare for that\\n // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage\\n switch add(lt(slength, 32), lt(newlength, 32))\\n case 2 {\\n // Since the new array still fits in the slot, we just need to\\n // update the contents of the slot.\\n // uint256(bytes_storage) = uint256(bytes_storage) + uint256(bytes_memory) + new_length\\n sstore(\\n _preBytes.slot,\\n // all the modifications to the slot are inside this\\n // next block\\n add(\\n // we can just add to the slot contents because the\\n // bytes we want to change are the LSBs\\n fslot,\\n add(\\n mul(\\n div(\\n // load the bytes from memory\\n mload(add(_postBytes, 0x20)),\\n // zero all bytes to the right\\n exp(0x100, sub(32, mlength))\\n ),\\n // and now shift left the number of bytes to\\n // leave space for the length in the slot\\n exp(0x100, sub(32, newlength))\\n ),\\n // increase length by the double of the memory\\n // bytes length\\n mul(mlength, 2)\\n )\\n )\\n )\\n }\\n case 1 {\\n // The stored value fits in the slot, but the combined value\\n // will exceed it.\\n // get the keccak hash to get the contents of the array\\n mstore(0x0, _preBytes.slot)\\n let sc := add(keccak256(0x0, 0x20), div(slength, 32))\\n\\n // save new length\\n sstore(_preBytes.slot, add(mul(newlength, 2), 1))\\n\\n // The contents of the _postBytes array start 32 bytes into\\n // the structure. Our first read should obtain the `submod`\\n // bytes that can fit into the unused space in the last word\\n // of the stored array. To get this, we read 32 bytes starting\\n // from `submod`, so the data we read overlaps with the array\\n // contents by `submod` bytes. Masking the lowest-order\\n // `submod` bytes allows us to add that value directly to the\\n // stored value.\\n\\n let submod := sub(32, slength)\\n let mc := add(_postBytes, submod)\\n let end := add(_postBytes, mlength)\\n let mask := sub(exp(0x100, submod), 1)\\n\\n sstore(\\n sc,\\n add(\\n and(\\n fslot,\\n 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00\\n ),\\n and(mload(mc), mask)\\n )\\n )\\n\\n for {\\n mc := add(mc, 0x20)\\n sc := add(sc, 1)\\n } lt(mc, end) {\\n sc := add(sc, 1)\\n mc := add(mc, 0x20)\\n } {\\n sstore(sc, mload(mc))\\n }\\n\\n mask := exp(0x100, sub(mc, end))\\n\\n sstore(sc, mul(div(mload(mc), mask), mask))\\n }\\n default {\\n // get the keccak hash to get the contents of the array\\n mstore(0x0, _preBytes.slot)\\n // Start copying to the last used word of the stored array.\\n let sc := add(keccak256(0x0, 0x20), div(slength, 32))\\n\\n // save new length\\n sstore(_preBytes.slot, add(mul(newlength, 2), 1))\\n\\n // Copy over the first `submod` bytes of the new data as in\\n // case 1 above.\\n let slengthmod := mod(slength, 32)\\n let mlengthmod := mod(mlength, 32)\\n let submod := sub(32, slengthmod)\\n let mc := add(_postBytes, submod)\\n let end := add(_postBytes, mlength)\\n let mask := sub(exp(0x100, submod), 1)\\n\\n sstore(sc, add(sload(sc), and(mload(mc), mask)))\\n\\n for {\\n sc := add(sc, 1)\\n mc := add(mc, 0x20)\\n } lt(mc, end) {\\n sc := add(sc, 1)\\n mc := add(mc, 0x20)\\n } {\\n sstore(sc, mload(mc))\\n }\\n\\n mask := exp(0x100, sub(mc, end))\\n\\n sstore(sc, mul(div(mload(mc), mask), mask))\\n }\\n }\\n }\\n\\n function slice(bytes memory _bytes, uint _start, uint _length) internal pure returns (bytes memory res) {\\n if (_length == 0) {\\n return hex\\\"\\\";\\n }\\n uint _end = _start + _length;\\n require(_end > _start && _bytes.length >= _end, \\\"Slice out of bounds\\\");\\n\\n assembly {\\n // Alloc bytes array with additional 32 bytes afterspace and assign it's size\\n res := mload(0x40)\\n mstore(0x40, add(add(res, 64), _length))\\n mstore(res, _length)\\n\\n // Compute distance between source and destination pointers\\n let diff := sub(res, add(_bytes, _start))\\n\\n for {\\n let src := add(add(_bytes, 32), _start)\\n let end := add(src, _length)\\n } lt(src, end) {\\n src := add(src, 32)\\n } {\\n mstore(add(src, diff), mload(src))\\n }\\n }\\n }\\n\\n /// @notice Take a slice of the byte array, overwriting the destination.\\n /// The length of the slice will equal the length of the destination array.\\n /// @dev Make sure the destination array has afterspace if required.\\n /// @param _bytes The source array\\n /// @param _dest The destination array.\\n /// @param _start The location to start in the source array.\\n function sliceInPlace(\\n bytes memory _bytes,\\n bytes memory _dest,\\n uint _start\\n ) internal pure {\\n uint _length = _dest.length;\\n uint _end = _start + _length;\\n require(_end > _start && _bytes.length >= _end, \\\"Slice out of bounds\\\");\\n\\n assembly {\\n for {\\n let src := add(add(_bytes, 32), _start)\\n let res := add(_dest, 32)\\n let end := add(src, _length)\\n } lt(src, end) {\\n src := add(src, 32)\\n res := add(res, 32)\\n } {\\n mstore(res, mload(src))\\n }\\n }\\n }\\n\\n // Static slice functions, no bounds checking\\n /// @notice take a 32-byte slice from the specified position\\n function slice32(bytes memory _bytes, uint _start) internal pure returns (bytes32 res) {\\n assembly {\\n res := mload(add(add(_bytes, 32), _start))\\n }\\n }\\n\\n /// @notice take a 20-byte slice from the specified position\\n function slice20(bytes memory _bytes, uint _start) internal pure returns (bytes20) {\\n return bytes20(slice32(_bytes, _start));\\n }\\n\\n /// @notice take a 8-byte slice from the specified position\\n function slice8(bytes memory _bytes, uint _start) internal pure returns (bytes8) {\\n return bytes8(slice32(_bytes, _start));\\n }\\n\\n /// @notice take a 4-byte slice from the specified position\\n function slice4(bytes memory _bytes, uint _start) internal pure returns (bytes4) {\\n return bytes4(slice32(_bytes, _start));\\n }\\n\\n /// @notice take a 3-byte slice from the specified position\\n function slice3(bytes memory _bytes, uint _start) internal pure returns (bytes3) {\\n return bytes3(slice32(_bytes, _start));\\n }\\n\\n /// @notice take a 2-byte slice from the specified position\\n function slice2(bytes memory _bytes, uint _start) internal pure returns (bytes2) {\\n return bytes2(slice32(_bytes, _start));\\n }\\n\\n function toAddress(bytes memory _bytes, uint _start) internal pure returns (address) {\\n uint _totalLen = _start + 20;\\n require(_totalLen > _start && _bytes.length >= _totalLen, \\\"Address conversion out of bounds.\\\");\\n address tempAddress;\\n\\n assembly {\\n tempAddress := div(mload(add(add(_bytes, 0x20), _start)), 0x1000000000000000000000000)\\n }\\n\\n return tempAddress;\\n }\\n\\n function toUint(bytes memory _bytes, uint _start) internal pure returns (uint256) {\\n uint _totalLen = _start + 32;\\n require(_totalLen > _start && _bytes.length >= _totalLen, \\\"Uint conversion out of bounds.\\\");\\n uint256 tempUint;\\n\\n assembly {\\n tempUint := mload(add(add(_bytes, 0x20), _start))\\n }\\n\\n return tempUint;\\n }\\n\\n function equal(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bool) {\\n bool success = true;\\n\\n assembly {\\n let length := mload(_preBytes)\\n\\n // if lengths don't match the arrays are not equal\\n switch eq(length, mload(_postBytes))\\n case 1 {\\n // cb is a circuit breaker in the for loop since there's\\n // no said feature for inline assembly loops\\n // cb = 1 - don't breaker\\n // cb = 0 - break\\n let cb := 1\\n\\n let mc := add(_preBytes, 0x20)\\n let end := add(mc, length)\\n\\n for {\\n let cc := add(_postBytes, 0x20)\\n // the next line is the loop condition:\\n // while(uint(mc < end) + cb == 2)\\n } eq(add(lt(mc, end), cb), 2) {\\n mc := add(mc, 0x20)\\n cc := add(cc, 0x20)\\n } {\\n // if any of these checks fails then arrays are not equal\\n if iszero(eq(mload(mc), mload(cc))) {\\n // unsuccess:\\n success := 0\\n cb := 0\\n }\\n }\\n }\\n default {\\n // unsuccess:\\n success := 0\\n }\\n }\\n\\n return success;\\n }\\n\\n function equalStorage(bytes storage _preBytes, bytes memory _postBytes) internal view returns (bool) {\\n bool success = true;\\n\\n assembly {\\n // we know _preBytes_offset is 0\\n let fslot := sload(_preBytes.slot)\\n // Decode the length of the stored array like in concatStorage().\\n let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2)\\n let mlength := mload(_postBytes)\\n\\n // if lengths don't match the arrays are not equal\\n switch eq(slength, mlength)\\n case 1 {\\n // slength can contain both the length and contents of the array\\n // if length < 32 bytes so let's prepare for that\\n // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage\\n if iszero(iszero(slength)) {\\n switch lt(slength, 32)\\n case 1 {\\n // blank the last byte which is the length\\n fslot := mul(div(fslot, 0x100), 0x100)\\n\\n if iszero(eq(fslot, mload(add(_postBytes, 0x20)))) {\\n // unsuccess:\\n success := 0\\n }\\n }\\n default {\\n // cb is a circuit breaker in the for loop since there's\\n // no said feature for inline assembly loops\\n // cb = 1 - don't breaker\\n // cb = 0 - break\\n let cb := 1\\n\\n // get the keccak hash to get the contents of the array\\n mstore(0x0, _preBytes.slot)\\n let sc := keccak256(0x0, 0x20)\\n\\n let mc := add(_postBytes, 0x20)\\n let end := add(mc, mlength)\\n\\n // the next line is the loop condition:\\n // while(uint(mc < end) + cb == 2)\\n for {} eq(add(lt(mc, end), cb), 2) {\\n sc := add(sc, 1)\\n mc := add(mc, 0x20)\\n } {\\n if iszero(eq(sload(sc), mload(mc))) {\\n // unsuccess:\\n success := 0\\n cb := 0\\n }\\n }\\n }\\n }\\n }\\n default {\\n // unsuccess:\\n success := 0\\n }\\n }\\n\\n return success;\\n }\\n\\n function toBytes32(bytes memory _source) pure internal returns (bytes32 result) {\\n if (_source.length == 0) {\\n return 0x0;\\n }\\n\\n assembly {\\n result := mload(add(_source, 32))\\n }\\n }\\n\\n function keccak256Slice(bytes memory _bytes, uint _start, uint _length) pure internal returns (bytes32 result) {\\n uint _end = _start + _length;\\n require(_end > _start && _bytes.length >= _end, \\\"Slice out of bounds\\\");\\n\\n assembly {\\n result := keccak256(add(add(_bytes, 32), _start), _length)\\n }\\n }\\n}\\n\",\"keccak256\":\"0x43e0f3b3b23c861bd031588bf410dfdd02e2af17941a89aa38d70e534e0380d1\"},\"@keep-network/bitcoin-spv-sol/contracts/SafeMath.sol\":{\"content\":\"pragma solidity ^0.8.4;\\n\\n/*\\nThe MIT License (MIT)\\n\\nCopyright (c) 2016 Smart Contract Solutions, Inc.\\n\\nPermission is hereby granted, free of charge, to any person obtaining\\na copy of this software and associated documentation files (the\\n\\\"Software\\\"), to deal in the Software without restriction, including\\nwithout limitation the rights to use, copy, modify, merge, publish,\\ndistribute, sublicense, and/or sell copies of the Software, and to\\npermit persons to whom the Software is furnished to do so, subject to\\nthe following conditions:\\n\\nThe above copyright notice and this permission notice shall be included\\nin all copies or substantial portions of the Software.\\n\\nTHE SOFTWARE IS PROVIDED \\\"AS IS\\\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\\nOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\\n*/\\n\\n\\n/**\\n * @title SafeMath\\n * @dev Math operations with safety checks that throw on error\\n */\\nlibrary SafeMath {\\n\\n /**\\n * @dev Multiplies two numbers, throws on overflow.\\n */\\n function mul(uint256 _a, uint256 _b) internal pure returns (uint256 c) {\\n // Gas optimization: this is cheaper than asserting 'a' not being zero, but the\\n // benefit is lost if 'b' is also tested.\\n // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522\\n if (_a == 0) {\\n return 0;\\n }\\n\\n c = _a * _b;\\n require(c / _a == _b, \\\"Overflow during multiplication.\\\");\\n return c;\\n }\\n\\n /**\\n * @dev Integer division of two numbers, truncating the quotient.\\n */\\n function div(uint256 _a, uint256 _b) internal pure returns (uint256) {\\n // assert(_b > 0); // Solidity automatically throws when dividing by 0\\n // uint256 c = _a / _b;\\n // assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold\\n return _a / _b;\\n }\\n\\n /**\\n * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).\\n */\\n function sub(uint256 _a, uint256 _b) internal pure returns (uint256) {\\n require(_b <= _a, \\\"Underflow during subtraction.\\\");\\n return _a - _b;\\n }\\n\\n /**\\n * @dev Adds two numbers, throws on overflow.\\n */\\n function add(uint256 _a, uint256 _b) internal pure returns (uint256 c) {\\n c = _a + _b;\\n require(c >= _a, \\\"Overflow during addition.\\\");\\n return c;\\n }\\n}\\n\",\"keccak256\":\"0x35930d982394c7ffde439b82e5e696c5b21a6f09699d44861dfe409ef64084a3\"},\"@keep-network/bitcoin-spv-sol/contracts/ValidateSPV.sol\":{\"content\":\"pragma solidity ^0.8.4;\\n\\n/** @title ValidateSPV*/\\n/** @author Summa (https://summa.one) */\\n\\nimport {BytesLib} from \\\"./BytesLib.sol\\\";\\nimport {SafeMath} from \\\"./SafeMath.sol\\\";\\nimport {BTCUtils} from \\\"./BTCUtils.sol\\\";\\n\\n\\nlibrary ValidateSPV {\\n\\n using BTCUtils for bytes;\\n using BTCUtils for uint256;\\n using BytesLib for bytes;\\n using SafeMath for uint256;\\n\\n enum InputTypes { NONE, LEGACY, COMPATIBILITY, WITNESS }\\n enum OutputTypes { NONE, WPKH, WSH, OP_RETURN, PKH, SH, NONSTANDARD }\\n\\n uint256 constant ERR_BAD_LENGTH = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff;\\n uint256 constant ERR_INVALID_CHAIN = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe;\\n uint256 constant ERR_LOW_WORK = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd;\\n\\n function getErrBadLength() internal pure returns (uint256) {\\n return ERR_BAD_LENGTH;\\n }\\n\\n function getErrInvalidChain() internal pure returns (uint256) {\\n return ERR_INVALID_CHAIN;\\n }\\n\\n function getErrLowWork() internal pure returns (uint256) {\\n return ERR_LOW_WORK;\\n }\\n\\n /// @notice Validates a tx inclusion in the block\\n /// @dev `index` is not a reliable indicator of location within a block\\n /// @param _txid The txid (LE)\\n /// @param _merkleRoot The merkle root (as in the block header)\\n /// @param _intermediateNodes The proof's intermediate nodes (digests between leaf and root)\\n /// @param _index The leaf's index in the tree (0-indexed)\\n /// @return true if fully valid, false otherwise\\n function prove(\\n bytes32 _txid,\\n bytes32 _merkleRoot,\\n bytes memory _intermediateNodes,\\n uint _index\\n ) internal view returns (bool) {\\n // Shortcut the empty-block case\\n if (_txid == _merkleRoot && _index == 0 && _intermediateNodes.length == 0) {\\n return true;\\n }\\n\\n // If the Merkle proof failed, bubble up error\\n return BTCUtils.verifyHash256Merkle(\\n _txid,\\n _intermediateNodes,\\n _merkleRoot,\\n _index\\n );\\n }\\n\\n /// @notice Hashes transaction to get txid\\n /// @dev Supports Legacy and Witness\\n /// @param _version 4-bytes version\\n /// @param _vin Raw bytes length-prefixed input vector\\n /// @param _vout Raw bytes length-prefixed output vector\\n /// @param _locktime 4-byte tx locktime\\n /// @return 32-byte transaction id, little endian\\n function calculateTxId(\\n bytes4 _version,\\n bytes memory _vin,\\n bytes memory _vout,\\n bytes4 _locktime\\n ) internal view returns (bytes32) {\\n // Get transaction hash double-Sha256(version + nIns + inputs + nOuts + outputs + locktime)\\n return abi.encodePacked(_version, _vin, _vout, _locktime).hash256View();\\n }\\n\\n /// @notice Checks validity of header chain\\n /// @notice Compares the hash of each header to the prevHash in the next header\\n /// @param headers Raw byte array of header chain\\n /// @return totalDifficulty The total accumulated difficulty of the header chain, or an error code\\n function validateHeaderChain(\\n bytes memory headers\\n ) internal view returns (uint256 totalDifficulty) {\\n\\n // Check header chain length\\n if (headers.length % 80 != 0) {return ERR_BAD_LENGTH;}\\n\\n // Initialize header start index\\n bytes32 digest;\\n\\n totalDifficulty = 0;\\n\\n for (uint256 start = 0; start < headers.length; start += 80) {\\n\\n // After the first header, check that headers are in a chain\\n if (start != 0) {\\n if (!validateHeaderPrevHash(headers, start, digest)) {return ERR_INVALID_CHAIN;}\\n }\\n\\n // ith header target\\n uint256 target = headers.extractTargetAt(start);\\n\\n // Require that the header has sufficient work\\n digest = headers.hash256Slice(start, 80);\\n if(uint256(digest).reverseUint256() > target) {\\n return ERR_LOW_WORK;\\n }\\n\\n // Add ith header difficulty to difficulty sum\\n totalDifficulty = totalDifficulty + target.calculateDifficulty();\\n }\\n }\\n\\n /// @notice Checks validity of header work\\n /// @param digest Header digest\\n /// @param target The target threshold\\n /// @return true if header work is valid, false otherwise\\n function validateHeaderWork(\\n bytes32 digest,\\n uint256 target\\n ) internal pure returns (bool) {\\n if (digest == bytes32(0)) {return false;}\\n return (uint256(digest).reverseUint256() < target);\\n }\\n\\n /// @notice Checks validity of header chain\\n /// @dev Compares current header prevHash to previous header's digest\\n /// @param headers The raw bytes array containing the header\\n /// @param at The position of the header\\n /// @param prevHeaderDigest The previous header's digest\\n /// @return true if the connect is valid, false otherwise\\n function validateHeaderPrevHash(\\n bytes memory headers,\\n uint256 at,\\n bytes32 prevHeaderDigest\\n ) internal pure returns (bool) {\\n\\n // Extract prevHash of current header\\n bytes32 prevHash = headers.extractPrevBlockLEAt(at);\\n\\n // Compare prevHash of current header to previous header's digest\\n if (prevHash != prevHeaderDigest) {return false;}\\n\\n return true;\\n }\\n}\\n\",\"keccak256\":\"0xce3febbf3ad3a7ff8a8effd0c7ccaf7ccfa2719578b537d49ea196f0bae8062b\"},\"@openzeppelin/contracts/access/Ownable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/Context.sol\\\";\\n\\n/**\\n * @dev Contract module which provides a basic access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * By default, the owner account will be the one that deploys the contract. This\\n * can later be changed with {transferOwnership}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyOwner`, which can be applied to your functions to restrict their use to\\n * the owner.\\n */\\nabstract contract Ownable is Context {\\n address private _owner;\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the deployer as the initial owner.\\n */\\n constructor() {\\n _transferOwnership(_msgSender());\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n _;\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions anymore. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby removing any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n _transferOwnership(address(0));\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual onlyOwner {\\n require(newOwner != address(0), \\\"Ownable: new owner is the zero address\\\");\\n _transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual {\\n address oldOwner = _owner;\\n _owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n}\\n\",\"keccak256\":\"0x24e0364e503a9bbde94c715d26573a76f14cd2a202d45f96f52134ab806b67b9\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n}\\n\",\"keccak256\":\"0xe2e337e6dde9ef6b680e07338c493ebea1b5fd09b43424112868e9cc1706bca7\",\"license\":\"MIT\"},\"contracts/bridge/IRelay.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity 0.8.17;\\n\\n/// @title Interface for the Bitcoin relay\\n/// @notice Contains only the methods needed by tBTC v2. The Bitcoin relay\\n/// provides the difficulty of the previous and current epoch. One\\n/// difficulty epoch spans 2016 blocks.\\ninterface IRelay {\\n /// @notice Returns the difficulty of the current epoch.\\n function getCurrentEpochDifficulty() external view returns (uint256);\\n\\n /// @notice Returns the difficulty of the previous epoch.\\n function getPrevEpochDifficulty() external view returns (uint256);\\n}\\n\",\"keccak256\":\"0xf70c723fc0a1824d92061b5dc76c65c38c22eff6b18ef6a2057f511183ce3c5b\",\"license\":\"GPL-3.0-only\"},\"contracts/relay/LightRelay.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity 0.8.17;\\n\\nimport \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\n\\nimport {BytesLib} from \\\"@keep-network/bitcoin-spv-sol/contracts/BytesLib.sol\\\";\\nimport {BTCUtils} from \\\"@keep-network/bitcoin-spv-sol/contracts/BTCUtils.sol\\\";\\nimport {ValidateSPV} from \\\"@keep-network/bitcoin-spv-sol/contracts/ValidateSPV.sol\\\";\\n\\nimport \\\"../bridge/IRelay.sol\\\";\\n\\nstruct Epoch {\\n uint32 timestamp;\\n // By definition, bitcoin targets have at least 32 leading zero bits.\\n // Thus we can only store the bits that aren't guaranteed to be 0.\\n uint224 target;\\n}\\n\\ninterface ILightRelay is IRelay {\\n event Genesis(uint256 blockHeight);\\n event Retarget(uint256 oldDifficulty, uint256 newDifficulty);\\n event ProofLengthChanged(uint256 newLength);\\n event AuthorizationRequirementChanged(bool newStatus);\\n event SubmitterAuthorized(address submitter);\\n event SubmitterDeauthorized(address submitter);\\n\\n function retarget(bytes memory headers) external;\\n\\n function validateChain(bytes memory headers)\\n external\\n view\\n returns (uint256 startingHeaderTimestamp, uint256 headerCount);\\n\\n function getBlockDifficulty(uint256 blockNumber)\\n external\\n view\\n returns (uint256);\\n\\n function getEpochDifficulty(uint256 epochNumber)\\n external\\n view\\n returns (uint256);\\n\\n function getRelayRange()\\n external\\n view\\n returns (uint256 relayGenesis, uint256 currentEpochEnd);\\n}\\n\\nlibrary RelayUtils {\\n using BytesLib for bytes;\\n\\n /// @notice Extract the timestamp of the header at the given position.\\n /// @param headers Byte array containing the header of interest.\\n /// @param at The start of the header in the array.\\n /// @return The timestamp of the header.\\n /// @dev Assumes that the specified position contains a valid header.\\n /// Performs no validation whatsoever.\\n function extractTimestampAt(bytes memory headers, uint256 at)\\n internal\\n pure\\n returns (uint32)\\n {\\n return BTCUtils.reverseUint32(uint32(headers.slice4(68 + at)));\\n }\\n}\\n\\n/// @dev THE RELAY MUST NOT BE USED BEFORE GENESIS AND AT LEAST ONE RETARGET.\\ncontract LightRelay is Ownable, ILightRelay {\\n using BytesLib for bytes;\\n using BTCUtils for bytes;\\n using ValidateSPV for bytes;\\n using RelayUtils for bytes;\\n\\n bool public ready;\\n // Whether the relay requires the address submitting a retarget to be\\n // authorised in advance by governance.\\n bool public authorizationRequired;\\n // Number of blocks required for each side of a retarget proof:\\n // a retarget must provide `proofLength` blocks before the retarget\\n // and `proofLength` blocks after it.\\n // Governable\\n // Should be set to a fairly high number (e.g. 20-50) in production.\\n uint64 public proofLength;\\n // The number of the first epoch recorded by the relay.\\n // This should equal the height of the block starting the genesis epoch,\\n // divided by 2016, but this is not enforced as the relay has no\\n // information about block numbers.\\n uint64 public genesisEpoch;\\n // The number of the latest epoch whose difficulty is proven to the relay.\\n // If the genesis epoch's number is set correctly, and retargets along the\\n // way have been legitimate, this equals the height of the block starting\\n // the most recent epoch, divided by 2016.\\n uint64 public currentEpoch;\\n\\n uint256 internal currentEpochDifficulty;\\n uint256 internal prevEpochDifficulty;\\n\\n // Each epoch from genesis to the current one, keyed by their numbers.\\n mapping(uint256 => Epoch) internal epochs;\\n\\n mapping(address => bool) public isAuthorized;\\n\\n modifier relayActive() {\\n require(ready, \\\"Relay is not ready for use\\\");\\n _;\\n }\\n\\n /// @notice Establish a starting point for the relay by providing the\\n /// target, timestamp and blockheight of the first block of the relay\\n /// genesis epoch.\\n /// @param genesisHeader The first block header of the genesis epoch.\\n /// @param genesisHeight The block number of the first block of the epoch.\\n /// @param genesisProofLength The number of blocks required to accept a\\n /// proof.\\n /// @dev If the relay is used by querying the current and previous epoch\\n /// difficulty, at least one retarget needs to be provided after genesis;\\n /// otherwise the prevEpochDifficulty will be uninitialised and zero.\\n function genesis(\\n bytes calldata genesisHeader,\\n uint256 genesisHeight,\\n uint64 genesisProofLength\\n ) external onlyOwner {\\n require(!ready, \\\"Genesis already performed\\\");\\n\\n require(genesisHeader.length == 80, \\\"Invalid genesis header length\\\");\\n\\n require(\\n genesisHeight % 2016 == 0,\\n \\\"Invalid height of relay genesis block\\\"\\n );\\n\\n require(genesisProofLength < 2016, \\\"Proof length excessive\\\");\\n require(genesisProofLength > 0, \\\"Proof length may not be zero\\\");\\n\\n genesisEpoch = uint64(genesisHeight / 2016);\\n currentEpoch = genesisEpoch;\\n uint256 genesisTarget = genesisHeader.extractTarget();\\n uint256 genesisTimestamp = genesisHeader.extractTimestamp();\\n epochs[genesisEpoch] = Epoch(\\n uint32(genesisTimestamp),\\n uint224(genesisTarget)\\n );\\n proofLength = genesisProofLength;\\n currentEpochDifficulty = BTCUtils.calculateDifficulty(genesisTarget);\\n ready = true;\\n\\n emit Genesis(genesisHeight);\\n }\\n\\n /// @notice Set the number of blocks required to accept a header chain.\\n /// @param newLength The required number of blocks. Must be less than 2016.\\n /// @dev For production, a high number (e.g. 20-50) is recommended.\\n /// Small numbers are accepted but should only be used for testing.\\n function setProofLength(uint64 newLength) external relayActive onlyOwner {\\n require(newLength < 2016, \\\"Proof length excessive\\\");\\n require(newLength > 0, \\\"Proof length may not be zero\\\");\\n require(newLength != proofLength, \\\"Proof length unchanged\\\");\\n proofLength = newLength;\\n emit ProofLengthChanged(newLength);\\n }\\n\\n /// @notice Set whether the relay requires retarget submitters to be\\n /// pre-authorised by governance.\\n /// @param status True if authorisation is to be required, false if not.\\n function setAuthorizationStatus(bool status) external onlyOwner {\\n authorizationRequired = status;\\n emit AuthorizationRequirementChanged(status);\\n }\\n\\n /// @notice Authorise the given address to submit retarget proofs.\\n /// @param submitter The address to be authorised.\\n function authorize(address submitter) external onlyOwner {\\n isAuthorized[submitter] = true;\\n emit SubmitterAuthorized(submitter);\\n }\\n\\n /// @notice Rescind the authorisation of the submitter to retarget.\\n /// @param submitter The address to be deauthorised.\\n function deauthorize(address submitter) external onlyOwner {\\n isAuthorized[submitter] = false;\\n emit SubmitterDeauthorized(submitter);\\n }\\n\\n /// @notice Add a new epoch to the relay by providing a proof\\n /// of the difficulty before and after the retarget.\\n /// @param headers A chain of headers including the last X blocks before\\n /// the retarget, followed by the first X blocks after the retarget,\\n /// where X equals the current proof length.\\n /// @dev Checks that the first X blocks are valid in the most recent epoch,\\n /// that the difficulty of the new epoch is calculated correctly according\\n /// to the block timestamps, and that the next X blocks would be valid in\\n /// the new epoch.\\n /// We have no information of block heights, so we cannot enforce that\\n /// retargets only happen every 2016 blocks; instead, we assume that this\\n /// is the case if a valid proof of work is provided.\\n /// It is possible to cheat the relay by providing X blocks from earlier in\\n /// the most recent epoch, and then mining X new blocks after them.\\n /// However, each of these malicious blocks would have to be mined to a\\n /// higher difficulty than the legitimate ones.\\n /// Alternatively, if the retarget has not been performed yet, one could\\n /// first mine X blocks in the old difficulty with timestamps set far in\\n /// the future, and then another X blocks at a greatly reduced difficulty.\\n /// In either case, cheating the realy requires more work than mining X\\n /// legitimate blocks.\\n /// Only the most recent epoch is vulnerable to these attacks; once a\\n /// retarget has been proven to the relay, the epoch is immutable even if a\\n /// contradictory proof were to be presented later.\\n function retarget(bytes memory headers) external relayActive {\\n if (authorizationRequired) {\\n require(isAuthorized[msg.sender], \\\"Submitter unauthorized\\\");\\n }\\n\\n require(\\n // Require proofLength headers on both sides of the retarget\\n headers.length == (proofLength * 2 * 80),\\n \\\"Invalid header length\\\"\\n );\\n\\n Epoch storage latest = epochs[currentEpoch];\\n\\n uint256 oldTarget = latest.target;\\n\\n bytes32 previousHeaderDigest = bytes32(0);\\n\\n // Validate old chain\\n for (uint256 i = 0; i < proofLength; i++) {\\n (\\n bytes32 currentDigest,\\n uint256 currentHeaderTarget\\n ) = validateHeader(headers, i * 80, previousHeaderDigest);\\n\\n require(\\n currentHeaderTarget == oldTarget,\\n \\\"Invalid target in pre-retarget headers\\\"\\n );\\n\\n previousHeaderDigest = currentDigest;\\n }\\n\\n // get timestamp of retarget block\\n uint256 epochEndTimestamp = headers.extractTimestampAt(\\n (proofLength - 1) * 80\\n );\\n\\n // An attacker could produce blocks with timestamps in the future,\\n // in an attempt to reduce the difficulty after the retarget\\n // to make mining the second part of the retarget proof easier.\\n // In particular, the attacker could reuse all but one block\\n // from the legitimate chain, and only mine the last block.\\n // To hinder this, require that the epoch end timestamp does not\\n // exceed the ethereum timestamp.\\n // NOTE: both are unix seconds, so this comparison should be valid.\\n require(\\n /* solhint-disable-next-line not-rely-on-time */\\n epochEndTimestamp < block.timestamp,\\n \\\"Epoch cannot end in the future\\\"\\n );\\n\\n // Expected target is the full-length target\\n uint256 expectedTarget = BTCUtils.retargetAlgorithm(\\n oldTarget,\\n latest.timestamp,\\n epochEndTimestamp\\n );\\n\\n // Mined target is the header-encoded target\\n uint256 minedTarget = 0;\\n\\n uint256 epochStartTimestamp = headers.extractTimestampAt(\\n proofLength * 80\\n );\\n\\n // validate new chain\\n for (uint256 j = proofLength; j < proofLength * 2; j++) {\\n (\\n bytes32 _currentDigest,\\n uint256 _currentHeaderTarget\\n ) = validateHeader(headers, j * 80, previousHeaderDigest);\\n\\n if (minedTarget == 0) {\\n // The new target has not been set, so check its correctness\\n minedTarget = _currentHeaderTarget;\\n require(\\n // Although the target is a 256-bit number, there are only 32 bits of\\n // space in the Bitcoin header. Because of that, the version stored in\\n // the header is a less-precise representation of the actual target\\n // using base-256 version of scientific notation.\\n //\\n // The 256-bit unsigned integer returned from BTCUtils.retargetAlgorithm\\n // is the precise target value.\\n // The 256-bit unsigned integer returned from validateHeader is the less\\n // precise target value because it was read from 32 bits of space of\\n // Bitcoin block header.\\n //\\n // We can't compare the precise and less precise representations together\\n // so we first mask them to obtain the less precise version:\\n // (full & truncated) == truncated\\n _currentHeaderTarget ==\\n (expectedTarget & _currentHeaderTarget),\\n \\\"Invalid target in new epoch\\\"\\n );\\n } else {\\n // The new target has been set, so remaining targets should match.\\n require(\\n _currentHeaderTarget == minedTarget,\\n \\\"Unexpected target change after retarget\\\"\\n );\\n }\\n\\n previousHeaderDigest = _currentDigest;\\n }\\n\\n currentEpoch = currentEpoch + 1;\\n\\n epochs[currentEpoch] = Epoch(\\n uint32(epochStartTimestamp),\\n uint224(minedTarget)\\n );\\n\\n uint256 oldDifficulty = currentEpochDifficulty;\\n uint256 newDifficulty = BTCUtils.calculateDifficulty(minedTarget);\\n\\n prevEpochDifficulty = oldDifficulty;\\n currentEpochDifficulty = newDifficulty;\\n\\n emit Retarget(oldDifficulty, newDifficulty);\\n }\\n\\n /// @notice Check whether a given chain of headers should be accepted as\\n /// valid within the rules of the relay.\\n /// If the validation fails, this function throws an exception.\\n /// @param headers A chain of 2 to 2015 bitcoin headers.\\n /// @return startingHeaderTimestamp The timestamp of the first header.\\n /// @return headerCount The number of headers.\\n /// @dev A chain of headers is accepted as valid if:\\n /// - Its length is between 2 and 2015 headers.\\n /// - Headers in the chain are sequential and refer to previous digests.\\n /// - Each header is mined with the correct amount of work.\\n /// - The difficulty in each header matches an epoch of the relay,\\n /// as determined by the headers' timestamps. The headers must be between\\n /// the genesis epoch and the latest proven epoch (inclusive).\\n /// If the chain contains a retarget, it is accepted if the retarget has\\n /// already been proven to the relay.\\n /// If the chain contains blocks of an epoch that has not been proven to\\n /// the relay (after a retarget within the header chain, or when the entire\\n /// chain falls within an epoch that has not been proven yet), it will be\\n /// rejected.\\n /// One exception to this is when two subsequent epochs have exactly the\\n /// same difficulty; headers from the latter epoch will be accepted if the\\n /// previous epoch has been proven to the relay.\\n /// This is because it is not possible to distinguish such headers from\\n /// headers of the previous epoch.\\n ///\\n /// If the difficulty increases significantly between relay genesis and the\\n /// present, creating fraudulent proofs for earlier epochs becomes easier.\\n /// Users of the relay should check the timestamps of valid headers and\\n /// only accept appropriately recent ones.\\n function validateChain(bytes memory headers)\\n external\\n view\\n returns (uint256 startingHeaderTimestamp, uint256 headerCount)\\n {\\n require(headers.length % 80 == 0, \\\"Invalid header length\\\");\\n\\n headerCount = headers.length / 80;\\n\\n require(\\n headerCount > 1 && headerCount < 2016,\\n \\\"Invalid number of headers\\\"\\n );\\n\\n startingHeaderTimestamp = headers.extractTimestamp();\\n\\n // Short-circuit the first header's validation.\\n // We validate the header here to get the target which is needed to\\n // precisely identify the epoch.\\n (\\n bytes32 previousHeaderDigest,\\n uint256 currentHeaderTarget\\n ) = validateHeader(headers, 0, bytes32(0));\\n\\n Epoch memory nullEpoch = Epoch(0, 0);\\n\\n uint256 startingEpochNumber = currentEpoch;\\n Epoch memory startingEpoch = epochs[startingEpochNumber];\\n Epoch memory nextEpoch = nullEpoch;\\n\\n // Find the correct epoch for the given chain\\n // Fastest with recent epochs, but able to handle anything after genesis\\n //\\n // The rules for bitcoin timestamps are:\\n // - must be greater than the median of the last 11 blocks' timestamps\\n // - must be less than the network-adjusted time +2 hours\\n //\\n // Because of this, the timestamp of a header may be smaller than the\\n // starting time, or greater than the ending time of its epoch.\\n // However, a valid timestamp is guaranteed to fall within the window\\n // formed by the epochs immediately before and after its timestamp.\\n // We can identify cases like these by comparing the targets.\\n while (startingHeaderTimestamp < startingEpoch.timestamp) {\\n startingEpochNumber -= 1;\\n nextEpoch = startingEpoch;\\n startingEpoch = epochs[startingEpochNumber];\\n }\\n\\n // We have identified the centre of the window,\\n // by reaching the most recent epoch whose starting timestamp\\n // or reached before the genesis where epoch slots are empty.\\n // Therefore check that the timestamp is nonzero.\\n require(\\n startingEpoch.timestamp > 0,\\n \\\"Cannot validate chains before relay genesis\\\"\\n );\\n\\n // The targets don't match. This could be because the block is invalid,\\n // or it could be because of timestamp inaccuracy.\\n // To cover the latter case, check adjacent epochs.\\n if (currentHeaderTarget != startingEpoch.target) {\\n // The target matches the next epoch.\\n // This means we are right at the beginning of the next epoch,\\n // and retargets during the chain should not be possible.\\n if (currentHeaderTarget == nextEpoch.target) {\\n startingEpoch = nextEpoch;\\n nextEpoch = nullEpoch;\\n }\\n // The target doesn't match the next epoch.\\n // Therefore the only valid epoch is the previous one.\\n // Because the timestamp can't be more than 2 hours into the future\\n // we must be right near the end of the epoch,\\n // so a retarget is possible.\\n else {\\n startingEpochNumber -= 1;\\n nextEpoch = startingEpoch;\\n startingEpoch = epochs[startingEpochNumber];\\n\\n // We have failed to find a match,\\n // therefore the target has to be invalid.\\n require(\\n currentHeaderTarget == startingEpoch.target,\\n \\\"Invalid target in header chain\\\"\\n );\\n }\\n }\\n\\n // We've found the correct epoch for the first header.\\n // Validate the rest.\\n for (uint256 i = 1; i < headerCount; i++) {\\n bytes32 currentDigest;\\n (currentDigest, currentHeaderTarget) = validateHeader(\\n headers,\\n i * 80,\\n previousHeaderDigest\\n );\\n\\n // If the header's target does not match the expected target,\\n // check if a retarget is possible.\\n //\\n // If next epoch timestamp exists, a valid retarget is possible\\n // (if next epoch timestamp doesn't exist, either a retarget has\\n // already happened in this chain, the relay needs a retarget\\n // before this chain can be validated, or a retarget is not allowed\\n // because we know the headers are within a timestamp irregularity\\n // of the previous retarget).\\n //\\n // In this case the target must match the next epoch's target,\\n // and the header's timestamp must match the epoch's start.\\n if (currentHeaderTarget != startingEpoch.target) {\\n uint256 currentHeaderTimestamp = headers.extractTimestampAt(\\n i * 80\\n );\\n\\n require(\\n nextEpoch.timestamp != 0 &&\\n currentHeaderTarget == nextEpoch.target &&\\n currentHeaderTimestamp == nextEpoch.timestamp,\\n \\\"Invalid target in header chain\\\"\\n );\\n\\n startingEpoch = nextEpoch;\\n nextEpoch = nullEpoch;\\n }\\n\\n previousHeaderDigest = currentDigest;\\n }\\n\\n return (startingHeaderTimestamp, headerCount);\\n }\\n\\n /// @notice Get the difficulty of the specified block.\\n /// @param blockNumber The number of the block. Must fall within the relay\\n /// range (at or after the relay genesis, and at or before the end of the\\n /// most recent epoch proven to the relay).\\n /// @return The difficulty of the epoch.\\n function getBlockDifficulty(uint256 blockNumber)\\n external\\n view\\n returns (uint256)\\n {\\n return getEpochDifficulty(blockNumber / 2016);\\n }\\n\\n /// @notice Get the range of blocks the relay can accept proofs for.\\n /// @dev Assumes that the genesis has been set correctly.\\n /// Additionally, if the next epoch after the current one has the exact\\n /// same difficulty, headers for it can be validated as well.\\n /// This function should be used for informative purposes,\\n /// e.g. to determine whether a retarget must be provided before submitting\\n /// a header chain for validation.\\n /// @return relayGenesis The height of the earliest block that can be\\n /// included in header chains for the relay to validate.\\n /// @return currentEpochEnd The height of the last block that can be\\n /// included in header chains for the relay to validate.\\n function getRelayRange()\\n external\\n view\\n returns (uint256 relayGenesis, uint256 currentEpochEnd)\\n {\\n relayGenesis = genesisEpoch * 2016;\\n currentEpochEnd = (currentEpoch * 2016) + 2015;\\n }\\n\\n /// @notice Returns the difficulty of the current epoch.\\n /// @dev returns 0 if the relay is not ready.\\n /// @return The difficulty of the current epoch.\\n function getCurrentEpochDifficulty()\\n external\\n view\\n virtual\\n returns (uint256)\\n {\\n return currentEpochDifficulty;\\n }\\n\\n /// @notice Returns the difficulty of the previous epoch.\\n /// @dev Returns 0 if the relay is not ready or has not had a retarget.\\n /// @return The difficulty of the previous epoch.\\n function getPrevEpochDifficulty() external view virtual returns (uint256) {\\n return prevEpochDifficulty;\\n }\\n\\n function getCurrentAndPrevEpochDifficulty()\\n external\\n view\\n returns (uint256 current, uint256 previous)\\n {\\n return (currentEpochDifficulty, prevEpochDifficulty);\\n }\\n\\n /// @notice Get the difficulty of the specified epoch.\\n /// @param epochNumber The number of the epoch (the height of the first\\n /// block of the epoch, divided by 2016). Must fall within the relay range.\\n /// @return The difficulty of the epoch.\\n function getEpochDifficulty(uint256 epochNumber)\\n public\\n view\\n returns (uint256)\\n {\\n require(epochNumber >= genesisEpoch, \\\"Epoch is before relay genesis\\\");\\n require(\\n epochNumber <= currentEpoch,\\n \\\"Epoch is not proven to the relay yet\\\"\\n );\\n return BTCUtils.calculateDifficulty(epochs[epochNumber].target);\\n }\\n\\n /// @notice Check that the specified header forms a correct chain with the\\n /// digest of the previous header (if provided), and has sufficient work.\\n /// @param headers The byte array containing the header of interest.\\n /// @param start The start of the header in the array.\\n /// @param prevDigest The digest of the previous header\\n /// (optional; providing zeros for the digest skips the check).\\n /// @return digest The digest of the current header.\\n /// @return target The PoW target of the header.\\n /// @dev Throws an exception if the header's chain or PoW are invalid.\\n /// Performs no other validation.\\n function validateHeader(\\n bytes memory headers,\\n uint256 start,\\n bytes32 prevDigest\\n ) internal view returns (bytes32 digest, uint256 target) {\\n // If previous block digest has been provided, require that it matches\\n if (prevDigest != bytes32(0)) {\\n require(\\n headers.validateHeaderPrevHash(start, prevDigest),\\n \\\"Invalid chain\\\"\\n );\\n }\\n\\n // Require that the header has sufficient work for its stated target\\n target = headers.extractTargetAt(start);\\n digest = headers.hash256Slice(start, 80);\\n require(ValidateSPV.validateHeaderWork(digest, target), \\\"Invalid work\\\");\\n\\n return (digest, target);\\n }\\n}\\n\",\"keccak256\":\"0x5329ba57ec3db13128ba0a90569682b16211f7fbc3fbab764fd0cd60386a7441\",\"license\":\"GPL-3.0-only\"}},\"version\":1}",
|
|
472
|
-
"bytecode": "0x608060405234801561001057600080fd5b5061001a3361001f565b61006f565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6122748061007e6000396000f3fe608060405234801561001057600080fd5b50600436106101825760003560e01c8063715018a6116100d8578063b6a5d7de1161008c578063f2fde38b11610066578063f2fde38b14610322578063f5619fda14610335578063fe9fbb801461035057600080fd5b8063b6a5d7de146102e8578063b70e6be6146102fb578063eb8695ef1461030f57600080fd5b80637ca5b1dd116100bd5780637ca5b1dd146102a65780638da5cb5b146102b957806395410d2b146102d457600080fd5b8063715018a61461026a578063766718081461027257600080fd5b806327c97fa51161013a5780634ca49f51116101145780634ca49f5114610220578063620414e6146102335780636defbf801461024657600080fd5b806327c97fa5146101fa5780632b97be241461020d5780633a1b77b01461021557600080fd5b8063113764be1161016b578063113764be146101ca578063189179a3146101d257806319c9aa32146101e557600080fd5b806306a274221461018757806310b76ed8146101ad575b600080fd5b61019a610195366004611e14565b610373565b6040519081526020015b60405180910390f35b6101b561038a565b604080519283526020830191909152016101a4565b60025461019a565b6101b56101e0366004611e43565b6103ea565b6101f86101f3366004611f11565b6107e2565b005b6101f8610208366004611f2c565b610a27565b60035461019a565b6002546003546101b5565b6101f861022e366004611f55565b610ad2565b61019a610241366004611e14565b610eed565b60005461025a90600160a01b900460ff1681565b60405190151581526020016101a4565b6101f8610ffd565b60015461028d90600160401b900467ffffffffffffffff1681565b60405167ffffffffffffffff90911681526020016101a4565b6101f86102b4366004611e43565b611063565b6000546040516001600160a01b0390911681526020016101a4565b60005461025a90600160a81b900460ff1681565b6101f86102f6366004611f2c565b611601565b60015461028d9067ffffffffffffffff1681565b6101f861031d366004611fde565b6116af565b6101f8610330366004611f2c565b611771565b60005461028d90600160b01b900467ffffffffffffffff1681565b61025a61035e366004611f2c565b60056020526000908152604090205460ff1681565b60006103846102416107e08461202c565b92915050565b60015460009081906103a89067ffffffffffffffff166107e0612040565b60015467ffffffffffffffff91821693506103ce91600160401b909104166107e0612040565b6103da906107df61206c565b67ffffffffffffffff1690509091565b600080605083516103fb9190612094565b1561044d5760405162461bcd60e51b815260206004820152601560248201527f496e76616c696420686561646572206c656e677468000000000000000000000060448201526064015b60405180910390fd5b6050835161045b919061202c565b905060018111801561046e57506107e081105b6104ba5760405162461bcd60e51b815260206004820152601960248201527f496e76616c6964206e756d626572206f662068656164657273000000000000006044820152606401610444565b6104c383611853565b63ffffffff1691506000806104d9858280611887565b6040805180820182526000808252602080830182905260015467ffffffffffffffff600160401b90910416808352600482529184902084518086019095525463ffffffff8116855264010000000090046001600160e01b031690840152939550919350909190825b815163ffffffff1688101561059f5761055b6001846120a8565b60008181526004602090815260409182902082518084019093525463ffffffff8116835264010000000090046001600160e01b031690820152909350919050610541565b815163ffffffff166106195760405162461bcd60e51b815260206004820152602b60248201527f43616e6e6f742076616c696461746520636861696e73206265666f726520726560448201527f6c61792067656e657369730000000000000000000000000000000000000000006064820152608401610444565b81602001516001600160e01b031685146106e35780602001516001600160e01b03168503610649579050826106e3565b6106546001846120a8565b60008181526004602090815260409182902082518084019093525463ffffffff8116835264010000000090046001600160e01b031690820181905291945092915085146106e35760405162461bcd60e51b815260206004820152601e60248201527f496e76616c69642074617267657420696e2068656164657220636861696e00006044820152606401610444565b60015b878110156107d65760006107058b6106ff8460506120bb565b8a611887565b60208601519098509091506001600160e01b031687146107c257600061073661072f8460506120bb565b8d9061195f565b845163ffffffff9182169250161580159061075d575083602001516001600160e01b031688145b801561076f5750835163ffffffff1681145b6107bb5760405162461bcd60e51b815260206004820152601e60248201527f496e76616c69642074617267657420696e2068656164657220636861696e00006044820152606401610444565b5091925084915b9650806107ce816120d2565b9150506106e6565b50505050505050915091565b600054600160a01b900460ff1661083b5760405162461bcd60e51b815260206004820152601a60248201527f52656c6179206973206e6f7420726561647920666f72207573650000000000006044820152606401610444565b6000546001600160a01b031633146108955760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610444565b6107e08167ffffffffffffffff16106108f05760405162461bcd60e51b815260206004820152601660248201527f50726f6f66206c656e67746820657863657373697665000000000000000000006044820152606401610444565b60008167ffffffffffffffff161161094a5760405162461bcd60e51b815260206004820152601c60248201527f50726f6f66206c656e677468206d6179206e6f74206265207a65726f000000006044820152606401610444565b60005467ffffffffffffffff600160b01b9091048116908216036109b05760405162461bcd60e51b815260206004820152601660248201527f50726f6f66206c656e67746820756e6368616e676564000000000000000000006044820152606401610444565b600080547fffff0000000000000000ffffffffffffffffffffffffffffffffffffffffffff16600160b01b67ffffffffffffffff8416908102919091179091556040519081527f3e9f904d8cf11753c79b67c8259c582056d4a7d8af120f81257a59eeb8824b96906020015b60405180910390a150565b6000546001600160a01b03163314610a815760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610444565b6001600160a01b038116600081815260056020908152604091829020805460ff1916905590519182527f7498b96beeabea5ad3139f1a2861a03e480034254e36b10aae2e6e42ad7b4b689101610a1c565b6000546001600160a01b03163314610b2c5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610444565b600054600160a01b900460ff1615610b865760405162461bcd60e51b815260206004820152601960248201527f47656e6573697320616c726561647920706572666f726d6564000000000000006044820152606401610444565b60508314610bd65760405162461bcd60e51b815260206004820152601d60248201527f496e76616c69642067656e6573697320686561646572206c656e6774680000006044820152606401610444565b610be26107e083612094565b15610c555760405162461bcd60e51b815260206004820152602560248201527f496e76616c696420686569676874206f662072656c61792067656e657369732060448201527f626c6f636b0000000000000000000000000000000000000000000000000000006064820152608401610444565b6107e08167ffffffffffffffff1610610cb05760405162461bcd60e51b815260206004820152601660248201527f50726f6f66206c656e67746820657863657373697665000000000000000000006044820152606401610444565b60008167ffffffffffffffff1611610d0a5760405162461bcd60e51b815260206004820152601c60248201527f50726f6f66206c656e677468206d6179206e6f74206265207a65726f000000006044820152606401610444565b610d166107e08361202c565b600180547fffffffffffffffffffffffffffffffff000000000000000000000000000000001667ffffffffffffffff92909216918217600160401b92909202919091179055604080516020601f8601819004810282018101909252848152600091610d9c9190879087908190840183828082843760009201919091525061198092505050565b90506000610ddf86868080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061185392505050565b60408051808201825263ffffffff9283168082526001600160e01b03808716602080850191825260015467ffffffffffffffff9081166000908152600490925295812094519151909216640100000000029516949094179091558254918616600160b01b027fffff0000000000000000ffffffffffffffffffffffffffffffffffffffffffff909216919091179091559050610e7a8261198d565b600255600080547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff16600160a01b1790556040517f2381d16925551c2fb1a5edfcf4fce2f6d085e1f85f4b88340c09c9d191f9d4e990610edd9086815260200190565b60405180910390a1505050505050565b60015460009067ffffffffffffffff16821015610f4c5760405162461bcd60e51b815260206004820152601d60248201527f45706f6368206973206265666f72652072656c61792067656e657369730000006044820152606401610444565b600154600160401b900467ffffffffffffffff16821115610fd45760405162461bcd60e51b8152602060048201526024808201527f45706f6368206973206e6f742070726f76656e20746f207468652072656c617960448201527f20796574000000000000000000000000000000000000000000000000000000006064820152608401610444565b6000828152600460205260409020546103849064010000000090046001600160e01b031661198d565b6000546001600160a01b031633146110575760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610444565b61106160006119b5565b565b600054600160a01b900460ff166110bc5760405162461bcd60e51b815260206004820152601a60248201527f52656c6179206973206e6f7420726561647920666f72207573650000000000006044820152606401610444565b600054600160a81b900460ff161561112d573360009081526005602052604090205460ff1661112d5760405162461bcd60e51b815260206004820152601660248201527f5375626d697474657220756e617574686f72697a6564000000000000000000006044820152606401610444565b60005461114c90600160b01b900467ffffffffffffffff166002612040565b611157906050612040565b67ffffffffffffffff168151146111b05760405162461bcd60e51b815260206004820152601560248201527f496e76616c696420686561646572206c656e67746800000000000000000000006044820152606401610444565b600154600160401b900467ffffffffffffffff166000908152600460205260408120805490916401000000009091046001600160e01b031690805b600054600160b01b900467ffffffffffffffff168110156112ac5760008061121e876112188560506120bb565b86611887565b915091508481146112975760405162461bcd60e51b815260206004820152602660248201527f496e76616c69642074617267657420696e207072652d7265746172676574206860448201527f65616465727300000000000000000000000000000000000000000000000000006064820152608401610444565b509150806112a4816120d2565b9150506111eb565b50600080546112ee906112d290600190600160b01b900467ffffffffffffffff166120eb565b6112dd906050612040565b869067ffffffffffffffff1661195f565b63ffffffff1690504281106113455760405162461bcd60e51b815260206004820152601e60248201527f45706f63682063616e6e6f7420656e6420696e207468652066757475726500006044820152606401610444565b835460009061135c90859063ffffffff1684611a1d565b9050600080611398600060169054906101000a900467ffffffffffffffff1660506113879190612040565b899067ffffffffffffffff1661195f565b60005463ffffffff919091169150600160b01b900467ffffffffffffffff165b6000546113d790600160b01b900467ffffffffffffffff166002612040565b67ffffffffffffffff168110156114e9576000806113fa8b6106ff8560506120bb565b915091508460000361145f57809450808616811461145a5760405162461bcd60e51b815260206004820152601b60248201527f496e76616c69642074617267657420696e206e65772065706f636800000000006044820152606401610444565b6114d4565b8481146114d45760405162461bcd60e51b815260206004820152602760248201527f556e657870656374656420746172676574206368616e6765206166746572207260448201527f65746172676574000000000000000000000000000000000000000000000000006064820152608401610444565b509550806114e1816120d2565b9150506113b8565b50600160089054906101000a900467ffffffffffffffff16600161150d919061206c565b6001805467ffffffffffffffff928316600160401b9081027fffffffffffffffffffffffffffffffff0000000000000000ffffffffffffffff909216919091179182905560408051808201825263ffffffff80871682526001600160e01b03808916602080850191825295909604909616600090815260049094529183209051935190941664010000000002921691909117909155600254906115af8461198d565b6003839055600281905560408051848152602081018390529192507fa282ee798b132f9dc11e06cd4d8e767e562be8709602ca14fea7ab3392acbdab910160405180910390a150505050505050505050565b6000546001600160a01b0316331461165b5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610444565b6001600160a01b038116600081815260056020908152604091829020805460ff1916600117905590519182527fd53649b492f738bb59d6825099b5955073efda0bf9e3a7ad20da22e110122e299101610a1c565b6000546001600160a01b031633146117095760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610444565b60008054821515600160a81b027fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff9091161790556040517fd813b248d49c8bf08be2b6947126da6763df310beed7bea97756456c5727419a90610a1c90831515815260200190565b6000546001600160a01b031633146117cb5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610444565b6001600160a01b0381166118475760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610444565b611850816119b5565b50565b600061038461186183611ab1565b60d881901c63ff00ff001662ff00ff60e89290921c9190911617601081811b91901c1790565b60008082156118e75761189b858585611abe565b6118e75760405162461bcd60e51b815260206004820152600d60248201527f496e76616c696420636861696e000000000000000000000000000000000000006044820152606401610444565b6118f18585611ae9565b90506118ff85856050611b8b565b915061190b8282611bb5565b6119575760405162461bcd60e51b815260206004820152600c60248201527f496e76616c696420776f726b00000000000000000000000000000000000000006044820152606401610444565b935093915050565b600061197961186161197284604461210c565b8590611d0e565b9392505050565b6000610384826000611ae9565b60006103847bffff000000000000000000000000000000000000000000000000000083611d1d565b600080546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600080611a2a8385611d29565b9050611a3a621275006004611d1d565b811015611a5257611a4f621275006004611d1d565b90505b611a60621275006004611d85565b811115611a7857611a75621275006004611d85565b90505b6000611a9182611a8b8862010000611d1d565b90611d85565b9050611aa762010000611a8b8362127500611d1d565b9695505050505050565b6000610384826044611d0e565b600080611acb8585611dfb565b9050828114611ade576000915050611979565b506001949350505050565b600080611afa61197284604861210c565b60e81c9050600084611b0d85604b61210c565b81518110611b1d57611b1d61211f565b016020015160f81c90506000611b5183600060108262ffffff16901c8261ff001660108462ffffff16901b17179050919050565b62ffffff1690506000611b65600384612135565b60ff169050611b7681610100612232565b611b8090836120bb565b979650505050505050565b6000602060008385602001870160025afa50602060006020600060025afa50506000519392505050565b600082611bc457506000610384565b81611d068460008190506008817eff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff16901b600882901c7eff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff161790506010817dffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff16901b601082901c7dffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff161790506020817bffffffff00000000ffffffff00000000ffffffff00000000ffffffff16901b602082901c7bffffffff00000000ffffffff00000000ffffffff00000000ffffffff1617905060408177ffffffffffffffff0000000000000000ffffffffffffffff16901b604082901c77ffffffffffffffff0000000000000000ffffffffffffffff16179050608081901b608082901c179050919050565b109392505050565b60006119798383016020015190565b6000611979828461202c565b600082821115611d7b5760405162461bcd60e51b815260206004820152601d60248201527f556e646572666c6f7720647572696e67207375627472616374696f6e2e0000006044820152606401610444565b61197982846120a8565b600082600003611d9757506000610384565b611da182846120bb565b905081611dae848361202c565b146103845760405162461bcd60e51b815260206004820152601f60248201527f4f766572666c6f7720647572696e67206d756c7469706c69636174696f6e2e006044820152606401610444565b6000611979611e0b83600461210c565b84016020015190565b600060208284031215611e2657600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b600060208284031215611e5557600080fd5b813567ffffffffffffffff80821115611e6d57600080fd5b818401915084601f830112611e8157600080fd5b813581811115611e9357611e93611e2d565b604051601f8201601f19908116603f01168101908382118183101715611ebb57611ebb611e2d565b81604052828152876020848701011115611ed457600080fd5b826020860160208301376000928101602001929092525095945050505050565b803567ffffffffffffffff81168114611f0c57600080fd5b919050565b600060208284031215611f2357600080fd5b61197982611ef4565b600060208284031215611f3e57600080fd5b81356001600160a01b038116811461197957600080fd5b60008060008060608587031215611f6b57600080fd5b843567ffffffffffffffff80821115611f8357600080fd5b818701915087601f830112611f9757600080fd5b813581811115611fa657600080fd5b886020828501011115611fb857600080fd5b602092830196509450508501359150611fd360408601611ef4565b905092959194509250565b600060208284031215611ff057600080fd5b8135801515811461197957600080fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b60008261203b5761203b612000565b500490565b67ffffffffffffffff81811683821602808216919082811461206457612064612016565b505092915050565b67ffffffffffffffff81811683821601908082111561208d5761208d612016565b5092915050565b6000826120a3576120a3612000565b500690565b8181038181111561038457610384612016565b808202811582820484141761038457610384612016565b6000600182016120e4576120e4612016565b5060010190565b67ffffffffffffffff82811682821603908082111561208d5761208d612016565b8082018082111561038457610384612016565b634e487b7160e01b600052603260045260246000fd5b60ff828116828216039081111561038457610384612016565b600181815b8085111561218957816000190482111561216f5761216f612016565b8085161561217c57918102915b93841c9390800290612153565b509250929050565b6000826121a057506001610384565b816121ad57506000610384565b81600181146121c357600281146121cd576121e9565b6001915050610384565b60ff8411156121de576121de612016565b50506001821b610384565b5060208310610133831016604e8410600b841016171561220c575081810a610384565b612216838361214e565b806000190482111561222a5761222a612016565b029392505050565b6000611979838361219156fea264697066735822122018ceadb31a71f313826b2debd631f3528b052732b43f13559c05ff21b0f0819264736f6c63430008110033",
|
|
473
|
-
"deployedBytecode": "0x608060405234801561001057600080fd5b50600436106101825760003560e01c8063715018a6116100d8578063b6a5d7de1161008c578063f2fde38b11610066578063f2fde38b14610322578063f5619fda14610335578063fe9fbb801461035057600080fd5b8063b6a5d7de146102e8578063b70e6be6146102fb578063eb8695ef1461030f57600080fd5b80637ca5b1dd116100bd5780637ca5b1dd146102a65780638da5cb5b146102b957806395410d2b146102d457600080fd5b8063715018a61461026a578063766718081461027257600080fd5b806327c97fa51161013a5780634ca49f51116101145780634ca49f5114610220578063620414e6146102335780636defbf801461024657600080fd5b806327c97fa5146101fa5780632b97be241461020d5780633a1b77b01461021557600080fd5b8063113764be1161016b578063113764be146101ca578063189179a3146101d257806319c9aa32146101e557600080fd5b806306a274221461018757806310b76ed8146101ad575b600080fd5b61019a610195366004611e14565b610373565b6040519081526020015b60405180910390f35b6101b561038a565b604080519283526020830191909152016101a4565b60025461019a565b6101b56101e0366004611e43565b6103ea565b6101f86101f3366004611f11565b6107e2565b005b6101f8610208366004611f2c565b610a27565b60035461019a565b6002546003546101b5565b6101f861022e366004611f55565b610ad2565b61019a610241366004611e14565b610eed565b60005461025a90600160a01b900460ff1681565b60405190151581526020016101a4565b6101f8610ffd565b60015461028d90600160401b900467ffffffffffffffff1681565b60405167ffffffffffffffff90911681526020016101a4565b6101f86102b4366004611e43565b611063565b6000546040516001600160a01b0390911681526020016101a4565b60005461025a90600160a81b900460ff1681565b6101f86102f6366004611f2c565b611601565b60015461028d9067ffffffffffffffff1681565b6101f861031d366004611fde565b6116af565b6101f8610330366004611f2c565b611771565b60005461028d90600160b01b900467ffffffffffffffff1681565b61025a61035e366004611f2c565b60056020526000908152604090205460ff1681565b60006103846102416107e08461202c565b92915050565b60015460009081906103a89067ffffffffffffffff166107e0612040565b60015467ffffffffffffffff91821693506103ce91600160401b909104166107e0612040565b6103da906107df61206c565b67ffffffffffffffff1690509091565b600080605083516103fb9190612094565b1561044d5760405162461bcd60e51b815260206004820152601560248201527f496e76616c696420686561646572206c656e677468000000000000000000000060448201526064015b60405180910390fd5b6050835161045b919061202c565b905060018111801561046e57506107e081105b6104ba5760405162461bcd60e51b815260206004820152601960248201527f496e76616c6964206e756d626572206f662068656164657273000000000000006044820152606401610444565b6104c383611853565b63ffffffff1691506000806104d9858280611887565b6040805180820182526000808252602080830182905260015467ffffffffffffffff600160401b90910416808352600482529184902084518086019095525463ffffffff8116855264010000000090046001600160e01b031690840152939550919350909190825b815163ffffffff1688101561059f5761055b6001846120a8565b60008181526004602090815260409182902082518084019093525463ffffffff8116835264010000000090046001600160e01b031690820152909350919050610541565b815163ffffffff166106195760405162461bcd60e51b815260206004820152602b60248201527f43616e6e6f742076616c696461746520636861696e73206265666f726520726560448201527f6c61792067656e657369730000000000000000000000000000000000000000006064820152608401610444565b81602001516001600160e01b031685146106e35780602001516001600160e01b03168503610649579050826106e3565b6106546001846120a8565b60008181526004602090815260409182902082518084019093525463ffffffff8116835264010000000090046001600160e01b031690820181905291945092915085146106e35760405162461bcd60e51b815260206004820152601e60248201527f496e76616c69642074617267657420696e2068656164657220636861696e00006044820152606401610444565b60015b878110156107d65760006107058b6106ff8460506120bb565b8a611887565b60208601519098509091506001600160e01b031687146107c257600061073661072f8460506120bb565b8d9061195f565b845163ffffffff9182169250161580159061075d575083602001516001600160e01b031688145b801561076f5750835163ffffffff1681145b6107bb5760405162461bcd60e51b815260206004820152601e60248201527f496e76616c69642074617267657420696e2068656164657220636861696e00006044820152606401610444565b5091925084915b9650806107ce816120d2565b9150506106e6565b50505050505050915091565b600054600160a01b900460ff1661083b5760405162461bcd60e51b815260206004820152601a60248201527f52656c6179206973206e6f7420726561647920666f72207573650000000000006044820152606401610444565b6000546001600160a01b031633146108955760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610444565b6107e08167ffffffffffffffff16106108f05760405162461bcd60e51b815260206004820152601660248201527f50726f6f66206c656e67746820657863657373697665000000000000000000006044820152606401610444565b60008167ffffffffffffffff161161094a5760405162461bcd60e51b815260206004820152601c60248201527f50726f6f66206c656e677468206d6179206e6f74206265207a65726f000000006044820152606401610444565b60005467ffffffffffffffff600160b01b9091048116908216036109b05760405162461bcd60e51b815260206004820152601660248201527f50726f6f66206c656e67746820756e6368616e676564000000000000000000006044820152606401610444565b600080547fffff0000000000000000ffffffffffffffffffffffffffffffffffffffffffff16600160b01b67ffffffffffffffff8416908102919091179091556040519081527f3e9f904d8cf11753c79b67c8259c582056d4a7d8af120f81257a59eeb8824b96906020015b60405180910390a150565b6000546001600160a01b03163314610a815760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610444565b6001600160a01b038116600081815260056020908152604091829020805460ff1916905590519182527f7498b96beeabea5ad3139f1a2861a03e480034254e36b10aae2e6e42ad7b4b689101610a1c565b6000546001600160a01b03163314610b2c5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610444565b600054600160a01b900460ff1615610b865760405162461bcd60e51b815260206004820152601960248201527f47656e6573697320616c726561647920706572666f726d6564000000000000006044820152606401610444565b60508314610bd65760405162461bcd60e51b815260206004820152601d60248201527f496e76616c69642067656e6573697320686561646572206c656e6774680000006044820152606401610444565b610be26107e083612094565b15610c555760405162461bcd60e51b815260206004820152602560248201527f496e76616c696420686569676874206f662072656c61792067656e657369732060448201527f626c6f636b0000000000000000000000000000000000000000000000000000006064820152608401610444565b6107e08167ffffffffffffffff1610610cb05760405162461bcd60e51b815260206004820152601660248201527f50726f6f66206c656e67746820657863657373697665000000000000000000006044820152606401610444565b60008167ffffffffffffffff1611610d0a5760405162461bcd60e51b815260206004820152601c60248201527f50726f6f66206c656e677468206d6179206e6f74206265207a65726f000000006044820152606401610444565b610d166107e08361202c565b600180547fffffffffffffffffffffffffffffffff000000000000000000000000000000001667ffffffffffffffff92909216918217600160401b92909202919091179055604080516020601f8601819004810282018101909252848152600091610d9c9190879087908190840183828082843760009201919091525061198092505050565b90506000610ddf86868080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061185392505050565b60408051808201825263ffffffff9283168082526001600160e01b03808716602080850191825260015467ffffffffffffffff9081166000908152600490925295812094519151909216640100000000029516949094179091558254918616600160b01b027fffff0000000000000000ffffffffffffffffffffffffffffffffffffffffffff909216919091179091559050610e7a8261198d565b600255600080547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff16600160a01b1790556040517f2381d16925551c2fb1a5edfcf4fce2f6d085e1f85f4b88340c09c9d191f9d4e990610edd9086815260200190565b60405180910390a1505050505050565b60015460009067ffffffffffffffff16821015610f4c5760405162461bcd60e51b815260206004820152601d60248201527f45706f6368206973206265666f72652072656c61792067656e657369730000006044820152606401610444565b600154600160401b900467ffffffffffffffff16821115610fd45760405162461bcd60e51b8152602060048201526024808201527f45706f6368206973206e6f742070726f76656e20746f207468652072656c617960448201527f20796574000000000000000000000000000000000000000000000000000000006064820152608401610444565b6000828152600460205260409020546103849064010000000090046001600160e01b031661198d565b6000546001600160a01b031633146110575760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610444565b61106160006119b5565b565b600054600160a01b900460ff166110bc5760405162461bcd60e51b815260206004820152601a60248201527f52656c6179206973206e6f7420726561647920666f72207573650000000000006044820152606401610444565b600054600160a81b900460ff161561112d573360009081526005602052604090205460ff1661112d5760405162461bcd60e51b815260206004820152601660248201527f5375626d697474657220756e617574686f72697a6564000000000000000000006044820152606401610444565b60005461114c90600160b01b900467ffffffffffffffff166002612040565b611157906050612040565b67ffffffffffffffff168151146111b05760405162461bcd60e51b815260206004820152601560248201527f496e76616c696420686561646572206c656e67746800000000000000000000006044820152606401610444565b600154600160401b900467ffffffffffffffff166000908152600460205260408120805490916401000000009091046001600160e01b031690805b600054600160b01b900467ffffffffffffffff168110156112ac5760008061121e876112188560506120bb565b86611887565b915091508481146112975760405162461bcd60e51b815260206004820152602660248201527f496e76616c69642074617267657420696e207072652d7265746172676574206860448201527f65616465727300000000000000000000000000000000000000000000000000006064820152608401610444565b509150806112a4816120d2565b9150506111eb565b50600080546112ee906112d290600190600160b01b900467ffffffffffffffff166120eb565b6112dd906050612040565b869067ffffffffffffffff1661195f565b63ffffffff1690504281106113455760405162461bcd60e51b815260206004820152601e60248201527f45706f63682063616e6e6f7420656e6420696e207468652066757475726500006044820152606401610444565b835460009061135c90859063ffffffff1684611a1d565b9050600080611398600060169054906101000a900467ffffffffffffffff1660506113879190612040565b899067ffffffffffffffff1661195f565b60005463ffffffff919091169150600160b01b900467ffffffffffffffff165b6000546113d790600160b01b900467ffffffffffffffff166002612040565b67ffffffffffffffff168110156114e9576000806113fa8b6106ff8560506120bb565b915091508460000361145f57809450808616811461145a5760405162461bcd60e51b815260206004820152601b60248201527f496e76616c69642074617267657420696e206e65772065706f636800000000006044820152606401610444565b6114d4565b8481146114d45760405162461bcd60e51b815260206004820152602760248201527f556e657870656374656420746172676574206368616e6765206166746572207260448201527f65746172676574000000000000000000000000000000000000000000000000006064820152608401610444565b509550806114e1816120d2565b9150506113b8565b50600160089054906101000a900467ffffffffffffffff16600161150d919061206c565b6001805467ffffffffffffffff928316600160401b9081027fffffffffffffffffffffffffffffffff0000000000000000ffffffffffffffff909216919091179182905560408051808201825263ffffffff80871682526001600160e01b03808916602080850191825295909604909616600090815260049094529183209051935190941664010000000002921691909117909155600254906115af8461198d565b6003839055600281905560408051848152602081018390529192507fa282ee798b132f9dc11e06cd4d8e767e562be8709602ca14fea7ab3392acbdab910160405180910390a150505050505050505050565b6000546001600160a01b0316331461165b5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610444565b6001600160a01b038116600081815260056020908152604091829020805460ff1916600117905590519182527fd53649b492f738bb59d6825099b5955073efda0bf9e3a7ad20da22e110122e299101610a1c565b6000546001600160a01b031633146117095760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610444565b60008054821515600160a81b027fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff9091161790556040517fd813b248d49c8bf08be2b6947126da6763df310beed7bea97756456c5727419a90610a1c90831515815260200190565b6000546001600160a01b031633146117cb5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610444565b6001600160a01b0381166118475760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610444565b611850816119b5565b50565b600061038461186183611ab1565b60d881901c63ff00ff001662ff00ff60e89290921c9190911617601081811b91901c1790565b60008082156118e75761189b858585611abe565b6118e75760405162461bcd60e51b815260206004820152600d60248201527f496e76616c696420636861696e000000000000000000000000000000000000006044820152606401610444565b6118f18585611ae9565b90506118ff85856050611b8b565b915061190b8282611bb5565b6119575760405162461bcd60e51b815260206004820152600c60248201527f496e76616c696420776f726b00000000000000000000000000000000000000006044820152606401610444565b935093915050565b600061197961186161197284604461210c565b8590611d0e565b9392505050565b6000610384826000611ae9565b60006103847bffff000000000000000000000000000000000000000000000000000083611d1d565b600080546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600080611a2a8385611d29565b9050611a3a621275006004611d1d565b811015611a5257611a4f621275006004611d1d565b90505b611a60621275006004611d85565b811115611a7857611a75621275006004611d85565b90505b6000611a9182611a8b8862010000611d1d565b90611d85565b9050611aa762010000611a8b8362127500611d1d565b9695505050505050565b6000610384826044611d0e565b600080611acb8585611dfb565b9050828114611ade576000915050611979565b506001949350505050565b600080611afa61197284604861210c565b60e81c9050600084611b0d85604b61210c565b81518110611b1d57611b1d61211f565b016020015160f81c90506000611b5183600060108262ffffff16901c8261ff001660108462ffffff16901b17179050919050565b62ffffff1690506000611b65600384612135565b60ff169050611b7681610100612232565b611b8090836120bb565b979650505050505050565b6000602060008385602001870160025afa50602060006020600060025afa50506000519392505050565b600082611bc457506000610384565b81611d068460008190506008817eff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff16901b600882901c7eff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff161790506010817dffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff16901b601082901c7dffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff161790506020817bffffffff00000000ffffffff00000000ffffffff00000000ffffffff16901b602082901c7bffffffff00000000ffffffff00000000ffffffff00000000ffffffff1617905060408177ffffffffffffffff0000000000000000ffffffffffffffff16901b604082901c77ffffffffffffffff0000000000000000ffffffffffffffff16179050608081901b608082901c179050919050565b109392505050565b60006119798383016020015190565b6000611979828461202c565b600082821115611d7b5760405162461bcd60e51b815260206004820152601d60248201527f556e646572666c6f7720647572696e67207375627472616374696f6e2e0000006044820152606401610444565b61197982846120a8565b600082600003611d9757506000610384565b611da182846120bb565b905081611dae848361202c565b146103845760405162461bcd60e51b815260206004820152601f60248201527f4f766572666c6f7720647572696e67206d756c7469706c69636174696f6e2e006044820152606401610444565b6000611979611e0b83600461210c565b84016020015190565b600060208284031215611e2657600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b600060208284031215611e5557600080fd5b813567ffffffffffffffff80821115611e6d57600080fd5b818401915084601f830112611e8157600080fd5b813581811115611e9357611e93611e2d565b604051601f8201601f19908116603f01168101908382118183101715611ebb57611ebb611e2d565b81604052828152876020848701011115611ed457600080fd5b826020860160208301376000928101602001929092525095945050505050565b803567ffffffffffffffff81168114611f0c57600080fd5b919050565b600060208284031215611f2357600080fd5b61197982611ef4565b600060208284031215611f3e57600080fd5b81356001600160a01b038116811461197957600080fd5b60008060008060608587031215611f6b57600080fd5b843567ffffffffffffffff80821115611f8357600080fd5b818701915087601f830112611f9757600080fd5b813581811115611fa657600080fd5b886020828501011115611fb857600080fd5b602092830196509450508501359150611fd360408601611ef4565b905092959194509250565b600060208284031215611ff057600080fd5b8135801515811461197957600080fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b60008261203b5761203b612000565b500490565b67ffffffffffffffff81811683821602808216919082811461206457612064612016565b505092915050565b67ffffffffffffffff81811683821601908082111561208d5761208d612016565b5092915050565b6000826120a3576120a3612000565b500690565b8181038181111561038457610384612016565b808202811582820484141761038457610384612016565b6000600182016120e4576120e4612016565b5060010190565b67ffffffffffffffff82811682821603908082111561208d5761208d612016565b8082018082111561038457610384612016565b634e487b7160e01b600052603260045260246000fd5b60ff828116828216039081111561038457610384612016565b600181815b8085111561218957816000190482111561216f5761216f612016565b8085161561217c57918102915b93841c9390800290612153565b509250929050565b6000826121a057506001610384565b816121ad57506000610384565b81600181146121c357600281146121cd576121e9565b6001915050610384565b60ff8411156121de576121de612016565b50506001821b610384565b5060208310610133831016604e8410600b841016171561220c575081810a610384565b612216838361214e565b806000190482111561222a5761222a612016565b029392505050565b6000611979838361219156fea264697066735822122018ceadb31a71f313826b2debd631f3528b052732b43f13559c05ff21b0f0819264736f6c63430008110033",
|
|
470
|
+
"solcInputHash": "2cb3f9e60e45f0ca528d3d5260ff3139",
|
|
471
|
+
"metadata": "{\"compiler\":{\"version\":\"0.8.17+commit.8df45f5f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"newStatus\",\"type\":\"bool\"}],\"name\":\"AuthorizationRequirementChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"blockHeight\",\"type\":\"uint256\"}],\"name\":\"Genesis\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newLength\",\"type\":\"uint256\"}],\"name\":\"ProofLengthChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldDifficulty\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newDifficulty\",\"type\":\"uint256\"}],\"name\":\"Retarget\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"submitter\",\"type\":\"address\"}],\"name\":\"SubmitterAuthorized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"submitter\",\"type\":\"address\"}],\"name\":\"SubmitterDeauthorized\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"authorizationRequired\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"submitter\",\"type\":\"address\"}],\"name\":\"authorize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"currentEpoch\",\"outputs\":[{\"internalType\":\"uint64\",\"name\":\"\",\"type\":\"uint64\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"submitter\",\"type\":\"address\"}],\"name\":\"deauthorize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"genesisHeader\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"genesisHeight\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"genesisProofLength\",\"type\":\"uint64\"}],\"name\":\"genesis\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"genesisEpoch\",\"outputs\":[{\"internalType\":\"uint64\",\"name\":\"\",\"type\":\"uint64\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"}],\"name\":\"getBlockDifficulty\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCurrentAndPrevEpochDifficulty\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"current\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"previous\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCurrentEpochDifficulty\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"epochNumber\",\"type\":\"uint256\"}],\"name\":\"getEpochDifficulty\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getPrevEpochDifficulty\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getRelayRange\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"relayGenesis\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"currentEpochEnd\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"isAuthorized\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"proofLength\",\"outputs\":[{\"internalType\":\"uint64\",\"name\":\"\",\"type\":\"uint64\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"ready\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"headers\",\"type\":\"bytes\"}],\"name\":\"retarget\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bool\",\"name\":\"status\",\"type\":\"bool\"}],\"name\":\"setAuthorizationStatus\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"newLength\",\"type\":\"uint64\"}],\"name\":\"setProofLength\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"headers\",\"type\":\"bytes\"}],\"name\":\"validateChain\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"startingHeaderTimestamp\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"headerCount\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"THE RELAY MUST NOT BE USED BEFORE GENESIS AND AT LEAST ONE RETARGET.\",\"kind\":\"dev\",\"methods\":{\"authorize(address)\":{\"params\":{\"submitter\":\"The address to be authorised.\"}},\"deauthorize(address)\":{\"params\":{\"submitter\":\"The address to be deauthorised.\"}},\"genesis(bytes,uint256,uint64)\":{\"details\":\"If the relay is used by querying the current and previous epoch difficulty, at least one retarget needs to be provided after genesis; otherwise the prevEpochDifficulty will be uninitialised and zero.\",\"params\":{\"genesisHeader\":\"The first block header of the genesis epoch.\",\"genesisHeight\":\"The block number of the first block of the epoch.\",\"genesisProofLength\":\"The number of blocks required to accept a proof.\"}},\"getBlockDifficulty(uint256)\":{\"params\":{\"blockNumber\":\"The number of the block. Must fall within the relay range (at or after the relay genesis, and at or before the end of the most recent epoch proven to the relay).\"},\"returns\":{\"_0\":\"The difficulty of the epoch.\"}},\"getCurrentEpochDifficulty()\":{\"details\":\"returns 0 if the relay is not ready.\",\"returns\":{\"_0\":\"The difficulty of the current epoch.\"}},\"getEpochDifficulty(uint256)\":{\"params\":{\"epochNumber\":\"The number of the epoch (the height of the first block of the epoch, divided by 2016). Must fall within the relay range.\"},\"returns\":{\"_0\":\"The difficulty of the epoch.\"}},\"getPrevEpochDifficulty()\":{\"details\":\"Returns 0 if the relay is not ready or has not had a retarget.\",\"returns\":{\"_0\":\"The difficulty of the previous epoch.\"}},\"getRelayRange()\":{\"details\":\"Assumes that the genesis has been set correctly. Additionally, if the next epoch after the current one has the exact same difficulty, headers for it can be validated as well. This function should be used for informative purposes, e.g. to determine whether a retarget must be provided before submitting a header chain for validation.\",\"returns\":{\"currentEpochEnd\":\"The height of the last block that can be included in header chains for the relay to validate.\",\"relayGenesis\":\"The height of the earliest block that can be included in header chains for the relay to validate.\"}},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.\"},\"retarget(bytes)\":{\"details\":\"Checks that the first X blocks are valid in the most recent epoch, that the difficulty of the new epoch is calculated correctly according to the block timestamps, and that the next X blocks would be valid in the new epoch. We have no information of block heights, so we cannot enforce that retargets only happen every 2016 blocks; instead, we assume that this is the case if a valid proof of work is provided. It is possible to cheat the relay by providing X blocks from earlier in the most recent epoch, and then mining X new blocks after them. However, each of these malicious blocks would have to be mined to a higher difficulty than the legitimate ones. Alternatively, if the retarget has not been performed yet, one could first mine X blocks in the old difficulty with timestamps set far in the future, and then another X blocks at a greatly reduced difficulty. In either case, cheating the realy requires more work than mining X legitimate blocks. Only the most recent epoch is vulnerable to these attacks; once a retarget has been proven to the relay, the epoch is immutable even if a contradictory proof were to be presented later.\",\"params\":{\"headers\":\"A chain of headers including the last X blocks before the retarget, followed by the first X blocks after the retarget, where X equals the current proof length.\"}},\"setAuthorizationStatus(bool)\":{\"params\":{\"status\":\"True if authorisation is to be required, false if not.\"}},\"setProofLength(uint64)\":{\"details\":\"For production, a high number (e.g. 20-50) is recommended. Small numbers are accepted but should only be used for testing.\",\"params\":{\"newLength\":\"The required number of blocks. Must be less than 2016.\"}},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"},\"validateChain(bytes)\":{\"details\":\"A chain of headers is accepted as valid if: - Its length is between 2 and 2015 headers. - Headers in the chain are sequential and refer to previous digests. - Each header is mined with the correct amount of work. - The difficulty in each header matches an epoch of the relay, as determined by the headers' timestamps. The headers must be between the genesis epoch and the latest proven epoch (inclusive). If the chain contains a retarget, it is accepted if the retarget has already been proven to the relay. If the chain contains blocks of an epoch that has not been proven to the relay (after a retarget within the header chain, or when the entire chain falls within an epoch that has not been proven yet), it will be rejected. One exception to this is when two subsequent epochs have exactly the same difficulty; headers from the latter epoch will be accepted if the previous epoch has been proven to the relay. This is because it is not possible to distinguish such headers from headers of the previous epoch. If the difficulty increases significantly between relay genesis and the present, creating fraudulent proofs for earlier epochs becomes easier. Users of the relay should check the timestamps of valid headers and only accept appropriately recent ones.\",\"params\":{\"headers\":\"A chain of 2 to 2015 bitcoin headers.\"},\"returns\":{\"headerCount\":\"The number of headers.\",\"startingHeaderTimestamp\":\"The timestamp of the first header.\"}}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"authorize(address)\":{\"notice\":\"Authorise the given address to submit retarget proofs.\"},\"deauthorize(address)\":{\"notice\":\"Rescind the authorisation of the submitter to retarget.\"},\"genesis(bytes,uint256,uint64)\":{\"notice\":\"Establish a starting point for the relay by providing the target, timestamp and blockheight of the first block of the relay genesis epoch.\"},\"getBlockDifficulty(uint256)\":{\"notice\":\"Get the difficulty of the specified block.\"},\"getCurrentEpochDifficulty()\":{\"notice\":\"Returns the difficulty of the current epoch.\"},\"getEpochDifficulty(uint256)\":{\"notice\":\"Get the difficulty of the specified epoch.\"},\"getPrevEpochDifficulty()\":{\"notice\":\"Returns the difficulty of the previous epoch.\"},\"getRelayRange()\":{\"notice\":\"Get the range of blocks the relay can accept proofs for.\"},\"retarget(bytes)\":{\"notice\":\"Add a new epoch to the relay by providing a proof of the difficulty before and after the retarget.\"},\"setAuthorizationStatus(bool)\":{\"notice\":\"Set whether the relay requires retarget submitters to be pre-authorised by governance.\"},\"setProofLength(uint64)\":{\"notice\":\"Set the number of blocks required to accept a header chain.\"},\"validateChain(bytes)\":{\"notice\":\"Check whether a given chain of headers should be accepted as valid within the rules of the relay. If the validation fails, this function throws an exception.\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/relay/LightRelay.sol\":\"LightRelay\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":1000},\"remappings\":[]},\"sources\":{\"@keep-network/bitcoin-spv-sol/contracts/BTCUtils.sol\":{\"content\":\"pragma solidity ^0.8.4;\\n\\n/** @title BitcoinSPV */\\n/** @author Summa (https://summa.one) */\\n\\nimport {BytesLib} from \\\"./BytesLib.sol\\\";\\nimport {SafeMath} from \\\"./SafeMath.sol\\\";\\n\\nlibrary BTCUtils {\\n using BytesLib for bytes;\\n using SafeMath for uint256;\\n\\n // The target at minimum Difficulty. Also the target of the genesis block\\n uint256 public constant DIFF1_TARGET = 0xffff0000000000000000000000000000000000000000000000000000;\\n\\n uint256 public constant RETARGET_PERIOD = 2 * 7 * 24 * 60 * 60; // 2 weeks in seconds\\n uint256 public constant RETARGET_PERIOD_BLOCKS = 2016; // 2 weeks in blocks\\n\\n uint256 public constant ERR_BAD_ARG = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff;\\n\\n /* ***** */\\n /* UTILS */\\n /* ***** */\\n\\n /// @notice Determines the length of a VarInt in bytes\\n /// @dev A VarInt of >1 byte is prefixed with a flag indicating its length\\n /// @param _flag The first byte of a VarInt\\n /// @return The number of non-flag bytes in the VarInt\\n function determineVarIntDataLength(bytes memory _flag) internal pure returns (uint8) {\\n return determineVarIntDataLengthAt(_flag, 0);\\n }\\n\\n /// @notice Determines the length of a VarInt in bytes\\n /// @dev A VarInt of >1 byte is prefixed with a flag indicating its length\\n /// @param _b The byte array containing a VarInt\\n /// @param _at The position of the VarInt in the array\\n /// @return The number of non-flag bytes in the VarInt\\n function determineVarIntDataLengthAt(bytes memory _b, uint256 _at) internal pure returns (uint8) {\\n if (uint8(_b[_at]) == 0xff) {\\n return 8; // one-byte flag, 8 bytes data\\n }\\n if (uint8(_b[_at]) == 0xfe) {\\n return 4; // one-byte flag, 4 bytes data\\n }\\n if (uint8(_b[_at]) == 0xfd) {\\n return 2; // one-byte flag, 2 bytes data\\n }\\n\\n return 0; // flag is data\\n }\\n\\n /// @notice Parse a VarInt into its data length and the number it represents\\n /// @dev Useful for Parsing Vins and Vouts. Returns ERR_BAD_ARG if insufficient bytes.\\n /// Caller SHOULD explicitly handle this case (or bubble it up)\\n /// @param _b A byte-string starting with a VarInt\\n /// @return number of bytes in the encoding (not counting the tag), the encoded int\\n function parseVarInt(bytes memory _b) internal pure returns (uint256, uint256) {\\n return parseVarIntAt(_b, 0);\\n }\\n\\n /// @notice Parse a VarInt into its data length and the number it represents\\n /// @dev Useful for Parsing Vins and Vouts. Returns ERR_BAD_ARG if insufficient bytes.\\n /// Caller SHOULD explicitly handle this case (or bubble it up)\\n /// @param _b A byte-string containing a VarInt\\n /// @param _at The position of the VarInt\\n /// @return number of bytes in the encoding (not counting the tag), the encoded int\\n function parseVarIntAt(bytes memory _b, uint256 _at) internal pure returns (uint256, uint256) {\\n uint8 _dataLen = determineVarIntDataLengthAt(_b, _at);\\n\\n if (_dataLen == 0) {\\n return (0, uint8(_b[_at]));\\n }\\n if (_b.length < 1 + _dataLen + _at) {\\n return (ERR_BAD_ARG, 0);\\n }\\n uint256 _number;\\n if (_dataLen == 2) {\\n _number = reverseUint16(uint16(_b.slice2(1 + _at)));\\n } else if (_dataLen == 4) {\\n _number = reverseUint32(uint32(_b.slice4(1 + _at)));\\n } else if (_dataLen == 8) {\\n _number = reverseUint64(uint64(_b.slice8(1 + _at)));\\n }\\n return (_dataLen, _number);\\n }\\n\\n /// @notice Changes the endianness of a byte array\\n /// @dev Returns a new, backwards, bytes\\n /// @param _b The bytes to reverse\\n /// @return The reversed bytes\\n function reverseEndianness(bytes memory _b) internal pure returns (bytes memory) {\\n bytes memory _newValue = new bytes(_b.length);\\n\\n for (uint i = 0; i < _b.length; i++) {\\n _newValue[_b.length - i - 1] = _b[i];\\n }\\n\\n return _newValue;\\n }\\n\\n /// @notice Changes the endianness of a uint256\\n /// @dev https://graphics.stanford.edu/~seander/bithacks.html#ReverseParallel\\n /// @param _b The unsigned integer to reverse\\n /// @return v The reversed value\\n function reverseUint256(uint256 _b) internal pure returns (uint256 v) {\\n v = _b;\\n\\n // swap bytes\\n v = ((v >> 8) & 0x00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF) |\\n ((v & 0x00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF) << 8);\\n // swap 2-byte long pairs\\n v = ((v >> 16) & 0x0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF) |\\n ((v & 0x0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF) << 16);\\n // swap 4-byte long pairs\\n v = ((v >> 32) & 0x00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF) |\\n ((v & 0x00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF) << 32);\\n // swap 8-byte long pairs\\n v = ((v >> 64) & 0x0000000000000000FFFFFFFFFFFFFFFF0000000000000000FFFFFFFFFFFFFFFF) |\\n ((v & 0x0000000000000000FFFFFFFFFFFFFFFF0000000000000000FFFFFFFFFFFFFFFF) << 64);\\n // swap 16-byte long pairs\\n v = (v >> 128) | (v << 128);\\n }\\n\\n /// @notice Changes the endianness of a uint64\\n /// @param _b The unsigned integer to reverse\\n /// @return v The reversed value\\n function reverseUint64(uint64 _b) internal pure returns (uint64 v) {\\n v = _b;\\n\\n // swap bytes\\n v = ((v >> 8) & 0x00FF00FF00FF00FF) |\\n ((v & 0x00FF00FF00FF00FF) << 8);\\n // swap 2-byte long pairs\\n v = ((v >> 16) & 0x0000FFFF0000FFFF) |\\n ((v & 0x0000FFFF0000FFFF) << 16);\\n // swap 4-byte long pairs\\n v = (v >> 32) | (v << 32);\\n }\\n\\n /// @notice Changes the endianness of a uint32\\n /// @param _b The unsigned integer to reverse\\n /// @return v The reversed value\\n function reverseUint32(uint32 _b) internal pure returns (uint32 v) {\\n v = _b;\\n\\n // swap bytes\\n v = ((v >> 8) & 0x00FF00FF) |\\n ((v & 0x00FF00FF) << 8);\\n // swap 2-byte long pairs\\n v = (v >> 16) | (v << 16);\\n }\\n\\n /// @notice Changes the endianness of a uint24\\n /// @param _b The unsigned integer to reverse\\n /// @return v The reversed value\\n function reverseUint24(uint24 _b) internal pure returns (uint24 v) {\\n v = (_b << 16) | (_b & 0x00FF00) | (_b >> 16);\\n }\\n\\n /// @notice Changes the endianness of a uint16\\n /// @param _b The unsigned integer to reverse\\n /// @return v The reversed value\\n function reverseUint16(uint16 _b) internal pure returns (uint16 v) {\\n v = (_b << 8) | (_b >> 8);\\n }\\n\\n\\n /// @notice Converts big-endian bytes to a uint\\n /// @dev Traverses the byte array and sums the bytes\\n /// @param _b The big-endian bytes-encoded integer\\n /// @return The integer representation\\n function bytesToUint(bytes memory _b) internal pure returns (uint256) {\\n uint256 _number;\\n\\n for (uint i = 0; i < _b.length; i++) {\\n _number = _number + uint8(_b[i]) * (2 ** (8 * (_b.length - (i + 1))));\\n }\\n\\n return _number;\\n }\\n\\n /// @notice Get the last _num bytes from a byte array\\n /// @param _b The byte array to slice\\n /// @param _num The number of bytes to extract from the end\\n /// @return The last _num bytes of _b\\n function lastBytes(bytes memory _b, uint256 _num) internal pure returns (bytes memory) {\\n uint256 _start = _b.length.sub(_num);\\n\\n return _b.slice(_start, _num);\\n }\\n\\n /// @notice Implements bitcoin's hash160 (rmd160(sha2()))\\n /// @dev abi.encodePacked changes the return to bytes instead of bytes32\\n /// @param _b The pre-image\\n /// @return The digest\\n function hash160(bytes memory _b) internal pure returns (bytes memory) {\\n return abi.encodePacked(ripemd160(abi.encodePacked(sha256(_b))));\\n }\\n\\n /// @notice Implements bitcoin's hash160 (sha2 + ripemd160)\\n /// @dev sha2 precompile at address(2), ripemd160 at address(3)\\n /// @param _b The pre-image\\n /// @return res The digest\\n function hash160View(bytes memory _b) internal view returns (bytes20 res) {\\n // solium-disable-next-line security/no-inline-assembly\\n assembly {\\n pop(staticcall(gas(), 2, add(_b, 32), mload(_b), 0x00, 32))\\n pop(staticcall(gas(), 3, 0x00, 32, 0x00, 32))\\n // read from position 12 = 0c\\n res := mload(0x0c)\\n }\\n }\\n\\n /// @notice Implements bitcoin's hash256 (double sha2)\\n /// @dev abi.encodePacked changes the return to bytes instead of bytes32\\n /// @param _b The pre-image\\n /// @return The digest\\n function hash256(bytes memory _b) internal pure returns (bytes32) {\\n return sha256(abi.encodePacked(sha256(_b)));\\n }\\n\\n /// @notice Implements bitcoin's hash256 (double sha2)\\n /// @dev sha2 is precompiled smart contract located at address(2)\\n /// @param _b The pre-image\\n /// @return res The digest\\n function hash256View(bytes memory _b) internal view returns (bytes32 res) {\\n // solium-disable-next-line security/no-inline-assembly\\n assembly {\\n pop(staticcall(gas(), 2, add(_b, 32), mload(_b), 0x00, 32))\\n pop(staticcall(gas(), 2, 0x00, 32, 0x00, 32))\\n res := mload(0x00)\\n }\\n }\\n\\n /// @notice Implements bitcoin's hash256 on a pair of bytes32\\n /// @dev sha2 is precompiled smart contract located at address(2)\\n /// @param _a The first bytes32 of the pre-image\\n /// @param _b The second bytes32 of the pre-image\\n /// @return res The digest\\n function hash256Pair(bytes32 _a, bytes32 _b) internal view returns (bytes32 res) {\\n // solium-disable-next-line security/no-inline-assembly\\n assembly {\\n mstore(0x00, _a)\\n mstore(0x20, _b)\\n pop(staticcall(gas(), 2, 0x00, 64, 0x00, 32))\\n pop(staticcall(gas(), 2, 0x00, 32, 0x00, 32))\\n res := mload(0x00)\\n }\\n }\\n\\n /// @notice Implements bitcoin's hash256 (double sha2)\\n /// @dev sha2 is precompiled smart contract located at address(2)\\n /// @param _b The array containing the pre-image\\n /// @param at The start of the pre-image\\n /// @param len The length of the pre-image\\n /// @return res The digest\\n function hash256Slice(\\n bytes memory _b,\\n uint256 at,\\n uint256 len\\n ) internal view returns (bytes32 res) {\\n // solium-disable-next-line security/no-inline-assembly\\n assembly {\\n pop(staticcall(gas(), 2, add(_b, add(32, at)), len, 0x00, 32))\\n pop(staticcall(gas(), 2, 0x00, 32, 0x00, 32))\\n res := mload(0x00)\\n }\\n }\\n\\n /* ************ */\\n /* Legacy Input */\\n /* ************ */\\n\\n /// @notice Extracts the nth input from the vin (0-indexed)\\n /// @dev Iterates over the vin. If you need to extract several, write a custom function\\n /// @param _vin The vin as a tightly-packed byte array\\n /// @param _index The 0-indexed location of the input to extract\\n /// @return The input as a byte array\\n function extractInputAtIndex(bytes memory _vin, uint256 _index) internal pure returns (bytes memory) {\\n uint256 _varIntDataLen;\\n uint256 _nIns;\\n\\n (_varIntDataLen, _nIns) = parseVarInt(_vin);\\n require(_varIntDataLen != ERR_BAD_ARG, \\\"Read overrun during VarInt parsing\\\");\\n require(_index < _nIns, \\\"Vin read overrun\\\");\\n\\n uint256 _len = 0;\\n uint256 _offset = 1 + _varIntDataLen;\\n\\n for (uint256 _i = 0; _i < _index; _i ++) {\\n _len = determineInputLengthAt(_vin, _offset);\\n require(_len != ERR_BAD_ARG, \\\"Bad VarInt in scriptSig\\\");\\n _offset = _offset + _len;\\n }\\n\\n _len = determineInputLengthAt(_vin, _offset);\\n require(_len != ERR_BAD_ARG, \\\"Bad VarInt in scriptSig\\\");\\n return _vin.slice(_offset, _len);\\n }\\n\\n /// @notice Determines whether an input is legacy\\n /// @dev False if no scriptSig, otherwise True\\n /// @param _input The input\\n /// @return True for legacy, False for witness\\n function isLegacyInput(bytes memory _input) internal pure returns (bool) {\\n return _input[36] != hex\\\"00\\\";\\n }\\n\\n /// @notice Determines the length of a scriptSig in an input\\n /// @dev Will return 0 if passed a witness input.\\n /// @param _input The LEGACY input\\n /// @return The length of the script sig\\n function extractScriptSigLen(bytes memory _input) internal pure returns (uint256, uint256) {\\n return extractScriptSigLenAt(_input, 0);\\n }\\n\\n /// @notice Determines the length of a scriptSig in an input\\n /// starting at the specified position\\n /// @dev Will return 0 if passed a witness input.\\n /// @param _input The byte array containing the LEGACY input\\n /// @param _at The position of the input in the array\\n /// @return The length of the script sig\\n function extractScriptSigLenAt(bytes memory _input, uint256 _at) internal pure returns (uint256, uint256) {\\n if (_input.length < 37 + _at) {\\n return (ERR_BAD_ARG, 0);\\n }\\n\\n uint256 _varIntDataLen;\\n uint256 _scriptSigLen;\\n (_varIntDataLen, _scriptSigLen) = parseVarIntAt(_input, _at + 36);\\n\\n return (_varIntDataLen, _scriptSigLen);\\n }\\n\\n /// @notice Determines the length of an input from its scriptSig\\n /// @dev 36 for outpoint, 1 for scriptSig length, 4 for sequence\\n /// @param _input The input\\n /// @return The length of the input in bytes\\n function determineInputLength(bytes memory _input) internal pure returns (uint256) {\\n return determineInputLengthAt(_input, 0);\\n }\\n\\n /// @notice Determines the length of an input from its scriptSig,\\n /// starting at the specified position\\n /// @dev 36 for outpoint, 1 for scriptSig length, 4 for sequence\\n /// @param _input The byte array containing the input\\n /// @param _at The position of the input in the array\\n /// @return The length of the input in bytes\\n function determineInputLengthAt(bytes memory _input, uint256 _at) internal pure returns (uint256) {\\n uint256 _varIntDataLen;\\n uint256 _scriptSigLen;\\n (_varIntDataLen, _scriptSigLen) = extractScriptSigLenAt(_input, _at);\\n if (_varIntDataLen == ERR_BAD_ARG) {\\n return ERR_BAD_ARG;\\n }\\n\\n return 36 + 1 + _varIntDataLen + _scriptSigLen + 4;\\n }\\n\\n /// @notice Extracts the LE sequence bytes from an input\\n /// @dev Sequence is used for relative time locks\\n /// @param _input The LEGACY input\\n /// @return The sequence bytes (LE uint)\\n function extractSequenceLELegacy(bytes memory _input) internal pure returns (bytes4) {\\n uint256 _varIntDataLen;\\n uint256 _scriptSigLen;\\n (_varIntDataLen, _scriptSigLen) = extractScriptSigLen(_input);\\n require(_varIntDataLen != ERR_BAD_ARG, \\\"Bad VarInt in scriptSig\\\");\\n return _input.slice4(36 + 1 + _varIntDataLen + _scriptSigLen);\\n }\\n\\n /// @notice Extracts the sequence from the input\\n /// @dev Sequence is a 4-byte little-endian number\\n /// @param _input The LEGACY input\\n /// @return The sequence number (big-endian uint)\\n function extractSequenceLegacy(bytes memory _input) internal pure returns (uint32) {\\n uint32 _leSeqence = uint32(extractSequenceLELegacy(_input));\\n uint32 _beSequence = reverseUint32(_leSeqence);\\n return _beSequence;\\n }\\n /// @notice Extracts the VarInt-prepended scriptSig from the input in a tx\\n /// @dev Will return hex\\\"00\\\" if passed a witness input\\n /// @param _input The LEGACY input\\n /// @return The length-prepended scriptSig\\n function extractScriptSig(bytes memory _input) internal pure returns (bytes memory) {\\n uint256 _varIntDataLen;\\n uint256 _scriptSigLen;\\n (_varIntDataLen, _scriptSigLen) = extractScriptSigLen(_input);\\n require(_varIntDataLen != ERR_BAD_ARG, \\\"Bad VarInt in scriptSig\\\");\\n return _input.slice(36, 1 + _varIntDataLen + _scriptSigLen);\\n }\\n\\n\\n /* ************* */\\n /* Witness Input */\\n /* ************* */\\n\\n /// @notice Extracts the LE sequence bytes from an input\\n /// @dev Sequence is used for relative time locks\\n /// @param _input The WITNESS input\\n /// @return The sequence bytes (LE uint)\\n function extractSequenceLEWitness(bytes memory _input) internal pure returns (bytes4) {\\n return _input.slice4(37);\\n }\\n\\n /// @notice Extracts the sequence from the input in a tx\\n /// @dev Sequence is a 4-byte little-endian number\\n /// @param _input The WITNESS input\\n /// @return The sequence number (big-endian uint)\\n function extractSequenceWitness(bytes memory _input) internal pure returns (uint32) {\\n uint32 _leSeqence = uint32(extractSequenceLEWitness(_input));\\n uint32 _inputeSequence = reverseUint32(_leSeqence);\\n return _inputeSequence;\\n }\\n\\n /// @notice Extracts the outpoint from the input in a tx\\n /// @dev 32-byte tx id with 4-byte index\\n /// @param _input The input\\n /// @return The outpoint (LE bytes of prev tx hash + LE bytes of prev tx index)\\n function extractOutpoint(bytes memory _input) internal pure returns (bytes memory) {\\n return _input.slice(0, 36);\\n }\\n\\n /// @notice Extracts the outpoint tx id from an input\\n /// @dev 32-byte tx id\\n /// @param _input The input\\n /// @return The tx id (little-endian bytes)\\n function extractInputTxIdLE(bytes memory _input) internal pure returns (bytes32) {\\n return _input.slice32(0);\\n }\\n\\n /// @notice Extracts the outpoint tx id from an input\\n /// starting at the specified position\\n /// @dev 32-byte tx id\\n /// @param _input The byte array containing the input\\n /// @param _at The position of the input\\n /// @return The tx id (little-endian bytes)\\n function extractInputTxIdLeAt(bytes memory _input, uint256 _at) internal pure returns (bytes32) {\\n return _input.slice32(_at);\\n }\\n\\n /// @notice Extracts the LE tx input index from the input in a tx\\n /// @dev 4-byte tx index\\n /// @param _input The input\\n /// @return The tx index (little-endian bytes)\\n function extractTxIndexLE(bytes memory _input) internal pure returns (bytes4) {\\n return _input.slice4(32);\\n }\\n\\n /// @notice Extracts the LE tx input index from the input in a tx\\n /// starting at the specified position\\n /// @dev 4-byte tx index\\n /// @param _input The byte array containing the input\\n /// @param _at The position of the input\\n /// @return The tx index (little-endian bytes)\\n function extractTxIndexLeAt(bytes memory _input, uint256 _at) internal pure returns (bytes4) {\\n return _input.slice4(32 + _at);\\n }\\n\\n /* ****** */\\n /* Output */\\n /* ****** */\\n\\n /// @notice Determines the length of an output\\n /// @dev Works with any properly formatted output\\n /// @param _output The output\\n /// @return The length indicated by the prefix, error if invalid length\\n function determineOutputLength(bytes memory _output) internal pure returns (uint256) {\\n return determineOutputLengthAt(_output, 0);\\n }\\n\\n /// @notice Determines the length of an output\\n /// starting at the specified position\\n /// @dev Works with any properly formatted output\\n /// @param _output The byte array containing the output\\n /// @param _at The position of the output\\n /// @return The length indicated by the prefix, error if invalid length\\n function determineOutputLengthAt(bytes memory _output, uint256 _at) internal pure returns (uint256) {\\n if (_output.length < 9 + _at) {\\n return ERR_BAD_ARG;\\n }\\n uint256 _varIntDataLen;\\n uint256 _scriptPubkeyLength;\\n (_varIntDataLen, _scriptPubkeyLength) = parseVarIntAt(_output, 8 + _at);\\n\\n if (_varIntDataLen == ERR_BAD_ARG) {\\n return ERR_BAD_ARG;\\n }\\n\\n // 8-byte value, 1-byte for tag itself\\n return 8 + 1 + _varIntDataLen + _scriptPubkeyLength;\\n }\\n\\n /// @notice Extracts the output at a given index in the TxOuts vector\\n /// @dev Iterates over the vout. If you need to extract multiple, write a custom function\\n /// @param _vout The _vout to extract from\\n /// @param _index The 0-indexed location of the output to extract\\n /// @return The specified output\\n function extractOutputAtIndex(bytes memory _vout, uint256 _index) internal pure returns (bytes memory) {\\n uint256 _varIntDataLen;\\n uint256 _nOuts;\\n\\n (_varIntDataLen, _nOuts) = parseVarInt(_vout);\\n require(_varIntDataLen != ERR_BAD_ARG, \\\"Read overrun during VarInt parsing\\\");\\n require(_index < _nOuts, \\\"Vout read overrun\\\");\\n\\n uint256 _len = 0;\\n uint256 _offset = 1 + _varIntDataLen;\\n\\n for (uint256 _i = 0; _i < _index; _i ++) {\\n _len = determineOutputLengthAt(_vout, _offset);\\n require(_len != ERR_BAD_ARG, \\\"Bad VarInt in scriptPubkey\\\");\\n _offset += _len;\\n }\\n\\n _len = determineOutputLengthAt(_vout, _offset);\\n require(_len != ERR_BAD_ARG, \\\"Bad VarInt in scriptPubkey\\\");\\n return _vout.slice(_offset, _len);\\n }\\n\\n /// @notice Extracts the value bytes from the output in a tx\\n /// @dev Value is an 8-byte little-endian number\\n /// @param _output The output\\n /// @return The output value as LE bytes\\n function extractValueLE(bytes memory _output) internal pure returns (bytes8) {\\n return _output.slice8(0);\\n }\\n\\n /// @notice Extracts the value from the output in a tx\\n /// @dev Value is an 8-byte little-endian number\\n /// @param _output The output\\n /// @return The output value\\n function extractValue(bytes memory _output) internal pure returns (uint64) {\\n uint64 _leValue = uint64(extractValueLE(_output));\\n uint64 _beValue = reverseUint64(_leValue);\\n return _beValue;\\n }\\n\\n /// @notice Extracts the value from the output in a tx\\n /// @dev Value is an 8-byte little-endian number\\n /// @param _output The byte array containing the output\\n /// @param _at The starting index of the output in the array\\n /// @return The output value\\n function extractValueAt(bytes memory _output, uint256 _at) internal pure returns (uint64) {\\n uint64 _leValue = uint64(_output.slice8(_at));\\n uint64 _beValue = reverseUint64(_leValue);\\n return _beValue;\\n }\\n\\n /// @notice Extracts the data from an op return output\\n /// @dev Returns hex\\\"\\\" if no data or not an op return\\n /// @param _output The output\\n /// @return Any data contained in the opreturn output, null if not an op return\\n function extractOpReturnData(bytes memory _output) internal pure returns (bytes memory) {\\n if (_output[9] != hex\\\"6a\\\") {\\n return hex\\\"\\\";\\n }\\n bytes1 _dataLen = _output[10];\\n return _output.slice(11, uint256(uint8(_dataLen)));\\n }\\n\\n /// @notice Extracts the hash from the output script\\n /// @dev Determines type by the length prefix and validates format\\n /// @param _output The output\\n /// @return The hash committed to by the pk_script, or null for errors\\n function extractHash(bytes memory _output) internal pure returns (bytes memory) {\\n return extractHashAt(_output, 8, _output.length - 8);\\n }\\n\\n /// @notice Extracts the hash from the output script\\n /// @dev Determines type by the length prefix and validates format\\n /// @param _output The byte array containing the output\\n /// @param _at The starting index of the output script in the array\\n /// (output start + 8)\\n /// @param _len The length of the output script\\n /// (output length - 8)\\n /// @return The hash committed to by the pk_script, or null for errors\\n function extractHashAt(\\n bytes memory _output,\\n uint256 _at,\\n uint256 _len\\n ) internal pure returns (bytes memory) {\\n uint8 _scriptLen = uint8(_output[_at]);\\n\\n // don't have to worry about overflow here.\\n // if _scriptLen + 1 overflows, then output length would have to be < 1\\n // for this check to pass. if it's < 1, then we errored when assigning\\n // _scriptLen\\n if (_scriptLen + 1 != _len) {\\n return hex\\\"\\\";\\n }\\n\\n if (uint8(_output[_at + 1]) == 0) {\\n if (_scriptLen < 2) {\\n return hex\\\"\\\";\\n }\\n uint256 _payloadLen = uint8(_output[_at + 2]);\\n // Check for maliciously formatted witness outputs.\\n // No need to worry about underflow as long b/c of the `< 2` check\\n if (_payloadLen != _scriptLen - 2 || (_payloadLen != 0x20 && _payloadLen != 0x14)) {\\n return hex\\\"\\\";\\n }\\n return _output.slice(_at + 3, _payloadLen);\\n } else {\\n bytes3 _tag = _output.slice3(_at);\\n // p2pkh\\n if (_tag == hex\\\"1976a9\\\") {\\n // Check for maliciously formatted p2pkh\\n // No need to worry about underflow, b/c of _scriptLen check\\n if (uint8(_output[_at + 3]) != 0x14 ||\\n _output.slice2(_at + _len - 2) != hex\\\"88ac\\\") {\\n return hex\\\"\\\";\\n }\\n return _output.slice(_at + 4, 20);\\n //p2sh\\n } else if (_tag == hex\\\"17a914\\\") {\\n // Check for maliciously formatted p2sh\\n // No need to worry about underflow, b/c of _scriptLen check\\n if (uint8(_output[_at + _len - 1]) != 0x87) {\\n return hex\\\"\\\";\\n }\\n return _output.slice(_at + 3, 20);\\n }\\n }\\n return hex\\\"\\\"; /* NB: will trigger on OPRETURN and any non-standard that doesn't overrun */\\n }\\n\\n /* ********** */\\n /* Witness TX */\\n /* ********** */\\n\\n\\n /// @notice Checks that the vin passed up is properly formatted\\n /// @dev Consider a vin with a valid vout in its scriptsig\\n /// @param _vin Raw bytes length-prefixed input vector\\n /// @return True if it represents a validly formatted vin\\n function validateVin(bytes memory _vin) internal pure returns (bool) {\\n uint256 _varIntDataLen;\\n uint256 _nIns;\\n\\n (_varIntDataLen, _nIns) = parseVarInt(_vin);\\n\\n // Not valid if it says there are too many or no inputs\\n if (_nIns == 0 || _varIntDataLen == ERR_BAD_ARG) {\\n return false;\\n }\\n\\n uint256 _offset = 1 + _varIntDataLen;\\n\\n for (uint256 i = 0; i < _nIns; i++) {\\n // If we're at the end, but still expect more\\n if (_offset >= _vin.length) {\\n return false;\\n }\\n\\n // Grab the next input and determine its length.\\n uint256 _nextLen = determineInputLengthAt(_vin, _offset);\\n if (_nextLen == ERR_BAD_ARG) {\\n return false;\\n }\\n\\n // Increase the offset by that much\\n _offset += _nextLen;\\n }\\n\\n // Returns false if we're not exactly at the end\\n return _offset == _vin.length;\\n }\\n\\n /// @notice Checks that the vout passed up is properly formatted\\n /// @dev Consider a vout with a valid scriptpubkey\\n /// @param _vout Raw bytes length-prefixed output vector\\n /// @return True if it represents a validly formatted vout\\n function validateVout(bytes memory _vout) internal pure returns (bool) {\\n uint256 _varIntDataLen;\\n uint256 _nOuts;\\n\\n (_varIntDataLen, _nOuts) = parseVarInt(_vout);\\n\\n // Not valid if it says there are too many or no outputs\\n if (_nOuts == 0 || _varIntDataLen == ERR_BAD_ARG) {\\n return false;\\n }\\n\\n uint256 _offset = 1 + _varIntDataLen;\\n\\n for (uint256 i = 0; i < _nOuts; i++) {\\n // If we're at the end, but still expect more\\n if (_offset >= _vout.length) {\\n return false;\\n }\\n\\n // Grab the next output and determine its length.\\n // Increase the offset by that much\\n uint256 _nextLen = determineOutputLengthAt(_vout, _offset);\\n if (_nextLen == ERR_BAD_ARG) {\\n return false;\\n }\\n\\n _offset += _nextLen;\\n }\\n\\n // Returns false if we're not exactly at the end\\n return _offset == _vout.length;\\n }\\n\\n\\n\\n /* ************ */\\n /* Block Header */\\n /* ************ */\\n\\n /// @notice Extracts the transaction merkle root from a block header\\n /// @dev Use verifyHash256Merkle to verify proofs with this root\\n /// @param _header The header\\n /// @return The merkle root (little-endian)\\n function extractMerkleRootLE(bytes memory _header) internal pure returns (bytes32) {\\n return _header.slice32(36);\\n }\\n\\n /// @notice Extracts the target from a block header\\n /// @dev Target is a 256-bit number encoded as a 3-byte mantissa and 1-byte exponent\\n /// @param _header The header\\n /// @return The target threshold\\n function extractTarget(bytes memory _header) internal pure returns (uint256) {\\n return extractTargetAt(_header, 0);\\n }\\n\\n /// @notice Extracts the target from a block header\\n /// @dev Target is a 256-bit number encoded as a 3-byte mantissa and 1-byte exponent\\n /// @param _header The array containing the header\\n /// @param at The start of the header\\n /// @return The target threshold\\n function extractTargetAt(bytes memory _header, uint256 at) internal pure returns (uint256) {\\n uint24 _m = uint24(_header.slice3(72 + at));\\n uint8 _e = uint8(_header[75 + at]);\\n uint256 _mantissa = uint256(reverseUint24(_m));\\n uint _exponent = _e - 3;\\n\\n return _mantissa * (256 ** _exponent);\\n }\\n\\n /// @notice Calculate difficulty from the difficulty 1 target and current target\\n /// @dev Difficulty 1 is 0x1d00ffff on mainnet and testnet\\n /// @dev Difficulty 1 is a 256-bit number encoded as a 3-byte mantissa and 1-byte exponent\\n /// @param _target The current target\\n /// @return The block difficulty (bdiff)\\n function calculateDifficulty(uint256 _target) internal pure returns (uint256) {\\n // Difficulty 1 calculated from 0x1d00ffff\\n return DIFF1_TARGET.div(_target);\\n }\\n\\n /// @notice Extracts the previous block's hash from a block header\\n /// @dev Block headers do NOT include block number :(\\n /// @param _header The header\\n /// @return The previous block's hash (little-endian)\\n function extractPrevBlockLE(bytes memory _header) internal pure returns (bytes32) {\\n return _header.slice32(4);\\n }\\n\\n /// @notice Extracts the previous block's hash from a block header\\n /// @dev Block headers do NOT include block number :(\\n /// @param _header The array containing the header\\n /// @param at The start of the header\\n /// @return The previous block's hash (little-endian)\\n function extractPrevBlockLEAt(\\n bytes memory _header,\\n uint256 at\\n ) internal pure returns (bytes32) {\\n return _header.slice32(4 + at);\\n }\\n\\n /// @notice Extracts the timestamp from a block header\\n /// @dev Time is not 100% reliable\\n /// @param _header The header\\n /// @return The timestamp (little-endian bytes)\\n function extractTimestampLE(bytes memory _header) internal pure returns (bytes4) {\\n return _header.slice4(68);\\n }\\n\\n /// @notice Extracts the timestamp from a block header\\n /// @dev Time is not 100% reliable\\n /// @param _header The header\\n /// @return The timestamp (uint)\\n function extractTimestamp(bytes memory _header) internal pure returns (uint32) {\\n return reverseUint32(uint32(extractTimestampLE(_header)));\\n }\\n\\n /// @notice Extracts the expected difficulty from a block header\\n /// @dev Does NOT verify the work\\n /// @param _header The header\\n /// @return The difficulty as an integer\\n function extractDifficulty(bytes memory _header) internal pure returns (uint256) {\\n return calculateDifficulty(extractTarget(_header));\\n }\\n\\n /// @notice Concatenates and hashes two inputs for merkle proving\\n /// @param _a The first hash\\n /// @param _b The second hash\\n /// @return The double-sha256 of the concatenated hashes\\n function _hash256MerkleStep(bytes memory _a, bytes memory _b) internal view returns (bytes32) {\\n return hash256View(abi.encodePacked(_a, _b));\\n }\\n\\n /// @notice Concatenates and hashes two inputs for merkle proving\\n /// @param _a The first hash\\n /// @param _b The second hash\\n /// @return The double-sha256 of the concatenated hashes\\n function _hash256MerkleStep(bytes32 _a, bytes32 _b) internal view returns (bytes32) {\\n return hash256Pair(_a, _b);\\n }\\n\\n\\n /// @notice Verifies a Bitcoin-style merkle tree\\n /// @dev Leaves are 0-indexed. Inefficient version.\\n /// @param _proof The proof. Tightly packed LE sha256 hashes. The last hash is the root\\n /// @param _index The index of the leaf\\n /// @return true if the proof is valid, else false\\n function verifyHash256Merkle(bytes memory _proof, uint _index) internal view returns (bool) {\\n // Not an even number of hashes\\n if (_proof.length % 32 != 0) {\\n return false;\\n }\\n\\n // Special case for coinbase-only blocks\\n if (_proof.length == 32) {\\n return true;\\n }\\n\\n // Should never occur\\n if (_proof.length == 64) {\\n return false;\\n }\\n\\n bytes32 _root = _proof.slice32(_proof.length - 32);\\n bytes32 _current = _proof.slice32(0);\\n bytes memory _tree = _proof.slice(32, _proof.length - 64);\\n\\n return verifyHash256Merkle(_current, _tree, _root, _index);\\n }\\n\\n /// @notice Verifies a Bitcoin-style merkle tree\\n /// @dev Leaves are 0-indexed. Efficient version.\\n /// @param _leaf The leaf of the proof. LE sha256 hash.\\n /// @param _tree The intermediate nodes in the proof.\\n /// Tightly packed LE sha256 hashes.\\n /// @param _root The root of the proof. LE sha256 hash.\\n /// @param _index The index of the leaf\\n /// @return true if the proof is valid, else false\\n function verifyHash256Merkle(\\n bytes32 _leaf,\\n bytes memory _tree,\\n bytes32 _root,\\n uint _index\\n ) internal view returns (bool) {\\n // Not an even number of hashes\\n if (_tree.length % 32 != 0) {\\n return false;\\n }\\n\\n // Should never occur\\n if (_tree.length == 0) {\\n return false;\\n }\\n\\n uint _idx = _index;\\n bytes32 _current = _leaf;\\n\\n // i moves in increments of 32\\n for (uint i = 0; i < _tree.length; i += 32) {\\n if (_idx % 2 == 1) {\\n _current = _hash256MerkleStep(_tree.slice32(i), _current);\\n } else {\\n _current = _hash256MerkleStep(_current, _tree.slice32(i));\\n }\\n _idx = _idx >> 1;\\n }\\n return _current == _root;\\n }\\n\\n /*\\n NB: https://github.com/bitcoin/bitcoin/blob/78dae8caccd82cfbfd76557f1fb7d7557c7b5edb/src/pow.cpp#L49-L72\\n NB: We get a full-bitlength target from this. For comparison with\\n header-encoded targets we need to mask it with the header target\\n e.g. (full & truncated) == truncated\\n */\\n /// @notice performs the bitcoin difficulty retarget\\n /// @dev implements the Bitcoin algorithm precisely\\n /// @param _previousTarget the target of the previous period\\n /// @param _firstTimestamp the timestamp of the first block in the difficulty period\\n /// @param _secondTimestamp the timestamp of the last block in the difficulty period\\n /// @return the new period's target threshold\\n function retargetAlgorithm(\\n uint256 _previousTarget,\\n uint256 _firstTimestamp,\\n uint256 _secondTimestamp\\n ) internal pure returns (uint256) {\\n uint256 _elapsedTime = _secondTimestamp.sub(_firstTimestamp);\\n\\n // Normalize ratio to factor of 4 if very long or very short\\n if (_elapsedTime < RETARGET_PERIOD.div(4)) {\\n _elapsedTime = RETARGET_PERIOD.div(4);\\n }\\n if (_elapsedTime > RETARGET_PERIOD.mul(4)) {\\n _elapsedTime = RETARGET_PERIOD.mul(4);\\n }\\n\\n /*\\n NB: high targets e.g. ffff0020 can cause overflows here\\n so we divide it by 256**2, then multiply by 256**2 later\\n we know the target is evenly divisible by 256**2, so this isn't an issue\\n */\\n\\n uint256 _adjusted = _previousTarget.div(65536).mul(_elapsedTime);\\n return _adjusted.div(RETARGET_PERIOD).mul(65536);\\n }\\n}\\n\",\"keccak256\":\"0x439eaa97e9239705f3d31e8d39dccbad32311f1f119e295d53c65e0ae3c5a5fc\"},\"@keep-network/bitcoin-spv-sol/contracts/BytesLib.sol\":{\"content\":\"pragma solidity ^0.8.4;\\n\\n/*\\n\\nhttps://github.com/GNSPS/solidity-bytes-utils/\\n\\nThis is free and unencumbered software released into the public domain.\\n\\nAnyone is free to copy, modify, publish, use, compile, sell, or\\ndistribute this software, either in source code form or as a compiled\\nbinary, for any purpose, commercial or non-commercial, and by any\\nmeans.\\n\\nIn jurisdictions that recognize copyright laws, the author or authors\\nof this software dedicate any and all copyright interest in the\\nsoftware to the public domain. We make this dedication for the benefit\\nof the public at large and to the detriment of our heirs and\\nsuccessors. We intend this dedication to be an overt act of\\nrelinquishment in perpetuity of all present and future rights to this\\nsoftware under copyright law.\\n\\nTHE SOFTWARE IS PROVIDED \\\"AS IS\\\", WITHOUT WARRANTY OF ANY KIND,\\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\\nIN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR\\nOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,\\nARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\\nOTHER DEALINGS IN THE SOFTWARE.\\n\\nFor more information, please refer to <https://unlicense.org>\\n*/\\n\\n\\n/** @title BytesLib **/\\n/** @author https://github.com/GNSPS **/\\n\\nlibrary BytesLib {\\n function concat(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bytes memory) {\\n bytes memory tempBytes;\\n\\n assembly {\\n // Get a location of some free memory and store it in tempBytes as\\n // Solidity does for memory variables.\\n tempBytes := mload(0x40)\\n\\n // Store the length of the first bytes array at the beginning of\\n // the memory for tempBytes.\\n let length := mload(_preBytes)\\n mstore(tempBytes, length)\\n\\n // Maintain a memory counter for the current write location in the\\n // temp bytes array by adding the 32 bytes for the array length to\\n // the starting location.\\n let mc := add(tempBytes, 0x20)\\n // Stop copying when the memory counter reaches the length of the\\n // first bytes array.\\n let end := add(mc, length)\\n\\n for {\\n // Initialize a copy counter to the start of the _preBytes data,\\n // 32 bytes into its memory.\\n let cc := add(_preBytes, 0x20)\\n } lt(mc, end) {\\n // Increase both counters by 32 bytes each iteration.\\n mc := add(mc, 0x20)\\n cc := add(cc, 0x20)\\n } {\\n // Write the _preBytes data into the tempBytes memory 32 bytes\\n // at a time.\\n mstore(mc, mload(cc))\\n }\\n\\n // Add the length of _postBytes to the current length of tempBytes\\n // and store it as the new length in the first 32 bytes of the\\n // tempBytes memory.\\n length := mload(_postBytes)\\n mstore(tempBytes, add(length, mload(tempBytes)))\\n\\n // Move the memory counter back from a multiple of 0x20 to the\\n // actual end of the _preBytes data.\\n mc := end\\n // Stop copying when the memory counter reaches the new combined\\n // length of the arrays.\\n end := add(mc, length)\\n\\n for {\\n let cc := add(_postBytes, 0x20)\\n } lt(mc, end) {\\n mc := add(mc, 0x20)\\n cc := add(cc, 0x20)\\n } {\\n mstore(mc, mload(cc))\\n }\\n\\n // Update the free-memory pointer by padding our last write location\\n // to 32 bytes: add 31 bytes to the end of tempBytes to move to the\\n // next 32 byte block, then round down to the nearest multiple of\\n // 32. If the sum of the length of the two arrays is zero then add\\n // one before rounding down to leave a blank 32 bytes (the length block with 0).\\n mstore(0x40, and(\\n add(add(end, iszero(add(length, mload(_preBytes)))), 31),\\n not(31) // Round down to the nearest 32 bytes.\\n ))\\n }\\n\\n return tempBytes;\\n }\\n\\n function concatStorage(bytes storage _preBytes, bytes memory _postBytes) internal {\\n assembly {\\n // Read the first 32 bytes of _preBytes storage, which is the length\\n // of the array. (We don't need to use the offset into the slot\\n // because arrays use the entire slot.)\\n let fslot := sload(_preBytes.slot)\\n // Arrays of 31 bytes or less have an even value in their slot,\\n // while longer arrays have an odd value. The actual length is\\n // the slot divided by two for odd values, and the lowest order\\n // byte divided by two for even values.\\n // If the slot is even, bitwise and the slot with 255 and divide by\\n // two to get the length. If the slot is odd, bitwise and the slot\\n // with -1 and divide by two.\\n let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2)\\n let mlength := mload(_postBytes)\\n let newlength := add(slength, mlength)\\n // slength can contain both the length and contents of the array\\n // if length < 32 bytes so let's prepare for that\\n // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage\\n switch add(lt(slength, 32), lt(newlength, 32))\\n case 2 {\\n // Since the new array still fits in the slot, we just need to\\n // update the contents of the slot.\\n // uint256(bytes_storage) = uint256(bytes_storage) + uint256(bytes_memory) + new_length\\n sstore(\\n _preBytes.slot,\\n // all the modifications to the slot are inside this\\n // next block\\n add(\\n // we can just add to the slot contents because the\\n // bytes we want to change are the LSBs\\n fslot,\\n add(\\n mul(\\n div(\\n // load the bytes from memory\\n mload(add(_postBytes, 0x20)),\\n // zero all bytes to the right\\n exp(0x100, sub(32, mlength))\\n ),\\n // and now shift left the number of bytes to\\n // leave space for the length in the slot\\n exp(0x100, sub(32, newlength))\\n ),\\n // increase length by the double of the memory\\n // bytes length\\n mul(mlength, 2)\\n )\\n )\\n )\\n }\\n case 1 {\\n // The stored value fits in the slot, but the combined value\\n // will exceed it.\\n // get the keccak hash to get the contents of the array\\n mstore(0x0, _preBytes.slot)\\n let sc := add(keccak256(0x0, 0x20), div(slength, 32))\\n\\n // save new length\\n sstore(_preBytes.slot, add(mul(newlength, 2), 1))\\n\\n // The contents of the _postBytes array start 32 bytes into\\n // the structure. Our first read should obtain the `submod`\\n // bytes that can fit into the unused space in the last word\\n // of the stored array. To get this, we read 32 bytes starting\\n // from `submod`, so the data we read overlaps with the array\\n // contents by `submod` bytes. Masking the lowest-order\\n // `submod` bytes allows us to add that value directly to the\\n // stored value.\\n\\n let submod := sub(32, slength)\\n let mc := add(_postBytes, submod)\\n let end := add(_postBytes, mlength)\\n let mask := sub(exp(0x100, submod), 1)\\n\\n sstore(\\n sc,\\n add(\\n and(\\n fslot,\\n 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00\\n ),\\n and(mload(mc), mask)\\n )\\n )\\n\\n for {\\n mc := add(mc, 0x20)\\n sc := add(sc, 1)\\n } lt(mc, end) {\\n sc := add(sc, 1)\\n mc := add(mc, 0x20)\\n } {\\n sstore(sc, mload(mc))\\n }\\n\\n mask := exp(0x100, sub(mc, end))\\n\\n sstore(sc, mul(div(mload(mc), mask), mask))\\n }\\n default {\\n // get the keccak hash to get the contents of the array\\n mstore(0x0, _preBytes.slot)\\n // Start copying to the last used word of the stored array.\\n let sc := add(keccak256(0x0, 0x20), div(slength, 32))\\n\\n // save new length\\n sstore(_preBytes.slot, add(mul(newlength, 2), 1))\\n\\n // Copy over the first `submod` bytes of the new data as in\\n // case 1 above.\\n let slengthmod := mod(slength, 32)\\n let mlengthmod := mod(mlength, 32)\\n let submod := sub(32, slengthmod)\\n let mc := add(_postBytes, submod)\\n let end := add(_postBytes, mlength)\\n let mask := sub(exp(0x100, submod), 1)\\n\\n sstore(sc, add(sload(sc), and(mload(mc), mask)))\\n\\n for {\\n sc := add(sc, 1)\\n mc := add(mc, 0x20)\\n } lt(mc, end) {\\n sc := add(sc, 1)\\n mc := add(mc, 0x20)\\n } {\\n sstore(sc, mload(mc))\\n }\\n\\n mask := exp(0x100, sub(mc, end))\\n\\n sstore(sc, mul(div(mload(mc), mask), mask))\\n }\\n }\\n }\\n\\n function slice(bytes memory _bytes, uint _start, uint _length) internal pure returns (bytes memory res) {\\n if (_length == 0) {\\n return hex\\\"\\\";\\n }\\n uint _end = _start + _length;\\n require(_end > _start && _bytes.length >= _end, \\\"Slice out of bounds\\\");\\n\\n assembly {\\n // Alloc bytes array with additional 32 bytes afterspace and assign it's size\\n res := mload(0x40)\\n mstore(0x40, add(add(res, 64), _length))\\n mstore(res, _length)\\n\\n // Compute distance between source and destination pointers\\n let diff := sub(res, add(_bytes, _start))\\n\\n for {\\n let src := add(add(_bytes, 32), _start)\\n let end := add(src, _length)\\n } lt(src, end) {\\n src := add(src, 32)\\n } {\\n mstore(add(src, diff), mload(src))\\n }\\n }\\n }\\n\\n /// @notice Take a slice of the byte array, overwriting the destination.\\n /// The length of the slice will equal the length of the destination array.\\n /// @dev Make sure the destination array has afterspace if required.\\n /// @param _bytes The source array\\n /// @param _dest The destination array.\\n /// @param _start The location to start in the source array.\\n function sliceInPlace(\\n bytes memory _bytes,\\n bytes memory _dest,\\n uint _start\\n ) internal pure {\\n uint _length = _dest.length;\\n uint _end = _start + _length;\\n require(_end > _start && _bytes.length >= _end, \\\"Slice out of bounds\\\");\\n\\n assembly {\\n for {\\n let src := add(add(_bytes, 32), _start)\\n let res := add(_dest, 32)\\n let end := add(src, _length)\\n } lt(src, end) {\\n src := add(src, 32)\\n res := add(res, 32)\\n } {\\n mstore(res, mload(src))\\n }\\n }\\n }\\n\\n // Static slice functions, no bounds checking\\n /// @notice take a 32-byte slice from the specified position\\n function slice32(bytes memory _bytes, uint _start) internal pure returns (bytes32 res) {\\n assembly {\\n res := mload(add(add(_bytes, 32), _start))\\n }\\n }\\n\\n /// @notice take a 20-byte slice from the specified position\\n function slice20(bytes memory _bytes, uint _start) internal pure returns (bytes20) {\\n return bytes20(slice32(_bytes, _start));\\n }\\n\\n /// @notice take a 8-byte slice from the specified position\\n function slice8(bytes memory _bytes, uint _start) internal pure returns (bytes8) {\\n return bytes8(slice32(_bytes, _start));\\n }\\n\\n /// @notice take a 4-byte slice from the specified position\\n function slice4(bytes memory _bytes, uint _start) internal pure returns (bytes4) {\\n return bytes4(slice32(_bytes, _start));\\n }\\n\\n /// @notice take a 3-byte slice from the specified position\\n function slice3(bytes memory _bytes, uint _start) internal pure returns (bytes3) {\\n return bytes3(slice32(_bytes, _start));\\n }\\n\\n /// @notice take a 2-byte slice from the specified position\\n function slice2(bytes memory _bytes, uint _start) internal pure returns (bytes2) {\\n return bytes2(slice32(_bytes, _start));\\n }\\n\\n function toAddress(bytes memory _bytes, uint _start) internal pure returns (address) {\\n uint _totalLen = _start + 20;\\n require(_totalLen > _start && _bytes.length >= _totalLen, \\\"Address conversion out of bounds.\\\");\\n address tempAddress;\\n\\n assembly {\\n tempAddress := div(mload(add(add(_bytes, 0x20), _start)), 0x1000000000000000000000000)\\n }\\n\\n return tempAddress;\\n }\\n\\n function toUint(bytes memory _bytes, uint _start) internal pure returns (uint256) {\\n uint _totalLen = _start + 32;\\n require(_totalLen > _start && _bytes.length >= _totalLen, \\\"Uint conversion out of bounds.\\\");\\n uint256 tempUint;\\n\\n assembly {\\n tempUint := mload(add(add(_bytes, 0x20), _start))\\n }\\n\\n return tempUint;\\n }\\n\\n function equal(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bool) {\\n bool success = true;\\n\\n assembly {\\n let length := mload(_preBytes)\\n\\n // if lengths don't match the arrays are not equal\\n switch eq(length, mload(_postBytes))\\n case 1 {\\n // cb is a circuit breaker in the for loop since there's\\n // no said feature for inline assembly loops\\n // cb = 1 - don't breaker\\n // cb = 0 - break\\n let cb := 1\\n\\n let mc := add(_preBytes, 0x20)\\n let end := add(mc, length)\\n\\n for {\\n let cc := add(_postBytes, 0x20)\\n // the next line is the loop condition:\\n // while(uint(mc < end) + cb == 2)\\n } eq(add(lt(mc, end), cb), 2) {\\n mc := add(mc, 0x20)\\n cc := add(cc, 0x20)\\n } {\\n // if any of these checks fails then arrays are not equal\\n if iszero(eq(mload(mc), mload(cc))) {\\n // unsuccess:\\n success := 0\\n cb := 0\\n }\\n }\\n }\\n default {\\n // unsuccess:\\n success := 0\\n }\\n }\\n\\n return success;\\n }\\n\\n function equalStorage(bytes storage _preBytes, bytes memory _postBytes) internal view returns (bool) {\\n bool success = true;\\n\\n assembly {\\n // we know _preBytes_offset is 0\\n let fslot := sload(_preBytes.slot)\\n // Decode the length of the stored array like in concatStorage().\\n let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2)\\n let mlength := mload(_postBytes)\\n\\n // if lengths don't match the arrays are not equal\\n switch eq(slength, mlength)\\n case 1 {\\n // slength can contain both the length and contents of the array\\n // if length < 32 bytes so let's prepare for that\\n // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage\\n if iszero(iszero(slength)) {\\n switch lt(slength, 32)\\n case 1 {\\n // blank the last byte which is the length\\n fslot := mul(div(fslot, 0x100), 0x100)\\n\\n if iszero(eq(fslot, mload(add(_postBytes, 0x20)))) {\\n // unsuccess:\\n success := 0\\n }\\n }\\n default {\\n // cb is a circuit breaker in the for loop since there's\\n // no said feature for inline assembly loops\\n // cb = 1 - don't breaker\\n // cb = 0 - break\\n let cb := 1\\n\\n // get the keccak hash to get the contents of the array\\n mstore(0x0, _preBytes.slot)\\n let sc := keccak256(0x0, 0x20)\\n\\n let mc := add(_postBytes, 0x20)\\n let end := add(mc, mlength)\\n\\n // the next line is the loop condition:\\n // while(uint(mc < end) + cb == 2)\\n for {} eq(add(lt(mc, end), cb), 2) {\\n sc := add(sc, 1)\\n mc := add(mc, 0x20)\\n } {\\n if iszero(eq(sload(sc), mload(mc))) {\\n // unsuccess:\\n success := 0\\n cb := 0\\n }\\n }\\n }\\n }\\n }\\n default {\\n // unsuccess:\\n success := 0\\n }\\n }\\n\\n return success;\\n }\\n\\n function toBytes32(bytes memory _source) pure internal returns (bytes32 result) {\\n if (_source.length == 0) {\\n return 0x0;\\n }\\n\\n assembly {\\n result := mload(add(_source, 32))\\n }\\n }\\n\\n function keccak256Slice(bytes memory _bytes, uint _start, uint _length) pure internal returns (bytes32 result) {\\n uint _end = _start + _length;\\n require(_end > _start && _bytes.length >= _end, \\\"Slice out of bounds\\\");\\n\\n assembly {\\n result := keccak256(add(add(_bytes, 32), _start), _length)\\n }\\n }\\n}\\n\",\"keccak256\":\"0x43e0f3b3b23c861bd031588bf410dfdd02e2af17941a89aa38d70e534e0380d1\"},\"@keep-network/bitcoin-spv-sol/contracts/SafeMath.sol\":{\"content\":\"pragma solidity ^0.8.4;\\n\\n/*\\nThe MIT License (MIT)\\n\\nCopyright (c) 2016 Smart Contract Solutions, Inc.\\n\\nPermission is hereby granted, free of charge, to any person obtaining\\na copy of this software and associated documentation files (the\\n\\\"Software\\\"), to deal in the Software without restriction, including\\nwithout limitation the rights to use, copy, modify, merge, publish,\\ndistribute, sublicense, and/or sell copies of the Software, and to\\npermit persons to whom the Software is furnished to do so, subject to\\nthe following conditions:\\n\\nThe above copyright notice and this permission notice shall be included\\nin all copies or substantial portions of the Software.\\n\\nTHE SOFTWARE IS PROVIDED \\\"AS IS\\\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\\nOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\\n*/\\n\\n\\n/**\\n * @title SafeMath\\n * @dev Math operations with safety checks that throw on error\\n */\\nlibrary SafeMath {\\n\\n /**\\n * @dev Multiplies two numbers, throws on overflow.\\n */\\n function mul(uint256 _a, uint256 _b) internal pure returns (uint256 c) {\\n // Gas optimization: this is cheaper than asserting 'a' not being zero, but the\\n // benefit is lost if 'b' is also tested.\\n // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522\\n if (_a == 0) {\\n return 0;\\n }\\n\\n c = _a * _b;\\n require(c / _a == _b, \\\"Overflow during multiplication.\\\");\\n return c;\\n }\\n\\n /**\\n * @dev Integer division of two numbers, truncating the quotient.\\n */\\n function div(uint256 _a, uint256 _b) internal pure returns (uint256) {\\n // assert(_b > 0); // Solidity automatically throws when dividing by 0\\n // uint256 c = _a / _b;\\n // assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold\\n return _a / _b;\\n }\\n\\n /**\\n * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).\\n */\\n function sub(uint256 _a, uint256 _b) internal pure returns (uint256) {\\n require(_b <= _a, \\\"Underflow during subtraction.\\\");\\n return _a - _b;\\n }\\n\\n /**\\n * @dev Adds two numbers, throws on overflow.\\n */\\n function add(uint256 _a, uint256 _b) internal pure returns (uint256 c) {\\n c = _a + _b;\\n require(c >= _a, \\\"Overflow during addition.\\\");\\n return c;\\n }\\n}\\n\",\"keccak256\":\"0x35930d982394c7ffde439b82e5e696c5b21a6f09699d44861dfe409ef64084a3\"},\"@keep-network/bitcoin-spv-sol/contracts/ValidateSPV.sol\":{\"content\":\"pragma solidity ^0.8.4;\\n\\n/** @title ValidateSPV*/\\n/** @author Summa (https://summa.one) */\\n\\nimport {BytesLib} from \\\"./BytesLib.sol\\\";\\nimport {SafeMath} from \\\"./SafeMath.sol\\\";\\nimport {BTCUtils} from \\\"./BTCUtils.sol\\\";\\n\\n\\nlibrary ValidateSPV {\\n\\n using BTCUtils for bytes;\\n using BTCUtils for uint256;\\n using BytesLib for bytes;\\n using SafeMath for uint256;\\n\\n enum InputTypes { NONE, LEGACY, COMPATIBILITY, WITNESS }\\n enum OutputTypes { NONE, WPKH, WSH, OP_RETURN, PKH, SH, NONSTANDARD }\\n\\n uint256 constant ERR_BAD_LENGTH = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff;\\n uint256 constant ERR_INVALID_CHAIN = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe;\\n uint256 constant ERR_LOW_WORK = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd;\\n\\n function getErrBadLength() internal pure returns (uint256) {\\n return ERR_BAD_LENGTH;\\n }\\n\\n function getErrInvalidChain() internal pure returns (uint256) {\\n return ERR_INVALID_CHAIN;\\n }\\n\\n function getErrLowWork() internal pure returns (uint256) {\\n return ERR_LOW_WORK;\\n }\\n\\n /// @notice Validates a tx inclusion in the block\\n /// @dev `index` is not a reliable indicator of location within a block\\n /// @param _txid The txid (LE)\\n /// @param _merkleRoot The merkle root (as in the block header)\\n /// @param _intermediateNodes The proof's intermediate nodes (digests between leaf and root)\\n /// @param _index The leaf's index in the tree (0-indexed)\\n /// @return true if fully valid, false otherwise\\n function prove(\\n bytes32 _txid,\\n bytes32 _merkleRoot,\\n bytes memory _intermediateNodes,\\n uint _index\\n ) internal view returns (bool) {\\n // Shortcut the empty-block case\\n if (_txid == _merkleRoot && _index == 0 && _intermediateNodes.length == 0) {\\n return true;\\n }\\n\\n // If the Merkle proof failed, bubble up error\\n return BTCUtils.verifyHash256Merkle(\\n _txid,\\n _intermediateNodes,\\n _merkleRoot,\\n _index\\n );\\n }\\n\\n /// @notice Hashes transaction to get txid\\n /// @dev Supports Legacy and Witness\\n /// @param _version 4-bytes version\\n /// @param _vin Raw bytes length-prefixed input vector\\n /// @param _vout Raw bytes length-prefixed output vector\\n /// @param _locktime 4-byte tx locktime\\n /// @return 32-byte transaction id, little endian\\n function calculateTxId(\\n bytes4 _version,\\n bytes memory _vin,\\n bytes memory _vout,\\n bytes4 _locktime\\n ) internal view returns (bytes32) {\\n // Get transaction hash double-Sha256(version + nIns + inputs + nOuts + outputs + locktime)\\n return abi.encodePacked(_version, _vin, _vout, _locktime).hash256View();\\n }\\n\\n /// @notice Checks validity of header chain\\n /// @notice Compares the hash of each header to the prevHash in the next header\\n /// @param headers Raw byte array of header chain\\n /// @return totalDifficulty The total accumulated difficulty of the header chain, or an error code\\n function validateHeaderChain(\\n bytes memory headers\\n ) internal view returns (uint256 totalDifficulty) {\\n\\n // Check header chain length\\n if (headers.length % 80 != 0) {return ERR_BAD_LENGTH;}\\n\\n // Initialize header start index\\n bytes32 digest;\\n\\n totalDifficulty = 0;\\n\\n for (uint256 start = 0; start < headers.length; start += 80) {\\n\\n // After the first header, check that headers are in a chain\\n if (start != 0) {\\n if (!validateHeaderPrevHash(headers, start, digest)) {return ERR_INVALID_CHAIN;}\\n }\\n\\n // ith header target\\n uint256 target = headers.extractTargetAt(start);\\n\\n // Require that the header has sufficient work\\n digest = headers.hash256Slice(start, 80);\\n if(uint256(digest).reverseUint256() > target) {\\n return ERR_LOW_WORK;\\n }\\n\\n // Add ith header difficulty to difficulty sum\\n totalDifficulty = totalDifficulty + target.calculateDifficulty();\\n }\\n }\\n\\n /// @notice Checks validity of header work\\n /// @param digest Header digest\\n /// @param target The target threshold\\n /// @return true if header work is valid, false otherwise\\n function validateHeaderWork(\\n bytes32 digest,\\n uint256 target\\n ) internal pure returns (bool) {\\n if (digest == bytes32(0)) {return false;}\\n return (uint256(digest).reverseUint256() < target);\\n }\\n\\n /// @notice Checks validity of header chain\\n /// @dev Compares current header prevHash to previous header's digest\\n /// @param headers The raw bytes array containing the header\\n /// @param at The position of the header\\n /// @param prevHeaderDigest The previous header's digest\\n /// @return true if the connect is valid, false otherwise\\n function validateHeaderPrevHash(\\n bytes memory headers,\\n uint256 at,\\n bytes32 prevHeaderDigest\\n ) internal pure returns (bool) {\\n\\n // Extract prevHash of current header\\n bytes32 prevHash = headers.extractPrevBlockLEAt(at);\\n\\n // Compare prevHash of current header to previous header's digest\\n if (prevHash != prevHeaderDigest) {return false;}\\n\\n return true;\\n }\\n}\\n\",\"keccak256\":\"0xce3febbf3ad3a7ff8a8effd0c7ccaf7ccfa2719578b537d49ea196f0bae8062b\"},\"@openzeppelin/contracts/access/Ownable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/Context.sol\\\";\\n\\n/**\\n * @dev Contract module which provides a basic access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * By default, the owner account will be the one that deploys the contract. This\\n * can later be changed with {transferOwnership}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyOwner`, which can be applied to your functions to restrict their use to\\n * the owner.\\n */\\nabstract contract Ownable is Context {\\n address private _owner;\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the deployer as the initial owner.\\n */\\n constructor() {\\n _transferOwnership(_msgSender());\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n _checkOwner();\\n _;\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if the sender is not the owner.\\n */\\n function _checkOwner() internal view virtual {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions anymore. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby removing any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n _transferOwnership(address(0));\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual onlyOwner {\\n require(newOwner != address(0), \\\"Ownable: new owner is the zero address\\\");\\n _transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual {\\n address oldOwner = _owner;\\n _owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n}\\n\",\"keccak256\":\"0xa94b34880e3c1b0b931662cb1c09e5dfa6662f31cba80e07c5ee71cd135c9673\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n}\\n\",\"keccak256\":\"0xe2e337e6dde9ef6b680e07338c493ebea1b5fd09b43424112868e9cc1706bca7\",\"license\":\"MIT\"},\"contracts/bridge/IRelay.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity 0.8.17;\\n\\n/// @title Interface for the Bitcoin relay\\n/// @notice Contains only the methods needed by tBTC v2. The Bitcoin relay\\n/// provides the difficulty of the previous and current epoch. One\\n/// difficulty epoch spans 2016 blocks.\\ninterface IRelay {\\n /// @notice Returns the difficulty of the current epoch.\\n function getCurrentEpochDifficulty() external view returns (uint256);\\n\\n /// @notice Returns the difficulty of the previous epoch.\\n function getPrevEpochDifficulty() external view returns (uint256);\\n}\\n\",\"keccak256\":\"0xf70c723fc0a1824d92061b5dc76c65c38c22eff6b18ef6a2057f511183ce3c5b\",\"license\":\"GPL-3.0-only\"},\"contracts/relay/LightRelay.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity 0.8.17;\\n\\nimport \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\n\\nimport {BytesLib} from \\\"@keep-network/bitcoin-spv-sol/contracts/BytesLib.sol\\\";\\nimport {BTCUtils} from \\\"@keep-network/bitcoin-spv-sol/contracts/BTCUtils.sol\\\";\\nimport {ValidateSPV} from \\\"@keep-network/bitcoin-spv-sol/contracts/ValidateSPV.sol\\\";\\n\\nimport \\\"../bridge/IRelay.sol\\\";\\n\\nstruct Epoch {\\n uint32 timestamp;\\n // By definition, bitcoin targets have at least 32 leading zero bits.\\n // Thus we can only store the bits that aren't guaranteed to be 0.\\n uint224 target;\\n}\\n\\ninterface ILightRelay is IRelay {\\n event Genesis(uint256 blockHeight);\\n event Retarget(uint256 oldDifficulty, uint256 newDifficulty);\\n event ProofLengthChanged(uint256 newLength);\\n event AuthorizationRequirementChanged(bool newStatus);\\n event SubmitterAuthorized(address submitter);\\n event SubmitterDeauthorized(address submitter);\\n\\n function retarget(bytes memory headers) external;\\n\\n function validateChain(bytes memory headers)\\n external\\n view\\n returns (uint256 startingHeaderTimestamp, uint256 headerCount);\\n\\n function getBlockDifficulty(uint256 blockNumber)\\n external\\n view\\n returns (uint256);\\n\\n function getEpochDifficulty(uint256 epochNumber)\\n external\\n view\\n returns (uint256);\\n\\n function getRelayRange()\\n external\\n view\\n returns (uint256 relayGenesis, uint256 currentEpochEnd);\\n}\\n\\nlibrary RelayUtils {\\n using BytesLib for bytes;\\n\\n /// @notice Extract the timestamp of the header at the given position.\\n /// @param headers Byte array containing the header of interest.\\n /// @param at The start of the header in the array.\\n /// @return The timestamp of the header.\\n /// @dev Assumes that the specified position contains a valid header.\\n /// Performs no validation whatsoever.\\n function extractTimestampAt(bytes memory headers, uint256 at)\\n internal\\n pure\\n returns (uint32)\\n {\\n return BTCUtils.reverseUint32(uint32(headers.slice4(68 + at)));\\n }\\n}\\n\\n/// @dev THE RELAY MUST NOT BE USED BEFORE GENESIS AND AT LEAST ONE RETARGET.\\ncontract LightRelay is Ownable, ILightRelay {\\n using BytesLib for bytes;\\n using BTCUtils for bytes;\\n using ValidateSPV for bytes;\\n using RelayUtils for bytes;\\n\\n bool public ready;\\n // Whether the relay requires the address submitting a retarget to be\\n // authorised in advance by governance.\\n bool public authorizationRequired;\\n // Number of blocks required for each side of a retarget proof:\\n // a retarget must provide `proofLength` blocks before the retarget\\n // and `proofLength` blocks after it.\\n // Governable\\n // Should be set to a fairly high number (e.g. 20-50) in production.\\n uint64 public proofLength;\\n // The number of the first epoch recorded by the relay.\\n // This should equal the height of the block starting the genesis epoch,\\n // divided by 2016, but this is not enforced as the relay has no\\n // information about block numbers.\\n uint64 public genesisEpoch;\\n // The number of the latest epoch whose difficulty is proven to the relay.\\n // If the genesis epoch's number is set correctly, and retargets along the\\n // way have been legitimate, this equals the height of the block starting\\n // the most recent epoch, divided by 2016.\\n uint64 public currentEpoch;\\n\\n uint256 internal currentEpochDifficulty;\\n uint256 internal prevEpochDifficulty;\\n\\n // Each epoch from genesis to the current one, keyed by their numbers.\\n mapping(uint256 => Epoch) internal epochs;\\n\\n mapping(address => bool) public isAuthorized;\\n\\n modifier relayActive() {\\n require(ready, \\\"Relay is not ready for use\\\");\\n _;\\n }\\n\\n /// @notice Establish a starting point for the relay by providing the\\n /// target, timestamp and blockheight of the first block of the relay\\n /// genesis epoch.\\n /// @param genesisHeader The first block header of the genesis epoch.\\n /// @param genesisHeight The block number of the first block of the epoch.\\n /// @param genesisProofLength The number of blocks required to accept a\\n /// proof.\\n /// @dev If the relay is used by querying the current and previous epoch\\n /// difficulty, at least one retarget needs to be provided after genesis;\\n /// otherwise the prevEpochDifficulty will be uninitialised and zero.\\n function genesis(\\n bytes calldata genesisHeader,\\n uint256 genesisHeight,\\n uint64 genesisProofLength\\n ) external onlyOwner {\\n require(!ready, \\\"Genesis already performed\\\");\\n\\n require(genesisHeader.length == 80, \\\"Invalid genesis header length\\\");\\n\\n require(\\n genesisHeight % 2016 == 0,\\n \\\"Invalid height of relay genesis block\\\"\\n );\\n\\n require(genesisProofLength < 2016, \\\"Proof length excessive\\\");\\n require(genesisProofLength > 0, \\\"Proof length may not be zero\\\");\\n\\n genesisEpoch = uint64(genesisHeight / 2016);\\n currentEpoch = genesisEpoch;\\n uint256 genesisTarget = genesisHeader.extractTarget();\\n uint256 genesisTimestamp = genesisHeader.extractTimestamp();\\n epochs[genesisEpoch] = Epoch(\\n uint32(genesisTimestamp),\\n uint224(genesisTarget)\\n );\\n proofLength = genesisProofLength;\\n currentEpochDifficulty = BTCUtils.calculateDifficulty(genesisTarget);\\n ready = true;\\n\\n emit Genesis(genesisHeight);\\n }\\n\\n /// @notice Set the number of blocks required to accept a header chain.\\n /// @param newLength The required number of blocks. Must be less than 2016.\\n /// @dev For production, a high number (e.g. 20-50) is recommended.\\n /// Small numbers are accepted but should only be used for testing.\\n function setProofLength(uint64 newLength) external relayActive onlyOwner {\\n require(newLength < 2016, \\\"Proof length excessive\\\");\\n require(newLength > 0, \\\"Proof length may not be zero\\\");\\n require(newLength != proofLength, \\\"Proof length unchanged\\\");\\n proofLength = newLength;\\n emit ProofLengthChanged(newLength);\\n }\\n\\n /// @notice Set whether the relay requires retarget submitters to be\\n /// pre-authorised by governance.\\n /// @param status True if authorisation is to be required, false if not.\\n function setAuthorizationStatus(bool status) external onlyOwner {\\n authorizationRequired = status;\\n emit AuthorizationRequirementChanged(status);\\n }\\n\\n /// @notice Authorise the given address to submit retarget proofs.\\n /// @param submitter The address to be authorised.\\n function authorize(address submitter) external onlyOwner {\\n isAuthorized[submitter] = true;\\n emit SubmitterAuthorized(submitter);\\n }\\n\\n /// @notice Rescind the authorisation of the submitter to retarget.\\n /// @param submitter The address to be deauthorised.\\n function deauthorize(address submitter) external onlyOwner {\\n isAuthorized[submitter] = false;\\n emit SubmitterDeauthorized(submitter);\\n }\\n\\n /// @notice Add a new epoch to the relay by providing a proof\\n /// of the difficulty before and after the retarget.\\n /// @param headers A chain of headers including the last X blocks before\\n /// the retarget, followed by the first X blocks after the retarget,\\n /// where X equals the current proof length.\\n /// @dev Checks that the first X blocks are valid in the most recent epoch,\\n /// that the difficulty of the new epoch is calculated correctly according\\n /// to the block timestamps, and that the next X blocks would be valid in\\n /// the new epoch.\\n /// We have no information of block heights, so we cannot enforce that\\n /// retargets only happen every 2016 blocks; instead, we assume that this\\n /// is the case if a valid proof of work is provided.\\n /// It is possible to cheat the relay by providing X blocks from earlier in\\n /// the most recent epoch, and then mining X new blocks after them.\\n /// However, each of these malicious blocks would have to be mined to a\\n /// higher difficulty than the legitimate ones.\\n /// Alternatively, if the retarget has not been performed yet, one could\\n /// first mine X blocks in the old difficulty with timestamps set far in\\n /// the future, and then another X blocks at a greatly reduced difficulty.\\n /// In either case, cheating the realy requires more work than mining X\\n /// legitimate blocks.\\n /// Only the most recent epoch is vulnerable to these attacks; once a\\n /// retarget has been proven to the relay, the epoch is immutable even if a\\n /// contradictory proof were to be presented later.\\n function retarget(bytes memory headers) external relayActive {\\n if (authorizationRequired) {\\n require(isAuthorized[msg.sender], \\\"Submitter unauthorized\\\");\\n }\\n\\n require(\\n // Require proofLength headers on both sides of the retarget\\n headers.length == (proofLength * 2 * 80),\\n \\\"Invalid header length\\\"\\n );\\n\\n Epoch storage latest = epochs[currentEpoch];\\n\\n uint256 oldTarget = latest.target;\\n\\n bytes32 previousHeaderDigest = bytes32(0);\\n\\n // Validate old chain\\n for (uint256 i = 0; i < proofLength; i++) {\\n (\\n bytes32 currentDigest,\\n uint256 currentHeaderTarget\\n ) = validateHeader(headers, i * 80, previousHeaderDigest);\\n\\n require(\\n currentHeaderTarget == oldTarget,\\n \\\"Invalid target in pre-retarget headers\\\"\\n );\\n\\n previousHeaderDigest = currentDigest;\\n }\\n\\n // get timestamp of retarget block\\n uint256 epochEndTimestamp = headers.extractTimestampAt(\\n (proofLength - 1) * 80\\n );\\n\\n // An attacker could produce blocks with timestamps in the future,\\n // in an attempt to reduce the difficulty after the retarget\\n // to make mining the second part of the retarget proof easier.\\n // In particular, the attacker could reuse all but one block\\n // from the legitimate chain, and only mine the last block.\\n // To hinder this, require that the epoch end timestamp does not\\n // exceed the ethereum timestamp.\\n // NOTE: both are unix seconds, so this comparison should be valid.\\n require(\\n /* solhint-disable-next-line not-rely-on-time */\\n epochEndTimestamp < block.timestamp,\\n \\\"Epoch cannot end in the future\\\"\\n );\\n\\n // Expected target is the full-length target\\n uint256 expectedTarget = BTCUtils.retargetAlgorithm(\\n oldTarget,\\n latest.timestamp,\\n epochEndTimestamp\\n );\\n\\n // Mined target is the header-encoded target\\n uint256 minedTarget = 0;\\n\\n uint256 epochStartTimestamp = headers.extractTimestampAt(\\n proofLength * 80\\n );\\n\\n // validate new chain\\n for (uint256 j = proofLength; j < proofLength * 2; j++) {\\n (\\n bytes32 _currentDigest,\\n uint256 _currentHeaderTarget\\n ) = validateHeader(headers, j * 80, previousHeaderDigest);\\n\\n if (minedTarget == 0) {\\n // The new target has not been set, so check its correctness\\n minedTarget = _currentHeaderTarget;\\n require(\\n // Although the target is a 256-bit number, there are only 32 bits of\\n // space in the Bitcoin header. Because of that, the version stored in\\n // the header is a less-precise representation of the actual target\\n // using base-256 version of scientific notation.\\n //\\n // The 256-bit unsigned integer returned from BTCUtils.retargetAlgorithm\\n // is the precise target value.\\n // The 256-bit unsigned integer returned from validateHeader is the less\\n // precise target value because it was read from 32 bits of space of\\n // Bitcoin block header.\\n //\\n // We can't compare the precise and less precise representations together\\n // so we first mask them to obtain the less precise version:\\n // (full & truncated) == truncated\\n _currentHeaderTarget ==\\n (expectedTarget & _currentHeaderTarget),\\n \\\"Invalid target in new epoch\\\"\\n );\\n } else {\\n // The new target has been set, so remaining targets should match.\\n require(\\n _currentHeaderTarget == minedTarget,\\n \\\"Unexpected target change after retarget\\\"\\n );\\n }\\n\\n previousHeaderDigest = _currentDigest;\\n }\\n\\n currentEpoch = currentEpoch + 1;\\n\\n epochs[currentEpoch] = Epoch(\\n uint32(epochStartTimestamp),\\n uint224(minedTarget)\\n );\\n\\n uint256 oldDifficulty = currentEpochDifficulty;\\n uint256 newDifficulty = BTCUtils.calculateDifficulty(minedTarget);\\n\\n prevEpochDifficulty = oldDifficulty;\\n currentEpochDifficulty = newDifficulty;\\n\\n emit Retarget(oldDifficulty, newDifficulty);\\n }\\n\\n /// @notice Check whether a given chain of headers should be accepted as\\n /// valid within the rules of the relay.\\n /// If the validation fails, this function throws an exception.\\n /// @param headers A chain of 2 to 2015 bitcoin headers.\\n /// @return startingHeaderTimestamp The timestamp of the first header.\\n /// @return headerCount The number of headers.\\n /// @dev A chain of headers is accepted as valid if:\\n /// - Its length is between 2 and 2015 headers.\\n /// - Headers in the chain are sequential and refer to previous digests.\\n /// - Each header is mined with the correct amount of work.\\n /// - The difficulty in each header matches an epoch of the relay,\\n /// as determined by the headers' timestamps. The headers must be between\\n /// the genesis epoch and the latest proven epoch (inclusive).\\n /// If the chain contains a retarget, it is accepted if the retarget has\\n /// already been proven to the relay.\\n /// If the chain contains blocks of an epoch that has not been proven to\\n /// the relay (after a retarget within the header chain, or when the entire\\n /// chain falls within an epoch that has not been proven yet), it will be\\n /// rejected.\\n /// One exception to this is when two subsequent epochs have exactly the\\n /// same difficulty; headers from the latter epoch will be accepted if the\\n /// previous epoch has been proven to the relay.\\n /// This is because it is not possible to distinguish such headers from\\n /// headers of the previous epoch.\\n ///\\n /// If the difficulty increases significantly between relay genesis and the\\n /// present, creating fraudulent proofs for earlier epochs becomes easier.\\n /// Users of the relay should check the timestamps of valid headers and\\n /// only accept appropriately recent ones.\\n function validateChain(bytes memory headers)\\n external\\n view\\n returns (uint256 startingHeaderTimestamp, uint256 headerCount)\\n {\\n require(headers.length % 80 == 0, \\\"Invalid header length\\\");\\n\\n headerCount = headers.length / 80;\\n\\n require(\\n headerCount > 1 && headerCount < 2016,\\n \\\"Invalid number of headers\\\"\\n );\\n\\n startingHeaderTimestamp = headers.extractTimestamp();\\n\\n // Short-circuit the first header's validation.\\n // We validate the header here to get the target which is needed to\\n // precisely identify the epoch.\\n (\\n bytes32 previousHeaderDigest,\\n uint256 currentHeaderTarget\\n ) = validateHeader(headers, 0, bytes32(0));\\n\\n Epoch memory nullEpoch = Epoch(0, 0);\\n\\n uint256 startingEpochNumber = currentEpoch;\\n Epoch memory startingEpoch = epochs[startingEpochNumber];\\n Epoch memory nextEpoch = nullEpoch;\\n\\n // Find the correct epoch for the given chain\\n // Fastest with recent epochs, but able to handle anything after genesis\\n //\\n // The rules for bitcoin timestamps are:\\n // - must be greater than the median of the last 11 blocks' timestamps\\n // - must be less than the network-adjusted time +2 hours\\n //\\n // Because of this, the timestamp of a header may be smaller than the\\n // starting time, or greater than the ending time of its epoch.\\n // However, a valid timestamp is guaranteed to fall within the window\\n // formed by the epochs immediately before and after its timestamp.\\n // We can identify cases like these by comparing the targets.\\n while (startingHeaderTimestamp < startingEpoch.timestamp) {\\n startingEpochNumber -= 1;\\n nextEpoch = startingEpoch;\\n startingEpoch = epochs[startingEpochNumber];\\n }\\n\\n // We have identified the centre of the window,\\n // by reaching the most recent epoch whose starting timestamp\\n // or reached before the genesis where epoch slots are empty.\\n // Therefore check that the timestamp is nonzero.\\n require(\\n startingEpoch.timestamp > 0,\\n \\\"Cannot validate chains before relay genesis\\\"\\n );\\n\\n // The targets don't match. This could be because the block is invalid,\\n // or it could be because of timestamp inaccuracy.\\n // To cover the latter case, check adjacent epochs.\\n if (currentHeaderTarget != startingEpoch.target) {\\n // The target matches the next epoch.\\n // This means we are right at the beginning of the next epoch,\\n // and retargets during the chain should not be possible.\\n if (currentHeaderTarget == nextEpoch.target) {\\n startingEpoch = nextEpoch;\\n nextEpoch = nullEpoch;\\n }\\n // The target doesn't match the next epoch.\\n // Therefore the only valid epoch is the previous one.\\n // Because the timestamp can't be more than 2 hours into the future\\n // we must be right near the end of the epoch,\\n // so a retarget is possible.\\n else {\\n startingEpochNumber -= 1;\\n nextEpoch = startingEpoch;\\n startingEpoch = epochs[startingEpochNumber];\\n\\n // We have failed to find a match,\\n // therefore the target has to be invalid.\\n require(\\n currentHeaderTarget == startingEpoch.target,\\n \\\"Invalid target in header chain\\\"\\n );\\n }\\n }\\n\\n // We've found the correct epoch for the first header.\\n // Validate the rest.\\n for (uint256 i = 1; i < headerCount; i++) {\\n bytes32 currentDigest;\\n (currentDigest, currentHeaderTarget) = validateHeader(\\n headers,\\n i * 80,\\n previousHeaderDigest\\n );\\n\\n // If the header's target does not match the expected target,\\n // check if a retarget is possible.\\n //\\n // If next epoch timestamp exists, a valid retarget is possible\\n // (if next epoch timestamp doesn't exist, either a retarget has\\n // already happened in this chain, the relay needs a retarget\\n // before this chain can be validated, or a retarget is not allowed\\n // because we know the headers are within a timestamp irregularity\\n // of the previous retarget).\\n //\\n // In this case the target must match the next epoch's target,\\n // and the header's timestamp must match the epoch's start.\\n if (currentHeaderTarget != startingEpoch.target) {\\n uint256 currentHeaderTimestamp = headers.extractTimestampAt(\\n i * 80\\n );\\n\\n require(\\n nextEpoch.timestamp != 0 &&\\n currentHeaderTarget == nextEpoch.target &&\\n currentHeaderTimestamp == nextEpoch.timestamp,\\n \\\"Invalid target in header chain\\\"\\n );\\n\\n startingEpoch = nextEpoch;\\n nextEpoch = nullEpoch;\\n }\\n\\n previousHeaderDigest = currentDigest;\\n }\\n\\n return (startingHeaderTimestamp, headerCount);\\n }\\n\\n /// @notice Get the difficulty of the specified block.\\n /// @param blockNumber The number of the block. Must fall within the relay\\n /// range (at or after the relay genesis, and at or before the end of the\\n /// most recent epoch proven to the relay).\\n /// @return The difficulty of the epoch.\\n function getBlockDifficulty(uint256 blockNumber)\\n external\\n view\\n returns (uint256)\\n {\\n return getEpochDifficulty(blockNumber / 2016);\\n }\\n\\n /// @notice Get the range of blocks the relay can accept proofs for.\\n /// @dev Assumes that the genesis has been set correctly.\\n /// Additionally, if the next epoch after the current one has the exact\\n /// same difficulty, headers for it can be validated as well.\\n /// This function should be used for informative purposes,\\n /// e.g. to determine whether a retarget must be provided before submitting\\n /// a header chain for validation.\\n /// @return relayGenesis The height of the earliest block that can be\\n /// included in header chains for the relay to validate.\\n /// @return currentEpochEnd The height of the last block that can be\\n /// included in header chains for the relay to validate.\\n function getRelayRange()\\n external\\n view\\n returns (uint256 relayGenesis, uint256 currentEpochEnd)\\n {\\n relayGenesis = genesisEpoch * 2016;\\n currentEpochEnd = (currentEpoch * 2016) + 2015;\\n }\\n\\n /// @notice Returns the difficulty of the current epoch.\\n /// @dev returns 0 if the relay is not ready.\\n /// @return The difficulty of the current epoch.\\n function getCurrentEpochDifficulty()\\n external\\n view\\n virtual\\n returns (uint256)\\n {\\n return currentEpochDifficulty;\\n }\\n\\n /// @notice Returns the difficulty of the previous epoch.\\n /// @dev Returns 0 if the relay is not ready or has not had a retarget.\\n /// @return The difficulty of the previous epoch.\\n function getPrevEpochDifficulty() external view virtual returns (uint256) {\\n return prevEpochDifficulty;\\n }\\n\\n function getCurrentAndPrevEpochDifficulty()\\n external\\n view\\n returns (uint256 current, uint256 previous)\\n {\\n return (currentEpochDifficulty, prevEpochDifficulty);\\n }\\n\\n /// @notice Get the difficulty of the specified epoch.\\n /// @param epochNumber The number of the epoch (the height of the first\\n /// block of the epoch, divided by 2016). Must fall within the relay range.\\n /// @return The difficulty of the epoch.\\n function getEpochDifficulty(uint256 epochNumber)\\n public\\n view\\n returns (uint256)\\n {\\n require(epochNumber >= genesisEpoch, \\\"Epoch is before relay genesis\\\");\\n require(\\n epochNumber <= currentEpoch,\\n \\\"Epoch is not proven to the relay yet\\\"\\n );\\n return BTCUtils.calculateDifficulty(epochs[epochNumber].target);\\n }\\n\\n /// @notice Check that the specified header forms a correct chain with the\\n /// digest of the previous header (if provided), and has sufficient work.\\n /// @param headers The byte array containing the header of interest.\\n /// @param start The start of the header in the array.\\n /// @param prevDigest The digest of the previous header\\n /// (optional; providing zeros for the digest skips the check).\\n /// @return digest The digest of the current header.\\n /// @return target The PoW target of the header.\\n /// @dev Throws an exception if the header's chain or PoW are invalid.\\n /// Performs no other validation.\\n function validateHeader(\\n bytes memory headers,\\n uint256 start,\\n bytes32 prevDigest\\n ) internal view returns (bytes32 digest, uint256 target) {\\n // If previous block digest has been provided, require that it matches\\n if (prevDigest != bytes32(0)) {\\n require(\\n headers.validateHeaderPrevHash(start, prevDigest),\\n \\\"Invalid chain\\\"\\n );\\n }\\n\\n // Require that the header has sufficient work for its stated target\\n target = headers.extractTargetAt(start);\\n digest = headers.hash256Slice(start, 80);\\n require(ValidateSPV.validateHeaderWork(digest, target), \\\"Invalid work\\\");\\n\\n return (digest, target);\\n }\\n}\\n\",\"keccak256\":\"0x5329ba57ec3db13128ba0a90569682b16211f7fbc3fbab764fd0cd60386a7441\",\"license\":\"GPL-3.0-only\"}},\"version\":1}",
|
|
472
|
+
"bytecode": "0x608060405234801561001057600080fd5b5061001a3361001f565b61006f565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6120908061007e6000396000f3fe608060405234801561001057600080fd5b50600436106101825760003560e01c8063715018a6116100d8578063b6a5d7de1161008c578063f2fde38b11610066578063f2fde38b14610322578063f5619fda14610335578063fe9fbb801461035057600080fd5b8063b6a5d7de146102e8578063b70e6be6146102fb578063eb8695ef1461030f57600080fd5b80637ca5b1dd116100bd5780637ca5b1dd146102a65780638da5cb5b146102b957806395410d2b146102d457600080fd5b8063715018a61461026a578063766718081461027257600080fd5b806327c97fa51161013a5780634ca49f51116101145780634ca49f5114610220578063620414e6146102335780636defbf801461024657600080fd5b806327c97fa5146101fa5780632b97be241461020d5780633a1b77b01461021557600080fd5b8063113764be1161016b578063113764be146101ca578063189179a3146101d257806319c9aa32146101e557600080fd5b806306a274221461018757806310b76ed8146101ad575b600080fd5b61019a610195366004611c30565b610373565b6040519081526020015b60405180910390f35b6101b561038a565b604080519283526020830191909152016101a4565b60025461019a565b6101b56101e0366004611c5f565b6103ea565b6101f86101f3366004611d2d565b6107e2565b005b6101f8610208366004611d48565b6109d5565b60035461019a565b6002546003546101b5565b6101f861022e366004611d71565b610a2e565b61019a610241366004611c30565b610df7565b60005461025a90600160a01b900460ff1681565b60405190151581526020016101a4565b6101f8610f07565b60015461028d90600160401b900467ffffffffffffffff1681565b60405167ffffffffffffffff90911681526020016101a4565b6101f86102b4366004611c5f565b610f1b565b6000546040516001600160a01b0390911681526020016101a4565b60005461025a90600160a81b900460ff1681565b6101f86102f6366004611d48565b6114b9565b60015461028d9067ffffffffffffffff1681565b6101f861031d366004611dfa565b611515565b6101f8610330366004611d48565b611585565b60005461028d90600160b01b900467ffffffffffffffff1681565b61025a61035e366004611d48565b60056020526000908152604090205460ff1681565b60006103846102416107e084611e48565b92915050565b60015460009081906103a89067ffffffffffffffff166107e0611e5c565b60015467ffffffffffffffff91821693506103ce91600160401b909104166107e0611e5c565b6103da906107df611e88565b67ffffffffffffffff1690509091565b600080605083516103fb9190611eb0565b1561044d5760405162461bcd60e51b815260206004820152601560248201527f496e76616c696420686561646572206c656e677468000000000000000000000060448201526064015b60405180910390fd5b6050835161045b9190611e48565b905060018111801561046e57506107e081105b6104ba5760405162461bcd60e51b815260206004820152601960248201527f496e76616c6964206e756d626572206f662068656164657273000000000000006044820152606401610444565b6104c383611615565b63ffffffff1691506000806104d9858280611649565b6040805180820182526000808252602080830182905260015467ffffffffffffffff600160401b90910416808352600482529184902084518086019095525463ffffffff8116855264010000000090046001600160e01b031690840152939550919350909190825b815163ffffffff1688101561059f5761055b600184611ec4565b60008181526004602090815260409182902082518084019093525463ffffffff8116835264010000000090046001600160e01b031690820152909350919050610541565b815163ffffffff166106195760405162461bcd60e51b815260206004820152602b60248201527f43616e6e6f742076616c696461746520636861696e73206265666f726520726560448201527f6c61792067656e657369730000000000000000000000000000000000000000006064820152608401610444565b81602001516001600160e01b031685146106e35780602001516001600160e01b03168503610649579050826106e3565b610654600184611ec4565b60008181526004602090815260409182902082518084019093525463ffffffff8116835264010000000090046001600160e01b031690820181905291945092915085146106e35760405162461bcd60e51b815260206004820152601e60248201527f496e76616c69642074617267657420696e2068656164657220636861696e00006044820152606401610444565b60015b878110156107d65760006107058b6106ff846050611ed7565b8a611649565b60208601519098509091506001600160e01b031687146107c257600061073661072f846050611ed7565b8d90611721565b845163ffffffff9182169250161580159061075d575083602001516001600160e01b031688145b801561076f5750835163ffffffff1681145b6107bb5760405162461bcd60e51b815260206004820152601e60248201527f496e76616c69642074617267657420696e2068656164657220636861696e00006044820152606401610444565b5091925084915b9650806107ce81611eee565b9150506106e6565b50505050505050915091565b600054600160a01b900460ff1661083b5760405162461bcd60e51b815260206004820152601a60248201527f52656c6179206973206e6f7420726561647920666f72207573650000000000006044820152606401610444565b610843611742565b6107e08167ffffffffffffffff161061089e5760405162461bcd60e51b815260206004820152601660248201527f50726f6f66206c656e67746820657863657373697665000000000000000000006044820152606401610444565b60008167ffffffffffffffff16116108f85760405162461bcd60e51b815260206004820152601c60248201527f50726f6f66206c656e677468206d6179206e6f74206265207a65726f000000006044820152606401610444565b60005467ffffffffffffffff600160b01b90910481169082160361095e5760405162461bcd60e51b815260206004820152601660248201527f50726f6f66206c656e67746820756e6368616e676564000000000000000000006044820152606401610444565b600080547fffff0000000000000000ffffffffffffffffffffffffffffffffffffffffffff16600160b01b67ffffffffffffffff8416908102919091179091556040519081527f3e9f904d8cf11753c79b67c8259c582056d4a7d8af120f81257a59eeb8824b96906020015b60405180910390a150565b6109dd611742565b6001600160a01b038116600081815260056020908152604091829020805460ff1916905590519182527f7498b96beeabea5ad3139f1a2861a03e480034254e36b10aae2e6e42ad7b4b6891016109ca565b610a36611742565b600054600160a01b900460ff1615610a905760405162461bcd60e51b815260206004820152601960248201527f47656e6573697320616c726561647920706572666f726d6564000000000000006044820152606401610444565b60508314610ae05760405162461bcd60e51b815260206004820152601d60248201527f496e76616c69642067656e6573697320686561646572206c656e6774680000006044820152606401610444565b610aec6107e083611eb0565b15610b5f5760405162461bcd60e51b815260206004820152602560248201527f496e76616c696420686569676874206f662072656c61792067656e657369732060448201527f626c6f636b0000000000000000000000000000000000000000000000000000006064820152608401610444565b6107e08167ffffffffffffffff1610610bba5760405162461bcd60e51b815260206004820152601660248201527f50726f6f66206c656e67746820657863657373697665000000000000000000006044820152606401610444565b60008167ffffffffffffffff1611610c145760405162461bcd60e51b815260206004820152601c60248201527f50726f6f66206c656e677468206d6179206e6f74206265207a65726f000000006044820152606401610444565b610c206107e083611e48565b600180547fffffffffffffffffffffffffffffffff000000000000000000000000000000001667ffffffffffffffff92909216918217600160401b92909202919091179055604080516020601f8601819004810282018101909252848152600091610ca69190879087908190840183828082843760009201919091525061179c92505050565b90506000610ce986868080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061161592505050565b60408051808201825263ffffffff9283168082526001600160e01b03808716602080850191825260015467ffffffffffffffff9081166000908152600490925295812094519151909216640100000000029516949094179091558254918616600160b01b027fffff0000000000000000ffffffffffffffffffffffffffffffffffffffffffff909216919091179091559050610d84826117a9565b600255600080547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff16600160a01b1790556040517f2381d16925551c2fb1a5edfcf4fce2f6d085e1f85f4b88340c09c9d191f9d4e990610de79086815260200190565b60405180910390a1505050505050565b60015460009067ffffffffffffffff16821015610e565760405162461bcd60e51b815260206004820152601d60248201527f45706f6368206973206265666f72652072656c61792067656e657369730000006044820152606401610444565b600154600160401b900467ffffffffffffffff16821115610ede5760405162461bcd60e51b8152602060048201526024808201527f45706f6368206973206e6f742070726f76656e20746f207468652072656c617960448201527f20796574000000000000000000000000000000000000000000000000000000006064820152608401610444565b6000828152600460205260409020546103849064010000000090046001600160e01b03166117a9565b610f0f611742565b610f1960006117d1565b565b600054600160a01b900460ff16610f745760405162461bcd60e51b815260206004820152601a60248201527f52656c6179206973206e6f7420726561647920666f72207573650000000000006044820152606401610444565b600054600160a81b900460ff1615610fe5573360009081526005602052604090205460ff16610fe55760405162461bcd60e51b815260206004820152601660248201527f5375626d697474657220756e617574686f72697a6564000000000000000000006044820152606401610444565b60005461100490600160b01b900467ffffffffffffffff166002611e5c565b61100f906050611e5c565b67ffffffffffffffff168151146110685760405162461bcd60e51b815260206004820152601560248201527f496e76616c696420686561646572206c656e67746800000000000000000000006044820152606401610444565b600154600160401b900467ffffffffffffffff166000908152600460205260408120805490916401000000009091046001600160e01b031690805b600054600160b01b900467ffffffffffffffff16811015611164576000806110d6876110d0856050611ed7565b86611649565b9150915084811461114f5760405162461bcd60e51b815260206004820152602660248201527f496e76616c69642074617267657420696e207072652d7265746172676574206860448201527f65616465727300000000000000000000000000000000000000000000000000006064820152608401610444565b5091508061115c81611eee565b9150506110a3565b50600080546111a69061118a90600190600160b01b900467ffffffffffffffff16611f07565b611195906050611e5c565b869067ffffffffffffffff16611721565b63ffffffff1690504281106111fd5760405162461bcd60e51b815260206004820152601e60248201527f45706f63682063616e6e6f7420656e6420696e207468652066757475726500006044820152606401610444565b835460009061121490859063ffffffff1684611839565b9050600080611250600060169054906101000a900467ffffffffffffffff16605061123f9190611e5c565b899067ffffffffffffffff16611721565b60005463ffffffff919091169150600160b01b900467ffffffffffffffff165b60005461128f90600160b01b900467ffffffffffffffff166002611e5c565b67ffffffffffffffff168110156113a1576000806112b28b6106ff856050611ed7565b91509150846000036113175780945080861681146113125760405162461bcd60e51b815260206004820152601b60248201527f496e76616c69642074617267657420696e206e65772065706f636800000000006044820152606401610444565b61138c565b84811461138c5760405162461bcd60e51b815260206004820152602760248201527f556e657870656374656420746172676574206368616e6765206166746572207260448201527f65746172676574000000000000000000000000000000000000000000000000006064820152608401610444565b5095508061139981611eee565b915050611270565b50600160089054906101000a900467ffffffffffffffff1660016113c59190611e88565b6001805467ffffffffffffffff928316600160401b9081027fffffffffffffffffffffffffffffffff0000000000000000ffffffffffffffff909216919091179182905560408051808201825263ffffffff80871682526001600160e01b0380891660208085019182529590960490961660009081526004909452918320905193519094166401000000000292169190911790915560025490611467846117a9565b6003839055600281905560408051848152602081018390529192507fa282ee798b132f9dc11e06cd4d8e767e562be8709602ca14fea7ab3392acbdab910160405180910390a150505050505050505050565b6114c1611742565b6001600160a01b038116600081815260056020908152604091829020805460ff1916600117905590519182527fd53649b492f738bb59d6825099b5955073efda0bf9e3a7ad20da22e110122e2991016109ca565b61151d611742565b60008054821515600160a81b027fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff9091161790556040517fd813b248d49c8bf08be2b6947126da6763df310beed7bea97756456c5727419a906109ca90831515815260200190565b61158d611742565b6001600160a01b0381166116095760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610444565b611612816117d1565b50565b6000610384611623836118cd565b60d881901c63ff00ff001662ff00ff60e89290921c9190911617601081811b91901c1790565b60008082156116a95761165d8585856118da565b6116a95760405162461bcd60e51b815260206004820152600d60248201527f496e76616c696420636861696e000000000000000000000000000000000000006044820152606401610444565b6116b38585611905565b90506116c1858560506119a7565b91506116cd82826119d1565b6117195760405162461bcd60e51b815260206004820152600c60248201527f496e76616c696420776f726b00000000000000000000000000000000000000006044820152606401610444565b935093915050565b600061173b611623611734846044611f28565b8590611b2a565b9392505050565b6000546001600160a01b03163314610f195760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610444565b6000610384826000611905565b60006103847bffff000000000000000000000000000000000000000000000000000083611b39565b600080546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000806118468385611b45565b9050611856621275006004611b39565b81101561186e5761186b621275006004611b39565b90505b61187c621275006004611ba1565b81111561189457611891621275006004611ba1565b90505b60006118ad826118a78862010000611b39565b90611ba1565b90506118c3620100006118a78362127500611b39565b9695505050505050565b6000610384826044611b2a565b6000806118e78585611c17565b90508281146118fa57600091505061173b565b506001949350505050565b600080611916611734846048611f28565b60e81c905060008461192985604b611f28565b8151811061193957611939611f3b565b016020015160f81c9050600061196d83600060108262ffffff16901c8261ff001660108462ffffff16901b17179050919050565b62ffffff1690506000611981600384611f51565b60ff1690506119928161010061204e565b61199c9083611ed7565b979650505050505050565b6000602060008385602001870160025afa50602060006020600060025afa50506000519392505050565b6000826119e057506000610384565b81611b228460008190506008817eff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff16901b600882901c7eff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff161790506010817dffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff16901b601082901c7dffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff161790506020817bffffffff00000000ffffffff00000000ffffffff00000000ffffffff16901b602082901c7bffffffff00000000ffffffff00000000ffffffff00000000ffffffff1617905060408177ffffffffffffffff0000000000000000ffffffffffffffff16901b604082901c77ffffffffffffffff0000000000000000ffffffffffffffff16179050608081901b608082901c179050919050565b109392505050565b600061173b8383016020015190565b600061173b8284611e48565b600082821115611b975760405162461bcd60e51b815260206004820152601d60248201527f556e646572666c6f7720647572696e67207375627472616374696f6e2e0000006044820152606401610444565b61173b8284611ec4565b600082600003611bb357506000610384565b611bbd8284611ed7565b905081611bca8483611e48565b146103845760405162461bcd60e51b815260206004820152601f60248201527f4f766572666c6f7720647572696e67206d756c7469706c69636174696f6e2e006044820152606401610444565b600061173b611c27836004611f28565b84016020015190565b600060208284031215611c4257600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b600060208284031215611c7157600080fd5b813567ffffffffffffffff80821115611c8957600080fd5b818401915084601f830112611c9d57600080fd5b813581811115611caf57611caf611c49565b604051601f8201601f19908116603f01168101908382118183101715611cd757611cd7611c49565b81604052828152876020848701011115611cf057600080fd5b826020860160208301376000928101602001929092525095945050505050565b803567ffffffffffffffff81168114611d2857600080fd5b919050565b600060208284031215611d3f57600080fd5b61173b82611d10565b600060208284031215611d5a57600080fd5b81356001600160a01b038116811461173b57600080fd5b60008060008060608587031215611d8757600080fd5b843567ffffffffffffffff80821115611d9f57600080fd5b818701915087601f830112611db357600080fd5b813581811115611dc257600080fd5b886020828501011115611dd457600080fd5b602092830196509450508501359150611def60408601611d10565b905092959194509250565b600060208284031215611e0c57600080fd5b8135801515811461173b57600080fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600082611e5757611e57611e1c565b500490565b67ffffffffffffffff818116838216028082169190828114611e8057611e80611e32565b505092915050565b67ffffffffffffffff818116838216019080821115611ea957611ea9611e32565b5092915050565b600082611ebf57611ebf611e1c565b500690565b8181038181111561038457610384611e32565b808202811582820484141761038457610384611e32565b600060018201611f0057611f00611e32565b5060010190565b67ffffffffffffffff828116828216039080821115611ea957611ea9611e32565b8082018082111561038457610384611e32565b634e487b7160e01b600052603260045260246000fd5b60ff828116828216039081111561038457610384611e32565b600181815b80851115611fa5578160001904821115611f8b57611f8b611e32565b80851615611f9857918102915b93841c9390800290611f6f565b509250929050565b600082611fbc57506001610384565b81611fc957506000610384565b8160018114611fdf5760028114611fe957612005565b6001915050610384565b60ff841115611ffa57611ffa611e32565b50506001821b610384565b5060208310610133831016604e8410600b8410161715612028575081810a610384565b6120328383611f6a565b806000190482111561204657612046611e32565b029392505050565b600061173b8383611fad56fea26469706673582212206679d3b0bc8016a8c7553e93c862ce838632e31c0ba6405d8c7af33c9ebc986464736f6c63430008110033",
|
|
473
|
+
"deployedBytecode": "0x608060405234801561001057600080fd5b50600436106101825760003560e01c8063715018a6116100d8578063b6a5d7de1161008c578063f2fde38b11610066578063f2fde38b14610322578063f5619fda14610335578063fe9fbb801461035057600080fd5b8063b6a5d7de146102e8578063b70e6be6146102fb578063eb8695ef1461030f57600080fd5b80637ca5b1dd116100bd5780637ca5b1dd146102a65780638da5cb5b146102b957806395410d2b146102d457600080fd5b8063715018a61461026a578063766718081461027257600080fd5b806327c97fa51161013a5780634ca49f51116101145780634ca49f5114610220578063620414e6146102335780636defbf801461024657600080fd5b806327c97fa5146101fa5780632b97be241461020d5780633a1b77b01461021557600080fd5b8063113764be1161016b578063113764be146101ca578063189179a3146101d257806319c9aa32146101e557600080fd5b806306a274221461018757806310b76ed8146101ad575b600080fd5b61019a610195366004611c30565b610373565b6040519081526020015b60405180910390f35b6101b561038a565b604080519283526020830191909152016101a4565b60025461019a565b6101b56101e0366004611c5f565b6103ea565b6101f86101f3366004611d2d565b6107e2565b005b6101f8610208366004611d48565b6109d5565b60035461019a565b6002546003546101b5565b6101f861022e366004611d71565b610a2e565b61019a610241366004611c30565b610df7565b60005461025a90600160a01b900460ff1681565b60405190151581526020016101a4565b6101f8610f07565b60015461028d90600160401b900467ffffffffffffffff1681565b60405167ffffffffffffffff90911681526020016101a4565b6101f86102b4366004611c5f565b610f1b565b6000546040516001600160a01b0390911681526020016101a4565b60005461025a90600160a81b900460ff1681565b6101f86102f6366004611d48565b6114b9565b60015461028d9067ffffffffffffffff1681565b6101f861031d366004611dfa565b611515565b6101f8610330366004611d48565b611585565b60005461028d90600160b01b900467ffffffffffffffff1681565b61025a61035e366004611d48565b60056020526000908152604090205460ff1681565b60006103846102416107e084611e48565b92915050565b60015460009081906103a89067ffffffffffffffff166107e0611e5c565b60015467ffffffffffffffff91821693506103ce91600160401b909104166107e0611e5c565b6103da906107df611e88565b67ffffffffffffffff1690509091565b600080605083516103fb9190611eb0565b1561044d5760405162461bcd60e51b815260206004820152601560248201527f496e76616c696420686561646572206c656e677468000000000000000000000060448201526064015b60405180910390fd5b6050835161045b9190611e48565b905060018111801561046e57506107e081105b6104ba5760405162461bcd60e51b815260206004820152601960248201527f496e76616c6964206e756d626572206f662068656164657273000000000000006044820152606401610444565b6104c383611615565b63ffffffff1691506000806104d9858280611649565b6040805180820182526000808252602080830182905260015467ffffffffffffffff600160401b90910416808352600482529184902084518086019095525463ffffffff8116855264010000000090046001600160e01b031690840152939550919350909190825b815163ffffffff1688101561059f5761055b600184611ec4565b60008181526004602090815260409182902082518084019093525463ffffffff8116835264010000000090046001600160e01b031690820152909350919050610541565b815163ffffffff166106195760405162461bcd60e51b815260206004820152602b60248201527f43616e6e6f742076616c696461746520636861696e73206265666f726520726560448201527f6c61792067656e657369730000000000000000000000000000000000000000006064820152608401610444565b81602001516001600160e01b031685146106e35780602001516001600160e01b03168503610649579050826106e3565b610654600184611ec4565b60008181526004602090815260409182902082518084019093525463ffffffff8116835264010000000090046001600160e01b031690820181905291945092915085146106e35760405162461bcd60e51b815260206004820152601e60248201527f496e76616c69642074617267657420696e2068656164657220636861696e00006044820152606401610444565b60015b878110156107d65760006107058b6106ff846050611ed7565b8a611649565b60208601519098509091506001600160e01b031687146107c257600061073661072f846050611ed7565b8d90611721565b845163ffffffff9182169250161580159061075d575083602001516001600160e01b031688145b801561076f5750835163ffffffff1681145b6107bb5760405162461bcd60e51b815260206004820152601e60248201527f496e76616c69642074617267657420696e2068656164657220636861696e00006044820152606401610444565b5091925084915b9650806107ce81611eee565b9150506106e6565b50505050505050915091565b600054600160a01b900460ff1661083b5760405162461bcd60e51b815260206004820152601a60248201527f52656c6179206973206e6f7420726561647920666f72207573650000000000006044820152606401610444565b610843611742565b6107e08167ffffffffffffffff161061089e5760405162461bcd60e51b815260206004820152601660248201527f50726f6f66206c656e67746820657863657373697665000000000000000000006044820152606401610444565b60008167ffffffffffffffff16116108f85760405162461bcd60e51b815260206004820152601c60248201527f50726f6f66206c656e677468206d6179206e6f74206265207a65726f000000006044820152606401610444565b60005467ffffffffffffffff600160b01b90910481169082160361095e5760405162461bcd60e51b815260206004820152601660248201527f50726f6f66206c656e67746820756e6368616e676564000000000000000000006044820152606401610444565b600080547fffff0000000000000000ffffffffffffffffffffffffffffffffffffffffffff16600160b01b67ffffffffffffffff8416908102919091179091556040519081527f3e9f904d8cf11753c79b67c8259c582056d4a7d8af120f81257a59eeb8824b96906020015b60405180910390a150565b6109dd611742565b6001600160a01b038116600081815260056020908152604091829020805460ff1916905590519182527f7498b96beeabea5ad3139f1a2861a03e480034254e36b10aae2e6e42ad7b4b6891016109ca565b610a36611742565b600054600160a01b900460ff1615610a905760405162461bcd60e51b815260206004820152601960248201527f47656e6573697320616c726561647920706572666f726d6564000000000000006044820152606401610444565b60508314610ae05760405162461bcd60e51b815260206004820152601d60248201527f496e76616c69642067656e6573697320686561646572206c656e6774680000006044820152606401610444565b610aec6107e083611eb0565b15610b5f5760405162461bcd60e51b815260206004820152602560248201527f496e76616c696420686569676874206f662072656c61792067656e657369732060448201527f626c6f636b0000000000000000000000000000000000000000000000000000006064820152608401610444565b6107e08167ffffffffffffffff1610610bba5760405162461bcd60e51b815260206004820152601660248201527f50726f6f66206c656e67746820657863657373697665000000000000000000006044820152606401610444565b60008167ffffffffffffffff1611610c145760405162461bcd60e51b815260206004820152601c60248201527f50726f6f66206c656e677468206d6179206e6f74206265207a65726f000000006044820152606401610444565b610c206107e083611e48565b600180547fffffffffffffffffffffffffffffffff000000000000000000000000000000001667ffffffffffffffff92909216918217600160401b92909202919091179055604080516020601f8601819004810282018101909252848152600091610ca69190879087908190840183828082843760009201919091525061179c92505050565b90506000610ce986868080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061161592505050565b60408051808201825263ffffffff9283168082526001600160e01b03808716602080850191825260015467ffffffffffffffff9081166000908152600490925295812094519151909216640100000000029516949094179091558254918616600160b01b027fffff0000000000000000ffffffffffffffffffffffffffffffffffffffffffff909216919091179091559050610d84826117a9565b600255600080547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff16600160a01b1790556040517f2381d16925551c2fb1a5edfcf4fce2f6d085e1f85f4b88340c09c9d191f9d4e990610de79086815260200190565b60405180910390a1505050505050565b60015460009067ffffffffffffffff16821015610e565760405162461bcd60e51b815260206004820152601d60248201527f45706f6368206973206265666f72652072656c61792067656e657369730000006044820152606401610444565b600154600160401b900467ffffffffffffffff16821115610ede5760405162461bcd60e51b8152602060048201526024808201527f45706f6368206973206e6f742070726f76656e20746f207468652072656c617960448201527f20796574000000000000000000000000000000000000000000000000000000006064820152608401610444565b6000828152600460205260409020546103849064010000000090046001600160e01b03166117a9565b610f0f611742565b610f1960006117d1565b565b600054600160a01b900460ff16610f745760405162461bcd60e51b815260206004820152601a60248201527f52656c6179206973206e6f7420726561647920666f72207573650000000000006044820152606401610444565b600054600160a81b900460ff1615610fe5573360009081526005602052604090205460ff16610fe55760405162461bcd60e51b815260206004820152601660248201527f5375626d697474657220756e617574686f72697a6564000000000000000000006044820152606401610444565b60005461100490600160b01b900467ffffffffffffffff166002611e5c565b61100f906050611e5c565b67ffffffffffffffff168151146110685760405162461bcd60e51b815260206004820152601560248201527f496e76616c696420686561646572206c656e67746800000000000000000000006044820152606401610444565b600154600160401b900467ffffffffffffffff166000908152600460205260408120805490916401000000009091046001600160e01b031690805b600054600160b01b900467ffffffffffffffff16811015611164576000806110d6876110d0856050611ed7565b86611649565b9150915084811461114f5760405162461bcd60e51b815260206004820152602660248201527f496e76616c69642074617267657420696e207072652d7265746172676574206860448201527f65616465727300000000000000000000000000000000000000000000000000006064820152608401610444565b5091508061115c81611eee565b9150506110a3565b50600080546111a69061118a90600190600160b01b900467ffffffffffffffff16611f07565b611195906050611e5c565b869067ffffffffffffffff16611721565b63ffffffff1690504281106111fd5760405162461bcd60e51b815260206004820152601e60248201527f45706f63682063616e6e6f7420656e6420696e207468652066757475726500006044820152606401610444565b835460009061121490859063ffffffff1684611839565b9050600080611250600060169054906101000a900467ffffffffffffffff16605061123f9190611e5c565b899067ffffffffffffffff16611721565b60005463ffffffff919091169150600160b01b900467ffffffffffffffff165b60005461128f90600160b01b900467ffffffffffffffff166002611e5c565b67ffffffffffffffff168110156113a1576000806112b28b6106ff856050611ed7565b91509150846000036113175780945080861681146113125760405162461bcd60e51b815260206004820152601b60248201527f496e76616c69642074617267657420696e206e65772065706f636800000000006044820152606401610444565b61138c565b84811461138c5760405162461bcd60e51b815260206004820152602760248201527f556e657870656374656420746172676574206368616e6765206166746572207260448201527f65746172676574000000000000000000000000000000000000000000000000006064820152608401610444565b5095508061139981611eee565b915050611270565b50600160089054906101000a900467ffffffffffffffff1660016113c59190611e88565b6001805467ffffffffffffffff928316600160401b9081027fffffffffffffffffffffffffffffffff0000000000000000ffffffffffffffff909216919091179182905560408051808201825263ffffffff80871682526001600160e01b0380891660208085019182529590960490961660009081526004909452918320905193519094166401000000000292169190911790915560025490611467846117a9565b6003839055600281905560408051848152602081018390529192507fa282ee798b132f9dc11e06cd4d8e767e562be8709602ca14fea7ab3392acbdab910160405180910390a150505050505050505050565b6114c1611742565b6001600160a01b038116600081815260056020908152604091829020805460ff1916600117905590519182527fd53649b492f738bb59d6825099b5955073efda0bf9e3a7ad20da22e110122e2991016109ca565b61151d611742565b60008054821515600160a81b027fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff9091161790556040517fd813b248d49c8bf08be2b6947126da6763df310beed7bea97756456c5727419a906109ca90831515815260200190565b61158d611742565b6001600160a01b0381166116095760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610444565b611612816117d1565b50565b6000610384611623836118cd565b60d881901c63ff00ff001662ff00ff60e89290921c9190911617601081811b91901c1790565b60008082156116a95761165d8585856118da565b6116a95760405162461bcd60e51b815260206004820152600d60248201527f496e76616c696420636861696e000000000000000000000000000000000000006044820152606401610444565b6116b38585611905565b90506116c1858560506119a7565b91506116cd82826119d1565b6117195760405162461bcd60e51b815260206004820152600c60248201527f496e76616c696420776f726b00000000000000000000000000000000000000006044820152606401610444565b935093915050565b600061173b611623611734846044611f28565b8590611b2a565b9392505050565b6000546001600160a01b03163314610f195760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610444565b6000610384826000611905565b60006103847bffff000000000000000000000000000000000000000000000000000083611b39565b600080546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000806118468385611b45565b9050611856621275006004611b39565b81101561186e5761186b621275006004611b39565b90505b61187c621275006004611ba1565b81111561189457611891621275006004611ba1565b90505b60006118ad826118a78862010000611b39565b90611ba1565b90506118c3620100006118a78362127500611b39565b9695505050505050565b6000610384826044611b2a565b6000806118e78585611c17565b90508281146118fa57600091505061173b565b506001949350505050565b600080611916611734846048611f28565b60e81c905060008461192985604b611f28565b8151811061193957611939611f3b565b016020015160f81c9050600061196d83600060108262ffffff16901c8261ff001660108462ffffff16901b17179050919050565b62ffffff1690506000611981600384611f51565b60ff1690506119928161010061204e565b61199c9083611ed7565b979650505050505050565b6000602060008385602001870160025afa50602060006020600060025afa50506000519392505050565b6000826119e057506000610384565b81611b228460008190506008817eff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff16901b600882901c7eff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff161790506010817dffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff16901b601082901c7dffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff161790506020817bffffffff00000000ffffffff00000000ffffffff00000000ffffffff16901b602082901c7bffffffff00000000ffffffff00000000ffffffff00000000ffffffff1617905060408177ffffffffffffffff0000000000000000ffffffffffffffff16901b604082901c77ffffffffffffffff0000000000000000ffffffffffffffff16179050608081901b608082901c179050919050565b109392505050565b600061173b8383016020015190565b600061173b8284611e48565b600082821115611b975760405162461bcd60e51b815260206004820152601d60248201527f556e646572666c6f7720647572696e67207375627472616374696f6e2e0000006044820152606401610444565b61173b8284611ec4565b600082600003611bb357506000610384565b611bbd8284611ed7565b905081611bca8483611e48565b146103845760405162461bcd60e51b815260206004820152601f60248201527f4f766572666c6f7720647572696e67206d756c7469706c69636174696f6e2e006044820152606401610444565b600061173b611c27836004611f28565b84016020015190565b600060208284031215611c4257600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b600060208284031215611c7157600080fd5b813567ffffffffffffffff80821115611c8957600080fd5b818401915084601f830112611c9d57600080fd5b813581811115611caf57611caf611c49565b604051601f8201601f19908116603f01168101908382118183101715611cd757611cd7611c49565b81604052828152876020848701011115611cf057600080fd5b826020860160208301376000928101602001929092525095945050505050565b803567ffffffffffffffff81168114611d2857600080fd5b919050565b600060208284031215611d3f57600080fd5b61173b82611d10565b600060208284031215611d5a57600080fd5b81356001600160a01b038116811461173b57600080fd5b60008060008060608587031215611d8757600080fd5b843567ffffffffffffffff80821115611d9f57600080fd5b818701915087601f830112611db357600080fd5b813581811115611dc257600080fd5b886020828501011115611dd457600080fd5b602092830196509450508501359150611def60408601611d10565b905092959194509250565b600060208284031215611e0c57600080fd5b8135801515811461173b57600080fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600082611e5757611e57611e1c565b500490565b67ffffffffffffffff818116838216028082169190828114611e8057611e80611e32565b505092915050565b67ffffffffffffffff818116838216019080821115611ea957611ea9611e32565b5092915050565b600082611ebf57611ebf611e1c565b500690565b8181038181111561038457610384611e32565b808202811582820484141761038457610384611e32565b600060018201611f0057611f00611e32565b5060010190565b67ffffffffffffffff828116828216039080821115611ea957611ea9611e32565b8082018082111561038457610384611e32565b634e487b7160e01b600052603260045260246000fd5b60ff828116828216039081111561038457610384611e32565b600181815b80851115611fa5578160001904821115611f8b57611f8b611e32565b80851615611f9857918102915b93841c9390800290611f6f565b509250929050565b600082611fbc57506001610384565b81611fc957506000610384565b8160018114611fdf5760028114611fe957612005565b6001915050610384565b60ff841115611ffa57611ffa611e32565b50506001821b610384565b5060208310610133831016604e8410600b8410161715612028575081810a610384565b6120328383611f6a565b806000190482111561204657612046611e32565b029392505050565b600061173b8383611fad56fea26469706673582212206679d3b0bc8016a8c7553e93c862ce838632e31c0ba6405d8c7af33c9ebc986464736f6c63430008110033",
|
|
474
474
|
"devdoc": {
|
|
475
475
|
"details": "THE RELAY MUST NOT BE USED BEFORE GENESIS AND AT LEAST ONE RETARGET.",
|
|
476
476
|
"kind": "dev",
|
|
@@ -612,7 +612,7 @@
|
|
|
612
612
|
"storageLayout": {
|
|
613
613
|
"storage": [
|
|
614
614
|
{
|
|
615
|
-
"astId":
|
|
615
|
+
"astId": 17669,
|
|
616
616
|
"contract": "contracts/relay/LightRelay.sol:LightRelay",
|
|
617
617
|
"label": "_owner",
|
|
618
618
|
"offset": 0,
|
|
@@ -620,7 +620,7 @@
|
|
|
620
620
|
"type": "t_address"
|
|
621
621
|
},
|
|
622
622
|
{
|
|
623
|
-
"astId":
|
|
623
|
+
"astId": 43301,
|
|
624
624
|
"contract": "contracts/relay/LightRelay.sol:LightRelay",
|
|
625
625
|
"label": "ready",
|
|
626
626
|
"offset": 20,
|
|
@@ -628,7 +628,7 @@
|
|
|
628
628
|
"type": "t_bool"
|
|
629
629
|
},
|
|
630
630
|
{
|
|
631
|
-
"astId":
|
|
631
|
+
"astId": 43303,
|
|
632
632
|
"contract": "contracts/relay/LightRelay.sol:LightRelay",
|
|
633
633
|
"label": "authorizationRequired",
|
|
634
634
|
"offset": 21,
|
|
@@ -636,7 +636,7 @@
|
|
|
636
636
|
"type": "t_bool"
|
|
637
637
|
},
|
|
638
638
|
{
|
|
639
|
-
"astId":
|
|
639
|
+
"astId": 43305,
|
|
640
640
|
"contract": "contracts/relay/LightRelay.sol:LightRelay",
|
|
641
641
|
"label": "proofLength",
|
|
642
642
|
"offset": 22,
|
|
@@ -644,7 +644,7 @@
|
|
|
644
644
|
"type": "t_uint64"
|
|
645
645
|
},
|
|
646
646
|
{
|
|
647
|
-
"astId":
|
|
647
|
+
"astId": 43307,
|
|
648
648
|
"contract": "contracts/relay/LightRelay.sol:LightRelay",
|
|
649
649
|
"label": "genesisEpoch",
|
|
650
650
|
"offset": 0,
|
|
@@ -652,7 +652,7 @@
|
|
|
652
652
|
"type": "t_uint64"
|
|
653
653
|
},
|
|
654
654
|
{
|
|
655
|
-
"astId":
|
|
655
|
+
"astId": 43309,
|
|
656
656
|
"contract": "contracts/relay/LightRelay.sol:LightRelay",
|
|
657
657
|
"label": "currentEpoch",
|
|
658
658
|
"offset": 8,
|
|
@@ -660,7 +660,7 @@
|
|
|
660
660
|
"type": "t_uint64"
|
|
661
661
|
},
|
|
662
662
|
{
|
|
663
|
-
"astId":
|
|
663
|
+
"astId": 43311,
|
|
664
664
|
"contract": "contracts/relay/LightRelay.sol:LightRelay",
|
|
665
665
|
"label": "currentEpochDifficulty",
|
|
666
666
|
"offset": 0,
|
|
@@ -668,7 +668,7 @@
|
|
|
668
668
|
"type": "t_uint256"
|
|
669
669
|
},
|
|
670
670
|
{
|
|
671
|
-
"astId":
|
|
671
|
+
"astId": 43313,
|
|
672
672
|
"contract": "contracts/relay/LightRelay.sol:LightRelay",
|
|
673
673
|
"label": "prevEpochDifficulty",
|
|
674
674
|
"offset": 0,
|
|
@@ -676,15 +676,15 @@
|
|
|
676
676
|
"type": "t_uint256"
|
|
677
677
|
},
|
|
678
678
|
{
|
|
679
|
-
"astId":
|
|
679
|
+
"astId": 43318,
|
|
680
680
|
"contract": "contracts/relay/LightRelay.sol:LightRelay",
|
|
681
681
|
"label": "epochs",
|
|
682
682
|
"offset": 0,
|
|
683
683
|
"slot": "4",
|
|
684
|
-
"type": "t_mapping(t_uint256,t_struct(Epoch)
|
|
684
|
+
"type": "t_mapping(t_uint256,t_struct(Epoch)43190_storage)"
|
|
685
685
|
},
|
|
686
686
|
{
|
|
687
|
-
"astId":
|
|
687
|
+
"astId": 43322,
|
|
688
688
|
"contract": "contracts/relay/LightRelay.sol:LightRelay",
|
|
689
689
|
"label": "isAuthorized",
|
|
690
690
|
"offset": 0,
|
|
@@ -710,19 +710,19 @@
|
|
|
710
710
|
"numberOfBytes": "32",
|
|
711
711
|
"value": "t_bool"
|
|
712
712
|
},
|
|
713
|
-
"t_mapping(t_uint256,t_struct(Epoch)
|
|
713
|
+
"t_mapping(t_uint256,t_struct(Epoch)43190_storage)": {
|
|
714
714
|
"encoding": "mapping",
|
|
715
715
|
"key": "t_uint256",
|
|
716
716
|
"label": "mapping(uint256 => struct Epoch)",
|
|
717
717
|
"numberOfBytes": "32",
|
|
718
|
-
"value": "t_struct(Epoch)
|
|
718
|
+
"value": "t_struct(Epoch)43190_storage"
|
|
719
719
|
},
|
|
720
|
-
"t_struct(Epoch)
|
|
720
|
+
"t_struct(Epoch)43190_storage": {
|
|
721
721
|
"encoding": "inplace",
|
|
722
722
|
"label": "struct Epoch",
|
|
723
723
|
"members": [
|
|
724
724
|
{
|
|
725
|
-
"astId":
|
|
725
|
+
"astId": 43187,
|
|
726
726
|
"contract": "contracts/relay/LightRelay.sol:LightRelay",
|
|
727
727
|
"label": "timestamp",
|
|
728
728
|
"offset": 0,
|
|
@@ -730,7 +730,7 @@
|
|
|
730
730
|
"type": "t_uint32"
|
|
731
731
|
},
|
|
732
732
|
{
|
|
733
|
-
"astId":
|
|
733
|
+
"astId": 43189,
|
|
734
734
|
"contract": "contracts/relay/LightRelay.sol:LightRelay",
|
|
735
735
|
"label": "target",
|
|
736
736
|
"offset": 4,
|