Bitcoin

Sign Transaction

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

getBitcoinSignedTransaction()

Supported Coin Type

  • BITCOIN

  • MONACOIN

Parameters :

  • transaction: this value generated by getBitcoinTransactionObject()

Usage:

// generate Bitcoin Transaction object
let transaction = DcentWebConnector.getBitcoinTransactionObject(dcent.coinType.BITCOIN)
// Set input parameter(previous tx) in Bitcoin Transaction object
transaction = DcentWebConnector.addBitcoinTransactionInput(transaction,
    '0100000001e297417c46........293fce63b88ac00000000', //  full of previous tx data
    1, // index of previous tx output to be sent
    dcent.bitcoinTxType.p2pkh, // bitcoin tx type for this UTXO
    "m/44'/0'/0'/1/0") // signing key path
transaction = DcentWebConnector.addBitcoinTransactionInput(transaction,
    '0100000001e297417c46.........93fce63b88ac00000000',
    0,
    dcent.bitcoinTxType.p2pkh,
    "m/44'/0'/0'/0/7")
// Set output parameter(spending information) in Bitcoin Transaction object
transaction = DcentWebConnector.addBitcoinTransactionOutput(transaction,
        dcent.bitcoinTxType.p2pkh, // transaction type or this field can indicate output as a “change”
        '10000', // amount of coin to spend. Satoshi unit.
        ['1traqiFvydVk2hWdCj3WGRJbe4CGtfyHA']) // Base58Check encoded address of the receiver.
    result = await DcentWebConnector.getBitcoinSignedTransaction(transaction)

Returned response object:

{
    "header": {
        "version": "1.0",
        "response_from": "erc20",
        "status": "success"
    },
    "body": {
        "command": "transaction",
        "parameter": {
            "signed": "0100000002233ee1fbcf.....71e088ac00000000"
        }
    }
}

Last updated