-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Bitcoin/Rust] Add support for creating Ordinal NFT inscriptions (#3297)
* expand comment on MIME data prefix in the construction of ordinal inscription * add NFT module * update comment on push_opcode * add test for NFT inscription * expand full list of inscription types * compare NFT inscription test data with expected values * avoid splitting expected values into individual consts, use slices directly * fix warnings * rename new_image to just new * add tw_build_nft_inscription FFI function * test tw_build_nft_inscription FFI function * test protobuf NFT inscriptions * rename ImageType to MimeType * rename TW::Rust::tw_build_brc20_inscribe_transfer to TW::Rust::tw_build_brc20_transfer_inscription in Script.cpp * bitcoin-nft-inscriptions * add Script::buildNftInscription to CXX files, include correct path to MimeType * add CXX test for SignNftInscription * add CXX test SignNftInscriptionReveal * expand C interfaces with NFT inscription construction * track TWBitcoinOrdinalsMimeType.h * add Swift tests for NFT inscription * track TWOrdMimeType.h * correctly set payload when reading from file * compare substrings * avoid var name reuse * add nft inscription hex data of image and expected output * small cleanup * replace TW::Rust::MimeType with TWOrdMimeType * pass raw integer to Rust, derived from enum variant * reverse txId for Swift tests * trigger CI * run cargo fmt * revert Podlock and update rust/coverage.stats * update wallet-core-kotlin version in kmp * clear todos * rename tw_build_nft_inscription to tw_build_ordinal_nft_inscription * remove Foundation import in Swift tests * add Ordinal prefix to Nft inscriptions where appropriate, deprecate MimeType enum and use strings directly * pass mime type as string from C++ to Rust * rename tw_build_ordinal_nft_inscription to tw_bitcoin_build_nft_inscription, fix CoinType import issue * update wallet-core-kotlin * update Pods in samples * run cargo fmt * update pods in swift/ and swift/Example * fix how mime type is passed in swift tests * pass string directly to Rust functions * undo pod changes in samples * run cargo fmt * embed image content and raw transaction in CPP file directly * embed image as raw hex in Rust * add embedded data in CPP files into separate file
- Loading branch information
Showing
23 changed files
with
2,236 additions
and
47 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
@@ -1 +1 @@ | ||
87.8 | ||
86.4 |
This file contains 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 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 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 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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use crate::ordinals::OrdinalsInscription; | ||
use crate::{Recipient, Result}; | ||
use bitcoin::PublicKey; | ||
|
||
pub struct OrdinalNftInscription(OrdinalsInscription); | ||
|
||
impl OrdinalNftInscription { | ||
// Constructs an [Ordinal inscription] with a given MIME type. Common MIME | ||
// types are: | ||
// * "application/json", | ||
// * "application/pdf", | ||
// * "image/gif", | ||
// * "image/jpeg", | ||
// * "image/png", | ||
// * "text/plain;charset=utf-8" | ||
// * ... | ||
// | ||
// [Ordinal inscription]: https://docs.ordinals.com/inscriptions.html | ||
pub fn new(mime_type: &[u8], data: &[u8], recipient: Recipient<PublicKey>) -> Result<Self> { | ||
OrdinalsInscription::new(mime_type, data, recipient).map(OrdinalNftInscription) | ||
} | ||
pub fn inscription(&self) -> &OrdinalsInscription { | ||
&self.0 | ||
} | ||
} |
This file contains 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 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
Oops, something went wrong.