Skip to content

Commit

Permalink
Dusty release 1.2.0 (#195)
Browse files Browse the repository at this point in the history
* Bump version

* Fix BTC lock script duration sanity check

* Fix code format

* Fix version
  • Loading branch information
akru authored Jul 7, 2020
1 parent 9be1825 commit 2e99ac0
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 27 deletions.
12 changes: 6 additions & 6 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion bin/node/cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "plasm-cli"
version = "1.1.0"
version = "1.2.0"
authors = ["Stake Technologies <[email protected]>"]
description = "Plasm node implementation in Rust."
build = "build.rs"
Expand Down
2 changes: 1 addition & 1 deletion bin/node/cli/lockdrop-oracle/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "lockdrop-oracle"
version = "1.1.0"
version = "1.2.0"
authors = ["Stake Technologies <[email protected]>"]
edition = "2018"

Expand Down
33 changes: 21 additions & 12 deletions bin/node/cli/lockdrop-oracle/src/btc_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,21 @@ fn bip68_encode(blocks: u32) -> u32 {
}

/// Compile BTC sequence lock script for givent public key and duration in blocks.
pub fn lock_script(public: &ecdsa::Public, duration: u32) -> Script {
let public_key = PublicKey::from_slice(public.as_ref()).unwrap();
let blocks = bip68_encode(duration) as i64;
let script = bitcoin_script! {
<blocks>
OP_CSV
OP_DROP
<public_key>
OP_CHECKSIG
};
script.to_p2sh()
pub fn lock_script(public: &ecdsa::Public, duration: u32) -> Result<Script, String> {
if duration > 0 && duration < 65535 {
let public_key = PublicKey::from_slice(public.as_ref()).unwrap();
let blocks = bip68_encode(duration) as i64;
let script = bitcoin_script! {
<blocks>
OP_CSV
OP_DROP
<public_key>
OP_CHECKSIG
};
Ok(script.to_p2sh())
} else {
return Err("Lock duration sanity check failed".to_string());
}
}

pub fn to_address(public: &ecdsa::Public) -> String {
Expand All @@ -42,8 +46,13 @@ mod tests {
let public = ecdsa::Public::from_slice(
&hex!["038ea27103fb646a2cea9eca9080737e0b23640caaaef2853416c9b286b353313e"][..],
);
assert_eq!(
lock_script(&public, 0),
Err("Lock duration sanity check failed".to_string())
);

let duration = 10;
let script = lock_script(&public, duration);
let script = lock_script(&public, duration).unwrap();
let address = Address::from_script(&script, Network::Testnet).unwrap();
assert_eq!(address.to_string(), "2MuJcWGWe8XkPc6h7pt6vQDyaTwDZxKJZ8p");
}
Expand Down
3 changes: 2 additions & 1 deletion bin/node/cli/lockdrop-oracle/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ pub async fn start(config: Config) {

// assembly bitcoin script for given params
let blocks = (lock.duration / 600) as u32;
let lock_script = btc_utils::lock_script(&lock.public_key, blocks);
let lock_script = btc_utils::lock_script(&lock.public_key, blocks)
.map_err(|e| tide::Error::from_str(tide::StatusCode::BadRequest, e))?;
log::debug!(
target: "lockdrop-oracle",
"Lock script address for public ({}), duration({}): {}",
Expand Down
2 changes: 1 addition & 1 deletion bin/node/primitives/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "plasm-primitives"
version = "1.1.0"
version = "1.2.0"
authors = ["Stake Technologies <[email protected]>"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion bin/node/rpc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "plasm-rpc"
version = "1.1.0"
version = "1.2.0"
authors = ["Stake Technologies <[email protected]>"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion bin/node/runtime/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "plasm-runtime"
version = "1.1.0"
version = "1.2.0"
authors = ["Stake Technologies <[email protected]>"]
edition = "2018"
build = "build.rs"
Expand Down
4 changes: 2 additions & 2 deletions bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
// and set impl_version to equal spec_version. If only runtime
// implementation changes and behavior does not, then leave spec_version as
// is and increment impl_version.
spec_version: 2,
impl_version: 2,
spec_version: 3,
impl_version: 3,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
};
Expand Down
2 changes: 1 addition & 1 deletion bin/subkey/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "subkey"
version = "1.1.0"
version = "1.2.0"
authors = ["Parity Technologies <[email protected]>"]
edition = "2018"

Expand Down

0 comments on commit 2e99ac0

Please sign in to comment.