whisky
Github
  • whisky
  • WASM - whisky-js
  • Tx Builder
    • Getting Started
      • Lock Fund
      • Unlock Fund
      • Mint Tokens
      • Delegate Stake
      • Complex Transaction
    • Service Integration
  • Tx Parser
    • Parse Transaction CBOR
    • Unit Testing Transaction
    • Rebuilding Transaction
  • Services
    • Providers
      • Fetcher
      • Evaluator
      • Submitter
Powered by GitBook
On this page
  1. Tx Parser

Rebuilding Transaction

Rebuilding a transaction starts from obtaining the TxBuilderBody , which can be obtained by either of the methods from TxParser:

  • get_builder_body - get the entire TxBuilderBody of the current transaction parsed

  • get_builder_body_without_change - get the TxBuilderBody without the last output

    • This is the recommended method for rebuilding the transaction since the complete method of TxBuilder would re-calculate the change as per the manipulation. Thus, the rebuilt transaction will be in an expected shape without one extra output.

Full Example

// let body = tx_parser.get_builder_body();
let body = tx_parser.get_builder_body_without_change();

let mut new_tx_builder = TxBuilder::new_core();

// manipulation of the `tx_builder_body` as needed here
new_tx_builder.tx_builder_body = body.clone();

new_tx_builder
    // extra tx building methods as needed here
    .complete_sync(None)
    .unwrap();
PreviousUnit Testing TransactionNextProviders

Last updated 11 days ago