remem9527 / bchmemo

A python package for memo. Memo is an on-chain social network built on Bitcoin Cash (Bitcoincash, BCH)
8 stars 6 forks source link

user.post_memo('sth') throws an error: 'Specify rawtx parameter' #1

Open lubokkanev opened 6 years ago

lubokkanev commented 6 years ago

I'm following the example from the readme, but when I try posting a memo, I keep getting this error:

>>> user.post_memo('sth')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/tmp/memo/bchmemo/memouser.py", line 150, in post_memo
    return self.__send_new_memo(memo)
  File "/tmp/memo/bchmemo/memouser.py", line 128, in __send_new_memo
    txid=memo.send_transaction()
  File "/tmp/memo/bchmemo/memo.py", line 396, in send_transaction
    NetworkAPI.broadcast_tx(self.signed_transaction)
  File "/tmp/memo/bchmemo/bitcash_modified/services.py", line 657, in broadcast_tx
    success = api_call(tx_hex)
  File "/tmp/memo/bchmemo/bitcash_modified/services.py", line 114, in broadcast_tx
    raise Exception(r.content)
Exception: b'Specify rawtx parameter'
>>>
jackmaninov commented 6 years ago

Seems to work if you revert to the upstream bitcash.network.services. In memo.py, replace it like so:

# from bchmemo.bitcash_modified.services import NetworkAPI
from bitcash.network.services import NetworkAPI
lubokkanev commented 6 years ago

user.post_memo() works now, for messages with less than 75 symbols. For 150 I'm getting the following:

  File "./create-memo-transaction-new.py", line 9, in <module>
    user.post_memo("012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789") # 150-symbols
  File "/mnt/x/Dropbox/source-code/java/projects/membo/bchmemo/memouser.py", line 151, in post_memo
    return self.__send_new_memo(memo)
  File "/mnt/x/Dropbox/source-code/java/projects/membo/bchmemo/memouser.py", line 129, in __send_new_memo
    txid=memo.send_transaction()
  File "/mnt/x/Dropbox/source-code/java/projects/membo/bchmemo/memo.py", line 398, in send_transaction
    NetworkAPI.broadcast_tx(self.signed_transaction)
  File "/usr/local/lib/python3.5/dist-packages/bitcash/network/services.py", line 341, in broadcast_tx
    raise ConnectionError('Transaction broadcast failed, or '
ConnectionError: Transaction broadcast failed, or Unspents were already used.

I've changed the hardcoded limit to 217 symbols and made sure I have enough funds.

Also user.get_memos() fails with this:

  File "./bchmemo/memouser.py", line 61, in get_memos
    total_txs,txs=NetworkAPI.get_transactions_by_addresses(self._address)
AttributeError: type object 'NetworkAPI' has no attribute 'get_transactions_by_addresses'
jackmaninov commented 6 years ago

get_transactions_by_addresses is in this repo's bitcash_modified\services.py, so looks like reverting to upstream isn't really a fix. Changes from upstream have to be merged (i.e. the CashExplorerBitcoinDotComAPI class).

I'm also seeing the "Transaction broadcast failed" error message, but this looks like an API failure. Perhaps the Insight API providers don't support BCH's new, longer OP_RETURN.

jackmaninov commented 6 years ago

Yep, definitely an API issue. A long post_memo() leads to an error 400 with text: 64: scriptpubkey. Code:-26.

Switching the MAIN_ENDPOINT of one of the classes over to https://bch-insight.bitpay.com/api/ gives success, but it seems that they don't actually broadcast transactions that you send them.

jackmaninov commented 6 years ago

Actually, I've tried submitting the raw_tx of a long message on several BCH sites, and I always get an error. Maybe the transaction generator has to be updated beyond changing the symbol limit to 217.