Skip to content
This repository has been archived by the owner on Dec 28, 2023. It is now read-only.

Commit

Permalink
use VersionedSlate for the owner_rpc api (mimblewimble#202)
Browse files Browse the repository at this point in the history
  • Loading branch information
antiochp authored and garyyu committed Sep 5, 2019
1 parent 6db9848 commit 59367b6
Showing 1 changed file with 48 additions and 19 deletions.
67 changes: 48 additions & 19 deletions api/src/owner_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ use crate::core::core::Transaction;
use crate::keychain::{Identifier, Keychain};
use crate::libwallet::{
AcctPathMapping, ErrorKind, InitTxArgs, IssueInvoiceTxArgs, NodeClient, NodeHeightResult,
OutputCommitMapping, Slate, TxLogEntry, WalletBackend, WalletInfo,
OutputCommitMapping, Slate, SlateVersion, TxLogEntry, VersionedSlate, WalletBackend, WalletInfo,
WalletLCProvider,
};
use crate::Owner;
use easy_jsonrpc;
Expand Down Expand Up @@ -413,7 +414,7 @@ pub trait OwnerRpc {
```
*/

fn init_send_tx(&self, args: InitTxArgs) -> Result<Slate, ErrorKind>;
fn init_send_tx(&self, args: InitTxArgs) -> Result<VersionedSlate, ErrorKind>;

/**
Networked version of [Owner::issue_invoice_tx](struct.Owner.html#method.issue_invoice_tx).
Expand Down Expand Up @@ -493,7 +494,7 @@ pub trait OwnerRpc {
```
*/

fn issue_invoice_tx(&self, args: IssueInvoiceTxArgs) -> Result<Slate, ErrorKind>;
fn issue_invoice_tx(&self, args: IssueInvoiceTxArgs) -> Result<VersionedSlate, ErrorKind>;

/**
Networked version of [Owner::process_invoice_tx](struct.Owner.html#method.process_invoice_tx).
Expand Down Expand Up @@ -641,7 +642,11 @@ pub trait OwnerRpc {
```
*/

fn process_invoice_tx(&self, slate: &Slate, args: InitTxArgs) -> Result<Slate, ErrorKind>;
fn process_invoice_tx(
&self,
slate: VersionedSlate,
args: InitTxArgs,
) -> Result<VersionedSlate, ErrorKind>;

/**
Networked version of [Owner::tx_lock_outputs](struct.Owner.html#method.tx_lock_outputs).
Expand Down Expand Up @@ -721,7 +726,11 @@ pub trait OwnerRpc {
```
*/
fn tx_lock_outputs(&self, slate: Slate, participant_id: usize) -> Result<(), ErrorKind>;
fn tx_lock_outputs(
&self,
slate: VersionedSlate,
participant_id: usize,
) -> Result<(), ErrorKind>;

/**
Networked version of [Owner::finalize_tx](struct.Owner.html#method.finalize_tx).
Expand Down Expand Up @@ -883,7 +892,7 @@ pub trait OwnerRpc {
# , 5, true, true, false);
```
*/
fn finalize_tx(&self, slate: Slate) -> Result<Slate, ErrorKind>;
fn finalize_tx(&self, slate: VersionedSlate) -> Result<VersionedSlate, ErrorKind>;

/**
Networked version of [Owner::post_tx](struct.Owner.html#method.post_tx).
Expand Down Expand Up @@ -1159,7 +1168,7 @@ pub trait OwnerRpc {
# ,5 ,true, false, false);
```
*/
fn verify_slate_messages(&self, slate: &Slate) -> Result<(), ErrorKind>;
fn verify_slate_messages(&self, slate: VersionedSlate) -> Result<(), ErrorKind>;

/**
Networked version of [Owner::restore](struct.Owner.html#method.restore).
Expand Down Expand Up @@ -1297,24 +1306,43 @@ where
.map_err(|e| e.kind())
}

fn init_send_tx(&self, args: InitTxArgs) -> Result<Slate, ErrorKind> {
Owner::init_send_tx(self, args).map_err(|e| e.kind())
fn init_send_tx(&self, args: InitTxArgs) -> Result<VersionedSlate, ErrorKind> {
let slate = Owner::init_send_tx(self, args).map_err(|e| e.kind())?;
let version = SlateVersion::V2;
Ok(VersionedSlate::into_version(slate, version))
}

fn issue_invoice_tx(&self, args: IssueInvoiceTxArgs) -> Result<Slate, ErrorKind> {
Owner::issue_invoice_tx(self, args).map_err(|e| e.kind())
fn issue_invoice_tx(&self, args: IssueInvoiceTxArgs) -> Result<VersionedSlate, ErrorKind> {
let slate = Owner::issue_invoice_tx(self, args).map_err(|e| e.kind())?;
let version = SlateVersion::V2;
Ok(VersionedSlate::into_version(slate, version))
}

fn process_invoice_tx(&self, slate: &Slate, args: InitTxArgs) -> Result<Slate, ErrorKind> {
Owner::process_invoice_tx(self, slate, args).map_err(|e| e.kind())
fn process_invoice_tx(
&self,
slate: VersionedSlate,
args: InitTxArgs,
) -> Result<VersionedSlate, ErrorKind> {
let in_slate = Slate::from(slate);
let out_slate = Owner::process_invoice_tx(self, &in_slate, args).map_err(|e| e.kind())?;
let version = SlateVersion::V2;
Ok(VersionedSlate::into_version(out_slate, version))
}

fn finalize_tx(&self, mut slate: Slate) -> Result<Slate, ErrorKind> {
Owner::finalize_tx(self, &mut slate, None, None).map_err(|e| e.kind())
fn finalize_tx(&self, slate: VersionedSlate) -> Result<VersionedSlate, ErrorKind> {
let in_slate = Slate::from(slate);
let out_slate = Owner::finalize_tx(self, &in_slate, None, None).map_err(|e| e.kind())?;
let version = SlateVersion::V2;
Ok(VersionedSlate::into_version(out_slate, version))
}

fn tx_lock_outputs(&self, mut slate: Slate, participant_id: usize) -> Result<(), ErrorKind> {
Owner::tx_lock_outputs(self, &mut slate, participant_id).map_err(|e| e.kind())
fn tx_lock_outputs(
&self,
slate: VersionedSlate,
participant_id: usize,
) -> Result<(), ErrorKind> {
let in_slate = Slate::from(slate);
Owner::tx_lock_outputs(self, &in_slate, participant_id).map_err(|e| e.kind())
}

fn cancel_tx(&self, tx_id: Option<u32>, tx_slate_id: Option<Uuid>) -> Result<(), ErrorKind> {
Expand All @@ -1334,8 +1362,9 @@ where
Owner::post_tx(self, tx_slate_id, tx, fluff).map_err(|e| e.kind())
}

fn verify_slate_messages(&self, slate: &Slate) -> Result<(), ErrorKind> {
Owner::verify_slate_messages(self, slate).map_err(|e| e.kind())
fn verify_slate_messages(&self, slate: VersionedSlate) -> Result<(), ErrorKind> {
let in_slate = Slate::from(slate);
Owner::verify_slate_messages(self, &in_slate).map_err(|e| e.kind())
}

fn restore(&self) -> Result<(), ErrorKind> {
Expand Down

0 comments on commit 59367b6

Please sign in to comment.