A modular system for validating and generating Bitcoin contract addresses with plugin support.
- 🧩 Plugin-based architecture for contract types
- 🔍 Automatic address generation from contract parameters
- 📦 Self-contained plugin system
npm install @unisat/bitcoin-address-verifier
# or
yarn add @unisat/bitcoin-address-verifier
import { verifyContract } from "./index";
const result = verifyContract("babylon:staking", {
stakerPk: "5092...",
covenantPks: ["5092...",],
finalityProviders: ["5092...",],
covenantThreshold: 1,
minUnbondingTime: 101,
stakingDuration: 144,
},{
address: "",
publicKey: ""
});
console.log(result);
// Use in PSBT signing
wallet.signPsbt(psbt, {
contracts: [{
id: 'babylon:staking',
params: { /* ... */ }
}]
});
- Run the generator:
yarn new:plugin
- Follow the interactive prompts
plugins/
└── your-project/
└── contract-name/
├── index.ts # Main implementation
└── plugin.test.ts # Test cases
// plugins/example/timelock/index.ts
export default {
id: 'example:timelock',
version: '1.0.0',
verify(params, account) {
// Implementation here
},
};
-
Fork the repository
-
Create a new branch (git checkout -b feature/your-plugin)
-
Commit your changes (git commit -am 'Add new plugin')
-
Push to the branch (git push origin feature/your-plugin)
-
Open a Pull Request
# Install dependencies
yarn
# Build project
yarn build
# Run tests
yarn test
bitcoin-contract-validator/
├── src/
│ ├── core-sdk/ # Core validation logic
│ ├── plugins/ # Plugin implementations
│ └── generated/ # Auto-generated registry
├── scripts/ # Generation scripts
└── test/ # Test cases