diff --git a/static/admin/css/style.css b/static/admin/css/style.css
index 536c8c0..2df66eb 100644
--- a/static/admin/css/style.css
+++ b/static/admin/css/style.css
@@ -551,6 +551,17 @@ button {
display: inline-block;
}
+#xpubs-export-actions span {
+ display: inline;
+}
+
+#xpubs-export-actions select {
+ width: 220px;
+ margin-left: 5px;
+ margin-right: 5px;
+ display: inline-block;
+}
+
#xpubs-tool-details #xpub-value {
overflow: hidden;
}
diff --git a/static/admin/dmt/xpubs-tools/xpubs-tools.html b/static/admin/dmt/xpubs-tools/xpubs-tools.html
index a890173..8524c4d 100644
--- a/static/admin/dmt/xpubs-tools/xpubs-tools.html
+++ b/static/admin/dmt/xpubs-tools/xpubs-tools.html
@@ -62,6 +62,7 @@
+
@@ -86,6 +87,19 @@
+
+
+ Do you want to export a list of
+
+ of this XPUB?
+
+
+
+
+
diff --git a/static/admin/dmt/xpubs-tools/xpubs-tools.js b/static/admin/dmt/xpubs-tools/xpubs-tools.js
index 014c4cd..1858517 100644
--- a/static/admin/dmt/xpubs-tools/xpubs-tools.js
+++ b/static/admin/dmt/xpubs-tools/xpubs-tools.js
@@ -12,10 +12,13 @@ const screenXpubsToolsScript = {
$('#btn-xpub-details-reset').click(() => {this.showSearchForm()})
$('#btn-xpub-details-rescan').click(() => {this.showRescanForm()})
$('#btn-xpub-details-delete').click(() => {this.showDeletionForm()})
+ $('#btn-xpub-details-export').click(() => {this.showExportForm()})
$('#btn-xpub-rescan-go').click(() => {this.rescanXpub()})
$('#btn-xpub-rescan-cancel').click(() => {this.hideRescanForm()})
$('#btn-xpub-delete-go').click(() => {this.deleteXpub()})
$('#btn-xpub-delete-cancel').click(() => {this.hideDeletionForm()})
+ $('#btn-xpub-export-go').click(() => {this.exportXpubHistory()})
+ $('#btn-xpub-export-cancel').click(() => {this.hideExportForm()})
$('#btn-xpub-import-go').click(() => {this.importXpub()})
$('#btn-xpub-details-retype').click(() => {this.showImportForm(true)})
$('#btn-xpub-import-cancel').click(() => {this.hideImportForm(this.isReimport)})
@@ -33,6 +36,7 @@ const screenXpubsToolsScript = {
this.hideRescanForm()
this.hideDeletionForm()
+ this.hideExportForm()
this.showSearchForm()
$("#xpub").focus()
},
@@ -148,6 +152,35 @@ const screenXpubsToolsScript = {
})
},
+ exportXpubHistory: function() {
+ lib_msg.displayMessage('Exporting the transactional history of this xpub. Please wait...')
+
+ const args = {
+ 'active': this.currentXpub,
+ 'page': 0,
+ 'count': 1000000000
+ }
+
+ if ($('#export-type').val() == 'notNull')
+ args['excludeNullXfer'] = 1
+
+ return lib_api.getTransactions(args)
+ .then(result => {
+ if (result['txs'] && result['txs'].length > 0) {
+ let content = 'data:text/csv;charset=utf-8,'
+ content += 'height,txid,date,flow\n'
+ for (let tx of result['txs'])
+ content += `${tx['block_height']},${tx['hash']},${new Date(tx['time']*1000).toString()},${tx['result']/100000000}\n`
+ const encodedURI = encodeURI(content)
+ window.open(encodedURI)
+ }
+ this.hideExportForm()
+ lib_msg.displayInfo('Transactional history successfully exported.')
+ }).catch(e => {
+ lib_errors.processError(e)
+ })
+ },
+
checkRescanStatus: function(callback) {
this.rescanStatusTimerId = setTimeout(() => {
lib_api.getXpubRescanStatus(this.currentXpub)
@@ -312,6 +345,17 @@ const screenXpubsToolsScript = {
$('#xpubs-tool-actions').show()
},
+ showExportForm: function() {
+ $('#xpubs-tool-actions').hide()
+ $('#xpubs-export-actions').show()
+ lib_msg.cleanMessagesUi()
+ },
+
+ hideExportForm: function() {
+ $('#xpubs-export-actions').hide()
+ $('#xpubs-tool-actions').show()
+ },
+
}
screenScripts.set('#screen-xpubs-tools', screenXpubsToolsScript)