BitcoinPod Overview
aka BOD
contract BitcoinPod is IBitcoinPod, OwnableUpgradeable {
address public operator;
bytes public operatorBtcPubKey;
bytes public bitcoinAddress;
uint256 public bitcoinBalance;
bool public locked;
address public immutable manager;
bytes public signedBitcoinWithdrawTransaction;function createPod(address operator, string memory btcAddress, bytes calldata scipt)
external
whenNotPaused
nonReentrant
returns (address)
{
require(_userToPod[msg.sender] == address(0), "User already has a pod");
require(IBitDSMRegistry(_bitDSMRegistry).isOperatorBtcKeyRegistered(operator), "Invalid operator");
bytes memory operatorBtcPubKey = IBitDSMRegistry(_bitDSMRegistry).getOperatorBtcPublicKey(operator);
// console.logBytes(operatorBtcPubKey);
// verify the btc address
// try catch block to handle the error
try IBitDSMServiceManager(_bitDSMServiceManager).verifyBTCAddress(btcAddress, scipt, operatorBtcPubKey) returns (bool isBtcAddress) {
console.log("isBtcAddress", isBtcAddress);
} catch (bytes memory reason) {
console.log("Error verifying BTC address");
console.logBytes(reason);
}
// console.log("isBtcAddress", isBtcAddress);
// emit BTCAddressVerified(operator, btcAddress);
// create the pod
BitcoinPod newPod = new BitcoinPod(address(this));
newPod.initialize(msg.sender, operator, operatorBtcPubKey, btcAddress);
// increment the total pods
_totalPods++;
// set the user to pod mapping
_setUserPod(msg.sender, address(newPod));
emit PodCreated(msg.sender, address(newPod), operator);
// return the pod address
return address(newPod);