Skip to content

Enable building transaction from any given ScriptPubKey #159

@thunderbiscuit

Description

@thunderbiscuit

This feature is required to make the language bindings interop with LDK.

The LDK workflow is the following:

  1. LDK gives you an output script in raw bytes which you must use to build a ready-to-be-broadcast transaction (the funding transaction)
  2. You must give this tx in its raw form back to LDK, which will then broadcast it (potentially using BDK as well, see Provide a way to broadcast raw transaction for LDK compatibility #157)

I have recreated what is required in Rust in this small cli tool. Of this workflow, I believe only a few lines would be "new" APIs for the bindings, namely:

// 1. transform the LDK output script from raw bytes into a Script type using either one of:
// let script: Script = Script::from_hex(&output_script_hex).unwrap();
let script: Script = Script::from(output_script_raw);

// 2. extract the tx from the psbt
let funding_tx: Transaction = psbt.extract_tx();

// 3. serialize the tx to give it back to LDK
let funding_tx_encoded = funding_tx.serialize();

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions