Skip to content

feat: add redeem broadcast and confirmation flow#280

Merged
sczembor merged 32 commits intomasterfrom
stan/broadcast-redeems
Jan 14, 2026
Merged

feat: add redeem broadcast and confirmation flow#280
sczembor merged 32 commits intomasterfrom
stan/broadcast-redeems

Conversation

@sczembor
Copy link
Contributor

@sczembor sczembor commented Jan 8, 2026

Description

Closes: #229


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • added appropriate labels to the PR
  • provided a link to the relevant issue or specification
  • added a changelog entry to CHANGELOG.md
  • included doc comments for public functions
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary

Summary by Sourcery

Automate nBTC redeem broadcasting and confirmation tracking across Bitcoin and Sui indexers, and expose redeem status via new APIs.

New Features:

  • Add support for broadcasting signed nBTC redeem Bitcoin transactions via Electrs from the redeem solver through the btcindexer RPC.
  • Introduce confirmation tracking for broadcasted redeem transactions by linking Bitcoin blocks to redeem requests.
  • Expose redeem requests and their confirmation status via new HTTP and RPC endpoints, including lookup by Sui address.

Enhancements:

  • Simplify and harden redeem input storage and verification flow, including marking inputs as verified from Sui SignatureRecorded events.
  • Extend Sui client and storage layers to fetch raw signed Bitcoin redeem transactions from Sui and to select ready-to-broadcast redeems based on verified inputs.
  • Update worker configurations, shared models, and generated Cloudflare types to support the new redeem broadcasting pipeline.

Signed-off-by: sczembor <stanislaw.czembor@gmail.com>
@sczembor sczembor requested a review from a team as a code owner January 8, 2026 16:01
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Jan 8, 2026

Reviewer's Guide

Implements the end-to-end Bitcoin redeem lifecycle across the indexer, Sui indexer, and redeem_solver, including broadcasting signed redeem transactions via Electrs/BTC indexer RPC, tracking confirmation in blocks, and exposing redeem data over storage, RPC, and HTTP APIs while wiring the redeem solver to the BTC indexer service.

Sequence diagram for broadcasting ready Bitcoin redeem transactions

sequenceDiagram
    actor Scheduler
    participant RedeemService
    participant RedeemStorage as D1Storage
    participant SuiClient as SuiClientImp
    participant BtcIndexer as BtcIndexerRpc
    participant Indexer as BtcIndexer.Indexer
    participant Electrs as ElectrsService
    participant BtcStorage as CFStorage

    Scheduler->>RedeemService: scheduled()
    RedeemService->>RedeemStorage: getSignedRedeems()
    RedeemStorage-->>RedeemService: list of RedeemRequest (status = solved, all inputs verified)
    loop for each redeem
        RedeemService->>RedeemService: broadcastRedeem(redeem)
        RedeemService->>SuiClient: getRedeemBtcTx(redeem_id, nbtc_pkg, nbtc_contract)
        SuiClient->>SuiClient: devInspectTransactionBlock(build redeem_request/raw_signed_tx)
        SuiClient-->>RedeemService: rawTxHex
        RedeemService->>BtcIndexer: broadcastRedeemTx(rawTxHex, btcNetwork, redeem_id)
        BtcIndexer->>Indexer: broadcastRedeemTx(rawTxHex, btcNetwork, redeem_id)
        Indexer->>Electrs: broadcastTx(rawTxHex)
        Electrs-->>Indexer: Response(ok, txId or error)
        alt broadcast ok
            Indexer->>BtcStorage: updateRedeemStatusToBroadcasted(redeem_id, txId)
            BtcStorage-->>Indexer: ok
            Indexer-->>BtcIndexer: { tx_id: txId }
            BtcIndexer-->>RedeemService: { tx_id: txId }
            RedeemService->>RedeemService: log success
        else broadcast failed
            Indexer-->>BtcIndexer: throw Error
            BtcIndexer-->>RedeemService: Error
            RedeemService->>RedeemService: logError(method broadcastRedeem)
        end
    end
Loading

Sequence diagram for confirming broadcasted redeems in new Bitcoin blocks

sequenceDiagram
    participant BlockIngestor as BlockIngestor
    participant Indexer as BtcIndexer.Indexer
    participant Electrs as ElectrsService
    participant BtcStorage as CFStorage

    BlockIngestor->>Indexer: insertBlock(blockInfo)
    Indexer->>Indexer: iterate block.transactions
    loop for each tx in block.transactions
        Indexer->>Indexer: process deposits (findNbtcDeposits)
        Indexer->>Indexer: collect tx.getId() into txIds[]
    end
    alt there are txIds
        Indexer->>BtcStorage: confirmRedeemsInBlock(txIds, blockInfo.height, blockInfo.hash)
        BtcStorage->>BtcStorage: UPDATE nbtc_redeem_requests
        BtcStorage-->>Indexer: ok
    end
    alt there are nbtcTxs
        Indexer->>BtcStorage: insertOrUpdateNbtcTxs(nbtcTxs)
        BtcStorage-->>Indexer: ok
    end
Loading

Sequence diagram for Sui indexer marking redeem inputs verified

sequenceDiagram
    participant SuiChain as SuiChain
    participant SuiIndexer as SuiIndexer.Handler
    participant SuiStorage as IndexerStorage

    SuiChain-->>SuiIndexer: stream of SuiEventNode
    loop for each SuiEventNode
        SuiIndexer->>SuiIndexer: handleEvents(events)
        alt SolvedEvent
            SuiIndexer->>SuiStorage: upsertRedeemInputs(redeem_id, utxo_ids, dwallet_ids)
            SuiStorage-->>SuiIndexer: ok
        else SignatureRecordedEvent
            SuiIndexer->>SuiStorage: markRedeemInputVerified(redeem_id, utxo_id)
            SuiStorage-->>SuiIndexer: ok
        end
    end

    note over SuiStorage: Redeem is considered fully signed when
    note over SuiStorage: all rows in nbtc_redeem_solutions for redeem_id
    note over SuiStorage: have verified = 1
Loading

ER diagram for updated redeem-related BTC indexer tables

erDiagram
    setups {
        int id PK
        string btc_network
        string nbtc_pkg
        string nbtc_contract
    }

    nbtc_redeem_requests {
        int redeem_id PK
        int setup_id FK
        string redeemer
        int amount_sats
        string sui_tx
        string btc_tx
        string status
        int created_at
        int btc_block_height
        string btc_block_hash
        int btc_broadcasted_at
    }

    nbtc_redeem_solutions {
        int redeem_id FK
        int utxo_id
        int input_index
        string dwallet_id
        int created_at
        int verified
    }

    setups ||--o{ nbtc_redeem_requests : has
    nbtc_redeem_requests ||--o{ nbtc_redeem_solutions : has
Loading

Class diagram for redeem lifecycle services and storage

classDiagram
    class RedeemService {
        -Storage storage
        -Map~SuiNet, SuiClient~ clients
        -Service btcIndexer
        -number utxoLockTimeMs
        -number redeemDurationMs
        +constructor(storage, clients, btcIndexer, utxoLockTimeMs, redeemDurationMs)
        +processPendingRedeems()
        +solveReadyRedeems()
        +processSolvedRedeems()
        +broadcastReadyRedeems()
        -broadcastRedeem(req RedeemRequest)
        -getSuiClient(net SuiNet) SuiClient
    }

    class SuiClient {
        <<interface>>
        +proposeRedeemUtxos(args ProposeRedeemCall) Promise~string~
        +getRedeemBtcTx(redeemId number, nbtcPkg string, nbtcContract string) Promise~string~
    }

    class SuiClientImp {
        +getRedeemBtcTx(redeemId number, nbtcPkg string, nbtcContract string) Promise~string~
    }
    SuiClient <|.. SuiClientImp

    class BtcIndexerRpcI {
        <<interface>>
        +latestHeight(network BtcNet) Promise~object~
        +putNbtcTx(txHex string, network BtcNet) Promise~PutNbtcTxResponse~
        +broadcastRedeemTx(txHex string, network BtcNet, redeemId number) Promise~object~
        +nbtcMintTx(txid string) Promise~NbtcTxResp~
        +nbtcMintTxsBySuiAddr(suiAddress string) Promise~NbtcTxResp[]~
        +depositsBySender(address string, network BtcNet) Promise~NbtcTxResp[]~
    }

    class BtcIndexerRpc {
        +latestHeight(network BtcNet) Promise~object~
        +putNbtcTx(txHex string, network BtcNet) Promise~PutNbtcTxResponse~
        +broadcastRedeemTx(txHex string, network BtcNet, redeemId number) Promise~object~
        +nbtcMintTx(txid string) Promise~NbtcTxResp~
        +nbtcMintTxsBySuiAddr(suiAddress string) Promise~NbtcTxResp[]~
        +depositsBySender(address string, network BtcNet) Promise~NbtcTxResp[]~
        -getIndexer() Promise~Indexer~
    }
    BtcIndexerRpcI <|.. BtcIndexerRpc

    class Indexer {
        -Storage storage
        -Electrs getElectrsClient(network BtcNet) Electrs
        +insertBlock(blockInfo BlockInfo) Promise~InsertBlockResult~
        +registerBroadcastedNbtcTx(txHex string, network BtcNet) Promise~PutNbtcTxResponse~
        +broadcastRedeemTx(txHex string, network BtcNet, redeemId number) Promise~object~
        +getLatestHeight(network BtcNet) Promise~object~
        +getRedeemsBySuiAddr(suiAddress string, network BtcNet) Promise~NbtcRedeemRow[]~
    }

    class Electrs {
        <<interface>>
        +getTx(txId string) Promise~Response~
        +broadcastTx(txHex string) Promise~Response~
    }

    class ElectrsService {
        -string baseUrl
        +getTx(txId string) Promise~Response~
        +broadcastTx(txHex string) Promise~Response~
    }
    Electrs <|.. ElectrsService

    class Storage {
        <<interface>>
        +updateRedeemStatusToBroadcasted(redeemId number, txId string) Promise~void~
        +confirmRedeemsInBlock(txIds string[], blockHeight number, blockHash string) Promise~void~
        +getNbtcRedeemsBySuiAddr(suiAddress string, network BtcNet) Promise~NbtcRedeemRow[]~
    }

    class CFStorage {
        +updateRedeemStatusToBroadcasted(redeemId number, txId string) Promise~void~
        +confirmRedeemsInBlock(txIds string[], blockHeight number, blockHash string) Promise~void~
        +getNbtcRedeemsBySuiAddr(suiAddress string, network BtcNet) Promise~NbtcRedeemRow[]~
    }
    Storage <|.. CFStorage

    class RedeemRequest {
        int redeem_id
        int setup_id
        string redeemer
        Uint8Array recipient_script
        int amount_sats
        string status
        int created_at
        string nbtc_pkg
        string nbtc_contract
        SuiNet sui_network
    }

    class RedeemRequestWithNetwork {
        int redeem_id
        string btc_network
    }

    RedeemService --> SuiClient : uses
    RedeemService --> BtcIndexerRpcI : calls via Service
    RedeemService --> Storage : uses
    BtcIndexerRpc --> Indexer : delegates
    Indexer --> Storage : uses
    Indexer --> Electrs : uses
    SuiClientImp --> RedeemRequest : builds Move calls
Loading

File-Level Changes

Change Details Files
Extend BTC indexer to track and confirm redeem transactions and expose them via storage, RPC, and HTTP APIs.
  • Collect transaction IDs while indexing blocks and confirm broadcasted redeems when their txids appear in new blocks.
  • Add Electrs broadcast support and a broadcastRedeemTx method on the Indexer and RPC layer that updates redeem status to 'broadcasted'.
  • Introduce storage methods to update redeem status to broadcasted, confirm redeems found in blocks, and query redeems by Sui address, plus the NbtcRedeemRow model.
  • Expose redeems by Sui address via a new /redeems/:address HTTP route and REST path, including confirmation count calculation in the Indexer.
packages/btcindexer/src/btcindexer.ts
packages/btcindexer/src/cf-storage.ts
packages/btcindexer/src/router.ts
packages/btcindexer/src/rpc.ts
packages/btcindexer/src/models.ts
packages/btcindexer/src/api/client.ts
packages/btcindexer/src/storage.ts
packages/btcindexer/src/electrs.ts
packages/btcindexer/src/electrs.test.ts
packages/btcindexer/src/rpc-interface.ts
packages/btcindexer/db/migrations/0001_initial_schema.sql
Extend redeem_solver to obtain raw signed Bitcoin redeem transactions from Sui, select fully verified redeems, and broadcast them through the BTC indexer service on its scheduled job.
  • Inject a BTC indexer RPC Service into RedeemService and worker entrypoint, and call broadcastRedeemTx for ready redeems.
  • Add Sui client support to dev-inspect the nbtc contract and fetch the raw signed Bitcoin redeem transaction hex for a redeem_id.
  • Add D1Storage query for 'signed' redeems whose inputs are all verified and use it in a new broadcastReadyRedeems workflow in the scheduled handler.
  • Wire the BTC indexer package as a workspace dependency of redeem_solver and declare the BTCINDEXER binding in wrangler types.
packages/redeem_solver/src/service.ts
packages/redeem_solver/src/sui_client.ts
packages/redeem_solver/src/storage.ts
packages/redeem_solver/src/index.ts
packages/redeem_solver/package.json
packages/redeem_solver/wrangler.jsonc
packages/redeem_solver/worker-configuration.d.ts
Enhance Sui indexer storage and event handling to track redeem input verification and support selecting fully signed redeems.
  • Simplify upsertRedeemInputs to a pure batch insert with a verified field defaulting to 0 and add a markRedeemInputVerified method.
  • Handle SignatureRecordedEvent from Sui, updating redeem solutions as verified and logging the change.
  • Extend redeem-related enums and raw event models to include a Confirmed status and SignatureRecordedEvent shape.
packages/sui-indexer/src/storage.ts
packages/sui-indexer/src/handler.ts
packages/sui-indexer/src/models.ts
Adjust BTC indexer mock and Cloudflare worker type declarations to match the new redeem flow and updated platform/AI APIs.
  • Simplify BtcIndexerRpcMock to just accept putNbtcTx and broadcastRedeemTx without doing Sui recipient parsing or mint status tracking, and make nbtcMintTx return null.
  • Refresh block-ingestor and redeem_solver worker-configuration.d.ts and Cloudflare AI-related types to the latest generated forms, including new model and utility types and removed/renamed ones.
packages/btcindexer/src/rpc-mock.ts
packages/block-ingestor/worker-configuration.d.ts
packages/redeem_solver/worker-configuration.d.ts

Possibly linked issues

  • #0: The PR implements redeem broadcasting, confirmation tracking, and related storage/APIs that fulfill the nBTC redeem confirmation issue.
  • #XXXX: PR updates nbtc_redeem_requests schema and exposes sui/btc tx plus confirmation counts, matching the redeem model issue
  • #Worker: redeem-resolver: obtain the raw btc tx and brodcast it to bitcoin network: They match: redeem worker now fetches raw BTC tx from Sui, broadcasts via indexer, tracks confirmations, and exposes redeem-status API.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sczembor
Copy link
Contributor Author

sczembor commented Jan 8, 2026

@sourcery-ai title

@sourcery-ai sourcery-ai bot changed the title draft feat: add redeem broadcast and confirmation flow Jan 8, 2026
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

  • In sui-indexer IndexerStorage.upsertRedeemInputs you removed the length mismatch check and error handling; consider keeping a guard (or at least an assertion) when utxoIds.length !== dwalletIds.length so bad input doesn’t silently insert inconsistent rows.
  • In RedeemService.broadcastRedeem you rely on // @ts-expect-error and a default btc_network of regtest; it would be more robust to extend the RedeemRequest/row type to include btc_network explicitly and avoid the type suppression and implicit defaulting.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `sui-indexer` `IndexerStorage.upsertRedeemInputs` you removed the length mismatch check and error handling; consider keeping a guard (or at least an assertion) when `utxoIds.length !== dwalletIds.length` so bad input doesn’t silently insert inconsistent rows.
- In `RedeemService.broadcastRedeem` you rely on `// @ts-expect-error` and a default `btc_network` of `regtest`; it would be more robust to extend the `RedeemRequest`/row type to include `btc_network` explicitly and avoid the type suppression and implicit defaulting.

## Individual Comments

### Comment 1
<location> `packages/sui-indexer/src/storage.ts:192-201` </location>
<code_context>
+	upsertRedeemInputs(redeemId: number, utxoIds: number[], dwalletIds: string[]): Promise<void> {
</code_context>

<issue_to_address>
**issue (bug_risk):** Reintroduced upsertRedeemInputs without length validation or error logging, which can now silently bind undefined values.

The previous version validated `utxoIds.length === dwalletIds.length` and logged structured errors on batch failure. The new version removes both the guard and error handling, so mismatched lengths can bind `dwalletIds[i]` as `undefined`, and D1 failures are dropped by the `.then()` chain. Please reintroduce input validation and either return `this.db.batch(batch)` directly or add a `.catch` that calls `logError` so failures are visible.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

sczembor and others added 5 commits January 8, 2026 17:07
Signed-off-by: sczembor <43810037+sczembor@users.noreply.github.com>
Signed-off-by: sczembor <stanislaw.czembor@gmail.com>
Signed-off-by: sczembor <stanislaw.czembor@gmail.com>
Signed-off-by: sczembor <stanislaw.czembor@gmail.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements a comprehensive redeem broadcast and confirmation flow for nBTC, enabling automated broadcasting of signed Bitcoin redemption transactions and tracking their confirmation status across the Bitcoin blockchain.

Key Changes:

  • Adds broadcasting pipeline for signed nBTC redeem transactions via Electrs in btcindexer
  • Implements confirmation tracking by matching Bitcoin block transactions to redeem requests
  • Introduces new HTTP and RPC endpoints to query redeem status by Sui address

Reviewed changes

Copilot reviewed 21 out of 24 changed files in this pull request and generated 15 comments.

Show a summary per file
File Description
packages/sui-indexer/src/storage.ts Refactored upsertRedeemInputs to use promise chaining and added markRedeemInputVerified method for tracking verified inputs
packages/sui-indexer/src/models.ts Added Confirmed status enum value and SignatureRecordedEventRaw interface
packages/sui-indexer/src/handler.ts Added event handler for SignatureRecordedEvent to mark inputs as verified
packages/redeem_solver/wrangler.jsonc Added service binding to btcindexer worker
packages/redeem_solver/worker-configuration.d.ts Auto-generated types updated with BTCINDEXER service binding
packages/redeem_solver/src/sui_client.ts Added getRedeemBtcTx method to fetch raw signed Bitcoin transaction from Sui
packages/redeem_solver/src/storage.ts Added getSignedRedeems query to select fully verified redeems ready for broadcast
packages/redeem_solver/src/service.ts Implemented broadcastReadyRedeems and broadcastRedeem methods for transaction broadcasting
packages/redeem_solver/src/index.ts Integrated broadcast task into scheduler with improved error logging
packages/redeem_solver/package.json Added btcindexer workspace dependency
packages/btcindexer/src/storage.ts Added interface methods for redeem status updates and confirmation tracking
packages/btcindexer/src/cf-storage.ts Implemented database operations for redeem broadcasting and confirmation
packages/btcindexer/src/btcindexer.ts Added broadcastRedeemTx and getRedeemsBySuiAddr methods with confirmation calculation
packages/btcindexer/src/rpc.ts Exposed broadcastRedeemTx RPC method with documentation
packages/btcindexer/src/rpc-interface.ts Added broadcastRedeemTx to RPC interface
packages/btcindexer/src/rpc-mock.ts Simplified mock implementation and added broadcastRedeemTx stub
packages/btcindexer/src/router.ts Added /redeems/:address HTTP endpoint for querying redeems by Sui address
packages/btcindexer/src/models.ts Added NbtcRedeemRow and NbtcRedeemResp types for redeem data structures
packages/btcindexer/src/electrs.ts Added broadcastTx method for submitting transactions to Bitcoin network
packages/btcindexer/src/electrs.test.ts Updated mock to include broadcastTx method
packages/btcindexer/src/api/client.ts Added redeems REST path constant
packages/btcindexer/db/migrations/0001_initial_schema.sql Added columns for Bitcoin transaction tracking and confirmation
packages/block-ingestor/worker-configuration.d.ts Auto-generated runtime type updates (unrelated to PR changes)
bun.lock Updated lockfile with new dependency resolution

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

sczembor and others added 3 commits January 9, 2026 10:56
Signed-off-by: sczembor <stanislaw.czembor@gmail.com>
Signed-off-by: sczembor <stanislaw.czembor@gmail.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 27 out of 30 changed files in this pull request and generated 10 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

sczembor and others added 8 commits January 9, 2026 18:31
Signed-off-by: sczembor <43810037+sczembor@users.noreply.github.com>
Signed-off-by: sczembor <stanislaw.czembor@gmail.com>
Signed-off-by: sczembor <stanislaw.czembor@gmail.com>
Signed-off-by: sczembor <stanislaw.czembor@gmail.com>
Signed-off-by: sczembor <stanislaw.czembor@gmail.com>
sczembor and others added 5 commits January 13, 2026 11:51
Signed-off-by: sczembor <stanislaw.czembor@gmail.com>
Signed-off-by: sczembor <stanislaw.czembor@gmail.com>
Signed-off-by: sczembor <stanislaw.czembor@gmail.com>
Signed-off-by: sczembor <stanislaw.czembor@gmail.com>
Signed-off-by: sczembor <stanislaw.czembor@gmail.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 30 out of 33 changed files in this pull request and generated 7 comments.

Comments suppressed due to low confidence (1)

packages/redeem_solver/src/rpc.ts:30

  • The removed RPC method redeemsBySuiAddr has been replaced with an HTTP endpoint, but the interface change is breaking. Any existing callers using the RPC service binding to fetch redeems will fail at runtime. Consider adding a deprecation notice or migration guide, or maintaining backward compatibility with a wrapper that calls the new HTTP endpoint.
export interface RedeemSolverRpc {
	finalizeRedeem: () => Promise<void>;
	putRedeemTx: (setupId: number, suiTxId: string, e: RedeemRequestEventRaw) => Promise<void>;
}

/**
 * RPC entrypoint for the worker.
 *
 * @see https://developers.cloudflare.com/workers/runtime-apis/bindings/service-bindings/rpc/
 */
export class RPC extends WorkerEntrypoint<Env> implements RedeemSolverRpc {
	/**
	 * Once BTC withdraw for the Redeem Request is confirmed and finalzed, this method
	 * will update the DB state and remove related UTXOs.
	 */
	async finalizeRedeem(): Promise<void> {
		return;
	}

	/**
	 * Stores a redeem request transaction emitted on Sui into the indexer storage, to be later
	 * tracked by the indexer to trigger solution (UTXOs) proposal in this worker scheduler.
	 *

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@robert-zaremba robert-zaremba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • let's move the not related api away from btcindexer

sczembor and others added 4 commits January 13, 2026 15:21
Signed-off-by: sczembor <stanislaw.czembor@gmail.com>
Signed-off-by: sczembor <43810037+sczembor@users.noreply.github.com>
Signed-off-by: sczembor <stanislaw.czembor@gmail.com>
Signed-off-by: sczembor <stanislaw.czembor@gmail.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 29 out of 32 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

sczembor and others added 4 commits January 14, 2026 10:30
Signed-off-by: sczembor <stanislaw.czembor@gmail.com>
Signed-off-by: sczembor <43810037+sczembor@users.noreply.github.com>
Signed-off-by: sczembor <stanislaw.czembor@gmail.com>
Signed-off-by: sczembor <stanislaw.czembor@gmail.com>
@sczembor sczembor merged commit 11dba0f into master Jan 14, 2026
12 checks passed
@sczembor sczembor deleted the stan/broadcast-redeems branch January 14, 2026 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Worker: redeem-resolver: obtain the raw btc tx and brodcast it to bitcoin network

3 participants