Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HF2 Slate Changes #258

Merged
merged 6 commits into from
Nov 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 12 additions & 2 deletions api/src/foreign_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pub trait ForeignRpc {
"Ok": {
"foreign_api_version": 2,
"supported_slate_versions": [
"V2"
"V3"
]
}
}
Expand Down Expand Up @@ -133,6 +133,8 @@ pub trait ForeignRpc {
"height": "4",
"id": "0436430c-2b02-624c-2032-570501212b00",
"lock_height": "4",
"ttl_cutoff_height": "0",
"payment_proof": null,
"num_participants": 2,
"participant_data": [
{
Expand Down Expand Up @@ -251,6 +253,8 @@ pub trait ForeignRpc {
"fee": "7000000",
"height": "5",
"lock_height": "0",
"ttl_cutoff_height": "0",
"payment_proof": null,
"participant_data": [
{
"id": "0",
Expand Down Expand Up @@ -279,6 +283,8 @@ pub trait ForeignRpc {
"height": "5",
"id": "0436430c-2b02-624c-2032-570501212b00",
"lock_height": "0",
"ttl_cutoff_height": "0",
"payment_proof": null,
"num_participants": 2,
"participant_data": [
{
Expand Down Expand Up @@ -414,6 +420,8 @@ pub trait ForeignRpc {
"fee": "7000000",
"height": "5",
"lock_height": "0",
"ttl_cutoff_height": "0",
"payment_proof": null,
"participant_data": [
{
"id": "1",
Expand Down Expand Up @@ -447,6 +455,8 @@ pub trait ForeignRpc {
"height": "5",
"id": "0436430c-2b02-624c-2032-570501212b00",
"lock_height": "0",
"ttl_cutoff_height": "0",
"payment_proof": null,
"num_participants": 2,
"participant_data": [
{
Expand Down Expand Up @@ -529,7 +539,7 @@ where

fn build_coinbase(&self, block_fees: &BlockFees) -> Result<VersionedCoinbase, ErrorKind> {
let cb: CbData = Foreign::build_coinbase(self, block_fees).map_err(|e| e.kind())?;
Ok(VersionedCoinbase::into_version(cb, SlateVersion::V2))
Ok(VersionedCoinbase::into_version(cb, SlateVersion::V3))
}

fn verify_slate_messages(&self, slate: VersionedSlate) -> Result<(), ErrorKind> {
Expand Down
68 changes: 42 additions & 26 deletions api/src/owner_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use uuid::Uuid;

use crate::core::core::Transaction;
use crate::keychain::{Identifier, Keychain};
use crate::libwallet::slate_versions::v2::TransactionV2;
use crate::libwallet::slate_versions::v3::TransactionV3;
use crate::libwallet::{
AcctPathMapping, ErrorKind, InitTxArgs, IssueInvoiceTxArgs, NodeClient, NodeHeightResult,
OutputCommitMapping, Slate, SlateVersion, TxLogEntry, VersionedSlate, WalletInfo,
Expand Down Expand Up @@ -358,6 +358,8 @@ pub trait OwnerRpc: Sync + Send {
"height": "4",
"id": "0436430c-2b02-624c-2032-570501212b00",
"lock_height": "0",
"ttl_cutoff_height": "0",
"payment_proof": null,
"num_participants": 2,
"participant_data": [
{
Expand Down Expand Up @@ -397,8 +399,8 @@ pub trait OwnerRpc: Sync + Send {
"offset": "d202964900000000d302964900000000d402964900000000d502964900000000"
},
"version_info": {
"orig_version": 2,
"version": 2,
"orig_version": 3,
"version": 3,
"block_header_version": 1
}
}
Expand Down Expand Up @@ -443,6 +445,8 @@ pub trait OwnerRpc: Sync + Send {
"height": "4",
"id": "0436430c-2b02-624c-2032-570501212b00",
"lock_height": "0",
"ttl_cutoff_height": "0",
"payment_proof": null,
"num_participants": 2,
"participant_data": [
{
Expand Down Expand Up @@ -477,8 +481,8 @@ pub trait OwnerRpc: Sync + Send {
"offset": "d202964900000000d302964900000000d402964900000000d502964900000000"
},
"version_info": {
"orig_version": 2,
"version": 2,
"orig_version": 3,
"version": 3,
"block_header_version": 1
}
}
Expand Down Expand Up @@ -507,6 +511,8 @@ pub trait OwnerRpc: Sync + Send {
"height": "4",
"id": "0436430c-2b02-624c-2032-570501212b00",
"lock_height": "0",
"ttl_cutoff_height": "0",
"payment_proof": null,
"num_participants": 2,
"participant_data": [
{
Expand Down Expand Up @@ -541,8 +547,8 @@ pub trait OwnerRpc: Sync + Send {
"offset": "d202964900000000d302964900000000d402964900000000d502964900000000"
},
"version_info": {
"orig_version": 2,
"version": 2,
"orig_version": 3,
"version": 3,
"block_header_version": 2
}
},
Expand Down Expand Up @@ -573,6 +579,8 @@ pub trait OwnerRpc: Sync + Send {
"height": "4",
"id": "0436430c-2b02-624c-2032-570501212b00",
"lock_height": "0",
"ttl_cutoff_height": "0",
"payment_proof": null,
"num_participants": 2,
"participant_data": [
{
Expand Down Expand Up @@ -625,8 +633,8 @@ pub trait OwnerRpc: Sync + Send {
"offset": "d202964900000000d302964900000000d402964900000000d502964900000000"
},
"version_info": {
"orig_version": 2,
"version": 2,
"orig_version": 3,
"version": 3,
"block_header_version": 2
}
}
Expand Down Expand Up @@ -659,6 +667,8 @@ pub trait OwnerRpc: Sync + Send {
"height": "4",
"id": "0436430c-2b02-624c-2032-570501212b00",
"lock_height": "4",
"ttl_cutoff_height": "0",
"payment_proof": null,
"num_participants": 2,
"participant_data": [
{
Expand Down Expand Up @@ -698,8 +708,8 @@ pub trait OwnerRpc: Sync + Send {
"offset": "d202964900000000d302964900000000d402964900000000d502964900000000"
},
"version_info": {
"orig_version": 2,
"version": 2,
"orig_version": 3,
"version": 3,
"block_header_version": 2
}
},
Expand Down Expand Up @@ -740,12 +750,14 @@ pub trait OwnerRpc: Sync + Send {
"params": [
{
"version_info": {
"version": 2,
"orig_version": 2,
"version": 3,
"orig_version": 3,
"block_header_version": 2
},
"num_participants": 2,
"id": "0436430c-2b02-624c-2032-570501212b00",
"ttl_cutoff_height": "0",
"payment_proof": null,
"tx": {
"offset": "d202964900000000d302964900000000d402964900000000d502964900000000",
"body": {
Expand Down Expand Up @@ -819,6 +831,8 @@ pub trait OwnerRpc: Sync + Send {
"fee": "7000000",
"height": "5",
"id": "0436430c-2b02-624c-2032-570501212b00",
"ttl_cutoff_height": "0",
"payment_proof": null,
"lock_height": "0",
"num_participants": 2,
"participant_data": [
Expand Down Expand Up @@ -876,8 +890,8 @@ pub trait OwnerRpc: Sync + Send {
"offset": "d202964900000000d302964900000000d402964900000000d502964900000000"
},
"version_info": {
"orig_version": 2,
"version": 2,
"orig_version": 3,
"version": 3,
"block_header_version": 2
}
}
Expand Down Expand Up @@ -954,7 +968,7 @@ pub trait OwnerRpc: Sync + Send {
```
*/

fn post_tx(&self, tx: TransactionV2, fluff: bool) -> Result<(), ErrorKind>;
fn post_tx(&self, tx: TransactionV3, fluff: bool) -> Result<(), ErrorKind>;

/**
Networked version of [Owner::cancel_tx](struct.Owner.html#method.cancel_tx).
Expand Down Expand Up @@ -1080,7 +1094,7 @@ pub trait OwnerRpc: Sync + Send {
# , false, 5, true, true, false);
```
*/
fn get_stored_tx(&self, tx: &TxLogEntry) -> Result<Option<TransactionV2>, ErrorKind>;
fn get_stored_tx(&self, tx: &TxLogEntry) -> Result<Option<TransactionV3>, ErrorKind>;

/**
Networked version of [Owner::verify_slate_messages](struct.Owner.html#method.verify_slate_messages).
Expand All @@ -1098,6 +1112,8 @@ pub trait OwnerRpc: Sync + Send {
"height": "4",
"id": "0436430c-2b02-624c-2032-570501212b00",
"lock_height": "4",
"ttl_cutoff_height": "0",
"payment_proof": null,
"num_participants": 2,
"participant_data": [
{
Expand Down Expand Up @@ -1137,8 +1153,8 @@ pub trait OwnerRpc: Sync + Send {
"offset": "d202964900000000d302964900000000d402964900000000d502964900000000"
},
"version_info": {
"orig_version": 2,
"version": 2,
"orig_version": 3,
"version": 3,
"block_header_version": 2
}
}
Expand Down Expand Up @@ -1271,13 +1287,13 @@ where

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

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

Expand All @@ -1288,14 +1304,14 @@ where
) -> Result<VersionedSlate, ErrorKind> {
let out_slate = Owner::process_invoice_tx(self, None, &Slate::from(in_slate), args)
.map_err(|e| e.kind())?;
let version = SlateVersion::V2;
let version = SlateVersion::V3;
Ok(VersionedSlate::into_version(out_slate, version))
}

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

Expand All @@ -1312,13 +1328,13 @@ where
Owner::cancel_tx(self, None, tx_id, tx_slate_id).map_err(|e| e.kind())
}

fn get_stored_tx(&self, tx: &TxLogEntry) -> Result<Option<TransactionV2>, ErrorKind> {
fn get_stored_tx(&self, tx: &TxLogEntry) -> Result<Option<TransactionV3>, ErrorKind> {
Owner::get_stored_tx(self, None, tx)
.map(|x| x.map(|y| TransactionV2::from(y)))
.map(|x| x.map(|y| TransactionV3::from(y)))
.map_err(|e| e.kind())
}

fn post_tx(&self, tx: TransactionV2, fluff: bool) -> Result<(), ErrorKind> {
fn post_tx(&self, tx: TransactionV3, fluff: bool) -> Result<(), ErrorKind> {
Owner::post_tx(self, None, &Transaction::from(tx), fluff).map_err(|e| e.kind())
}

Expand Down
Loading