Sha256: e80e4e883c616a965732fd9c785f551d1c307a57ea187705a314f22642e947c9
Contents?: true
Size: 1.25 KB
Versions: 2
Compression:
Stored size: 1.25 KB
Contents
#!/usr/bin/env ruby # This is an example of using the raw xdr objects to post a transaction # notice that we must manually hash/sign the structures and we must manually # fill out all the fields. # # Look at mid_level_transaction_post.rb to see a friendlier form require 'rbnacl' require 'stellar-base' require 'faraday' require 'digest/sha2' master = RbNaCl::SigningKey.new("allmylifemyhearthasbeensearching") destination = RbNaCl::SigningKey.new("allmylifemyhearthasbeensearching") tx = Stellar::Transaction.new tx.account = master.verify_key.to_bytes tx.fee = 1000 tx.seq_num = 1 payment = Stellar::PaymentOp.new payment.destination = destination.verify_key.to_bytes payment.currency = Stellar::Currency.new(:native) payment.amount = 200_000000 op = Stellar::Operation.new op.body = Stellar::Operation::Body.new(:payment, payment) tx.operations = [op] raw = tx.to_xdr tx_hash = Digest::SHA256.digest raw signature = master.sign(tx_hash) env = Stellar::TransactionEnvelope.new env.tx = tx env.signatures = [Stellar::DecoratedSignature.new({ hint:master.verify_key.to_bytes[0...4], signature:signature })] env_hex = env.to_xdr.unpack("H*").first result = Faraday.get('http://localhost:39132/tx', blob: env_hex) puts result.body
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
stellar-base-0.0.9 | examples/low_level_transaction_post.rb |
stellar-base-0.0.8 | examples/low_level_transaction_post.rb |