Skip to content

Commit

Permalink
Make it possible to display transaction message in utf8 and hex
Browse files Browse the repository at this point in the history
  • Loading branch information
Lesmiscore committed Apr 3, 2019
1 parent 069306e commit 7eec477
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 3 additions & 2 deletions component/txDetail.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
<v-ons-input v-model="txLabel" placeholder="名称未設定" @change="saveTxLabel"></v-ons-input>
</div>
</v-ons-list-item>
<v-ons-list-item v-show="!decodedCPMessage">
<v-ons-list-item v-show="!decodedCPMessage" @click="messageBinary=!messageBinary">
<div class="center">メッセージ</div>
<div class="right" v-if="message">{{message}}</div>
<div class="right" v-if="message&&messageBinary">{{message}}</div>
<div class="right" v-if="message&&!messageBinary">{{hexMessage}}</div>
<div class="right" v-if="!message">(メッセージ無し)</div>
</v-ons-list-item>
<v-ons-list-item v-show="decodedCPMessage">
Expand Down
9 changes: 7 additions & 2 deletions component/txDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ module.exports=require("../js/lang.js")({ja:require("./ja/txDetail.html"),en:req
return {
res:null,
message:"",
hexMessage:"",
fiat:this.$store.state.fiat,
coinId:this.$store.state.detail.coinId,
price:0,
txId:this.$store.state.detail.txId,
txLabel:"",
showScript:false,
messageBinary:true,
decodedCPMessage:null
}
},
Expand All @@ -49,8 +51,11 @@ module.exports=require("../js/lang.js")({ja:require("./ja/txDetail.html"),en:req
const txProm = cur.getTx(this.txId).then(v=>{
this.res=v
v.vout.forEach(o=>{
if(o.scriptPubKey.hex&&o.scriptPubKey.hex.substr(0,2)==="6a"){
this.message=bcLib.script.nullData.output.decode(new Buffer(o.scriptPubKey.hex,"hex")).toString('utf8')
const hexScript=o.scriptPubKey.hex
if(hexScript&&hexScript.substr(0,2)==="6a"){
const decoded=bcLib.script.nullData.output.decode(new Buffer(hexScript,"hex"))
this.message=decoded.toString('utf8')
this.hexMessage=decoded.toString('hex')
}
})
})
Expand Down

0 comments on commit 7eec477

Please sign in to comment.