use VersionedSlate for the owner_rpc api (#202)

This commit is contained in:
Antioch Peverell 2019-08-06 11:34:59 +01:00 committed by Yeastplume
parent c40e8a915b
commit 5cdd412205

View file

@ -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, WalletInfo, WalletLCProvider,
OutputCommitMapping, Slate, SlateVersion, TxLogEntry, VersionedSlate, WalletInfo,
WalletLCProvider,
};
use crate::util::Mutex;
use crate::Owner;
@ -403,7 +404,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).
@ -483,7 +484,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).
@ -631,7 +632,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).
@ -711,7 +716,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).
@ -873,7 +882,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).
@ -1142,7 +1151,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).
@ -1280,24 +1289,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).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).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> {
@ -1312,8 +1340,9 @@ where
Owner::post_tx(self, 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> {