signTransaction returns TransactionBuilder
This commit is contained in:
@@ -293,7 +293,7 @@ export class WalletHD extends BaseWallet {
|
||||
|
||||
async signTransaction(
|
||||
txTemplate: Partial<TransactionTemplate>,
|
||||
): Promise<Uint8Array> {
|
||||
): Promise<TransactionBuilder> {
|
||||
// Populate the final transaction template by merging with defaults.
|
||||
// NOTE: This is just a convenience to make "send" easier to use.
|
||||
const txTemplateFinal: TransactionTemplate = {
|
||||
@@ -317,21 +317,19 @@ export class WalletHD extends BaseWallet {
|
||||
const unspents = await this.getUnspentDirectives();
|
||||
|
||||
// Build the transaction.
|
||||
const tx = TransactionBuilder.build(
|
||||
return TransactionBuilder.build(
|
||||
txTemplateFinal,
|
||||
unspents.toArray(),
|
||||
changeLockingBytecode,
|
||||
);
|
||||
|
||||
// Generate the transaction.
|
||||
const generatedTxBytes = tx.toBytes();
|
||||
|
||||
return generatedTxBytes;
|
||||
}
|
||||
|
||||
async sendTransaction(txTemplate: Partial<TransactionTemplate>) {
|
||||
// Sign the transaction template.
|
||||
const generatedTxBytes = await this.signTransaction(txTemplate);
|
||||
// Generate the transaction.
|
||||
const generatedTx = await this.signTransaction(txTemplate);
|
||||
|
||||
// Convert the tx to bytes.
|
||||
const generatedTxBytes = generatedTx.toBytes();
|
||||
|
||||
// Broadcast the transaction to the blockchain.
|
||||
await this.blockchain.broadcastTransaction(generatedTxBytes);
|
||||
|
||||
Reference in New Issue
Block a user