$ ./bitcoin-cli -testnet4 getblocktemplate '{"rules":["segwit"]}'
{
"capabilities": [
"proposal"
],
"version": 536870912,
"rules": [
"csv",
"!segwit",
"taproot"
],
"vbavailable": {
},
"vbrequired": 0,
"previousblockhash": "00000000e4638c4e530c074a2703024445b8f3786c2b54f0977e67958f90bfe5",
"transactions": [
{
"data": "02000000027ebb48a39075aaac83c831500dd7a16ff6801e65cc10b8a9df1708c7be99ea2f010000006a47304402201e5e09eca4236c171f40c536e1d3df9a5004386ce23d037405f46922c32eba4e0220346cb04655fbb64f2951691c78c077c7d482252023e9c330679749c15183bec90121035d3c761a498da64b60b19eca302ed3fc7de2cf387c43e28ff53eddfac751dd65fdffffff2aa29fa2fd6b1d97508e1fc4ecd6327c4265e3ecd9864a609e29db4fac70e0a6010000006a473044022042a8a8b5bd0ca68e28b8be39a196eef568a0f5871ad91acaa899b59d5f07251d0220217e86f84e845b491eda7022781f09efe4b3576f876af4c54e7679129146d0f101210265d606112603849e67670012a6a45b1f5d1e1860bbd52a3a0b5f3578f479c203fdffffff020ac203000000000017a9145ba02b1f091846fd46893b93ced478f1172cc63c8782b00b00000000001600145fa28881cb5b0764a6461a2dc849118143ee0d6548bd0000",
"txid": "24e2fa9f084af2814fb8fe7eb57424c3822f9065df0c58d2efcc6f670bf22e1a",
"hash": "24e2fa9f084af2814fb8fe7eb57424c3822f9065df0c58d2efcc6f670bf22e1a",
"depends": [
],
"fee": 5386,
"sigops": 0,
"weight": 1468
},
{
"data": "02000000000101eea5f8f694506a9068858d2494748bbcd04c205a1d23dcebf028e41e6a3158a20100000000fdffffff022b0b000000000000160014306a4705f4554444b40bc852663faa0d18c643264ce90000000000001600144685d4c4dc66311f7828cb859e87138035b955fe0247304402203ed33ec2f600e9ff7ef5c2d5b57d21519756f3415f4fcf59858a94ba211b3786022030a76a74c41105e6a73bf50ad19306b4b8413c27b806ee78a7754f43d6efe77201210359ee745c5dde9692df29ef98894b6d87485d49031e24f830a7a5475ff9ae874b00000000",
"txid": "b122f43a346be288bd2da4c470b798112b5ae5d5c5a090c375a5225917eef4de",
"hash": "f4be9b8a7bbeed83994886c8985682ae0a09e838f29b23a4b45041d22e84c2e4",
"depends": [
],
"fee": 141,
"sigops": 1,
"weight": 561
}
],
"coinbaseaux": {
},
"coinbasevalue": 5000000000,
"longpollid": "00000000e4638c4e530c074a2703024445b8f3786c2b54f0977e67958f90bfe5577",
"target": "00000000ffff0000000000000000000000000000000000000000000000000000",
"mintime": 1727952073,
"mutable": [
"time",
"transactions",
"prevblock"
],
"noncerange": "00000000ffffffff",
"sigoplimit": 80000,
"sizelimit": 4000000,
"weightlimit": 4000000,
"curtime": 1727958156,
"bits": "1d00ffff",
"height": 48457,
"default_witness_commitment": "6a24aa21a9ed5d6ff26aa2222eed24a58f76598eab0740a06f1a36325180bf2f5cc4b96a63d6"
}
So, as you can see above, getblocktemplate command can give you everything you need. Then, the rest of your configuration is hardware-specific. The simplest case is to extract 80-byte block header, pass it to bitcoin-util, and then pass it back. This is what you can do on just a CPU. If you can do that, then you can use the same trick with any external tool, because usually, it just grinds a given 80-byte header (optionally, in case of stratum, it may also require a coinbase transaction, to grind the extra nonce).