This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Bitcoins::Index < BrowserAction | |
get "/bitcoins" do | |
addresses = KeyPairQuery.new.user_id(current_user.id).map { |key_pair| | |
{ key_pair.label, key_pair.public_key, "0" } | |
} | |
render IndexPage, addresses: addresses | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class KeyPairQuery < KeyPair::BaseQuery | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Bitcoins::Index < BrowserAction | |
get "/bitcoins" do | |
addresses = Array(Tuple(String, String, String)).new | |
render IndexPage, addresses: addresses, form: KeyPairForm.new | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Bitcoins::Create < BrowserAction | |
route do | |
KeyPairForm.create(params, user_id: current_user.id) do |form, key_pair| | |
if key_pair | |
flash.info = "Bitcoin address successfully generated" | |
redirect to: Bitcoins::Index | |
else | |
flash.danger = "Unable to generate Bitcoin Address, Please try again." | |
addresses = KeyPairQuery.new.user_id(current_user.id).map{ |keypair| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Bitcoins::IndexPage < MainLayout | |
needs addresses : Array(Tuple(String, String, String)) | |
needs form : KeyPairForm | |
def content | |
render_key_pair_form(@form) | |
h1 "Your Bitcoin Addresses" | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class KeyPairForm < KeyPair::BaseForm | |
fillable label | |
fillable public_key | |
fillable private_key | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "./user" | |
class KeyPair < BaseModel | |
table :key_pairs do | |
column label : String | |
column public_key : String | |
column private_key : String | |
belongs_to user : User | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Bitcoin from "bitcoinjs-lib" | |
const testnet = Bitcoin.networks.testnet | |
const keyPair = Bitcoin.ECPair.makeRandom({ network: testnet }) | |
console.log(Bitcoin.payments.p2pkh({ pubkey: keyPair.publicKey, network: testnet }).address) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Authentic.redirect_to_originally_requested_path(self, fallback: Bitcoins::Index) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Bitcoins::IndexPage < MainLayout | |
needs addresses : Array(Tuple(String, String, String)) | |
def content | |
h1 "Your Bitcoin Addresses" | |
table class: "table" do | |
thead do |