-
Notifications
You must be signed in to change notification settings - Fork 12
feat: special transactions #5
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
Merged
Merged
Changes from all commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
b40025d
transaction refactoring
QuantumExplorer fe35ed4
more dashification
QuantumExplorer 0feaf7a
more dashification
QuantumExplorer c32fae6
more refactoring
QuantumExplorer f664b7e
work on special transactions
QuantumExplorer 9ceb221
implemented all decodeable special transactions
QuantumExplorer 84e4d82
much more work on special transactions
QuantumExplorer ac7453c
much more work on special transactions
QuantumExplorer 338af0d
more fixes
QuantumExplorer 2d441b2
more fixes
QuantumExplorer 755bfe0
fixed addresses
QuantumExplorer 946fd3c
more work
QuantumExplorer a69bc4f
added asset lock and credit withdrawal
QuantumExplorer 0e45865
more docs
QuantumExplorer 0570932
small changes
QuantumExplorer 25a48fb
small changes
QuantumExplorer a69a1dc
serde
QuantumExplorer ea479d5
a lot more documentation
QuantumExplorer ad81fbb
a lot more documentation
QuantumExplorer 843ea8a
docs done
QuantumExplorer 1c71f73
derive serve for bls types
fominok 723ebd0
fixed some tests
QuantumExplorer 6f44591
Merge branch 'feat/specialTransactions' of github.com:dashevo/rust-da…
QuantumExplorer 5ae384a
test fixes
QuantumExplorer e3821e6
more fixes
QuantumExplorer 0336a12
more fixes
QuantumExplorer aa3c541
tests passing
QuantumExplorer b5fe289
doc fixes
QuantumExplorer 882ece9
increasing special transaction tests
QuantumExplorer a75322c
more work on tests
QuantumExplorer 049f56c
tx id working
QuantumExplorer de865e9
update service test
QuantumExplorer f223d9a
update registrar test
QuantumExplorer b3efdaa
fixes
QuantumExplorer ed3b042
updated readme
QuantumExplorer 9e1d592
small fix
QuantumExplorer b714c54
remove objc reference
QuantumExplorer 18fb3a9
removed hex requirement
QuantumExplorer e82f7fe
fix std, no-std modes
qrayven 712bfec
enable compilation for rust < 1.48
qrayven d243af1
disabling changed tests
qrayven fb0ec8f
fix addr in embedded tests
qrayven ebabc65
bump down toolchain for fuzzer
qrayven ca2f3d5
fix imports in fuzz tests
qrayven 93d1934
changed to swap bytes
QuantumExplorer 0959eac
changed to swap bytes
QuantumExplorer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,15 +30,18 @@ use hashes::hex::{self, HexIterator}; | |
| use hashes::sha256d; | ||
| use blockdata::opcodes; | ||
| use blockdata::script; | ||
| use blockdata::transaction::{OutPoint, Transaction, TxOut, TxIn}; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What was the problem with
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They got moved to their own files. |
||
| use blockdata::block::{Block, BlockHeader}; | ||
| use blockdata::transaction::outpoint::OutPoint; | ||
| use blockdata::transaction::txin::TxIn; | ||
| use blockdata::transaction::txout::TxOut; | ||
| use blockdata::witness::Witness; | ||
| use network::constants::Network; | ||
| use Transaction; | ||
| use util::uint::Uint256; | ||
|
|
||
| /// The maximum allowable sequence number | ||
| pub const MAX_SEQUENCE: u32 = 0xFFFFFFFF; | ||
| /// How many satoshis are in "one bitcoin" | ||
| /// How many duffs are in "one dash" | ||
| pub const COIN_VALUE: u64 = 100_000_000; | ||
| /// How many seconds between blocks we expect on average | ||
| pub const TARGET_BLOCK_SPACING: u32 = 600; | ||
|
|
@@ -54,14 +57,14 @@ pub const MIN_TRANSACTION_WEIGHT: u32 = 4 * 60; | |
| pub const WITNESS_SCALE_FACTOR: usize = 4; | ||
| /// The maximum allowed number of signature check operations in a block | ||
| pub const MAX_BLOCK_SIGOPS_COST: i64 = 80_000; | ||
| /// Mainnet (bitcoin) pubkey address prefix. | ||
| pub const PUBKEY_ADDRESS_PREFIX_MAIN: u8 = 0; // 0x00 | ||
| /// Mainnet (bitcoin) script address prefix. | ||
| pub const SCRIPT_ADDRESS_PREFIX_MAIN: u8 = 5; // 0x05 | ||
| /// Test (tesnet, signet, regtest) pubkey address prefix. | ||
| pub const PUBKEY_ADDRESS_PREFIX_TEST: u8 = 111; // 0x6f | ||
| /// Test (tesnet, signet, regtest) script address prefix. | ||
| pub const SCRIPT_ADDRESS_PREFIX_TEST: u8 = 196; // 0xc4 | ||
| /// Mainnet (dash) pubkey address prefix. | ||
| pub const PUBKEY_ADDRESS_PREFIX_MAIN: u8 = 76; // 0x4C | ||
| /// Mainnet (dash) script address prefix. | ||
| pub const SCRIPT_ADDRESS_PREFIX_MAIN: u8 = 16; // 0x10 | ||
| /// Test (testnet, devnet, regtest) pubkey address prefix. | ||
| pub const PUBKEY_ADDRESS_PREFIX_TEST: u8 = 140; // 0x8C | ||
| /// Test (testnet, devnet, regtest) script address prefix. | ||
| pub const SCRIPT_ADDRESS_PREFIX_TEST: u8 = 19; // 0x13 | ||
| /// The maximum allowed script size. | ||
| pub const MAX_SCRIPT_ELEMENT_SIZE: usize = 520; | ||
| /// How may blocks between halvings. | ||
|
|
@@ -80,13 +83,14 @@ pub fn max_money(_: Network) -> u64 { | |
| } | ||
|
|
||
| /// Constructs and returns the coinbase (and only) transaction of the Bitcoin genesis block | ||
| fn bitcoin_genesis_tx() -> Transaction { | ||
| fn dash_genesis_tx() -> Transaction { | ||
| // Base | ||
| let mut ret = Transaction { | ||
| version: 1, | ||
| lock_time: 0, | ||
| input: vec![], | ||
| output: vec![], | ||
| special_transaction_payload: None | ||
| }; | ||
|
|
||
| // Inputs | ||
|
|
@@ -120,11 +124,11 @@ fn bitcoin_genesis_tx() -> Transaction { | |
|
|
||
| /// Constructs and returns the genesis block | ||
| pub fn genesis_block(network: Network) -> Block { | ||
| let txdata = vec![bitcoin_genesis_tx()]; | ||
| let txdata = vec![dash_genesis_tx()]; | ||
| let hash: sha256d::Hash = txdata[0].txid().into(); | ||
| let merkle_root = hash.into(); | ||
| match network { | ||
| Network::Bitcoin => { | ||
| Network::Dash => { | ||
|
QuantumExplorer marked this conversation as resolved.
|
||
| Block { | ||
| header: BlockHeader { | ||
| version: 1, | ||
|
|
@@ -150,7 +154,7 @@ pub fn genesis_block(network: Network) -> Block { | |
| txdata, | ||
| } | ||
| } | ||
| Network::Signet => { | ||
| Network::Devnet => { | ||
|
QuantumExplorer marked this conversation as resolved.
|
||
| Block { | ||
| header: BlockHeader { | ||
| version: 1, | ||
|
|
@@ -186,12 +190,12 @@ mod test { | |
|
|
||
| use network::constants::Network; | ||
| use consensus::encode::serialize; | ||
| use blockdata::constants::{genesis_block, bitcoin_genesis_tx}; | ||
| use blockdata::constants::{genesis_block, dash_genesis_tx}; | ||
| use blockdata::constants::{MAX_SEQUENCE, COIN_VALUE}; | ||
|
|
||
| #[test] | ||
| fn bitcoin_genesis_first_transaction() { | ||
| let gen = bitcoin_genesis_tx(); | ||
| let gen = dash_genesis_tx(); | ||
|
|
||
| assert_eq!(gen.version, 1); | ||
| assert_eq!(gen.input.len(), 1); | ||
|
|
@@ -213,7 +217,7 @@ mod test { | |
|
|
||
| #[test] | ||
| fn bitcoin_genesis_full_block() { | ||
| let gen = genesis_block(Network::Bitcoin); | ||
| let gen = genesis_block(Network::Dash); | ||
|
|
||
| assert_eq!(gen.header.version, 1); | ||
| assert_eq!(gen.header.prev_blockhash, Default::default()); | ||
|
|
@@ -241,8 +245,8 @@ mod test { | |
| } | ||
|
|
||
| #[test] | ||
| fn signet_genesis_full_block() { | ||
| let gen = genesis_block(Network::Signet); | ||
| fn devnet_genesis_full_block() { | ||
| let gen = genesis_block(Network::Devnet); | ||
| assert_eq!(gen.header.version, 1); | ||
| assert_eq!(gen.header.prev_blockhash, Default::default()); | ||
| assert_eq!(format!("{:x}", gen.header.merkle_root), | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.