mirror of
https://github.com/mimblewimble/grin.git
synced 2025-01-20 19:11:08 +03:00
Fix API wallets calls (#1597)
* Add API Secret in wallet calls * File node api secret default to same api secret and directly in http parameter
This commit is contained in:
parent
5a83989cf6
commit
a13c20ceb2
18 changed files with 91 additions and 90 deletions
|
@ -326,7 +326,12 @@ fn comments() -> HashMap<String, String> {
|
|||
#where the wallet should find a running node
|
||||
".to_string(),
|
||||
);
|
||||
|
||||
retval.insert(
|
||||
"node_api_secret_path".to_string(),
|
||||
"
|
||||
#location of the node api secret for basic auth on the Grin API
|
||||
".to_string(),
|
||||
);
|
||||
retval.insert(
|
||||
"data_file_dir".to_string(),
|
||||
"
|
||||
|
|
|
@ -371,6 +371,10 @@ impl GlobalWalletConfig {
|
|||
secret_path.push(API_SECRET_FILE_NAME);
|
||||
self.members.as_mut().unwrap().wallet.api_secret_path =
|
||||
Some(secret_path.to_str().unwrap().to_owned());
|
||||
let mut node_secret_path = wallet_home.clone();
|
||||
node_secret_path.push(API_SECRET_FILE_NAME);
|
||||
self.members.as_mut().unwrap().wallet.node_api_secret_path =
|
||||
Some(node_secret_path.to_str().unwrap().to_owned());
|
||||
let mut log_path = wallet_home.clone();
|
||||
log_path.push(WALLET_LOG_FILE_NAME);
|
||||
self.members
|
||||
|
|
|
@ -263,7 +263,7 @@ impl LocalServerContainer {
|
|||
let _ = fs::create_dir_all(self.wallet_config.clone().data_file_dir);
|
||||
let r = wallet::WalletSeed::init_file(&self.wallet_config);
|
||||
|
||||
let client = HTTPWalletClient::new(&self.wallet_config.check_node_api_http_addr);
|
||||
let client = HTTPWalletClient::new(&self.wallet_config.check_node_api_http_addr, None);
|
||||
|
||||
if let Err(e) = r {
|
||||
//panic!("Error initializing wallet seed: {}", e);
|
||||
|
@ -305,7 +305,7 @@ impl LocalServerContainer {
|
|||
let keychain: keychain::ExtKeychain = wallet_seed
|
||||
.derive_keychain("")
|
||||
.expect("Failed to derive keychain from seed file and passphrase.");
|
||||
let client = HTTPWalletClient::new(&config.check_node_api_http_addr);
|
||||
let client = HTTPWalletClient::new(&config.check_node_api_http_addr, None);
|
||||
let mut wallet = FileWallet::new(config.clone(), "", client)
|
||||
.unwrap_or_else(|e| panic!("Error creating wallet: {:?} Config: {:?}", e, config));
|
||||
wallet.keychain = Some(keychain);
|
||||
|
@ -331,7 +331,7 @@ impl LocalServerContainer {
|
|||
.derive_keychain("")
|
||||
.expect("Failed to derive keychain from seed file and passphrase.");
|
||||
|
||||
let client = HTTPWalletClient::new(&config.check_node_api_http_addr);
|
||||
let client = HTTPWalletClient::new(&config.check_node_api_http_addr, None);
|
||||
|
||||
let max_outputs = 500;
|
||||
let change_outputs = 1;
|
||||
|
|
|
@ -423,7 +423,7 @@ fn replicate_tx_fluff_failure() {
|
|||
|
||||
// Create Wallet 1 (Mining Input) and start it listening
|
||||
// Wallet 1 post to another node, just for fun
|
||||
let client1 = HTTPWalletClient::new("http://127.0.0.1:23003");
|
||||
let client1 = HTTPWalletClient::new("http://127.0.0.1:23003", None);
|
||||
let wallet1 = create_wallet("target/tmp/tx_fluff/wallet1", client1.clone());
|
||||
let wallet1_handle = thread::spawn(move || {
|
||||
controller::foreign_listener(wallet1, "127.0.0.1:33000")
|
||||
|
@ -431,7 +431,7 @@ fn replicate_tx_fluff_failure() {
|
|||
});
|
||||
|
||||
// Create Wallet 2 (Recipient) and launch
|
||||
let client2 = HTTPWalletClient::new("http://127.0.0.1:23001");
|
||||
let client2 = HTTPWalletClient::new("http://127.0.0.1:23001", None);
|
||||
let wallet2 = create_wallet("target/tmp/tx_fluff/wallet2", client2.clone());
|
||||
let wallet2_handle = thread::spawn(move || {
|
||||
controller::foreign_listener(wallet2, "127.0.0.1:33001")
|
||||
|
|
|
@ -52,6 +52,7 @@ pub fn seed_exists(wallet_config: WalletConfig) -> bool {
|
|||
pub fn instantiate_wallet(
|
||||
wallet_config: WalletConfig,
|
||||
passphrase: &str,
|
||||
node_api_secret: Option<String>,
|
||||
) -> Box<WalletInst<HTTPWalletClient, keychain::ExtKeychain>> {
|
||||
if grin_wallet::needs_migrate(&wallet_config.data_file_dir) {
|
||||
// Migrate wallet automatically
|
||||
|
@ -67,7 +68,7 @@ pub fn instantiate_wallet(
|
|||
warn!(LOGGER, "If anything went wrong, you can try again by deleting the `db` directory and running a wallet command");
|
||||
warn!(LOGGER, "If all is okay, you can move/backup/delete all files in the wallet directory EXCEPT FOR wallet.seed");
|
||||
}
|
||||
let client = HTTPWalletClient::new(&wallet_config.check_node_api_http_addr);
|
||||
let client = HTTPWalletClient::new(&wallet_config.check_node_api_http_addr, node_api_secret);
|
||||
let db_wallet = LMDBBackend::new(wallet_config.clone(), "", client).unwrap_or_else(|e| {
|
||||
panic!(
|
||||
"Error creating DB wallet: {} Config: {:?}",
|
||||
|
@ -102,13 +103,15 @@ pub fn wallet_command(wallet_args: &ArgMatches, config: GlobalWalletConfig) {
|
|||
if wallet_args.is_present("show_spent") {
|
||||
show_spent = true;
|
||||
}
|
||||
let node_api_secret = get_first_line(wallet_config.node_api_secret_path.clone());
|
||||
|
||||
// Derive the keychain based on seed from seed file and specified passphrase.
|
||||
// Generate the initial wallet seed if we are running "wallet init".
|
||||
if let ("init", Some(_)) = wallet_args.subcommand() {
|
||||
WalletSeed::init_file(&wallet_config).expect("Failed to init wallet seed file.");
|
||||
info!(LOGGER, "Wallet seed file created");
|
||||
let client = HTTPWalletClient::new(&wallet_config.check_node_api_http_addr);
|
||||
let client =
|
||||
HTTPWalletClient::new(&wallet_config.check_node_api_http_addr, node_api_secret);
|
||||
let _: LMDBBackend<HTTPWalletClient, keychain::ExtKeychain> =
|
||||
LMDBBackend::new(wallet_config.clone(), "", client).unwrap_or_else(|e| {
|
||||
panic!(
|
||||
|
@ -126,11 +129,11 @@ pub fn wallet_command(wallet_args: &ArgMatches, config: GlobalWalletConfig) {
|
|||
let passphrase = wallet_args
|
||||
.value_of("pass")
|
||||
.expect("Failed to read passphrase.");
|
||||
|
||||
// Handle listener startup commands
|
||||
{
|
||||
let wallet = instantiate_wallet(wallet_config.clone(), passphrase);
|
||||
let wallet = instantiate_wallet(wallet_config.clone(), passphrase, node_api_secret.clone());
|
||||
let api_secret = get_first_line(wallet_config.api_secret_path.clone());
|
||||
|
||||
match wallet_args.subcommand() {
|
||||
("listen", Some(listen_args)) => {
|
||||
if let Some(port) = listen_args.value_of("port") {
|
||||
|
@ -174,6 +177,7 @@ pub fn wallet_command(wallet_args: &ArgMatches, config: GlobalWalletConfig) {
|
|||
let wallet = Arc::new(Mutex::new(instantiate_wallet(
|
||||
wallet_config.clone(),
|
||||
passphrase,
|
||||
node_api_secret,
|
||||
)));
|
||||
let res = controller::owner_single_use(wallet.clone(), |api| {
|
||||
match wallet_args.subcommand() {
|
||||
|
|
|
@ -63,13 +63,11 @@ pub fn create() -> Box<View> {
|
|||
let mut s: ViewRef<SelectView<&str>> = c.find_id(MAIN_MENU).unwrap();
|
||||
s.select_down(1)(c);
|
||||
Some(EventResult::Consumed(None));
|
||||
})
|
||||
.on_pre_event('k', move |c| {
|
||||
}).on_pre_event('k', move |c| {
|
||||
let mut s: ViewRef<SelectView<&str>> = c.find_id(MAIN_MENU).unwrap();
|
||||
s.select_up(1)(c);
|
||||
Some(EventResult::Consumed(None));
|
||||
})
|
||||
.on_pre_event(Key::Tab, move |c| {
|
||||
}).on_pre_event(Key::Tab, move |c| {
|
||||
let mut s: ViewRef<SelectView<&str>> = c.find_id(MAIN_MENU).unwrap();
|
||||
if s.selected_id().unwrap() == s.len() - 1 {
|
||||
s.set_selection(0)(c);
|
||||
|
|
|
@ -170,23 +170,17 @@ impl TUIStatusListener for TUIMiningView {
|
|||
let table_view = TableView::<WorkerStats, StratumWorkerColumn>::new()
|
||||
.column(StratumWorkerColumn::Id, "Worker ID", |c| {
|
||||
c.width_percent(10)
|
||||
})
|
||||
.column(StratumWorkerColumn::IsConnected, "Connected", |c| {
|
||||
}).column(StratumWorkerColumn::IsConnected, "Connected", |c| {
|
||||
c.width_percent(10)
|
||||
})
|
||||
.column(StratumWorkerColumn::LastSeen, "Last Seen", |c| {
|
||||
}).column(StratumWorkerColumn::LastSeen, "Last Seen", |c| {
|
||||
c.width_percent(20)
|
||||
})
|
||||
.column(StratumWorkerColumn::PowDifficulty, "Pow Difficulty", |c| {
|
||||
}).column(StratumWorkerColumn::PowDifficulty, "Pow Difficulty", |c| {
|
||||
c.width_percent(10)
|
||||
})
|
||||
.column(StratumWorkerColumn::NumAccepted, "Num Accepted", |c| {
|
||||
}).column(StratumWorkerColumn::NumAccepted, "Num Accepted", |c| {
|
||||
c.width_percent(10)
|
||||
})
|
||||
.column(StratumWorkerColumn::NumRejected, "Num Rejected", |c| {
|
||||
}).column(StratumWorkerColumn::NumRejected, "Num Rejected", |c| {
|
||||
c.width_percent(10)
|
||||
})
|
||||
.column(StratumWorkerColumn::NumStale, "Num Stale", |c| {
|
||||
}).column(StratumWorkerColumn::NumStale, "Num Stale", |c| {
|
||||
c.width_percent(10)
|
||||
});
|
||||
|
||||
|
@ -194,28 +188,22 @@ impl TUIStatusListener for TUIMiningView {
|
|||
.child(
|
||||
LinearLayout::new(Orientation::Horizontal)
|
||||
.child(TextView::new(" ").with_id("stratum_config_status")),
|
||||
)
|
||||
.child(
|
||||
).child(
|
||||
LinearLayout::new(Orientation::Horizontal)
|
||||
.child(TextView::new(" ").with_id("stratum_is_running_status")),
|
||||
)
|
||||
.child(
|
||||
).child(
|
||||
LinearLayout::new(Orientation::Horizontal)
|
||||
.child(TextView::new(" ").with_id("stratum_num_workers_status")),
|
||||
)
|
||||
.child(
|
||||
).child(
|
||||
LinearLayout::new(Orientation::Horizontal)
|
||||
.child(TextView::new(" ").with_id("stratum_block_height_status")),
|
||||
)
|
||||
.child(
|
||||
).child(
|
||||
LinearLayout::new(Orientation::Horizontal)
|
||||
.child(TextView::new(" ").with_id("stratum_network_difficulty_status")),
|
||||
)
|
||||
.child(
|
||||
).child(
|
||||
LinearLayout::new(Orientation::Horizontal)
|
||||
.child(TextView::new(" ").with_id("stratum_network_hashrate")),
|
||||
)
|
||||
.child(
|
||||
).child(
|
||||
LinearLayout::new(Orientation::Horizontal)
|
||||
.child(TextView::new(" ").with_id("stratum_cuckoo_size_status")),
|
||||
);
|
||||
|
@ -225,26 +213,22 @@ impl TUIStatusListener for TUIMiningView {
|
|||
.child(BoxView::with_full_screen(
|
||||
Dialog::around(table_view.with_id(TABLE_MINING_STATUS).min_size((50, 20)))
|
||||
.title("Mining Workers"),
|
||||
))
|
||||
.with_id("mining_device_view");
|
||||
)).with_id("mining_device_view");
|
||||
|
||||
let diff_status_view = LinearLayout::new(Orientation::Vertical)
|
||||
.child(
|
||||
LinearLayout::new(Orientation::Horizontal)
|
||||
.child(TextView::new("Tip Height: "))
|
||||
.child(TextView::new("").with_id("diff_cur_height")),
|
||||
)
|
||||
.child(
|
||||
).child(
|
||||
LinearLayout::new(Orientation::Horizontal)
|
||||
.child(TextView::new("Difficulty Adjustment Window: "))
|
||||
.child(TextView::new("").with_id("diff_adjust_window")),
|
||||
)
|
||||
.child(
|
||||
).child(
|
||||
LinearLayout::new(Orientation::Horizontal)
|
||||
.child(TextView::new("Average Block Time: "))
|
||||
.child(TextView::new("").with_id("diff_avg_block_time")),
|
||||
)
|
||||
.child(
|
||||
).child(
|
||||
LinearLayout::new(Orientation::Horizontal)
|
||||
.child(TextView::new("Average Difficulty: "))
|
||||
.child(TextView::new("").with_id("diff_avg_difficulty")),
|
||||
|
@ -253,11 +237,9 @@ impl TUIStatusListener for TUIMiningView {
|
|||
let diff_table_view = TableView::<DiffBlock, DiffColumn>::new()
|
||||
.column(DiffColumn::BlockNumber, "Block Number", |c| {
|
||||
c.width_percent(25)
|
||||
})
|
||||
.column(DiffColumn::Difficulty, "Network Difficulty", |c| {
|
||||
}).column(DiffColumn::Difficulty, "Network Difficulty", |c| {
|
||||
c.width_percent(25)
|
||||
})
|
||||
.column(DiffColumn::Time, "Block Time", |c| c.width_percent(25))
|
||||
}).column(DiffColumn::Time, "Block Time", |c| c.width_percent(25))
|
||||
.column(DiffColumn::Duration, "Duration", |c| c.width_percent(25));
|
||||
|
||||
let mining_difficulty_view = LinearLayout::new(Orientation::Vertical)
|
||||
|
@ -268,8 +250,7 @@ impl TUIStatusListener for TUIMiningView {
|
|||
.with_id(TABLE_MINING_DIFF_STATUS)
|
||||
.min_size((50, 20)),
|
||||
).title("Mining Difficulty Data"),
|
||||
))
|
||||
.with_id("mining_difficulty_view");
|
||||
)).with_id("mining_difficulty_view");
|
||||
|
||||
let view_stack = StackView::new()
|
||||
.layer(mining_difficulty_view)
|
||||
|
|
|
@ -86,21 +86,18 @@ impl TUIStatusListener for TUIPeerView {
|
|||
.column(PeerColumn::Direction, "Direction", |c| c.width_percent(20))
|
||||
.column(PeerColumn::TotalDifficulty, "Total Difficulty", |c| {
|
||||
c.width_percent(20)
|
||||
})
|
||||
.column(PeerColumn::Version, "Version", |c| c.width_percent(20));
|
||||
}).column(PeerColumn::Version, "Version", |c| c.width_percent(20));
|
||||
let peer_status_view = BoxView::with_full_screen(
|
||||
LinearLayout::new(Orientation::Vertical)
|
||||
.child(
|
||||
LinearLayout::new(Orientation::Horizontal)
|
||||
.child(TextView::new("Total Peers: "))
|
||||
.child(TextView::new(" ").with_id("peers_total")),
|
||||
)
|
||||
.child(
|
||||
).child(
|
||||
LinearLayout::new(Orientation::Horizontal)
|
||||
.child(TextView::new("Longest Chain: "))
|
||||
.child(TextView::new(" ").with_id("longest_work_peer")),
|
||||
)
|
||||
.child(TextView::new(" "))
|
||||
).child(TextView::new(" "))
|
||||
.child(
|
||||
Dialog::around(table_view.with_id(TABLE_PEER_STATUS).min_size((50, 20)))
|
||||
.title("Connected Peers"),
|
||||
|
|
|
@ -37,35 +37,28 @@ impl TUIStatusListener for TUIStatusView {
|
|||
LinearLayout::new(Orientation::Horizontal)
|
||||
.child(TextView::new("Current Status: "))
|
||||
.child(TextView::new("Starting").with_id("basic_current_status")),
|
||||
)
|
||||
.child(
|
||||
).child(
|
||||
LinearLayout::new(Orientation::Horizontal)
|
||||
.child(TextView::new("Connected Peers: "))
|
||||
.child(TextView::new("0").with_id("connected_peers")),
|
||||
)
|
||||
.child(
|
||||
).child(
|
||||
LinearLayout::new(Orientation::Horizontal)
|
||||
.child(TextView::new("Chain Height: "))
|
||||
.child(TextView::new(" ").with_id("chain_height")),
|
||||
)
|
||||
.child(
|
||||
).child(
|
||||
LinearLayout::new(Orientation::Horizontal)
|
||||
.child(TextView::new("Total Difficulty: "))
|
||||
.child(TextView::new(" ").with_id("basic_total_difficulty")),
|
||||
)
|
||||
.child(
|
||||
).child(
|
||||
LinearLayout::new(Orientation::Horizontal)
|
||||
.child(TextView::new("------------------------")),
|
||||
)
|
||||
.child(
|
||||
).child(
|
||||
LinearLayout::new(Orientation::Horizontal)
|
||||
.child(TextView::new(" ").with_id("basic_mining_config_status")),
|
||||
)
|
||||
.child(
|
||||
).child(
|
||||
LinearLayout::new(Orientation::Horizontal)
|
||||
.child(TextView::new(" ").with_id("basic_mining_status")),
|
||||
)
|
||||
.child(
|
||||
).child(
|
||||
LinearLayout::new(Orientation::Horizontal)
|
||||
.child(TextView::new(" ").with_id("basic_network_info")),
|
||||
), //.child(logo_view)
|
||||
|
|
|
@ -32,13 +32,15 @@ use util::{self, LOGGER};
|
|||
#[derive(Clone)]
|
||||
pub struct HTTPWalletClient {
|
||||
node_url: String,
|
||||
node_api_secret: Option<String>,
|
||||
}
|
||||
|
||||
impl HTTPWalletClient {
|
||||
/// Create a new client that will communicate with the given grin node
|
||||
pub fn new(node_url: &str) -> HTTPWalletClient {
|
||||
pub fn new(node_url: &str, node_api_secret: Option<String>) -> HTTPWalletClient {
|
||||
HTTPWalletClient {
|
||||
node_url: node_url.to_owned(),
|
||||
node_api_secret: node_api_secret,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -47,6 +49,9 @@ impl WalletClient for HTTPWalletClient {
|
|||
fn node_url(&self) -> &str {
|
||||
&self.node_url
|
||||
}
|
||||
fn node_api_secret(&self) -> Option<String> {
|
||||
self.node_api_secret.clone()
|
||||
}
|
||||
|
||||
/// Call the wallet API to create a coinbase output for the given
|
||||
/// block_fees. Will retry based on default "retry forever with backoff"
|
||||
|
@ -101,7 +106,7 @@ impl WalletClient for HTTPWalletClient {
|
|||
} else {
|
||||
url = format!("{}/v1/pool/push", dest);
|
||||
}
|
||||
api::client::post_no_ret(url.as_str(), None, tx).context(
|
||||
api::client::post_no_ret(url.as_str(), self.node_api_secret(), tx).context(
|
||||
libwallet::ErrorKind::ClientCallback("Posting transaction to node"),
|
||||
)?;
|
||||
Ok(())
|
||||
|
@ -111,7 +116,7 @@ impl WalletClient for HTTPWalletClient {
|
|||
fn get_chain_height(&self) -> Result<u64, libwallet::Error> {
|
||||
let addr = self.node_url();
|
||||
let url = format!("{}/v1/chain", addr);
|
||||
let res = api::client::get::<api::Tip>(url.as_str(), None).context(
|
||||
let res = api::client::get::<api::Tip>(url.as_str(), self.node_api_secret()).context(
|
||||
libwallet::ErrorKind::ClientCallback("Getting chain height from node"),
|
||||
)?;
|
||||
Ok(res.height)
|
||||
|
@ -138,7 +143,7 @@ impl WalletClient for HTTPWalletClient {
|
|||
let url = format!("{}/v1/chain/outputs/byids?{}", addr, query_chunk.join("&"),);
|
||||
tasks.push(api::client::get_async::<Vec<api::Output>>(
|
||||
url.as_str(),
|
||||
None,
|
||||
self.node_api_secret(),
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -184,7 +189,7 @@ impl WalletClient for HTTPWalletClient {
|
|||
let mut api_outputs: Vec<(pedersen::Commitment, pedersen::RangeProof, bool, u64)> =
|
||||
Vec::new();
|
||||
|
||||
match api::client::get::<api::OutputListing>(url.as_str(), None) {
|
||||
match api::client::get::<api::OutputListing>(url.as_str(), self.node_api_secret()) {
|
||||
Ok(o) => {
|
||||
for out in o.outputs {
|
||||
let is_coinbase = match out.output_type {
|
||||
|
|
|
@ -444,9 +444,9 @@ where
|
|||
// write details file
|
||||
let mut details_file =
|
||||
File::create(details_file_path).context(ErrorKind::FileWallet(&"Could not create "))?;
|
||||
let res_json = serde_json::to_string_pretty(&self.details).context(ErrorKind::FileWallet(
|
||||
"Error serializing wallet details file",
|
||||
))?;
|
||||
let res_json = serde_json::to_string_pretty(&self.details).context(
|
||||
ErrorKind::FileWallet("Error serializing wallet details file"),
|
||||
)?;
|
||||
details_file
|
||||
.write_all(res_json.into_bytes().as_slice())
|
||||
.context(ErrorKind::FileWallet(&"Error writing wallet details file"))
|
||||
|
|
|
@ -131,7 +131,7 @@ where
|
|||
|
||||
api_thread
|
||||
.join()
|
||||
.map_err(|e| ErrorKind::GenericError(format!("API thread paniced :{:?}", e)).into())
|
||||
.map_err(|e| ErrorKind::GenericError(format!("API thread panicked :{:?}", e)).into())
|
||||
}
|
||||
|
||||
type WalletResponseFuture = Box<Future<Item = Response<Body>, Error = Error> + Send>;
|
||||
|
@ -257,6 +257,7 @@ where
|
|||
|
||||
fn handle_get_request(&self, req: &Request<Body>) -> Result<Response<Body>, Error> {
|
||||
let api = APIOwner::new(self.wallet.clone());
|
||||
|
||||
Ok(match req
|
||||
.uri()
|
||||
.path()
|
||||
|
|
|
@ -56,8 +56,7 @@ where
|
|||
} else {
|
||||
out.status != OutputStatus::Spent
|
||||
}
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
}).collect::<Vec<_>>();
|
||||
|
||||
// only include outputs with a given tx_id if provided
|
||||
if let Some(id) = tx_id {
|
||||
|
@ -74,8 +73,7 @@ where
|
|||
.map(|out| {
|
||||
let commit = wallet.get_commitment(&out.key_id).unwrap();
|
||||
(out, commit)
|
||||
})
|
||||
.collect();
|
||||
}).collect();
|
||||
Ok(res)
|
||||
}
|
||||
|
||||
|
|
|
@ -157,6 +157,8 @@ where
|
|||
pub trait WalletClient: Sync + Send + Clone {
|
||||
/// Return the URL of the check node
|
||||
fn node_url(&self) -> &str;
|
||||
/// Return the node api secret
|
||||
fn node_api_secret(&self) -> Option<String>;
|
||||
|
||||
/// Call the wallet API to create a coinbase transaction
|
||||
fn create_coinbase(&self, dest: &str, block_fees: &BlockFees) -> Result<CbData, Error>;
|
||||
|
@ -417,7 +419,8 @@ impl BlockIdentifier {
|
|||
|
||||
/// convert to hex string
|
||||
pub fn from_hex(hex: &str) -> Result<BlockIdentifier, Error> {
|
||||
let hash = Hash::from_hex(hex).context(ErrorKind::GenericError("Invalid hex".to_owned()))?;
|
||||
let hash =
|
||||
Hash::from_hex(hex).context(ErrorKind::GenericError("Invalid hex".to_owned()))?;
|
||||
Ok(BlockIdentifier(hash))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -336,7 +336,11 @@ where
|
|||
|
||||
fn save_tx_log_entry(&self, t: TxLogEntry) -> Result<(), Error> {
|
||||
let tx_log_key = u64_to_key(TX_LOG_ENTRY_PREFIX, t.id as u64);
|
||||
self.db.borrow().as_ref().unwrap().put_ser(&tx_log_key, &t)?;
|
||||
self.db
|
||||
.borrow()
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.put_ser(&tx_log_key, &t)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
@ -41,6 +41,8 @@ pub struct WalletConfig {
|
|||
pub api_listen_port: u16,
|
||||
/// Location of the secret for basic auth on the Owner API
|
||||
pub api_secret_path: Option<String>,
|
||||
/// Location of the node api secret for basic auth on the Grin API
|
||||
pub node_api_secret_path: Option<String>,
|
||||
// The api address of a running server node against which transaction inputs
|
||||
// will be checked during send
|
||||
pub check_node_api_http_addr: String,
|
||||
|
@ -55,6 +57,7 @@ impl Default for WalletConfig {
|
|||
api_listen_interface: "127.0.0.1".to_string(),
|
||||
api_listen_port: 13415,
|
||||
api_secret_path: Some(".api_secret".to_string()),
|
||||
node_api_secret_path: Some(".api_secret".to_string()),
|
||||
check_node_api_http_addr: "http://127.0.0.1:13413".to_string(),
|
||||
data_file_dir: ".".to_string(),
|
||||
}
|
||||
|
|
|
@ -180,9 +180,9 @@ where
|
|||
libwallet::ErrorKind::ClientCallback("Error parsing TxWrapper"),
|
||||
)?;
|
||||
|
||||
let tx_bin = util::from_hex(wrapper.tx_hex).context(libwallet::ErrorKind::ClientCallback(
|
||||
"Error parsing TxWrapper: tx_bin",
|
||||
))?;
|
||||
let tx_bin = util::from_hex(wrapper.tx_hex).context(
|
||||
libwallet::ErrorKind::ClientCallback("Error parsing TxWrapper: tx_bin"),
|
||||
)?;
|
||||
|
||||
let tx: Transaction = ser::deserialize(&mut &tx_bin[..]).context(
|
||||
libwallet::ErrorKind::ClientCallback("Error parsing TxWrapper: tx"),
|
||||
|
@ -314,6 +314,9 @@ impl WalletClient for LocalWalletClient {
|
|||
fn node_url(&self) -> &str {
|
||||
"node"
|
||||
}
|
||||
fn node_api_secret(&self) -> Option<String> {
|
||||
None
|
||||
}
|
||||
|
||||
/// Call the wallet API to create a coinbase output for the given
|
||||
/// block_fees. Will retry based on default "retry forever with backoff"
|
||||
|
|
|
@ -91,6 +91,7 @@ fn basic_transaction_api(
|
|||
// few values to keep things shorter
|
||||
let reward = core::consensus::REWARD;
|
||||
let cm = global::coinbase_maturity(0); // assume all testing precedes soft fork height
|
||||
|
||||
// mine a few blocks
|
||||
let _ = common::award_blocks_to_wallet(&chain, wallet1.clone(), 10);
|
||||
|
||||
|
@ -344,6 +345,7 @@ fn tx_rollback(test_dir: &str, backend_type: common::BackendType) -> Result<(),
|
|||
// few values to keep things shorter
|
||||
let reward = core::consensus::REWARD;
|
||||
let cm = global::coinbase_maturity(0); // assume all testing precedes soft fork height
|
||||
|
||||
// mine a few blocks
|
||||
let _ = common::award_blocks_to_wallet(&chain, wallet1.clone(), 5);
|
||||
|
||||
|
|
Loading…
Reference in a new issue