Post
Topic
Board Electrum
Re: Offline signing with KeepKey or Trezor
by
Bridgewater
on 24/04/2016, 02:20:25 UTC
I got to the same place with a trezor Sad

I think the problem is here.  It even says "FIXME..."
https://github.com/spesmilo/electrum/blob/master/plugins/trezor/plugin.py

Code:
def get_input_tx(self, tx_hash):
        # First look up an input transaction in the wallet where it
        # will likely be.  If co-signing a transaction it may not have
        # all the input txs, in which case we ask the network.
        tx = self.transactions.get(tx_hash)
        if not tx:
            request = ('blockchain.transaction.get', [tx_hash])
            [b]# FIXME: what if offline?[/b]
            tx = Transaction(self.network.synchronous_get(request))
        return tx

    def sign_transaction(self, tx, password):
        if tx.is_complete():
            return
        # previous transactions used as inputs
        prev_tx = {}
        # path of the xpubs that are involved
        xpub_path = {}
        for txin in tx.inputs():
            tx_hash = txin['prevout_hash']
            prev_tx[tx_hash] = self.get_input_tx(tx_hash)
            for x_pubkey in txin['x_pubkeys']:
                if not is_extended_pubkey(x_pubkey):
                    continue
                xpub = x_to_xpub(x_pubkey)
                for k, v in self.master_public_keys.items():
                    if v == xpub:
                        acc_id = re.match("x/(\d+)'", k).group(1)
                        xpub_path[xpub] = self.account_derivation(acc_id)

        self.plugin.sign_transaction(self, tx, prev_tx, xpub_path)

See how it has to check for transactions before it will sign?

I was finally able to sign a transaction completely offline, but only by painstakingly copying the transaction history from the online watch-only electrum wallet of the same xpub, then copying it into the wallet of the offline electrum.