Skip to content

Conversation

@tcharding
Copy link
Contributor

@tcharding tcharding commented May 6, 2021

Description

The transaction builder changed a while ago, looks like some of the example code did not get updated.

Update the transaction creation code to use a mutable builder.

Checklists

All Submissions:

  • I've signed all my commits
  • I followed the contribution guidelines
  • I ran cargo fmt and cargo clippy before committing

@tcharding tcharding marked this pull request as draft May 6, 2021 06:14
@tcharding tcharding marked this pull request as ready for review May 6, 2021 23:08
@afilini
Copy link
Member

afilini commented May 7, 2021

Looks like they are being ignored for some reason, can you also change them to no_run instead so that we can keep them updated going forward?

I did a quick test and there's also another test failing on line 145 which can be trivially fixed (replace None with SignOptions::default())

@tcharding
Copy link
Contributor Author

Thanks for the review, will fix as suggested.

tcharding added 3 commits May 11, 2021 11:10
The transaction builder changed a while ago, looks like some of the
example code did not get updated.

Update the transaction creation code to use a mutable builder.
We have an attribute `no_run` that builds but does not run example code
in Rustdocs, this keeps the examples building as the codebase evolves.

use `no_run` and fix example code so it builds cleanly during test run.
Since we are cleaning up the example code in `lib.rs`; use the `bdk`
project imports stlye in the example code i.e., separate upstream
imports form bdk/crate imports.
@tcharding
Copy link
Contributor Author

@afilini I fixed as suggested including changing all ignores in lib.rs to no_runs (with code fixes). And, for the awesomely anal among us, I fixed the import lines to use dbk project style.

@afilini
Copy link
Member

afilini commented May 11, 2021

I think the CI is failing because the tests use the electrum stuff but they are not feature-gated. It's kinda ugly but there's a way to fix it:

bdk/src/keys/mod.rs

Lines 453 to 472 in 12641b9

#[cfg_attr(
feature = "keys-bip39",
doc = r##"
```rust
use bdk::bitcoin::Network;
use bdk::keys::{DerivableKey, ExtendedKey};
use bdk::keys::bip39::{Mnemonic, Language};
# fn main() -> Result<(), Box<dyn std::error::Error>> {
let xkey: ExtendedKey =
Mnemonic::from_phrase(
"jelly crash boy whisper mouse ecology tuna soccer memory million news short",
Language::English
)?
.into_extended_key()?;
let xprv = xkey.into_xprv(Network::Bitcoin).unwrap();
# Ok(()) }
```
"##
)]

@afilini
Copy link
Member

afilini commented May 12, 2021

Since we have to do the release today and this isn't ready yet I've cherry-picked abbea4b on the release branch, so at least we will have the correct example on the published crate

@tcharding
Copy link
Contributor Author

Wow, this opens a whole can of worms. The lib.rs inner doc comment documents behaviour from the default set of features (as one would expect) but we cannot expect folks to build with the default set of features so we do not currently build these docs. Attempting to use the idea suggested above leads to this error:

note: inner doc comments like this (starting with `//!` or `/*!`) can only appear before items

I don't have the inclination to dig further into this at the moment. Closing this issue for another day.

@tcharding tcharding closed this May 12, 2021
@tcharding tcharding deleted the docs-example branch August 17, 2021 06:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants