• About
  • FAQ
  • Earn Bitcoin while Surfing the net
  • Buy & Sell Crypto on Paxful
Newsletter
Approx Foundation
  • Home
    • Home – Layout 1
  • Bitcoin
  • Ethereum
  • Regulation
  • Market
  • Blockchain
  • Business
  • Guide
  • Contact Us
No Result
View All Result
  • Home
    • Home – Layout 1
  • Bitcoin
  • Ethereum
  • Regulation
  • Market
  • Blockchain
  • Business
  • Guide
  • Contact Us
No Result
View All Result
Approx Foundation
No Result
View All Result
Home Bitcoin

ordinals – I can’t create NFT because “`mandatory-script-verify-flag-failed (Invalid Schnorr signature)”}“`?

Moussa by Moussa
February 1, 2025
in Bitcoin
0
peer discovery – how to obtain the IP addresses of nodes for mining pools?
189
SHARES
1.5k
VIEWS
Share on FacebookShare on Twitter


I create collection successfully but I can’t create nft

import * as ecc from 'tiny-secp256k1';
import * as bitcoin from "bitcoinjs-lib";
import * as cbor from 'cbor';
import { Wallet } from "./wallet";
import { Client } from "./client";
import { tweakSigner } from './utils';

bitcoin.initEccLib(ecc);

const SEND_UTXO_LIMIT = 100;

const TESTNET_FEERATE = 20;

export class Nft extends Client {
  collectionAddress: string;
  parentInscriptionTXID: string;
  
  constructor({ collectionAddress, parentInscriptionTXID }) {
    super();
    this.collectionAddress = collectionAddress;
    this.parentInscriptionTXID = parentInscriptionTXID;
  }

  async deploy(wallet: Wallet, { metadata, commonContentUrl,  itemOwnerAddress }) {
    const txidBuffer = Buffer.from(this.parentInscriptionTXID, 'hex');
    const inscriptionBuffer = txidBuffer.reverse();
    
    const metaProtocol: Buffer = Buffer.concat([Buffer.from("parcel.bitmap", "utf8")]);

    const pointer1: number = 546 * 1;
    const pointerBuffer1: Buffer = Buffer.from(pointer1.toString(16).padStart(4, '0'), 'hex').reverse();

    const contentBufferData: Buffer = this.contentBuffer(commonContentUrl);
    const contentBufferArray: Array = this.splitBuffer(contentBufferData, 400);

    const ordinal_script = this.createTapscript({
      metadata, 
      publicKey: wallet.internalPubkey,
      inscriptionBuffer,
      pointerBuffer1: pointerBuffer1,
      metaProtocol,
      contentBufferArray
    });

    const scriptTree = {
      output: ordinal_script,
    };

    const redeem = {
      output: ordinal_script,
      redeemVersion: 192,
    };

    const internalPubkey = wallet.internalPubkey;

    const ordinal_p2tr = bitcoin.payments.p2tr({
      internalPubkey,
      network: wallet.network,
      scriptTree,
      redeem,
    });

    let utxos, utxo, psbt;
    // utxos = await this.getUTXO(wallet.address);
    // utxo = utxos.find((utxo) => utxo.value > SEND_UTXO_LIMIT);
    // if (utxo === undefined) throw new Error("No btcs");
    // let redeemPsbt = wallet.redeemSendUTXOPsbt(utxo);
    // redeemPsbt = wallet.signPsbt(redeemPsbt);
    // let redeemFee = redeemPsbt.extractTransaction().virtualSize();
    // //4532b27cf67d922318ad473b601a67192ee212679e39e50130cdc517d3595c44
    // psbt = wallet.sendUTXOPsbt(utxo, redeemFee, ordinal_p2tr.address);
    // let signerOfPsbt = wallet.signPsbt(psbt)
    // const txHex = signerOfPsbt.extractTransaction().toHex();
    // await this.sendTransaction(txHex);

    // Получаем UTXO
    utxos = await this.getUTXO(ordinal_p2tr.address);

    // console.log(await this.waitUntilUTXO(ordinal_p2tr.address));
    if (!utxos || utxos.length === 0) {
      throw new Error("No UTXOs found.");
    }
  
    utxo = utxos.find((utxo: any) => utxo.value > SEND_UTXO_LIMIT);
    if (utxo === undefined) throw new Error("No btcs");
    psbt = new bitcoin.Psbt({ network: wallet.network });
    //tb1ppfqcpem2kd0l9dymat0uxdtv54cz4npty87yk2ctnj6vtk47zxjs9xac6d\


    //const parentInscriptionUTXOs = await this.getUtxos(this.collectionAddress);
    // console.log(this.collectionAddress, parentInscriptionUTXOs, "parentInscriptionUTXOs");
    // return;
    const parentInscriptionUTXO = {
      txid: this.parentInscriptionTXID,
      vout: 0,
      value: 526
    }
    psbt.addInput({
      hash: parentInscriptionUTXO.txid,
      index: parentInscriptionUTXO.vout,
      witnessUtxo: {
        value: parentInscriptionUTXO.value,
        script: wallet.output,
      },
      tapInternalKey: internalPubkey
    });

    psbt.addInput({
      hash: utxos[0].txid,
      index: utxos[0].vout,
      tapInternalKey: internalPubkey,
      witnessUtxo: { value: utxos[0].value, script: ordinal_p2tr.output! },
      tapLeafScript: [
        {
          leafVersion: redeem.redeemVersion,
          script: redeem.output,
          controlBlock: ordinal_p2tr.witness![ordinal_p2tr.witness!.length - 1],
        },
      ],
    });

    psbt.addOutput({
      address: itemOwnerAddress, //Destination Address
      value: 546,
    });

    psbt.addOutput({
      address: itemOwnerAddress, //Destination Address
      value: 546,
    });
    const fee = 1200000;

    const change = utxos[0].value - 546 * 1;
    console.log(change, 'change');

    const signer = tweakSigner(wallet, psbt);
    psbt.signInput(0, signer);
    psbt.signInput(1, wallet.keyPair);
    psbt.finalizeAllInputs()
    const tx = psbt.extractTransaction();
    console.log(tx.virtualSize())
    console.log(tx.toHex());
    return this.pushTransaction(tx.toHex());
  }
  
  contentBuffer = (content: string) => {
    return Buffer.from(content, 'utf8')
  }

  splitBuffer = (buffer: Buffer, chunkSize: number) => {
    let chunks = [];
    for (let i = 0; i < buffer.length; i += chunkSize) {
      const chunk = buffer.subarray(i, i + chunkSize);
      chunks.push(chunk);
    }
    return chunks;
  };

  createTapscript({
    metadata,
    publicKey,
    inscriptionBuffer,
    pointerBuffer1,
    metaProtocol,
    contentBufferArray
  }) {
    const metadataBuffer = cbor.encode(metadata);
    const childOrdinalStacks = [
      publicKey,
      bitcoin.opcodes.OP_CHECKSIG,
      bitcoin.opcodes.OP_FALSE,
      bitcoin.opcodes.OP_IF,
      Buffer.from("ord", "utf8"),
      1, 1,
      Buffer.concat([Buffer.from("text/plain;charset=utf-8", "utf8")]),
      1, 2,
      pointerBuffer1,
      1, 3,
      inscriptionBuffer,
      1, 5,
      metadataBuffer,
      1, 7,
      metaProtocol,
      bitcoin.opcodes.OP_0,
    ];

    contentBufferArray.forEach((item: Buffer) => {
      childOrdinalStacks.push(item)
    });
    childOrdinalStacks.push(bitcoin.opcodes.OP_ENDIF)
    console.log(childOrdinalStacks);
    return bitcoin.script.compile(childOrdinalStacks);
  }
}

My hash
020000000001022f46fff10752aca1cf98a36f0176f4cbbdb22cc510d4ceddc972b76d0ce2cd020000000000ffffffff3a28cb2ac63846cdb0751c3ce87b2745a4a4bbdbeb85e02225e2d8b952eee18d0000000000ffffffff022202000000000000225120932a0391d2ec13cb8f303ded9297ece089f739b3ced40bc98eebdd277fdb9c9d2202000000000000225120932a0391d2ec13cb8f303ded9297ece089f739b3ced40bc98eebdd277fdb9c9d014070a9429d26549e9c451f0ae1ea4855b7d7bbcd2f726179b72ca227c26c2833fad94026a13d25e23870d472a7013f395b3840b1fe6bcd86eb8d75189bf88eb9510340ba9b3c4973046074ab49faca606e09874fc7b43abccaccca15ce29d35fcae62eac1dadc4fb460b0342d5431972d7f2a86160325c0e5dec831182adf376ff8545e8206705021108c86f6f7249e85d233414afa8eeaadaea2bad863b2ccce504126879ac0063036f7264010118746578742f706c61696e3b636861727365743d7574662d3801020222020103202f46fff10752aca1cf98a36f0176f4cbbdb22cc510d4ceddc972b76d0ce2cd02010528a264747970656b54657374204e46542023316b6465736372697074696f6e6954657374205465737401070d70617263656c2e6269746d6170003f68747470733a2f2f617277656176652e6e65742f4933326c517668673341514c583444632d334e48557773434e366e75382d6c78477352634e7765336372346821c06705021108c86f6f7249e85d233414afa8eeaadaea2bad863b2ccce50412687900000000

Collection address tb1ptewa8cpn7a9562s8saakyqdtlm34q6xjx7d7vp8x99sxx7kr8resvfp9x6
Parent Inscription Tx 02cde20c6db772c9ddced410c52cb2bdcbf476016fa398cfa1ac5207f1ff462f



Source link

Related articles

CFTC Cracks Open U.S. Market For Bitcoin And Crypto Perpetual Futures

CFTC Says Agency Will Write Rules Following Clarity Act Fail

September 16, 2026
Bitcoin Price Holds $75,500 as Traders Price In Fed Rate Hike

Bitcoin Price Holds $75,500 as Traders Price In Fed Rate Hike

September 16, 2026
Share76Tweet47

Related Posts

CFTC Cracks Open U.S. Market For Bitcoin And Crypto Perpetual Futures

CFTC Says Agency Will Write Rules Following Clarity Act Fail

by Moussa
September 16, 2026
0

Commodity Futures Trading Commission Chair Mike Selig has said that the top regulator will go ahead and use its powers...

Bitcoin Price Holds $75,500 as Traders Price In Fed Rate Hike

Bitcoin Price Holds $75,500 as Traders Price In Fed Rate Hike

by Moussa
September 16, 2026
0

Key TakeawaysBitcoin’s price fell below $75,000 as a failed CLARITY Act vote in Congress sparked over $140 million in liquidations.Crypto...

AI Prediction Market Odds: A 25% Bet on a Bot Being Killed Over Safety Concerns

AI Prediction Market Odds: A 25% Bet on a Bot Being Killed Over Safety Concerns

by Moussa
September 16, 2026
0

OpenAI’s global policy chief Chris Lehane confirmed on Tuesday that OpenAI has spent several weeks discussing AI safety with rivals...

Over 38 Million USDT in Risk-Related Funds Intercepted, Futures Insurance Fund Reaches 792 Million USDT

Over 38 Million USDT in Risk-Related Funds Intercepted, Futures Insurance Fund Reaches 792 Million USDT

by Moussa
September 16, 2026
0

Mutsamudu, Comoros, September 16, 2026 – MEXC, a pioneer in 0-fee digital asset trading, has released its July–August 2026 security...

How MSCI Shifted From Objective Benchmark To Defacto Market Regulator

How MSCI Shifted From Objective Benchmark To Defacto Market Regulator

by Moussa
September 16, 2026
0

For decades, the mechanics of global equity indexing were treated as plumbing—hidden, technical, and resolutely administrative. Providers like Morgan Stanley...

Load More

youssufi.com

sephina.com

[vc_row full_width="stretch_row" parallax="content-moving" vc_row_background="" background_repeat="no-repeat" background_position="center center" footer_scheme="dark" css=".vc_custom_1517813231908{padding-top: 60px !important;padding-bottom: 30px !important;background-color: #191818 !important;background-position: center;background-repeat: no-repeat !important;background-size: cover !important;}" footer_widget_title_color="#fcbf46" footer_button_bg="#fcb11e"][vc_column width="1/4"]

We bring you the latest in Crypto News

[/vc_column][vc_column width="1/4"][vc_wp_categories]
[/vc_column][vc_column width="1/4"][vc_wp_tagcloud taxonomy="post_tag"][/vc_column][vc_column width="1/4"]

Newsletter

[vc_raw_html]JTNDcCUzRSUzQ2RpdiUyMGNsYXNzJTNEJTIydG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TIyY2hlY2tib3glMjIlMjBuYW1lJTNEJTIybnklMjIlMjByZXF1aXJlZCUyMGNsYXNzJTNEJTIydG5wLXByaXZhY3klMjIlM0UlQzIlQTBCeSUyMGNvbnRpbnVpbmclMkMlMjB5b3UlMjBhY2NlcHQlMjB0aGUlMjBwcml2YWN5JTIwcG9saWN5JTNDJTJGbGFiZWwlM0UlM0MlMkZkaXYlM0UlM0NkaXYlMjBjbGFzcyUzRCUyMnRucC1maWVsZCUyMHRucC1maWVsZC1idXR0b24lMjIlM0UlM0NpbnB1dCUyMGNsYXNzJTNEJTIydG5wLXN1Ym1pdCUyMiUyMHR5cGUlM0QlMjJzdWJtaXQlMjIlMjB2YWx1ZSUzRCUyMlN1YnNjcmliZSUyMiUyMCUzRSUwQSUzQyUyRmRpdiUzRSUwQSUzQyUyRmZvcm0lM0UlMEElM0MlMkZkaXYlM0UlM0NiciUyRiUzRSUzQyUyRnAlM0U=[/vc_raw_html][/vc_column][/vc_row]
No Result
View All Result
  • Contact Us
  • Homepages
  • Business
  • Guide

© 2024 APPROX FOUNDATION - The Crypto Currency News