Skip to content
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

[Rust/Bitcoin/Utxo] Create tw_utxo and Proto structures #3351

Closed
wants to merge 2 commits into from
Closed

Conversation

lamafab
Copy link
Contributor

@lamafab lamafab commented Aug 4, 2023

First part of #3339 (still have a bunch of comments to add)

My working branch is messy right now, so this branch only contains the changes related to tw_utxo, plus the Utxo.proto. Will keep merging changes from my working branch to this branch. Regarding the tests: I just reused the ones in tw_bitcoin, but ideally I should create clean transactions using bitcoind -regtest.

@MaximPestryakov MaximPestryakov self-requested a review August 8, 2023 10:20
// The sequence number (TODO).
uint32 sequence = 7;

oneof sighash_method {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noob question. Shouldn't we also have P2SH here?

Copy link
Contributor Author

@lamafab lamafab Aug 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method (which I now renamed to signing_method) is only from the perspective of the Utxo structure which is not aware of any transaction standards (such as P2PKH, P2WPKH, etc). That field only tells this crate how to sign the input, such as "legacy" for P2SH/P2PKH, "segwit" for P2WPKH, etc. The Bitcoin input structure will look like this:

message Input {
	bytes txid = 1;

	uint32 vout = 2;

	uint64 amount = 3;

	Utxo.Proto.SighashType sighash_type = 4;

	oneof to_recipient {
		Builder builder = 5;
		ScriptWitness custom = 6;
	}

	// TODO: This should only be exposed for taproot
	bool one_prevout = 7;

	message Builder {
		oneof variant {
			// Pay-to-Script-Hash, specify the redeem script.
			bytes p2sh = 1;
			// Pay-to-Public-Key-Hash, specify the public key.
			bytes p2pkh = 2;
			// Pay-to-Witness-Script-Hash, specify the redeem script.
			bytes p2wsh = 3;
			// Pay-to-Public-Key-Hash, specify the public key.
			bytes p2wpkh = 6;
			// Pay-to-Taproot-key-path (balance transfers), specify the public key.
			bytes p2tr_key_path = 7;
			// Pay-to-Taproot-script-path (complex transfers)
			TaprootScriptPath p2tr_script_path = 8;
			Brc20Inscription brc20_inscribe = 9;
		}
	}

	message ScriptWitness {
		bytes script_sig = 1;
		repeated bytes witness_items = 2;
	}

	message TaprootScriptPath {
		bytes payload = 1;
		bytes control_block = 2;
	}

	message Brc20Inscription {
		bytes inscribe_to = 1;
		string ticker = 2;
		uint64 transfer_amount = 3;
	}
}

I will update everything of Friday evening.

@lamafab
Copy link
Contributor Author

lamafab commented Aug 17, 2023

Closing in favor of #3382

@lamafab lamafab closed this Aug 17, 2023
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.

None yet

2 participants