Skip to content

wollet, wasm, bindings: expose output secrets of built tx - #195

Draft
bitwalt wants to merge 1 commit into
Blockstream:masterfrom
kaleidoswap:wollet-built-tx-output-secrets
Draft

bitwalt wants to merge 1 commit into
Blockstream:masterfrom
kaleidoswap:wollet-built-tx-output-secrets

Conversation

@bitwalt

@bitwalt bitwalt commented Nov 5, 2026

Copy link
Copy Markdown

Fixes #177

TxBuilder::build() already returns a BuiltTx that keeps the blinding
factors computed by blind_last(), but only Update could use them.
This makes them readable per output:

  • lwk_wollet: add BuiltTx::output_secrets(), one
    Option<TxOutSecrets> per PSET output (None for the fee, explicit
    outputs and anything the wallet did not blind). The private
    unblinded() used by BuiltTx::update() is now derived from it.
  • lwk_wasm: add TxBuilder.build() and BuiltTx with pset() and
    outputSecrets(vout).
  • lwk_bindings: same for parity, TxBuilder::build() and
    BuiltTx::{pset, output_secrets}.

Why a new return type instead of PsetOutput.unblinded(): a PSET does
not carry the blinding factors (they are not serialized), so
PsetOutput cannot hold them, and finish() returns only the PSET.
build() is the existing API that returns more than a PSET, so no
existing signature changes.

The secrets only cover outputs blinded by this builder; a PSET blinded
elsewhere has to carry its own.

Test: unit test test_builttx_output_secrets (runs with
cargo test --lib) pins the mapping from blinding data to output index.
cargo test --lib -p lwk_wollet, clippy with -D warnings and
cargo fmt --check pass.

`TxBuilder::build()` returns a `BuiltTx` that keeps the blinding
factors computed by `blind_last()`, but they were only usable to build
an `Update`.

- wollet: add `BuiltTx::output_secrets()`, one `Option<TxOutSecrets>`
  per PSET output; `unblinded()` is now derived from it
- wasm: add `TxBuilder.build()` and `BuiltTx`
- bindings: add `TxBuilder::build()` and `BuiltTx` for parity

Fixes Blockstream#177

This branch has not been deployed

No deployments
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.

lwk_wasm: no way to read TxOutSecrets for a PSET output blinded by the wallet

1 participant