Skip to content

Add get_note_script() method to DataStore #1972

@bobbinth

Description

@bobbinth

To enable building of public output notes in the network transaction builder, we need to add get_note_script() method do the data store (for more info see #1748). This method could look like so:

pub trait DataStore: MastForestStore {
    fn get_note_script(
        &self,
        script_root: Word,
    ) -> impl FutureMaybeSend<Result<NoteScript, DataStoreError>>;
}

This method will try to find a note script with the specified root in the data store, and if not found, return an error (e.g., DataStoreError::NoteScriptNotFound).

This method will be used in the TransactionHost::on_note_after_created(). Specifically, we'd probably need to refactor how it works with the OutputNoteBuilder because the sequence would need to be:

  1. Read note parameters from the stack.
  2. Try to look up the RECIPIENT in the advice map. If found, extract SCRIPT_ROOT from it.
  3. Try to get the script associated with the SCRIPT_ROOT from the data store.
  4. Build the output note and add it to the set of output notes tracked by the host.

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions