Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
662 additions
and
220 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
function postError(data) { | ||
if (data != 'true') { | ||
alert('Error withdrawing.') | ||
} else { | ||
alert('Withdrawl succeeded. Please allow some time for it to confirm.') | ||
} | ||
} | ||
|
||
function withdraw_from_job(job_id) { | ||
var amount = $('#withdraw_amount_'+job_id).val(); | ||
var destaddr = $('#withdraw_address_'+job_id).val(); | ||
$.ajax({ | ||
method: "POST", | ||
url: "/withdraw", | ||
contentType: "application/json", | ||
data: JSON.stringify({ | ||
'job': job_id, | ||
'amount': amount, | ||
'addr': destaddr | ||
}), | ||
success: function(data) { | ||
postError(data); | ||
} | ||
}) | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{% extends "layout.html" %} | ||
{% from "_form_helpers.html" import render_error %} | ||
{% block body %} | ||
|
||
<script src="/js/wallet.js"></script> | ||
|
||
<br> | ||
<div class="well"> | ||
<h2>Wallet</h2> | ||
<br /> | ||
Overall Balance: {{balance}} | ||
<br /> | ||
{% if txs %} | ||
{% for txj in txs %} | ||
<br /><br /> | ||
<h3>Unspent Payments for Job <a href="/job/{{txj.ref}}">{{txj.ref}}</a></h3> | ||
{% if txj.txs %} | ||
<table class="table m-table table-bordered table-hover table-heading"> | ||
<thead> | ||
<th class="col-md-5">txid</th> | ||
<th>value</th> | ||
</thead> | ||
<tbody> | ||
{% for tx in txj.txs %} | ||
<tr> | ||
<td class="col-md-5"><a href="{{explorer}}/tx/{{tx.txid}}">{{tx.txid}}</a></td> | ||
<td>{{tx.value}}</td> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
<form onsubmit="withdraw_from_job('{{txj.ref}}'); return false;" class="form-inline"> | ||
<h4> Withdraw from this job's payments</h4> | ||
<div class="form-group"> | ||
 <label for="withdraw_amount" class="control-label">Amount (BTC):</label> | ||
<input type="text" name="withdraw_amount" id="withdraw_amount_{{txj.ref}}" pattern="[0-9.]{1,10}" value="" style="width:100px;"> | ||
</div> | ||
<div class="form-group"> | ||
 <label for="withdraw_address" class="control-label">Address:</label> | ||
<input type="text" name="withdraw_address" id="withdraw_address_{{txj.ref}}" value="{{withdraw_amount}}" style="width:300px;"> | ||
</div> | ||
<div class="form-group"> | ||
 <input type="submit" value="Withdraw"/> | ||
</div> | ||
</form> | ||
{% else %} | ||
None found. | ||
{% endif %} | ||
{% endfor %} | ||
{% else %} | ||
<p>No transactions.</p> | ||
{% endif %} | ||
</div> | ||
|
||
{% endblock %} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from sqlalchemy import Column, Integer, String, DateTime | ||
from sqlalchemy.ext.declarative import declarative_base | ||
import click | ||
|
||
Base = declarative_base() | ||
|
||
class Pubkeys(Base): | ||
__tablename__ = 'pubkeys' | ||
|
||
pubkey = Column(String(34), primary_key=True) | ||
privkey = Column(String(52)) | ||
userid = Column(Integer) | ||
|
||
def __init__(self, session, pubkey, privkey, userid=None): | ||
self.pubkey = pubkey | ||
self.privkey = privkey | ||
self.userid = userid | ||
session.add(self) | ||
session.commit() | ||
|
||
@classmethod | ||
def get(self, rein, pubkey, default=False): | ||
res = rein.session.query(Pubkeys).filter(Pubkeys.pubkey == pubkey).first() | ||
if res: | ||
return res.privkey | ||
else: | ||
return default | ||
|
||
@classmethod | ||
def set(self, rein, pubkey, privkey='', userid=None): | ||
res = rein.session.query(Pubkeys).filter(Pubkeys.pubkey == pubkey).first() | ||
if res: | ||
res.privkey = privkey | ||
if userid is not None: | ||
res.userid = userid | ||
rein.session.commit() | ||
else: | ||
p = Pubkeys(rein.session, pubkey, privkey=privkey, userid=userid) |
This file contains 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
This file contains 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
Oops, something went wrong.