Skip to content

Commit

Permalink
wip on payment workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Dec 2, 2023
1 parent 2d58939 commit 333057a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
27 changes: 20 additions & 7 deletions cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,11 @@ pub enum Command {
/// Fee
fee: Sats,

/// File for generated PSBT
psbt: PathBuf,

/// File for generated transfer consignment
consignment: PathBuf,

/// Name of PSBT file to save. If not given, prints PSBT to STDOUT
psbt: Option<PathBuf>,
},

/// Inspects any RGB data file
Expand Down Expand Up @@ -572,13 +572,26 @@ impl Exec for RgbArgs {
psbt: psbt_filename,
consignment: out_file,
} => {
// 1. BP Wallet: Do coin selection (using Layer2 components)
// 2. BP Wallet: Construct PSBT prototype (no state transitions)
// ... complete PSBT structure updates in multi-party protocols
// 3. RGB Std: Prepare stencil - main state transition and blank state
// transitions
// 4. RGB PSBT: Embed stencil into PSBT
// ... complete PSBT client-side updates in multi-party protocols
// 5. RGB PSBT: Anchorize PSBT, extract disclosure
// 6. RGB Std: Merge disclosure into the stash, cache and index
// 7. RGB Std: Prepare consignment

let mut runtime = self.rgb_runtime(&config)?;

// TODO: Support lock time and RBFs
let params = TxParams::with(*fee);

eprint!("Constructing PSBT ... ");
let mut psbt =
runtime
.wallet_mut()
.construct_psbt(coins, Invoice, TxParams::with(*fee))?;
let mut psbt = runtime
.wallet_mut()
.construct_psbt(coins, Invoice, params)?;
eprintln!("success");

eprint!("Constructing transfer consignment ... ");
Expand Down
5 changes: 3 additions & 2 deletions src/pay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,8 @@ impl Runtime {
}
};

// 3. Prepare and self-consume other transitions
// 3. Prepare other transitions
// Enumerate state
let mut contract_inputs = HashMap::<ContractId, Vec<Outpoint>>::new();
let mut spent_state = HashMap::<ContractId, BTreeMap<Opout, TypedState>>::new();
for outpoint in prev_outpoints {
Expand All @@ -215,7 +216,7 @@ impl Runtime {
.extend(self.state_for_outpoints(id, [outpoint])?);
}
}
// Construct blank transitions, self-consume them
// Construct blank transitions
let mut other_transitions = HashMap::with_capacity(spent_state.len());
for (id, opouts) in spent_state {
let mut blank_builder = self.blank_builder(id, iface.clone())?;
Expand Down

0 comments on commit 333057a

Please sign in to comment.