# Bitcoin

## **getBitcoinSignedTransaction**

The D'CENT Android SDK provides functions for signing transaction of coins.

**This function for :**

* `BITCOIN` (BTC) - bitcoin
* `BITCOIN_SV` (BSV) - bitcoin sv
* `BTC_SEGWIT` (BTC) - bitcoin segwit
* `MONACOIN` (MONA) - monacoin
* `LITECOIN` (LTC) - litecoin
* `LTC_SEGWIT` (LTC) - litecoin segwit
* `ZCASH` (ZEC) - zcash
* `HORIZEN` (ZEN) - horizen
* `BITCOINCASH` (BCH) - bitcoin cash
* `DOGECOIN` (DOGE) - dogecoin
* `BITCOINABC` (BCHA) - bitcoin cash abc
* `ECASH` (XEC) - ecash
* `DASH` (DASH) - dash
* `BITCOIN_GOLD` (BTG) - bitcoin gold
* `DIGIBYTE` (DGB) - digibyte
* `DGB_SEGWIT` (DGB)- digibyte segwit
* `RAVENCOIN` (RVN) - ravencoin
* `BITCOIN_TESTNET` (BTCt) - bitcoin testnset
* `BTC_SEGWIT_TESTNET` (BTCt) - bitcoin segwit testnet
* `MONACOIN_TESTNET` (MONAt) - monacoin testnet
* `LITE_TESTNET` (tLTC) - litecoin testnet
* `LTC_SEGWIT_TESTNET` (tLTC) - litecoin segwit testnet
* `ZCASH_TESTNET` (TAZ) - zcash testnet
* `BCH_TESTNET` (tBCH)- bitocin cash testnet
* `DASH_TESTENET` (tDASH) - dash testnet
* `BTG_TESTNET` (tBTG) - bitcoin gold testnet
* `DIGIBYTE_TESTNET` (tDGB) - digibyte testnet
* `DGB_SEGWIT_TESTNET` (tDGB) - digibyte segwit testnet
* `RVN_TESTNET` (tRVN) - ravencoin testnet

### **Parameters**

| Parameter   | Type                                            | Description                     |
| ----------- | ----------------------------------------------- | ------------------------------- |
| coinType    | `CoinType`                                      | bitcoin coin type.              |
| transaction | [BitCoinTransaction](#class-bitcointransaction) | bitcoin transaction parameters. |

#### **class BitCoinTransaction**

This class to be used for bitcoin transaction.

<table><thead><tr><th width="167.33333333333331">Name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td>version</td><td><code>int</code></td><td>version of bitcoin transaction. Currently 1<br>- <code>BCH</code> / <code>Dash</code> /<code>BTG</code> -> <code>2</code><br>- <code>ZCASH</code> -> <code>4</code></td></tr><tr><td>input</td><td><code>List&#x3C;</code><a href="#class-unspenttransactionoutput"><code>UnspentTransactionOutput</code></a><code>></code></td><td>previous transaction output information to be used</td></tr><tr><td>output</td><td><code>List&#x3C;</code><a href="#class-transactionoutput"><code>TransactionOutput</code></a><code>></code></td><td>coin spending information</td></tr><tr><td>locktime</td><td><code>int</code></td><td>locktime for this transaction</td></tr><tr><td>optionParam</td><td><code>String</code></td><td>(optional)option parameter</td></tr></tbody></table>

#### **class UnspentTransactionOutput**

The class for previous transaction output information to be used for bitcoin network transaction.

<table><thead><tr><th width="148.33333333333331">Name</th><th width="168">Type</th><th>Description</th></tr></thead><tbody><tr><td>prev_tx</td><td><code>String</code></td><td>full of previous transaction data</td></tr><tr><td>utxo_idx</td><td><code>int</code></td><td>index of previous transaction output to be sent</td></tr><tr><td>type</td><td><code>String</code></td><td>bitcoin transaction type for this UTXO</td></tr><tr><td>key</td><td><code>Bip44KeyPath</code></td><td>BIP44 key path for unlocking UTXO</td></tr></tbody></table>

#### class TransactionOutput

The class for coin spending information of Bitcoin network Transaction

<table><thead><tr><th width="121.33333333333331">Name</th><th width="175">Type</th><th>Description</th></tr></thead><tbody><tr><td>value</td><td><code>long</code></td><td>amount of coin to spend. Satoshi unit.</td></tr><tr><td>to</td><td><code>List&#x3C;String></code></td><td>if <code>type</code> is <code>p2pkh</code> or <code>p2sh</code>, Base58Check encoded address of the receiver.<br>The value of the field may follow the rule of version prefix.(<code>BITCOIN_BASE58CHECK</code>)<br>if the type is <code>p2pk</code>, Base58Check encoded non-compressed public key without version prefix.<br>if the type is <code>multisig</code>, Base58Check encoded non-compressed public key (without version prefix) list.<br>if the type is <code>change</code>, BIP44 formatted PATH to get change address. In this case, the transaction type is assumed as <code>p2pkh</code></td></tr><tr><td>type</td><td><code>String</code></td><td>bitcoin network transaction type or this field can indicate output as a <code>change</code></td></tr></tbody></table>

### **Returns**

`String` - signed transaction.j

### **Requirements**

* Refer to [D\`CENT Firmware Update History](https://dcentwallet.com/support/FirmwareUpdate) to determine which D'CENT Biometric Wallet versions are supported on each network.

**Example**

```java
UnspentTransactionOutput utxo = new UnspentTransactionOutput("01000000012b09bd990adc6792588225486c336fb2090890341fcbc6ae92c440c3bd266b98010000006a47304402201df6bd2294f9d51496c1be7ea09431fcfee4b0ca9359712c2c381aff9b2d6f070220595a5bb4e9f0f0d1f5fb9a800224c01ac99058d9b491cd7e6a60145bbd26ddca0121028cbb73e589f81937784eaf728cd14ad27984e5415766c04408211af8d9e30ee7ffffffff0127810000000000001976a9141c7254fac600ef7371664a613f0323c6c641cbd288ac00000000", 0, BitCoinTransaction.TxType.p2pkh, Bip44KeyPath.valueOf("m/44'/0'/0'/0/0")) ;

List<UnspentTransactionOutput> input = new ArrayList<>();
input.add(utxo) ;

TransactionOutput txo = new TransactionOutput(10000, Arrays.asList(new String[]{"1Ckii7MpiquSxcmo2ch1UTfQMConz31rpB"}), BitCoinTransaction.TxType.p2pkh  ) ;
List<TransactionOutput> output = new ArrayList<>();
output.add(txo) ;

BitCoinTransaction bitCoinTransaction = new BitCoinTransaction.Builder()
                .version(1)
                .input(input)
                .output(output)
                .locktime(0)
                .build();

String response = mDcentManager.getBitcoinSignedTransaction(CoinType.BITCOIN, bitCoinTransaction);
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://dev-docs.dcentwallet.com/dcent-biometric-wallet-for-mobile/dcent-biometric-sdk-android/bitcoin.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
