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

When I build and sign a BTC transaction, it defaults to type 1. Is it possible to build and sign a type 2 BTC transaction using Wallet Core? #119

Closed
Hilde-IT opened this issue Aug 29, 2024 · 1 comment

Comments

@Hilde-IT
Copy link

When I build and sign a BTC transaction, it defaults to type 1. Is it possible to build and sign a type 2 BTC transaction using Wallet Core?
image

This is how I'm building the tx, how can I convert it to type 2? Btw, is there any advantage to using transaction type 2?

      //BUILD TX
            val scriptUTXO = BitcoinScript.lockScriptForAddress(addressFrom, CoinType.BITCOIN)
            val scriptHash = scriptUTXO.matchPayToWitnessPublicKeyHash()
            val redeemScriptHash = scriptHash.toHexString()
            val redeemScript = BitcoinScript.lockScriptForAddress(addressFrom, CoinType.BITCOIN).data()

            //INPUT
            val input = Bitcoin.SigningInput.newBuilder().apply {
                this.amount = amount       //1962973
                if (maxAmount) {
                    this.useMaxAmount = true //auto-sweep
                }
                this.hashType = BitcoinSigHashType.ALL.value()
                this.toAddress = addressToTss //Receiver ADDRESS (TO) MUST BE TSS
                this.changeAddress = changeAddressLeftOver.ifEmpty { addressFrom } //LEFT OVER
                this.byteFee = byteFee.toLong()
                this.coinType = CoinType.BITCOIN.value()
                this.fixedDustThreshold = 1000 // or 546 for P2PKH, P2WPKH transfers
                this.dustPolicyCase
                //this.disableDustFilter = true
                this.addPrivateKey(ByteString.copyFrom(hexPrivateKey.hexStringToByteArray()))  //HEX
            }
            input.putScripts(redeemScriptHash, ByteString.copyFrom(redeemScript))

Originally posted by @ronaldoguedess in trustwallet/wallet-core#3874

@twaik
Copy link
Member

twaik commented Aug 29, 2024

Not related to termux.

@twaik twaik closed this as not planned Won't fix, can't repro, duplicate, stale Aug 29, 2024
@termux termux locked as spam and limited conversation to collaborators Aug 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants