Asks device to sign given inputs and outputs of pre-composed transaction. User is asked to confirm all transaction details on Trezor.
ES6
const result = await TrezorConnect.signTransaction(params);CommonJS
TrezorConnect.signTransaction(params).then(function(result) {
});inputs- obligatoryArrayof TransactionInput,outputs- obligatoryArrayof TransactionOutput,coin- obligatorystringDetermines network definition specified in coins.json file. Coinshortcut,nameorlabelcan be used.push- optionalbooleanBroadcast signed transaction to blockchain. Default is set to false
TrezorConnect.signTransaction({
inputs: [
{
address_n: [44 | 0x80000000, 0 | 0x80000000, 2 | 0x80000000, 1, 0],
prev_index: 0,
prev_hash: 'b035d89d4543ce5713c553d69431698116a822c57c03ddacf3f04b763d1999ac'
}
],
outputs: [
{
address_n: [44 | 0x80000000, 0 | 0x80000000, 2 | 0x80000000, 1, 1],
amount: '3181747',
script_type: 'PAYTOADDRESS'
}, {
address: '18WL2iZKmpDYWk1oFavJapdLALxwSjcSk2',
amount: '200000',
script_type: 'PAYTOADDRESS'
}
],
coin: "btc"
});TrezorConnect.signTransaction({
inputs: [
{
address_n: [49 | 0x80000000, 0 | 0x80000000, 2 | 0x80000000, 1, 0],
prev_index: 0,
prev_hash: 'b035d89d4543ce5713c553d69431698116a822c57c03ddacf3f04b763d1999ac'
amount: '3382047',
script_type: 'SPENDP2SHWITNESS'
}
],
outputs: [
{
address_n: [49 | 0x80000000, 0 | 0x80000000, 2 | 0x80000000, 1, 1],
amount: '3181747',
script_type: 'PAYTOP2SHWITNESS'
}, {
address: '18WL2iZKmpDYWk1oFavJapdLALxwSjcSk2',
amount: '200000',
script_type: 'PAYTOADDRESS'
}
],
coin: "btc"
});{
success: true,
payload: {
signatures: Array<string>, // Array of signer signatures
serializedTx: string, // serialized transaction
txid?: string, // broadcasted transaction id
}
}Error
{
success: false,
payload: {
error: string // error message
}
}version 4 and below
var inputs = [{
address_n: [44 | 0x80000000, 0 | 0x80000000, 2 | 0x80000000, 1, 0],
prev_index: 0,
prev_hash: 'b035d89d4543ce5713c553d69431698116a822c57c03ddacf3f04b763d1999ac'
}];
var outputs = [{
address_n: [44 | 0x80000000, 0 | 0x80000000, 2 | 0x80000000, 1, 1],
amount: 3181747,
script_type: 'PAYTOADDRESS'
}, {
address: '18WL2iZKmpDYWk1oFavJapdLALxwSjcSk2',
amount: 200000,
script_type: 'PAYTOADDRESS'
}];
TrezorConnect.setCurrency('BTC');
TrezorConnect.signTx(
inputs, // amount field retyped to a string
outputs, // amount field retyped to a string
"example message",
function(result) {
result.signatures // not changed
result.serialized_tx // renamed to "serializedTx"
// added "txid" field if "push" is set to true
},
"bitcoin"
);version 5
// params are key-value pairs inside Object
TrezorConnect.signTransaction({
inputs: [{
address_n: [44 | 0x80000000, 0 | 0x80000000, 2 | 0x80000000, 1, 0],
prev_index: 0,
prev_hash: 'b035d89d4543ce5713c553d69431698116a822c57c03ddacf3f04b763d1999ac'
}],
outputs: [{
address_n: [44 | 0x80000000, 0 | 0x80000000, 2 | 0x80000000, 1, 1],
amount: '3181747',
script_type: 'PAYTOADDRESS'
}, {
address: '18WL2iZKmpDYWk1oFavJapdLALxwSjcSk2',
amount: '200000',
script_type: 'PAYTOADDRESS'
}],
coin: "btc"
}).then(function(result) {
...
})