introduce VersionedCoinbase to add api stability around build_coinbase

This commit is contained in:
antiochp
2019-08-20 10:06:06 +01:00
parent 3efe36eb7d
commit 1a6b8aff3b
8 changed files with 84 additions and 32 deletions
+9 -5
View File
@@ -17,7 +17,8 @@
use crate::keychain::Keychain;
use crate::libwallet::{
self, BlockFees, CbData, ErrorKind, InitTxArgs, IssueInvoiceTxArgs, NodeClient,
NodeVersionInfo, Slate, VersionInfo, VersionedSlate, WalletLCProvider,
NodeVersionInfo, Slate, SlateVersion, VersionInfo, VersionedCoinbase, VersionedSlate,
WalletLCProvider,
};
use crate::{Foreign, ForeignCheckMiddlewareFn};
use easy_jsonrpc_mw;
@@ -94,7 +95,9 @@ pub trait ForeignRpc {
"kernel": {
"excess": "08dfe86d732f2dd24bac36aa7502685221369514197c26d33fac03041d47e4b490",
"excess_sig": "8f07ddd5e9f5179cff19486034181ed76505baaad53e5d994064127b56c5841be02fa098c54c9bf638e0ee1ad5eb896caa11565f632be7b9cd65643ba371044f",
"features": "Coinbase"
"features": "Coinbase",
"fee": "0",
"lock_height": "0"
},
"key_id": "0300000000000000000000000400000000",
"output": {
@@ -110,7 +113,7 @@ pub trait ForeignRpc {
```
*/
fn build_coinbase(&self, block_fees: &BlockFees) -> Result<CbData, ErrorKind>;
fn build_coinbase(&self, block_fees: &BlockFees) -> Result<VersionedCoinbase, ErrorKind>;
/**
Networked version of [Foreign::verify_slate_messages](struct.Foreign.html#method.verify_slate_messages).
@@ -524,8 +527,9 @@ where
Foreign::check_version(self).map_err(|e| e.kind())
}
fn build_coinbase(&self, block_fees: &BlockFees) -> Result<CbData, ErrorKind> {
Foreign::build_coinbase(self, block_fees).map_err(|e| e.kind())
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))
}
fn verify_slate_messages(&self, slate: VersionedSlate) -> Result<(), ErrorKind> {