<p><code>createTX()</code> doesn't sign the transaction. That is performed by <code>sign()</code> in <code>wallet.js</code>. If your private keys are offline anyway, what kind of unexpected behavior are you getting from <code>createTX()</code>? It wouldn't be able to sign without the keys...?</p>

<p>New functionality was also recently merged to return the MTX <em>before</em> the input scripts are templated (when the public keys are serialized and added to the witness): <a href="https://github.com/bcoin-org/bcoin/pull/557" rel="nofollow noreferrer">https://github.com/bcoin-org/bcoin/pull/557</a> I'm not sure if this helps out your use-case though.</p>

<p>You also might be interested in our own multisig wallet, bmultisig: <a href="https://github.com/bcoin-org/bmultisig" rel="nofollow noreferrer">https://github.com/bcoin-org/bmultisig</a></p>

<p>This application "plugs in" to the standard bcoin wallet (and full node) and offers hardware support like signing transactions from a Ledger device. Each counterparty of course can sign with their own hardware device at their own convenience. </p>

CC BY-SA 4.0
2019-07-17T00:20:23.833Z
Thank you @pinhead. You are right, I forgot that the private key is not in the wallet. I was considering using an MTX and using `fund()` to get the coins from the wallet, but `createTX()` would be a better choice. Thank you for suggesting bmultisig. This is probably what we need. We are expecting to use AWS HSM for signing. If you have any references or material in this regard I would really appreciate if you can share them. Thanks so much again.
madu
CC BY-SA 4.0
2019-07-16T21:18:21.370Z
2019-07-16T21:18:21.370Z
pinhead
<p>I have a multisig setup where the signing is done through external HSM's.
I am using Bcoin and its wallet to receive funds.
What I am trying to do is to create a transaction and sign it with the HSMs.
There are 2 approaches:</p>

<ol>
<li>Manually create the transaction using MTX.</li>
<li>Use the wallet to create the transaction.</li>
</ol>

<p>Method #1 solves my problem. The code is even shown <a href="https://bcoin.io/guides/multisig-tx.html" rel="nofollow noreferrer">here</a>.
However, this method has a big drawback. It requires that I create the Coins. That means, I need to manually create the VOuts and VIns. Meaning that I need to get my UTXO set and choose the ones I need for the transaction. This is very tedious and error prone.</p>

<p>Method #2 solves this issue. When using the wallet, <code>createTx()</code> will create the transaction for you, choosing the VOuts and VIns from the UTXO set for that wallet. However, the problem with this approach is that <code>createTX()</code> signs the transaction. I do not want this as the signing needs to be done by other sources.</p>

<p>So, is there a way for me to get the raw transaction from a wallet without it signing?
<code>MTX</code> has the method <code>toRaw()</code> which gives the raw transaction. Is there any way I can get the wallet to create the transaction, or at least create the VOut/Vin sets?</p>

<p>Thank you.</p>

<transactions><wallet><createrawtransaction><signrawtransaction><bcoin>
Create a transaction from a wallet coins (UTXOs) with the bcoin library
madu
# Create a transaction from a wallet coins (UTXOs) with the bcoin library

(Asked by: username_0 on 2019-07-11)

I have a multisig setup where the signing is done through external HSM's.
I am using Bcoin and its wallet to receive funds.
What I am trying to do is to create a transaction and sign it with the HSMs.
There are 2 approaches:

1. Manually create the transaction using MTX.
2. Use the wallet to create the transaction.

Method #1 solves my problem. The code is even shown [here](https://bcoin.io/guides/multisig-tx.html).
However, this method has a big drawback. It requires that I create the Coins. That means, I need to manually create the VOuts and VIns. Meaning that I need to get my UTXO set and choose the ones I need for the transaction. This is very tedious and error prone.

Method #2 solves this issue. When using the wallet, `createTx()` will create the transaction for you, choosing the VOuts and VIns from the UTXO set for that wallet. However, the problem with this approach is that `createTX()` signs the transaction. I do not want this as the signing needs to be done by other sources.

So, is there a way for me to get the raw transaction from a wallet without it signing?
`MTX` has the method `toRaw()` which gives the raw transaction. Is there any way I can get the wallet to create the transaction, or at least create the VOut/Vin sets?

Thank you.

**Tags:** transactions, wallet, createrawtransaction, signrawtransaction, bcoin


---

## 1 answers

### Answer by username_1 on 2019-07-16. Score: 1 | Accepted answer

`createTX()` doesn't sign the transaction. That is performed by `sign()` in `wallet.js`. If your private keys are offline anyway, what kind of unexpected behavior are you getting from `createTX()`? It wouldn't be able to sign without the keys...?

New functionality was also recently merged to return the MTX *before* the input scripts are templated (when the public keys are serialized and added to the witness): <https://github.com/bcoin-org/bcoin/pull/557> I'm not sure if this helps out your use-case though.

You also might be interested in our own multisig wallet, bmultisig: <https://github.com/bcoin-org/bmultisig>

This application "plugs in" to the standard bcoin wallet (and full node) and offers hardware support like signing transactions from a Ledger device. Each counterparty of course can sign with their own hardware device at their own convenience.

> **Comments:**
> **username_0**: Thank you @username_1. You are right, I forgot that the private key is not in the wallet. I was considering using an MTX and using `fund()` to get the coins from the wallet, but `createTX()` would be a better choice. Thank you for suggesting bmultisig. This is probably what we need. We are expecting to use AWS HSM for signing. If you have any references or material in this regard I would really appreciate if you can share them. Thanks so much again.  

---

