> For the complete documentation index, see [llms.txt](https://docs.stacks.co/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.stacks.co/reference/stacks.js/stacks-bitcoin-staking/proof/buildlockprooffromblock.md).

# buildLockProofFromBlock

Builds the [BondL1LockupOutput](/reference/stacks.js/stacks-bitcoin-staking/types/bondl1lockupoutput.md) for a lockup funding transaction from the block's ordered txid list, for callers without an Esplora `/merkle-proof` endpoint, such as those reading bitcoind directly. Computes the merkle branch, then calls [buildLockProof](/reference/stacks.js/stacks-bitcoin-staking/proof/buildlockproof.md). Pure computation: no network call.

***

### Usage

```ts
import { buildLockProofFromBlock } from '@stacks/bitcoin-staking';
import type { RegisterMetadata } from '@stacks/bitcoin-staking';

declare function rpc(method: string, params: unknown[]): Promise<any>; // your bitcoind RPC client
declare const txid: string; // funding transaction ID
declare const blockHash: string; // block that confirmed it
declare const meta: RegisterMetadata; // from buildRegisterMetadata

const block = await rpc('getblock', [blockHash, 1]);

const output = buildLockProofFromBlock({
  txHex: (await rpc('gettransaction', [txid, null, true])).hex,
  header: await rpc('getblockheader', [blockHash, false]),
  blockHeight: block.height,
  txids: block.tx,
  unlockHeight: meta.unlockHeight,
  lockScript: meta.lockScript,
});
```

#### Notes

* The transaction's position is found by hashing `txHex`, witness stripped, to its txid and looking it up in `txids`. Throws an `Error` whose message starts with `buildLockProofFromBlock: txid` if it is not there.
* `txCount` is `txids.length`. The merkle branch is computed from `txids` with standard Bitcoin construction: an odd row duplicates its last node.
* Output matching, witness stripping, the proof checks and their errors are those of [buildLockProof](/reference/stacks.js/stacks-bitcoin-staking/proof/buildlockproof.md).

[**Reference Link**](https://github.com/stx-labs/stacks.js/blob/6101c99efe5a9616ce7e16cef68e28fd10676e7e/packages/bitcoin-staking/src/proof.ts#L357-L436)

***

### Signature

```ts
function buildLockProofFromBlock(
  input: {
    txHex: string;
    header: Uint8Array | string;
    blockHeight: number;
    txids: string[];
    unlockHeight: IntegerType;
    outputIndex?: number;
  } & ExpectedScriptInput
): BondL1LockupOutput;
```

***

### Returns

`BondL1LockupOutput`

A [BondL1LockupOutput](/reference/stacks.js/stacks-bitcoin-staking/types/bondl1lockupoutput.md), as returned by [buildLockProof](/reference/stacks.js/stacks-bitcoin-staking/proof/buildlockproof.md).

***

### Parameters

#### input.txHex (required)

* **Type**: `string`

The raw funding transaction as hex. Segwit serialization is accepted.

#### input.header (required)

* **Type**: `Uint8Array | string`

The 80-byte header of the block that confirmed the transaction, as bytes or hex.

#### input.blockHeight (required)

* **Type**: `number`

The height of that block. pox-5 checks the header against the Bitcoin block at this height.

#### input.txids (required)

* **Type**: `string[]`

The block's txids in block order, as display-order (big-endian) hex: the `tx` array of `getblock` with verbosity 1.

#### input.unlockHeight (required)

* **Type**: `IntegerType`

The unlock height the lockup script commits to, the same value used to build it.

#### input.outputIndex (optional)

* **Type**: `number`

Which output to prove when the transaction pays the lockup script more than once. Omit when exactly one output matches.

#### input.outputScript or input.lockScript (required, exactly one)

* **Type**: `Uint8Array | string`

The P2WSH `scriptPubKey` or the witness script of the lockup. See [ExpectedScriptInput](/reference/stacks.js/stacks-bitcoin-staking/proof/expectedscriptinput.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.stacks.co/reference/stacks.js/stacks-bitcoin-staking/proof/buildlockprooffromblock.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
