How to create an omnilayer transaction by myself?

As far as I understand from reading a specification and this blogpost, creating Omnilayer transactions is a rather tough thing to do yourself, because format is quite intricate. Are there any examples on how to create and decode omni transactions in javascript/python? Or maybe there is even some lightweight library for this?

What I’m trying to do is to send my custom omni transactions to blockchain.info testnet and later discover them by another app. That’s why I need to be able to both create and decode them. However I couldn’t find any helpful resources on how to accomplish this.

How to confirm my node is on the network?

I wanted to verify that my node is on the bitcoin network. For this I used the ‘getnetworkinfo’ command on my bitcoincore console and was able to optain my node’s IP address. This is: 2001:0:9d38:6abd:18e2:3f37:8f79:532e
I then entered this address and port (8333) into https://bitnodes.earn.com and my node checked out.
However my node does not display, when I look at the map of live nodes at: https://bitnodes.earn.com/nodes/live-map/

Can someone tell me why my node is not appearing on the live map?

How to use litecoin testnet on fully synced litecoin core on amazon ec2 instance

I run a synced litecoind on amazon ec2 linux instance.

[ec2-user@ip-xxx-xx-xx-xxx ~]$ litecoind -version
Litecoin Core Daemon version v0.13.2.1  

[ec2-user@ip-xxx-xx-xx-xxx ~]$ litecoin-cli getblockcount
1411130

I tried starting daemon with below commands

  • litecoind -testnet -daemon
  • litecoind -daemon , then litecoind -testnet

I want to get litecoin testnet address to test sending LTCT. But when I generate address i get litecoin address. How can I use this core to switch between main net and testnet ?

UPDATE

[ec2-user@ip-xxx-xx-xx-xxx ~]$ litecoind --testnet --daemon
Litecoin server starting
[ec2-user@ip-xxx-xx-xx-xxx ~]$ litecoin-cli getnewaddress
error: couldn't connect to server

top command shows litecoind running.
5787 ec2-user 20 0 786m 26m 288 S 1.0 2.6 0:00.63 litecoind

Is it okay if i kill the daemon ??

Please Help!

How to send Bitcoin in the Testnet?

I’m using this library: https://github.com/lian/bitcoin-ruby

And here’s my code:

require 'open-uri'
require 'net/http'
require 'net/https'
require 'json'

require 'bitcoin'

Bitcoin.network = :testnet3

def get_response(prev_tx)
  url = "https://testnet.blockexplorer.com/api/rawtx/#{prev_tx}"
  uri = URI(url)
  response = Net::HTTP.get(uri)
  response = JSON.parse(response)
  response = response['rawtx'].to_s
  return response
end

def build_transaction(prev_tx, prev_out_index, key, satoshi_to_spend, addr, message)
  include Bitcoin::Builder

  new_tx = build_tx do |t|
    t.input do |i|
      i.prev_out prev_tx
      i.prev_out_index prev_out_index
      i.signature_key key
    end
    t.output do |o|
      o.value satoshi_to_spend
      o.script {|s| s.type :address; s.recipient addr }
    end
  end
  puts ""
  puts "--- new tx ---"
  puts new_tx.to_json
  return new_tx
end

def bin_to_hex(s)
  s.unpack('H*').first
end

bitcoin_key_1_pub = "0367e6251a89c5afc1212c3e2169866ccfe9d6059a4cfc15dc139b534b974fd7ca"
bitcoin_key_1_priv = "*****24c56528becd02d23076123a2edc2f3cf52c3c0202178c1b7fa9ac*****"
bitcoin_key_1_addr = "mxz4hu6JrTHevn22W4GDVjS3ko9MwXuHND"

# the previous transaction that has an output to your address #1
prev_tx_1 = "427138ed5f2443fbfbf8065e990f1bf9ce0236e14376e8abca0b2876eabca653"

# the number of the output you want to use
prev_out_index = 1

# 0.5 BTC in satoshis
btc_to_spend = 0.5
satoshi_to_spend = btc_to_spend * 100000000

bitcoin_key_2_pub = "02989d0578f715a1980d4d6e968bcba487077e74aaf8a219d11ee4384ea1fc1eda"
bitcoin_key_2_priv = "*****cb521a27f9782cc503b461bf5c6b470469ca00ba1d7dc26f4ab61b*****"
bitcoin_key_2_addr = "n4SYP6TJyK7pUouW65fnC1hDBrbb7Za8RR"

# fetch the tx from whereever you like and parse it
response = get_response(prev_tx_1)
$prev_tx = Bitcoin::P::Tx.new(response.htb)
prev_tx = $prev_tx

tx_value = prev_tx.outputs[prev_out_index].value
puts "tx_value: #{tx_value}"

key = Bitcoin::Key.new(bitcoin_key_1_priv, bitcoin_key_1_pub)
tx = build_transaction(prev_tx, prev_out_index, key, satoshi_to_spend, bitcoin_key_2_addr, "hello")

puts ""
puts "--- bin_to_hex ---"
puts bin_to_hex(tx.to_payload)

Here’s the output:

➜  examples git:(master) ✗ ruby sandbox.rb

tx_value: 75972791
/Users/glaksmono/.rvm/gems/ruby-2.4.2/gems/bitcoin-ruby-0.0.18/lib/bitcoin/script.rb:281: warning: constant ::Fixnum is deprecated
/Users/glaksmono/.rvm/gems/ruby-2.4.2/gems/bitcoin-ruby-0.0.18/lib/bitcoin/script.rb:455: warning: constant ::Fixnum is deprecated

--- new tx ---
/Users/glaksmono/.rvm/gems/ruby-2.4.2/gems/bitcoin-ruby-0.0.18/lib/bitcoin/script.rb:261: warning: constant ::Fixnum is deprecated
{
  "hash":"88217866a40829f144e2d2c19b2e506812ae013d08d9335ce8fa839582f1b18e",
  "ver":1,
  "vin_sz":1,
  "vout_sz":1,
  "lock_time":0,
  "size":191,
  "in":[
    {
      "prev_out":{
        "hash":"427138ed5f2443fbfbf8065e990f1bf9ce0236e14376e8abca0b2876eabca653",
        "n":1
      },
      "scriptSig":"304402201cf2d99b7f10c71a1c77ae629ec134a3f255c0027f47815aff3e43d500e6da46022008409ea148d6cce6876910c7a7218b8197c3a827a6a7bf3d5f064a3ed3a0616701 0367e6251a89c5afc1212c3e2169866ccfe9d6059a4cfc15dc139b534b974fd7ca"
    }
  ],
  "out":[
    {
      "value":"0.50000000",
      "scriptPubKey":"OP_DUP OP_HASH160 fb75447d6038b05bb736e5b05f18a3c9da2b34db OP_EQUALVERIFY OP_CHECKSIG"
    }
  ]
}

--- bin_to_hex ---
010000000153a6bcea76280bcaabe87643e13602cef91b0f995e06f8fbfb43245fed387142010000006a47304402201cf2d99b7f10c71a1c77ae629ec134a3f255c0027f47815aff3e43d500e6da46022008409ea148d6cce6876910c7a7218b8197c3a827a6a7bf3d5f064a3ed3a0616701210367e6251a89c5afc1212c3e2169866ccfe9d6059a4cfc15dc139b534b974fd7caffffffff0180f0fa02000000001976a914fb75447d6038b05bb736e5b05f18a3c9da2b34db88ac00000000

It seems to be successful, but I don’t see the BTC actually transferred from bitcoin_key_1_addr to bitcoin_key_2_addr on the Blockcypher Explorer:

As you notice in the Blockcypher Explorer, the BTC amount is not yet transferred from bitcoin_key_1_addr to bitcoin_key_2_addr. Ideas?

Funding channels In Lightning Network

I was attempting to learn more about LN and came across the post below.

https://medium.com/tokensoft/tokensoft-lightning-node-how-to-connect-for-free-62b9aaec18b8

I also made a picture of my interpretation of the instructions.

enter image description here

In it, the suggestion is made that Nodes 1, 2 and3 connect to the his own (main) Lighning Node.

The purpose of this exercise is for Nodes 1, 2, and 3 to “gain access to the Lightning Network” altogether.

I was wondering if this would not be an exercise of futility (since the channels are funded with such small amounts).

TIA

How Do Peers Choose Which Peer To Trust?

  1. So the way I understand how the blockchain works is that each new block uses the previous block’s hash, which means if my block[100].hash != someone_elses_block[100].hash that means that either I broke some rule, or the other person did; In this case, how does my client find a trusted peer? And WHERE does my client get the latest CORRECT blockchain? Is there a central server for it? If so, where did the server it from? Because the miner will have the longest chain, but what if they are not actually following the rules? Then what?

  2. Lets say I stopped my client for 100 days, during those 100 days there was 500 new transactions, which means that if I was to compare my last block with someone elses then my client would be outdated, therefore it needs to download the extra blocks, where does it find these blocks and how does it determine which peers to sync to and to trust?

  3. A question about the nonce, if lets say there was no nonce; If client A has a chain that followed the rules and client B was verifying transactions without actually doing all the proper checks, that means that client A at block[100].hash != client B at block[100] therefore client B is not following the rules, so the question is what is the real need for the nonce? Because in my mind it seems like it’s just there to make it harder to mine for people, correct? Or does it add some sort of security? And if it does, will it have the same security if let’s say the nonce was always any number between 0 and 15? Or would it have to be adjusted as mining gets faster?

Thanks!

Testnet Bitcoin Connection refused (111)

I have ah Raspberry and i will a BTC & Lightning node set up.

my bitcoin.conf

testnet=3 
Bitcoind options
server=1
daemon=1
txindex=1
disablewallet=1 
 Connection settings
rpcuser=raspibolt
rpcpassword=1212431
addnode=104.237.131.138
addnode=151.80.205.132
addnode=192.155.82.123
addnode=74.220.255.190
addnode=80.100.203.151
 Raspberry Pi optimizations
dbcache=100
maxorphantx=10
maxmempool=50
maxconnections=40
maxuploadtarget=5000

I have the addnode from this thread:

testnet3 node sync process is very slow

in the getnetworkinfo stands:

"version": 160000,
  "subversion": "/Satoshi:0.16.0/",
  "protocolversion": 70015,
  "localservices": "000000000000040d",
  "localrelay": true,
  "timeoffset": 0,
  "networkactive": true,
  "connections": 17,
  "networks": 
  "warnings": "Warning: unknown new rules activated (versionbit 28)"

and in the debug log stands:

2018-04-24 17:39:51 connect() to 85.207.214.190:18333 failed after select(): Connection refused (111)
2018-04-24 17:38:16 connect() to [2001:470:c144:cafe::a]:18333 failed: Network is unreachable (101)

anyone have an idea where the error lies?

my testnet port: 18333 is open.

many thanks for the help!

regards

What’s the difference between a Bitcoin Wallet and a Bitcoin Exchange?

I was thinking about investing a small amount of money in Bitcoin: actually I’m having second thoughts about this, after all the fraud stories I’ve been told about on the Personal Finance site. However, that doesn’t affect this question.

Reading this Investopedia article, I discovered that one should create a Bitcoin Wallet before buying Bitcoins on a Bitcoin Exchange such as Coinbase or Kraken. I don’t understand why I should do that, isn’t enough to download the Coinbase app, for example? Also, the link says that

While exchanges offer wallet capabilities to users, it’s not their primary business. Since wallets need to be kept safe and secure, exchanges do not encourage storing of Bitcoins for higher amounts or long periods of time. Hence, it is best to transfer your Bitcoins to a secure wallet.

What’s the reason for that? If I buy stock options, no one would object to me keeping them invested for years. Then why can’t I leave my investment on a Bitcoin Exchange for a long period?

  1. Do I risk that the Exchange goes bankrupt?

  2. Do I risk that someone hacks my account on the Exchange? If so, is that common?

  3. Something else?

Basically, I want to understand if, for the sake of investing a small amount of money in Bitcoins, it makes sense to put my “pocket money” in a Bitcoin Exchange and leave it there for a few years, or if the risk of fraud/hacking is so high that I should not do that. Note that this has nothing to do with the volatility of the Bitcoin investment – I’m ok with making a risky investment (a gamble) since it’s just very little money. But I’m not ok at all with having my money stolen, even if it’s a small amount.

Automated FIAT Transfer to bank from Exchange

is it possible to trigger an automated wire to a bank account with an exchange platform?

we do want to make a couple of transactions a day depending on the bitcoin trading price based on rule sets.

from our wallet –> send to exchange –> automated process to sell into EUR –> wire send to Bank

any ideas?